Skip to main content

LocalTimeOffsetEntry

Struct LocalTimeOffsetEntry 

Source
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: LangCode

ISO 3166 alpha country code.

§country_region_id: u8

6-bit country_region_id for sub-national regions.

§local_time_offset_negative: bool

Polarity: false = offset is positive (local = UTC + offset), true = offset is negative (local = UTC − offset).

§local_time_offset_bcd: u16

16-bit BCD HHMM local time offset.

§next_time_offset_bcd: u16

16-bit BCD HHMM next offset (applied after time_of_change).

Implementations§

Source§

impl LocalTimeOffsetEntry

Source

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.

Source

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.

Source

pub fn time_of_change_raw(&self) -> [u8; 5]

The raw 5-byte MJD+BCD time-of-change field (for serialization).

Source

pub fn set_time_of_change_raw(&mut self, raw: [u8; 5])

Set the time_of_change_raw field directly.

Source§

impl LocalTimeOffsetEntry

Source

pub fn local_time_offset(&self) -> Option<Duration>

Available on crate feature 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.

Source

pub fn next_time_offset(&self) -> Option<Duration>

Available on crate feature 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.

Source

pub fn time_of_change(&self) -> Option<DateTime<Utc>>

Available on crate feature 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.

Source

pub fn set_time_of_change(&mut self, dt: DateTime<Utc>) -> Result<()>

Available on crate feature 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.

Source

pub fn set_offsets(&mut self, local: Duration, next: Duration) -> Result<()>

Available on crate feature 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

Source§

fn clone(&self) -> LocalTimeOffsetEntry

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Copy for LocalTimeOffsetEntry

Source§

impl Debug for LocalTimeOffsetEntry

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Eq for LocalTimeOffsetEntry

Source§

impl PartialEq for LocalTimeOffsetEntry

Source§

fn eq(&self, other: &LocalTimeOffsetEntry) -> bool

Tests for self and other values to be equal, and is used by ==.
1.0.0 (const: unstable) · Source§

fn ne(&self, other: &Rhs) -> bool

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
Source§

impl Serialize for LocalTimeOffsetEntry

Source§

fn serialize<__S>(&self, __serializer: __S) -> Result<__S::Ok, __S::Error>
where __S: Serializer,

Serialize this value into the given Serde serializer. Read more
Source§

impl StructuralPartialEq for LocalTimeOffsetEntry

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> DescriptorObject for T
where T: Debug + Any + Send + Sync + Serialize,

Source§

fn as_any(&self) -> &(dyn Any + 'static)

Available on crate feature serde only.
Borrow as &dyn Any so the caller can downcast to the concrete type.
Source§

impl<T> ErasedDestructor for T
where T: 'static,

Source§

impl<T> ExtensionObject for T
where T: Debug + Any + Send + Sync + Serialize,

Source§

fn as_any(&self) -> &(dyn Any + 'static)

Available on crate feature serde only.
Borrow as &dyn Any so the caller can downcast to the concrete type.
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> Serialize for T
where T: Serialize + ?Sized,

Source§

fn erased_serialize(&self, serializer: &mut dyn Serializer) -> Result<(), Error>

Source§

fn do_erased_serialize( &self, serializer: &mut dyn Serializer, ) -> Result<(), ErrorImpl>

Source§

impl<T> TableObject for T
where T: Debug + Any + Send + Sync + Serialize,

Source§

fn as_any(&self) -> &(dyn Any + 'static)

Available on crate feature serde only.
Borrow as &dyn Any so the caller can downcast to the concrete type.
Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.