LocalUtcOffset

Trait LocalUtcOffset 

Source
pub trait LocalUtcOffset: SealUO {
    // Required methods
    fn current_local_offset() -> Option<UtcOffset>;
    fn local_offset_at(datetime: OffsetDateTime) -> Option<UtcOffset>;
}
Available on crate feature time only.
Expand description

Extension trait for a proper current_local_offset over UtcOffset.

Required Methods§

Source

fn current_local_offset() -> Option<UtcOffset>

Attempts to obtain the system’s current UTC offset. If the offset cannot be determined, None is returned.

§Platform specific behavior
  • On unix, this reads and decodes the /etc/localtime file.
  • On windows, this calls GetTimeZoneInformation and reads the Bias field of the structure.
Source

fn local_offset_at(datetime: OffsetDateTime) -> Option<UtcOffset>

Attempts to obtain the system’s UTC offset for the given UTC OffsetDateTime. If the offset cannot be determined, None is returned.

This searches for a matching offset in UTC time for the given input datetime.

§Platform specific behavior
  • On unix, this reads and decodes the /etc/localtime file.
  • On windows, this calls GetTimeZoneInformation and reads the Bias field of the structure.

Dyn Compatibility§

This trait is not dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.

Implementations on Foreign Types§

Source§

impl LocalUtcOffset for UtcOffset

Implementors§