Skip to main content

YmdHmsRich

Struct YmdHmsRich 

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

Gregorian calendar and time-of-day components of a Dt.

Implementations§

Source§

impl YmdHmsRich

Source

pub const WIRE_VERSION: u8 = 1

Current wire format version.

Source

pub const WIRE_SIZE: usize = 159

Size of the canonical wire representation in bytes (159 bytes).

Source

pub fn to_wire_bytes(&self) -> [u8; 159]

Serializes this YmdHmsRich into a fixed 159-byte buffer.

§Wire Format (Version 1)
  • Byte 0: Version (WIRE_VERSION)
  • Bytes 1..17: unix_attosec (i128)
  • Bytes 17..25: yr (i64)
  • Bytes 25..30: mo, day, hr, min, sec (u8 × 5)
  • Bytes 30..38: attos (u64)
  • Bytes 38..46: iso_yr (i64)
  • Bytes 46..48: iso_wk + iso_wkday (u8 × 2)
  • Bytes 48..50: day_of_yr (u16)
  • Byte 50: wkday (u8)
  • Bytes 51..53: wk_of_yr_sun + wk_of_yr_mon (u8 × 2)
  • Bytes 53..58: offset_sec (tag byte + i32)
  • Bytes 58..108: tz (tag byte + LiteStr<49>)
  • Bytes 108..158: tz_abbrev (tag byte + LiteStr<49>)
  • Byte 158: scale (1 byte via to_wire_byte)
Source

pub fn from_wire_bytes(bytes: &[u8]) -> Option<Self>

Deserializes a YmdHmsRich from exactly 159 bytes of wire data.

Returns None if the version is unknown or any field is invalid.

§Security

Safe for untrusted input. Fixed-size format with strict validation. No allocation or unsafe code used.

Source§

impl YmdHmsRich

Source

pub fn to_str(&self, fmt: &str) -> Result<String, DtErr>

Equivalent of strftime.

Requires "alloc" feature.

Source

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

No-allocation formatting.

use deep_time::{Dt, Scale};

let x = Dt::from_ymd(2000, 1, 1);
let y = x.to_ymdhms_rich(Scale::TAI);
let b = y.to_str_bin("%F").unwrap();
let s = b.as_str().unwrap();

println!("{}", s);
Source§

impl YmdHmsRich

Source

pub const fn to_dt(&self) -> Dt

Reconstructs a Dt. Round trips with [Dt::to_date_time].

Source

pub const fn unix_attosec(&self) -> i128

Attoseconds since 1970-01-01 midnight, on whatever time scale the object was created on.

Source

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

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

  • The timestamp will be on whatever Scale the [DateTime] was created on.
  • 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).

Trait Implementations§

Source§

impl Clone for YmdHmsRich

Source§

fn clone(&self) -> YmdHmsRich

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 YmdHmsRich

Source§

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

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

impl<'de> Deserialize<'de> for YmdHmsRich

Source§

fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>
where __D: Deserializer<'de>,

Deserialize this value from the given Serde deserializer. Read more
Source§

impl PartialEq for YmdHmsRich

Source§

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

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 Tsify for YmdHmsRich

Source§

const DECL: &'static str = "/**\n * Gregorian calendar and time-of-day components of a [`Dt`].\n */\nexport interface YmdHmsRich {\n /**\n * UNIX attoseconds counting from 1970 epoch\n */\n unix_attosec: number;\n /**\n * Gregorian year (proleptic Gregorian calendar, supports negative years and year 0).\n */\n yr: number;\n /**\n * Gregorian month in the range [1, 12].\n */\n mo: number;\n /**\n * Gregorian day of the month in the range [1, 31].\n */\n day: number;\n /**\n * Hour of the day in the range [0, 23].\n */\n hr: number;\n /**\n * Minute in the range [0, 59].\n */\n min: number;\n /**\n * Second in the range [0, 60] (60 only during UTC leap seconds).\n */\n sec: number;\n /**\n * Fractional part of the second expressed in attoseconds (u64).\n */\n attos: number;\n /**\n * ISO 8601 week year.\n */\n iso_yr: number;\n /**\n * ISO 8601 week number in the range [1, 53].\n */\n iso_wk: number;\n /**\n * ISO 8601 weekday enum e.g. Monday/Tuesday/...\n */\n iso_wkday: Weekday;\n /**\n * Ordinal day of the year (1-based).\n */\n day_of_yr: number;\n /**\n * Weekday number (0 = Sunday \u{2026} 6 = Saturday).\n */\n wkday: number;\n /**\n * Sunday based week of year (Range: `0..=53`).\n */\n wk_of_yr_sun: number;\n /**\n * Monday based week of year (Range: `0..=53`).\n */\n wk_of_yr_mon: number;\n /**\n * Used for formatting (strftime).\n * A stored offset in seconds, used within the crate.\n */\n offset_sec: number | null;\n /**\n * A stored IANA name, used within the crate, %Q.\n */\n tz: LiteStr | null;\n /**\n * UTC, EST, %Z\n */\n tz_abbrev: LiteStr | null;\n /**\n * Scale the instance was created on\n */\n scale: Scale;\n}"

Source§

const SERIALIZATION_CONFIG: SerializationConfig

Source§

type JsType = JsType

Source§

fn into_js(&self) -> Result<Self::JsType, Error>
where Self: Serialize,

Source§

fn from_js<T>(js: T) -> Result<Self, Error>
where T: Into<JsValue>, Self: DeserializeOwned,

Source§

impl Copy for YmdHmsRich

Source§

impl Eq for YmdHmsRich

Source§

impl StructuralPartialEq for YmdHmsRich

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<Q, K> Equivalent<K> for Q
where Q: Eq + ?Sized, K: Borrow<Q> + ?Sized,

Source§

fn equivalent(&self, key: &K) -> bool

Compare self to key and return true if they are equal.
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> 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.
Source§

impl<S, T> Upcast<T> for S
where T: UpcastFrom<S> + ?Sized, S: ?Sized,

Source§

fn upcast(&self) -> &T
where Self: ErasableGeneric, T: ErasableGeneric<Repr = Self::Repr>,

Perform a zero-cost type-safe upcast to a wider ref type within the Wasm bindgen generics type system. Read more
Source§

fn upcast_into(self) -> T
where Self: Sized + ErasableGeneric, T: ErasableGeneric<Repr = Self::Repr>,

Perform a zero-cost type-safe upcast to a wider type within the Wasm bindgen generics type system. Read more
Source§

impl<T> DeserializeOwned for T
where T: for<'de> Deserialize<'de>,