Expand description
This crate contains utilities for working with ICU4C’s zoneinfo64 format
// Needs to be u32-aligned
let resb = resb::include_bytes_as_u32!("./data/zoneinfo64.res");
// Then we parse the data
let zoneinfo = ZoneInfo64::try_from_u32s(resb)
.expect("Error processing resource bundle file");
let pacific = zoneinfo.get("America/Los_Angeles").unwrap();
// Calculate the timezone offset for 2024-01-01
let offset = pacific.for_timestamp(1704067200000);
let offset_seven = UtcOffset::from_seconds(-7 * 3600);
assert_eq!(offset.offset, offset_seven);
// Calculate possible offsets at 2025-11-02T01:00:00
// This is during a DST switchover and is ambiguous
let PossibleOffset::Ambiguous {
before,
after,
transition,
} = pacific.for_date_time(2025, 11, 2, 1, 0, 0)
else {
panic!()
};
let offset_eight = UtcOffset::from_seconds(-8 * 3600);
assert_eq!(before.offset, offset_seven);
assert!(before.rule_applies);
assert_eq!(after.offset, offset_eight);
assert!(!after.rule_applies);
assert_eq!(transition, 1762074000);Structs§
- Offset
- A resolved offset for a given point in time
- Transition
- A transition
- UtcOffset
- An offset from UTC time (stored to seconds precision)
- Zone
- Data for a given time zone
- Zone
Info64 - The primary type containing parsed
ZoneInfo64data
Enums§
- Possible
Offset - Possible offsets for a local datetime
Constants§
- ZONEINF
O64_ RES_ FOR_ TESTING - A bundled zoneinfo64.res that can be used for testing. No guarantee is made as to the version in use; though we will try to keep it up to date.