pub struct TimeZone(pub TimeZoneSource<'static>);
Expand description
A time zone, which here is a list of timespans, each containing a fixed offset for the current location’s time from UTC.
Tuple Fields§
§0: TimeZoneSource<'static>
Implementations§
Source§impl TimeZone
impl TimeZone
pub fn zone_name(&self) -> Option<&str>
Sourcepub fn offset(&self, datetime: LocalDateTime) -> i64
pub fn offset(&self, datetime: LocalDateTime) -> i64
Returns the total offset from UTC, in seconds, that this time zone has at the given datetime.
Sourcepub fn name(&self, datetime: LocalDateTime) -> String
pub fn name(&self, datetime: LocalDateTime) -> String
Returns the time zone abbreviation that this time zone has at the given datetime. As always, abbreviations are notoriously vague, and should only be used when referring to a known timezone.
Sourcepub fn is_fixed(&self) -> bool
pub fn is_fixed(&self) -> bool
Whether this time zone is “fixed”: a fixed time zone has no transitions, meaning it will always be at the same offset from UTC.
There are relatively few of these, namely the European timezones WET, CET, MET, and EET, and the North American timezones EST5EDT, CST6CDT, MST7MDT, and PST8PDT, none of which actually corresponds to a geographical location.
Sourcepub fn to_zoned(&self, datetime: LocalDateTime) -> LocalDateTime
pub fn to_zoned(&self, datetime: LocalDateTime) -> LocalDateTime
Converts a local datetime in UTC to a zoned datetime that uses this time zone.
Sourcepub fn convert_local(&self, local: LocalDateTime) -> LocalTimes<'_>
pub fn convert_local(&self, local: LocalDateTime) -> LocalTimes<'_>
Converts a local datetime that is already informally in this time zone into a zoned datetime that actually uses this time zone.
For example, say you have the current time for a time zone, but you
don’t know what the current offset from UTC is. This method
computes the offset, then subtracts rather than adds it, resulting
in a value that gets displayed as the current time. In other words,
calling hour()
or year()
or any of the other view methods on one
of the resulting values will always return the same as the
datetime initially passed in, no matter what the current offset is.
This method can return 0, 1, or 2 values, depending on whether the datetime passed in falls between two timespans (an impossible time) or overlaps two separate timespans (an ambiguous time). The result will almost always be precise, but there are edge cases you need to watch out for.
Trait Implementations§
Auto Trait Implementations§
impl Freeze for TimeZone
impl RefUnwindSafe for TimeZone
impl Send for TimeZone
impl Sync for TimeZone
impl Unpin for TimeZone
impl UnwindSafe for TimeZone
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§unsafe fn clone_to_uninit(&self, dst: *mut T)
unsafe fn clone_to_uninit(&self, dst: *mut T)
clone_to_uninit
)