Struct datetime::TimeZone
[−]
[src]
pub struct TimeZone(pub TimeZoneSource<'static>);
A time zone, which here is a list of timespans, each containing a fixed offset for the current location’s time from UTC.
Methods
impl TimeZone
[src]
fn zone_name(&self) -> Option<&str>
[src]
fn offset(&self, datetime: LocalDateTime) -> i64
[src]
Returns the total offset from UTC, in seconds, that this time zone has at the given datetime.
fn name(&self, datetime: LocalDateTime) -> String
[src]
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.
fn is_fixed(&self) -> bool
[src]
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.
fn to_zoned(&self, datetime: LocalDateTime) -> LocalDateTime
[src]
Converts a local datetime in UTC to a zoned datetime that uses this time zone.
fn convert_local(&self, local: LocalDateTime) -> LocalTimes
[src]
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.