tzif/data/
posix.rs

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
// This file is part of ICU4X. For terms of use, please see the file
// called LICENSE at the top level of the ICU4X source tree
// (online at: https://github.com/unicode-org/icu4x/blob/main/LICENSE ).

use super::time::Seconds;

/// A struct to hold a time-zone variant name and its offset.
/// The offset is how many hours must be added to the time to reach UTC.
#[derive(Debug, Clone, PartialEq, Eq)]
pub struct ZoneVariantInfo {
    /// The name of the time-zone variant.
    pub name: String,
    /// The offset time in seconds that must be added to reach UTC.
    pub offset: Seconds,
}

/// A struct to hold a DST transition date.
#[derive(Debug, Clone, Copy, PartialEq, Eq)]
pub struct TransitionDate {
    /// The day on which the transition occurrs.
    pub day: TransitionDay,
    /// The time in seconds in which the transition occurrs.
    pub time: Seconds,
}

/// A struct for defining a DST transition day.
#[derive(Debug, Clone, Copy, PartialEq, Eq)]
pub enum TransitionDay {
    /// The day of the year, ignoring Feb. 29 on leap years. Designated by `Jn`.
    ///
    /// Ranges from [1, 365]
    NoLeap(u16),

    /// The day of the year, accounting for Feb. 29 on leap years. Designated by `n`.
    ///
    /// Ranges from [0, 365]
    WithLeap(u16),

    /// The month, week, day value. Designated by `M.w.d`.
    ///
    /// `M` ranges from [1, 12].
    ///
    /// `w` ranges from [1, 5].
    ///
    /// `d` ranges from [0, 6].
    Mwd(u16, u16, u16),
}

/// A struct for holding DST transition info.
#[derive(Debug, Clone, PartialEq, Eq)]
pub struct DstTransitionInfo {
    /// The zone variant info including name and offset.
    pub variant_info: ZoneVariantInfo,

    /// The DST transition start date.
    pub start_date: TransitionDate,

    /// The DST transition end date.
    pub end_date: TransitionDate,
}

/// A struct for holding data encoded by a POSIX time-zone string.
#[derive(Debug, Clone, PartialEq, Eq)]
pub struct PosixTzString {
    /// The variant info of the STD time-zone variant.
    pub std_info: ZoneVariantInfo,

    /// The variant info of the DST time-zone variant if present.
    pub dst_info: Option<DstTransitionInfo>,
}