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
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
//! Utility crate to figure out the IANA (Olson) timezone of the current
//! machine. The IANA timezones have been largely established as the standard
//! for identifying timezones but retrieving the current timezone in that format
//! is a surprisingly complex problem. Additionally Windows machines use an
//! incompatible timezone system and this crate helps automaticaly mapping these
//! to the IANA timezones. For this it uses the CLDR maintained timezone mapping.
//!
//! # Getting Timezones
//!
//! To retrieve the current timezone call the [`get_local_zone`] function. It will
//! try different sources to get the current timezone. When the `auto_validation`
//! feature is enabled it will attempt to validate each source against the current
//! [`chrono_tz`](https://crates.io/crates/chrono-tz) database. Alternatively
//! [`get_local_zone_with_validation`] can be used an be supplied an alternative
//! validator function.
//!
//! If the timezone cannot be found a user of this crate shall assume the system is
//! running in UTC.
//!
//! # Features
//!
//! The following optional features exist:
//!
//! * `auto_validation`: when enabled timezones encountered are validated with
//! `chrono_tz` by default.
//! * `win_zones`: when enabled functions are exposed to map between windows and
//! IANA timezones.
pub use crate;
/// Returns the local timezone if it can be found.
///
/// If the `auto_validation` feature is enabled then encountered timezones
/// are validated with `chrono_tz`.
/// Returns the local timezone validating it with a custom function.
///
/// As this function probes different sources for the current timezone a validation
/// function is invoked to check if one of the choices is valid. If it is, then
/// that match is returned.