pub struct TimeZone { /* private fields */ }tariffs only.Expand description
The IANA time zone a Location is in, which the local-time restrictions are expressed in.
start_time: Start time of day in local time, the time zone is defined in thetime_zonefield of the Location.
A tariff that costs more after 17:00 is wrong by an hour for half the year unless the conversion goes through the real zone rules, so this resolves the name against the IANA database rather than assuming a fixed offset.
Implementations§
Source§impl TimeZone
impl TimeZone
Sourcepub fn named(name: &str) -> Result<Self, PricingError>
pub fn named(name: &str) -> Result<Self, PricingError>
Resolves an IANA time zone name, such as Europe/Oslo.
§Errors
Returns PricingError::TimeZone when the name is not in the IANA database.
Sourcepub fn offset_seconds_at(&self, instant: DateTime) -> Result<i32, PricingError>
pub fn offset_seconds_at(&self, instant: DateTime) -> Result<i32, PricingError>
The UTC offset in effect at instant, in seconds.
§Errors
Returns PricingError::TimeZone when the instant is outside the range the zone’s rules
cover.
Sourcepub fn to_local(&self, instant: DateTime) -> Result<LocalParts, PricingError>
pub fn to_local(&self, instant: DateTime) -> Result<LocalParts, PricingError>
The wall clock instant shows in this zone.
§Errors
Returns PricingError::TimeZone when the offset cannot be determined.