1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
//! IANA time-zone conversion for [`Timestamp`] (feature `tz`).
//!
//! [`Timestamp`] is always a UTC instant — the canonical, storage/compute form.
//! A [`TimeZone`] renders that same instant as *civil time* in a named zone
//! (e.g. `Europe/Istanbul`), applying the zone's UTC offset (including any DST
//! rule in effect at that instant). The instant itself never changes.
//!
//! ```
//! use klauthed_core::time::{Timestamp, TimeZone};
//!
//! let ts = Timestamp::from_unix_millis(1_700_000_000_000); // 2023-11-14T22:13:20Z
//! let tokyo = TimeZone::get("Asia/Tokyo").expect("known zone");
//!
//! // Same instant, expressed at Tokyo's +09:00 offset.
//! let local = ts.to_zone(&tokyo);
//! assert_eq!(local.offset().whole_hours(), 9);
//! assert_eq!(local.hour(), 7); // 22:13 UTC + 9h = 07:13 next day, Tokyo
//!
//! assert!(TimeZone::get("Mars/Olympus_Mons").is_none());
//! ```
use ;
// `TimeZone` trait imported anonymously: brings `.name()` into scope without
// clashing with our own `TimeZone` type below.
use ;
use Timestamp;
/// A named IANA time zone (e.g. `Europe/Istanbul`).
///
/// Cheap to copy — it borrows a zone from the statically compiled tz database.
;