pub struct GregorianTime { /* private fields */ }Expand description
UTC Civil calendar and time-of-day components of a Dt.
Implementations§
Source§impl GregorianTime
impl GregorianTime
Sourcepub const WIRE_VERSION: u8 = 1
pub const WIRE_VERSION: u8 = 1
Current wire format version.
Sourcepub const WIRE_SIZE: usize = 158
pub const WIRE_SIZE: usize = 158
Size of the canonical wire representation in bytes (158 bytes).
Sourcepub fn to_wire_bytes(&self) -> [u8; 158]
pub fn to_wire_bytes(&self) -> [u8; 158]
Serializes this GregorianTime into a fixed 158-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 +AsciiStr<49>) - Bytes
108..158:tz_abbrev(tag byte +AsciiStr<49>)
Sourcepub fn from_wire_bytes(bytes: &[u8]) -> Option<Self>
pub fn from_wire_bytes(bytes: &[u8]) -> Option<Self>
Deserializes a GregorianTime from exactly 158 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 GregorianTime
impl GregorianTime
Source§impl GregorianTime
impl GregorianTime
Sourcepub 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
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().
Sourcepub const fn unix_attosec(&self) -> i128
pub const fn unix_attosec(&self) -> i128
UNIX attoseconds since 1970 epoch
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 UTC as a tuple of
(whole_seconds, attoseconds).
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).
pub const fn offset_sec(&self) -> Option<i32>
pub const fn tz(&self) -> Option<&AsciiStr<49>>
pub const fn tz_abbrev(&self) -> Option<&AsciiStr<49>>
Trait Implementations§
Source§impl Clone for GregorianTime
impl Clone for GregorianTime
Source§fn clone(&self) -> GregorianTime
fn clone(&self) -> GregorianTime
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 GregorianTime
impl Debug for GregorianTime
Source§impl<'de> Deserialize<'de> for GregorianTime
impl<'de> Deserialize<'de> for GregorianTime
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 GregorianTime
impl PartialEq for GregorianTime
Source§fn eq(&self, other: &GregorianTime) -> bool
fn eq(&self, other: &GregorianTime) -> bool
self and other values to be equal, and is used by ==.Source§impl Serialize for GregorianTime
impl Serialize for GregorianTime
Source§impl Tsify for GregorianTime
impl Tsify for GregorianTime
const DECL: &'static str = "/**\n * UTC Civil calendar and time-of-day components of a [`Dt`].\n */\nexport interface GregorianTime {\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: AsciiStr | null;\n /**\n * UTC, EST, %Z\n */\n tz_abbrev: AsciiStr | null;\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 GregorianTime
impl Eq for GregorianTime
impl StructuralPartialEq for GregorianTime
Auto Trait Implementations§
impl Freeze for GregorianTime
impl RefUnwindSafe for GregorianTime
impl Send for GregorianTime
impl Sync for GregorianTime
impl Unpin for GregorianTime
impl UnsafeUnpin for GregorianTime
impl UnwindSafe for GregorianTime
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.