pub struct YmdHmsRich { /* private fields */ }Expand description
Gregorian calendar and time-of-day components of a Dt.
Implementations§
Source§impl YmdHmsRich
impl YmdHmsRich
Sourcepub const WIRE_VERSION: u8 = 1
pub const WIRE_VERSION: u8 = 1
Current wire format version.
Sourcepub const WIRE_SIZE: usize = 159
pub const WIRE_SIZE: usize = 159
Size of the canonical wire representation in bytes (159 bytes).
Sourcepub fn to_wire_bytes(&self) -> [u8; 159]
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 viato_wire_byte)
Sourcepub fn from_wire_bytes(bytes: &[u8]) -> Option<Self>
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
impl YmdHmsRich
Source§impl YmdHmsRich
impl YmdHmsRich
Sourcepub const fn unix_attosec(&self) -> i128
pub const fn unix_attosec(&self) -> i128
Attoseconds since 1970-01-01 midnight, on whatever time scale the object was created on.
Sourcepub const fn unix_timestamp(&self) -> (i64, u64)
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
Scalethe [DateTime] was created on. whole_secondscan be negative (for dates before 1970).- The fractional part (
attoseconds) is always in the range0..=999_999_999_999_999_999.
Sourcepub const fn yr(&self) -> i64
pub const fn yr(&self) -> i64
Gregorian year (proleptic Gregorian calendar, supports negative years and year 0).
Sourcepub const fn attos(&self) -> u64
pub const fn attos(&self) -> u64
Fractional part of the second expressed in attoseconds (0 ≤ attos < 10¹⁸).
Sourcepub const fn wk_of_yr_sun(&self) -> u8
pub const fn wk_of_yr_sun(&self) -> u8
Sunday based week of year (Range: 0..=53).
Sourcepub const fn wk_of_yr_mon(&self) -> u8
pub const fn wk_of_yr_mon(&self) -> u8
Monday based week of year (Range: 0..=53).
Trait Implementations§
Source§impl Clone for YmdHmsRich
impl Clone for YmdHmsRich
Source§fn clone(&self) -> YmdHmsRich
fn clone(&self) -> YmdHmsRich
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreSource§impl Debug for YmdHmsRich
impl Debug for YmdHmsRich
Source§impl<'de> Deserialize<'de> for YmdHmsRich
impl<'de> Deserialize<'de> for YmdHmsRich
Source§fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
Source§impl PartialEq for YmdHmsRich
impl PartialEq for YmdHmsRich
Source§fn eq(&self, other: &YmdHmsRich) -> bool
fn eq(&self, other: &YmdHmsRich) -> bool
self and other values to be equal, and is used by ==.Source§impl Serialize for YmdHmsRich
impl Serialize for YmdHmsRich
Source§impl Tsify for YmdHmsRich
impl Tsify for YmdHmsRich
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}"
const SERIALIZATION_CONFIG: SerializationConfig
type JsType = JsType
fn into_js(&self) -> Result<Self::JsType, Error>where
Self: Serialize,
fn from_js<T>(js: T) -> Result<Self, Error>
impl Copy for YmdHmsRich
impl Eq for YmdHmsRich
impl StructuralPartialEq for YmdHmsRich
Auto Trait Implementations§
impl Freeze for YmdHmsRich
impl RefUnwindSafe for YmdHmsRich
impl Send for YmdHmsRich
impl Sync for YmdHmsRich
impl Unpin for YmdHmsRich
impl UnsafeUnpin for YmdHmsRich
impl UnwindSafe for YmdHmsRich
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
key and return true if they are equal.