pub struct DateTime {
pub date: Date,
pub hour: u32,
pub minute: u32,
pub second: u32,
pub nanosecond: u32,
pub offset_minutes: Option<i32>,
pub has_time: bool,
}Expand description
An ISO-8601 datetime: a Date, an optional time of day, and an optional
UTC offset.
A value with no offset is treated as UTC for comparison, which is what
consumers need in order to answer “which verification is most recent”
across producers that write Z, +02:00, or nothing at all.
Fields§
§date: DateThe calendar date.
hour: u32Hour, 0 to 23 (0 when the value is date-only).
minute: u32Minute, 0 to 59.
second: u32Second, 0 to 60 (60 admits a leap second).
nanosecond: u32Fractional second in nanoseconds.
offset_minutes: Option<i32>Minutes east of UTC, or None when the value carries no zone.
has_time: boolfalse when only a date was written (2026-09-23).
Implementations§
Source§impl DateTime
impl DateTime
Sourcepub fn parse(s: &str) -> Option<Self>
pub fn parse(s: &str) -> Option<Self>
Parses an ISO-8601 datetime.
Accepts YYYY-MM-DD, YYYY-MM-DDTHH:MM[:SS[.fraction]] (with T, t,
or a space as the separator), and an optional Z / ±HH:MM / ±HHMM /
±HH zone.
Sourcepub fn to_utc_seconds(&self) -> i64
pub fn to_utc_seconds(&self) -> i64
Seconds since the Unix epoch, normalizing the zone (a missing offset is read as UTC).
Sourcepub fn utc_date(&self) -> Date
pub fn utc_date(&self) -> Date
The calendar date in UTC, which differs from DateTime::date when the
value carries an offset that crosses midnight.
Sourcepub const fn has_offset(&self) -> bool
pub const fn has_offset(&self) -> bool
true if the parsed datetime carries an explicit UTC offset.
Sourcepub const fn from_date_utc(date: Date) -> Self
pub const fn from_date_utc(date: Date) -> Self
Creates a UTC datetime at midnight (00:00:00Z) for a given Date.