kine_core/
providers.rs

1use crate::leap_seconds::{BuiltinIers, BuiltinIersSigil};
2
3cfg_if::cfg_if! {
4    if #[cfg(doc)] {
5        /// Time zone the `std::time::SystemTime` clock is in
6        ///
7        /// If this is not set properly, then all `Time`s (and dependent calculations) will
8        /// be off.
9        ///
10        /// Usually, `SystemTime` returns POSIX timestamps, so this should be an IERS leap
11        /// seconds timezone. Which one you choose depends on until which date you want time
12        /// calculations to be precise.
13        ///
14        /// Stability note: The real type of is currently exposed only because
15        /// type_alias_impl_trait is still unstable. IT WILL BE TURNED INTO
16        /// `impl ~const Default + Clone + Copy + TimeZone` IN A MINOR RELEASE!
17        /// And once extern existential types get done and stable, the various feature flags
18        /// will be replaced with making this existential type extern (but will be kept there
19        /// for backwards compatibility until the next major release)
20        pub type System = BuiltinIers;
21
22        /// Sigil for the system timezone provider, convenience
23        ///
24        /// Stability note: See System.
25        pub type SystemSigil = BuiltinIersSigil;
26
27    } else if #[cfg(feature = "tz-system-provider-builtin-iers")] {
28        pub type System = BuiltinIers;
29        pub type SystemSigil = BuiltinIersSigil;
30    } else {
31        compile_error!("Please define (exactly) one system timezone provider feature (tz-system-provider-*)");
32    }
33}
34
35/// Time zone for the system clock
36///
37/// If this is not set properly then all `Time`s (and dependent calculations) will be off
38///
39/// Stability note: See the stability note of `System`. This line will also need to
40/// change once it's possible to encode the fact that `default()` needs to be `const`, but
41/// the things you can do with it will mostly change when `System` will change.
42pub static SYSTEM: System = System::const_default();
43pub static SYSTEM_SIGIL: SystemSigil = SystemSigil::const_default();
44
45cfg_if::cfg_if! {
46    if #[cfg(doc)] {
47        /// Leap seconds provider for UTC
48        ///
49        /// If this is not set properly, then all `Time`s (and dependent calculations) will
50        /// be off. Which one you choose depends on until which date you want time
51        /// calculations to be precise.
52        ///
53        /// Stability note: The real type of is currently exposed only because
54        /// type_alias_impl_trait is still unstable. IT WILL BE TURNED INTO
55        /// `impl ~const Default + Clone + Copy + TimeZone` IN A MINOR RELEASE!
56        /// And once extern existential types get done and stable, the various feature flags
57        /// will be replaced with making this existential type extern (but will be kept there
58        /// for backwards compatibility until the next major release)
59        pub type Utc = BuiltinIers;
60
61        /// Sigil for UTC leap seconds provider, as a convenience
62        ///
63        /// Stability note: See Utc.
64        pub type UtcSigil = BuiltinIersSigil;
65
66    } else if #[cfg(feature = "tz-utc-provider-builtin-iers")] {
67        pub type Utc = BuiltinIers;
68        pub type UtcSigil = BuiltinIersSigil;
69    } else {
70        compile_error!("Please define (exactly) one UTC leap seconds provider feature (tz-utc-provider-*)");
71    }
72}
73
74/// Leap seconds provider for UTC
75///
76/// If this is not set properly then all `Time`s (and dependent calculations) will be off
77///
78/// Stability note: See the stability note of `Utc`. This line will also need to
79/// change once it's possible to encode the fact that `default()` needs to be `const`, but
80/// the things you can do with it will mostly change when `Utc` will change.
81pub static UTC: Utc = Utc::const_default();
82pub static UTC_SIGIL: UtcSigil = UtcSigil::const_default();