pub struct LocalTimeOffsetEntry {
pub country_code: LangCode,
pub country_region_id: u8,
pub local_time_offset_negative: bool,
pub local_time_offset_bcd: u16,
pub next_time_offset_bcd: u16,
/* private fields */
}Expand description
One per-country offset entry.
Fields§
§country_code: LangCodeISO 3166 alpha country code.
country_region_id: u86-bit country_region_id for sub-national regions.
local_time_offset_negative: boolPolarity: false = offset is positive (local = UTC + offset), true = offset is negative (local = UTC − offset).
local_time_offset_bcd: u1616-bit BCD HHMM local time offset.
next_time_offset_bcd: u1616-bit BCD HHMM next offset (applied after time_of_change).
Implementations§
Source§impl LocalTimeOffsetEntry
impl LocalTimeOffsetEntry
Sourcepub fn new(
country_code: LangCode,
country_region_id: u8,
local_time_offset_negative: bool,
local_time_offset_bcd: u16,
time_of_change_raw: [u8; 5],
next_time_offset_bcd: u16,
) -> Self
pub fn new( country_code: LangCode, country_region_id: u8, local_time_offset_negative: bool, local_time_offset_bcd: u16, time_of_change_raw: [u8; 5], next_time_offset_bcd: u16, ) -> Self
Create a new entry with all fields specified.
Sourcepub fn time_of_change_parts(&self) -> (u16, Option<u8>, Option<u8>, Option<u8>)
pub fn time_of_change_parts(&self) -> (u16, Option<u8>, Option<u8>, Option<u8>)
Decode time_of_change_raw into its MJD + BCD HHMMSS components
without requiring the chrono feature.
Returns (mjd, hours, minutes, seconds). Each BCD field is None if
its nibbles are non-decimal.
Sourcepub fn time_of_change_raw(&self) -> [u8; 5]
pub fn time_of_change_raw(&self) -> [u8; 5]
The raw 5-byte MJD+BCD time-of-change field (for serialization).
Sourcepub fn set_time_of_change_raw(&mut self, raw: [u8; 5])
pub fn set_time_of_change_raw(&mut self, raw: [u8; 5])
Set the time_of_change_raw field directly.
Source§impl LocalTimeOffsetEntry
impl LocalTimeOffsetEntry
Sourcepub fn local_time_offset(&self) -> Option<Duration>
Available on crate feature chrono only.
pub fn local_time_offset(&self) -> Option<Duration>
chrono only.Decode local_time_offset (BCD HHMM, signed by
local_time_offset_negative) to a chrono::Duration. None if the
BCD nibbles are out of range.
Sourcepub fn next_time_offset(&self) -> Option<Duration>
Available on crate feature chrono only.
pub fn next_time_offset(&self) -> Option<Duration>
chrono only.Decode next_time_offset (BCD HHMM) to a chrono::Duration. It
shares the single local_time_offset_negative polarity bit (EN 300 468
§6.2.20). None if the BCD nibbles are out of range.
Sourcepub fn time_of_change(&self) -> Option<DateTime<Utc>>
Available on crate feature chrono only.
pub fn time_of_change(&self) -> Option<DateTime<Utc>>
chrono only.Decode time_of_change_raw (16-bit MJD + 24-bit BCD UTC) to a UTC
datetime. None if the date/time fields are out of range.
Sourcepub fn set_time_of_change(&mut self, dt: DateTime<Utc>) -> Result<()>
Available on crate feature chrono only.
pub fn set_time_of_change(&mut self, dt: DateTime<Utc>) -> Result<()>
chrono only.Set the time_of_change, encoding it into the 40-bit raw field.
§Errors
ValueOutOfRange if the date is
outside the representable 16-bit MJD range.
Sourcepub fn set_offsets(&mut self, local: Duration, next: Duration) -> Result<()>
Available on crate feature chrono only.
pub fn set_offsets(&mut self, local: Duration, next: Duration) -> Result<()>
chrono only.Set both offsets and the shared polarity bit from signed durations.
The wire format carries one polarity bit for both offsets, so local
and next must share a sign (zero matches either).
§Errors
ValueOutOfRange if the two
offsets disagree in sign or a magnitude is 100 hours or longer.
Trait Implementations§
Source§impl Clone for LocalTimeOffsetEntry
impl Clone for LocalTimeOffsetEntry
Source§fn clone(&self) -> LocalTimeOffsetEntry
fn clone(&self) -> LocalTimeOffsetEntry
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreimpl Copy for LocalTimeOffsetEntry
Source§impl Debug for LocalTimeOffsetEntry
impl Debug for LocalTimeOffsetEntry
impl Eq for LocalTimeOffsetEntry
Source§impl PartialEq for LocalTimeOffsetEntry
impl PartialEq for LocalTimeOffsetEntry
Source§impl Serialize for LocalTimeOffsetEntry
Available on crate feature serde only.
impl Serialize for LocalTimeOffsetEntry
serde only.