Pure MoonBit IANA TZif v2/v3 parser and timezone conversion engine. UTC ↔ local time with full DST handling, POSIX TZ fallback, and no libc timezone API dependency.
Dependencies
moon run examples --target native1970-01-01T00:00:00Z becomes 1970-01-01T08:00:00+08:00 CST
embedded America/New_York: 2026-03-08T03:00:00-04:00 EDTTZIF_HEX=$(xxd -p /usr/share/zoneinfo/America/New_York | tr -d '\n')
moon run cli --target native -- utc-to-local "$TZIF_HEX" 17729532002026-03-08T03:00:00-04:00 EDTimport {
"caijiewei295/tzif-engine" @tzif,
"caijiewei295/tzif-engine/types",
}fn convert(
tzif_bytes : Bytes,
utc_time : Int64,
) -> Result[@types.LocalDateTime, @types.TzifError] {
let timezone = match @tzif.load(tzif_bytes) {
Ok(value) => value
Err(error) => return Err(error)
}
@tzif.utc_to_local(timezone, utc_time)
}fn choose_later_overlap(
timezone : @types.TzifData,
) -> Result[Int64, @types.TzifError] {
let local_time = match @tzif.parse_iso_local("2026-11-01T01:30:00") {
Ok(value) => value
Err(error) => return Err(error)
}
@tzif.local_to_utc(timezone, local_time, @types.PreferLater)
}moon fmt --check
moon check --target all --warn-list +73 --deny-warn
moon build --target all --warn-list +73 --deny-warn
moon test --target all --warn-list +73 --deny-warn
moon info --target allfn local_to_utc(tz : TzifData, ldt : LocalDateTime, strategy : AmbiguityStrategy) -> Result[Int64, TzifError]fn transition_details_between(tz : TzifData, start_utc : Int64, end_utc : Int64) -> Result[Array[TransitionDetail], TzifError]Pure MoonBit IANA TZif v2/v3 parser and timezone conversion engine. UTC ↔ local time with full DST handling, POSIX TZ fallback, and no libc timezone API dependency.
Dependencies