#[repr(align(8))]pub struct TimeZone {
pub version: u8,
pub checksum: u32,
pub designations: MaybeStaticSlice<Abbreviation>,
pub posix_tz: Option<TimeZone>,
pub types: MaybeStaticSlice<LocalTimeType>,
pub transitions: Transitions,
}Expand description
A representation of an unnamed time zone backed by TZif data.
Two time zones are considered equivalent when their CRC32 sums are equivalent.
Fields§
§version: u8An ASCII byte corresponding to the version number. So, 0x50 is ‘2’.
checksum: u32A CRC32 checksum of the underlying TZif data.
This, along with the time zone’s IANA identifier, is used to provide a “best effort” but also cheap notion of strict equality between two time zones.
designations: MaybeStaticSlice<Abbreviation>The time zone abbreviations referenced by local time types.
posix_tz: Option<TimeZone>A POSIX time zone used for determining time zone transitions after the last transition in some TZif data.
This is technically optional, but is usually present.
types: MaybeStaticSlice<LocalTimeType>The local time types in this TZif data.
Each local time type represents a distinct combination of offset, abbreviation and whether the region is in daylight saving time or not.
transitions: TransitionsThe concrete transitions that make up this time zone.
Implementations§
Source§impl TimeZone
impl TimeZone
Sourcepub fn parse(bytes: &[u8]) -> Result<TimeZone, ParseError>
pub fn parse(bytes: &[u8]) -> Result<TimeZone, ParseError>
Parses the given data as a TZif formatted file.
The name given is attached to the returned value, but is otherwise not significant.
In general, callers may assume that it is safe to pass arbitrary or even untrusted data to this function and count on it not panicking or using resources that are not limited to a small constant factor of the size of the data itself.
This is only available when the alloc feature is enabled because
parsing TZif data requires heap allocation.
Source§impl TimeZone
impl TimeZone
Sourcepub fn to_offset(&self, timestamp: Timestamp) -> Offset
pub fn to_offset(&self, timestamp: Timestamp) -> Offset
Returns the appropriate time zone offset to use for the given timestamp.
Sourcepub fn to_offset_info(&self, timestamp: Timestamp) -> OffsetInfo
pub fn to_offset_info(&self, timestamp: Timestamp) -> OffsetInfo
Returns the appropriate time zone offset to use for the given timestamp.
This also includes whether the offset returned should be considered to be DST or not, along with the time zone abbreviation (e.g., EST for standard time in New York, and EDT for DST in New York).
Sourcepub fn to_ambiguous_timestamp(&self, dt: DateTime) -> AmbiguousTimestamp
pub fn to_ambiguous_timestamp(&self, dt: DateTime) -> AmbiguousTimestamp
Returns a possibly ambiguous timestamp for the given civil datetime.
The given datetime should correspond to the “wall” clock time of what humans use to tell time for this time zone.
Note that “ambiguous timestamp” is represented by the possible selection of offsets that could be applied to the given datetime. In general, it is only ambiguous around transitions to-and-from DST. The ambiguity can arise as a “fold” (when a particular wall clock time is repeated) or as a “gap” (when a particular wall clock time is skipped entirely).
Sourcepub fn previous_transition<'t>(&'t self, ts: Timestamp) -> Option<Transition>
pub fn previous_transition<'t>(&'t self, ts: Timestamp) -> Option<Transition>
Returns the timestamp of the most recent time zone transition prior
to the timestamp given. If one doesn’t exist, None is returned.
Sourcepub fn next_transition<'t>(&'t self, ts: Timestamp) -> Option<Transition>
pub fn next_transition<'t>(&'t self, ts: Timestamp) -> Option<Transition>
Returns the timestamp of the soonest time zone transition after the
timestamp given. If one doesn’t exist, None is returned.
Source§impl TimeZone
impl TimeZone
Sourcepub fn into_named(self, name: TimeZoneId) -> MaybeNamedTimeZone
pub fn into_named(self, name: TimeZoneId) -> MaybeNamedTimeZone
Converts this unnamed time zone into a time zone with the given name.
Sourcepub fn into_maybe_named(self, name: Option<TimeZoneId>) -> MaybeNamedTimeZone
pub fn into_maybe_named(self, name: Option<TimeZoneId>) -> MaybeNamedTimeZone
Converts this unnamed time zone into a time zone with the given optional name.