Skip to main content

Rule

Struct Rule 

Source
pub struct Rule(/* private fields */);
Expand description

One transition rule of a POSIX TZ string, for example M3.5.0/2.

The value is a Copy type of 32 bits (size_of::<Rule>() == 4):

  • bits 0 to 1: the RuleKind,
  • bits 2 to 10: the date, 9 bits. For Mm.w.d it is ((m - 1) * 5 + (w - 1)) * 7 + d; for Jn it is n - 1; for n it is n,
  • bits 11 to 31: the time of day, biased by TIME_BIAS; 0 means the default 02:00:00 of a rule without /time. The bias covers the POSIX 2024 range of -167 to 167 hours with margin.

Implementations§

Source§

impl Rule

Source

pub const fn kind(&self) -> RuleKind

The kind of date this rule selects.

Source

pub const fn date_code(&self) -> u16

The 9-bit date code, see Rule for its layout.

Source

pub const fn has_explicit_time(&self) -> bool

Whether the rule carries an explicit /time.

Source

pub const fn time_seconds(&self) -> i32

The time of day of the transition in seconds, signed. POSIX 2024 allows -167 to 167 hours. A rule without /time returns the default 02:00:00.

Source

pub const fn month(&self) -> u8

The month of an Mm.w.d rule, 1 to 12.

Source

pub const fn week(&self) -> u8

The week of an Mm.w.d rule, 1 to 5, where 5 means the last.

Source

pub const fn weekday(&self) -> u8

The day of the week of an Mm.w.d rule, 0 for Sunday.

Source

pub const fn julian_day(&self) -> u16

The day of the year of a Jn rule, 1 to 365.

Source

pub const fn zero_based_day(&self) -> u16

The day of the year of an n rule, 0 to 365.

Trait Implementations§

Source§

impl Clone for Rule

Source§

fn clone(&self) -> Rule

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 Debug for Rule

Source§

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

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

impl Hash for Rule

Source§

fn hash<__H: Hasher>(&self, state: &mut __H)

Feeds this value into the given Hasher. Read more
1.3.0 · Source§

fn hash_slice<H>(data: &[Self], state: &mut H)
where H: Hasher, Self: Sized,

Feeds a slice of this type into the given Hasher. Read more
Source§

impl PartialEq for Rule

Source§

fn eq(&self, other: &Rule) -> 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 Copy for Rule

Source§

impl Eq for Rule

Source§

impl StructuralPartialEq for Rule

Auto Trait Implementations§

§

impl Freeze for Rule

§

impl RefUnwindSafe for Rule

§

impl Send for Rule

§

impl Sync for Rule

§

impl Unpin for Rule

§

impl UnsafeUnpin for Rule

§

impl UnwindSafe for Rule

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> 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, 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.