#[non_exhaustive]pub struct DateTime<'a> {
pub date: Date,
pub time: Time,
pub offset: Option<i32>,
pub zone: Option<&'a str>,
pub options: DateTimeOptions<'a>,
}Expand description
A date/time value: an application’s argument (crate::Arg::DateTime,
crate::CustomValue::as_date_time), a literal a date/time function
parsed, or what :datetime, :date or :time resolved — the value with
its DateTimeOptions. Build it with the constructors.
Fields (Non-exhaustive)§
This struct is marked as non-exhaustive
Struct { .. } syntax; cannot be matched against without a wildcard ..; and struct update syntax will not work.date: DateThe civil date (in the value’s offset, or floating).
time: TimeThe wall-clock time (00:00 when the value has no time).
offset: Option<i32>Seconds east of UTC; None: floating — no offset, so the formatting
time zone applies without conversion (datetime.md, “Date and Time
Operands”).
zone: Option<&'a str>The IANA time zone the value is in, when it names one.
options: DateTimeOptions<'a>What a date/time function resolved; empty for an argument, except for the override options an application value may carry.
Implementations§
Source§impl<'a> DateTime<'a>
impl<'a> DateTime<'a>
Sourcepub const fn from_epoch_ms(ms: i64) -> Option<DateTime<'a>>
pub const fn from_epoch_ms(ms: i64) -> Option<DateTime<'a>>
The instant ms milliseconds after 1970-01-01T00:00:00Z, in UTC
(datetime.md: an offset from an epoch includes UTC as its zone).
Sourcepub const fn to_epoch_ms(&self) -> Option<i64>
pub const fn to_epoch_ms(&self) -> Option<i64>
The instant, in milliseconds since the epoch; None when floating.
Sourcepub const fn with_offset(self, seconds: i32) -> Option<Self>
pub const fn with_offset(self, seconds: i32) -> Option<Self>
The same wall time at UTC offset seconds; None unless
|seconds| < 86,400.
Sourcepub const fn in_zone(self, zone: &'a str) -> Self
pub const fn in_zone(self, zone: &'a str) -> Self
The same value, in the IANA zone zone. A value with an offset is
an instant, and stays one: a date/time function shows it at the
zone’s wall time, converting through Host::zone_offset when the
offset is not the zone’s. A floating value’s wall time is placed in
zone.