Skip to main content

GregorianTime

Struct GregorianTime 

Source
pub struct GregorianTime { /* private fields */ }
Expand description

UTC Civil calendar and time-of-day components of a Dt.

Implementations§

Source§

impl GregorianTime

Source

pub fn to_ascii_str(&self, fmt: &str) -> Result<AsciiStr<STRFTIME_SIZE>, DtErr>

No-allocation formatting.

Source§

impl GregorianTime

Source

pub const fn new( unix_attosec: i128, yr: i64, mo: u8, day: u8, hr: u8, min: u8, sec: u8, attos: u64, iso_yr: i64, iso_wk: u8, iso_wkday: Weekday, day_of_yr: u16, wkday: u8, wk_of_yr_sun: u8, wk_of_yr_mon: u8, ) -> Self

Creates a new GregorianTime with all fields specified. This isn’t the recommended way to make a GregorianTime. It’s safer to use Dt::to_gregorian_time().

Source

pub const fn unix_attosec(&self) -> i128

UNIX attoseconds since 1970 epoch

Source

pub const fn unix_timestamp(&self) -> (i64, u64)

Returns the Unix timestamp since 1970-01-01 00:00:00 UTC as a tuple of (whole_seconds, attoseconds).

  • whole_seconds can be negative (for dates before 1970).
  • The fractional part (attoseconds) is always in the range 0..=999_999_999_999_999_999.
Source

pub const fn yr(&self) -> i64

Gregorian year (proleptic Gregorian calendar, supports negative years and year 0).

Source

pub const fn mo(&self) -> u8

Gregorian month in the range [1, 12].

Source

pub const fn day(&self) -> u8

Gregorian day of the month in the range [1, 31].

Source

pub const fn hr(&self) -> u8

Hour of the day in the range [0, 23].

Source

pub const fn min(&self) -> u8

Minute in the range [0, 59].

Source

pub const fn sec(&self) -> u8

Second in the range [0, 60] (60 only during UTC leap seconds).

Source

pub const fn attos(&self) -> u64

Fractional part of the second expressed in attoseconds (0 ≤ attos < 10¹⁸).

Source

pub const fn iso_yr(&self) -> i64

ISO 8601 week year.

Source

pub const fn iso_wk(&self) -> u8

ISO 8601 week number in the range [1, 53].

Source

pub const fn iso_wkday(&self) -> Weekday

ISO 8601 weekday (Monday-based Weekday enum).

Source

pub const fn day_of_yr(&self) -> u16

Ordinal day of the year (1-based).

Source

pub const fn wkday_sun(&self) -> u8

Weekday number (0 = Sunday … 6 = Saturday).

Source

pub const fn wkday_mon(&self) -> u8

ISO 8601 weekday (0 = Monday … 6 = Sunday).

Source

pub const fn wk_of_yr_sun(&self) -> u8

Sunday based week of year (Range: 0..=53).

Source

pub const fn wk_of_yr_mon(&self) -> u8

Monday based week of year (Range: 0..=53).

Source

pub const fn offset_sec(&self) -> Option<i32>

Source

pub const fn tz(&self) -> Option<&AsciiStr<50>>

Source

pub const fn tz_abbrev(&self) -> Option<&AsciiStr<29>>

Source

pub const fn to_time_point(self) -> Dt

Reconstructs a Dt from these UTC civil components.

Round-tripping with Dt::to_gregorian_time.

Trait Implementations§

Source§

impl Clone for GregorianTime

Source§

fn clone(&self) -> GregorianTime

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 GregorianTime

Source§

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

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

impl PartialEq for GregorianTime

Source§

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

Source§

impl Eq for GregorianTime

Source§

impl StructuralPartialEq for GregorianTime

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