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
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
//! Utility functions, including updating time zone information.
pub use ;
use crate Month;
/// Whether to adjust the date, and in which direction. Useful when implementing arithmetic.
pub
/// Get the number of days in the month of a given year.
///
/// ```rust
/// # use time::{Month, util};
/// assert_eq!(util::days_in_month(Month::February, 2020), 29);
/// ```
pub const
/// Get the number of days in the month of a given year.
///
/// ```rust
/// # #![allow(deprecated)]
/// # use time::{Month, util};
/// assert_eq!(util::days_in_year_month(2020, Month::February), 29);
/// ```
pub const
/// Update time zone information from the system.
///
/// For a version of this function that is guaranteed to be sound, see [`refresh_tz`].
///
/// # Safety
///
/// This is a system call with specific requirements. The following is from POSIX's description of
/// `tzset`:
///
/// > If a thread accesses `tzname`, `daylight`, or `timezone` directly while another thread is in a
/// > call to `tzset()`, or to any function that is required or allowed to set timezone information
/// > as if by calling `tzset()`, the behavior is undefined.
///
/// Effectively, this translates to the requirement that at least one of the following must be true:
///
/// - The operating system provides a thread-safe environment.
/// - The process is single-threaded.
/// - The process is multi-threaded **and** no other thread is mutating the environment in any way
/// at the same time a call to a method that obtains the local UTC offset. This includes adding,
/// removing, or modifying an environment variable.
///
/// ## Soundness is global
///
/// You must not only verify this safety conditions for your code, but for **all** code that will be
/// included in the final binary. Notably, it applies to both direct and transitive dependencies and
/// to both Rust and non-Rust code. **For this reason it is not possible for a library to soundly
/// call this method.**
///
/// ## Forward compatibility
///
/// This currently only does anything on Unix-like systems. On other systems, it is a no-op. This
/// may change in the future if necessary, expanding the safety requirements. It is expected that,
/// at a minimum, calling this method when the process is single-threaded will remain sound.
pub unsafe
/// Attempt to update time zone information from the system.
///
/// Returns `None` if the call is not known to be sound.