#[repr(C)]pub struct DateTime {
pub universal_time: i64,
}Fields§
§universal_time: i64Implementations§
Source§impl DateTime
impl DateTime
Sourcepub const UNIX_EPOCH: DateTime
pub const UNIX_EPOCH: DateTime
The DateTime value corresponding to 1970-01-01 00:00:00 UTC.
Sourcepub const TICKS_PER_SECOND: i64 = TICKS_PER_SECOND
pub const TICKS_PER_SECOND: i64 = TICKS_PER_SECOND
The number of 100-nanosecond ticks per second (matches
TimeSpan::TICKS_PER_SECOND).
Sourcepub const fn from_ticks(ticks: i64) -> DateTime
pub const fn from_ticks(ticks: i64) -> DateTime
Constructs a DateTime from a raw count of 100-nanosecond ticks since
1601-01-01 00:00:00 UTC.
Sourcepub const fn from_unix_secs(secs: i64) -> DateTime
pub const fn from_unix_secs(secs: i64) -> DateTime
Constructs a DateTime from a number of whole seconds since the Unix
epoch, saturating on overflow.
Sourcepub const fn from_unix_millis(millis: i64) -> DateTime
pub const fn from_unix_millis(millis: i64) -> DateTime
Constructs a DateTime from a number of whole milliseconds since the
Unix epoch, saturating on overflow.
Sourcepub const fn ticks(self) -> i64
pub const fn ticks(self) -> i64
Returns the raw count of 100-nanosecond ticks since 1601-01-01 UTC.
Sourcepub const fn unix_secs(self) -> i64
pub const fn unix_secs(self) -> i64
Returns the number of whole seconds between this DateTime and the
Unix epoch. Negative for pre-1970 values.
Sourcepub const fn unix_millis(self) -> i64
pub const fn unix_millis(self) -> i64
Returns the number of whole milliseconds between this DateTime and
the Unix epoch. Negative for pre-1970 values.
Sourcepub const fn unix_nanos(self) -> i128
pub const fn unix_nanos(self) -> i128
Returns the number of nanoseconds between this DateTime and the Unix
epoch, as an i128 to avoid overflow.
Sourcepub const fn checked_add(self, rhs: TimeSpan) -> Option<DateTime>
pub const fn checked_add(self, rhs: TimeSpan) -> Option<DateTime>
Checked addition of a TimeSpan. Returns None on overflow.
Sourcepub const fn checked_sub(self, rhs: TimeSpan) -> Option<DateTime>
pub const fn checked_sub(self, rhs: TimeSpan) -> Option<DateTime>
Checked subtraction of a TimeSpan. Returns None on overflow.
Sourcepub const fn checked_duration_since(self, earlier: DateTime) -> Option<TimeSpan>
pub const fn checked_duration_since(self, earlier: DateTime) -> Option<TimeSpan>
Returns the signed duration from earlier to self. Returns None on
overflow.
Sourcepub const fn saturating_add(self, rhs: TimeSpan) -> DateTime
pub const fn saturating_add(self, rhs: TimeSpan) -> DateTime
Saturating addition of a TimeSpan.
Sourcepub const fn saturating_sub(self, rhs: TimeSpan) -> DateTime
pub const fn saturating_sub(self, rhs: TimeSpan) -> DateTime
Saturating subtraction of a TimeSpan.
Sourcepub fn to_local(self) -> DateTime
pub fn to_local(self) -> DateTime
Converts this DateTime from UTC to local time by applying the
system’s current timezone offset (including DST adjustments).
The returned DateTime has its ticks shifted so that the decomposition
methods (year, month, day, etc.) return local calendar values.
§Example
use windows_time::DateTime;
let local = DateTime::now().to_local();
println!("{:02}:{:02}:{:02}", local.hour(), local.minute(), local.second());Sourcepub const fn milliseconds(self) -> u32
pub const fn milliseconds(self) -> u32
The milliseconds (0-999).
Sourcepub const fn day_of_week(self) -> u32
pub const fn day_of_week(self) -> u32
The day of the week (0 = Sunday, 6 = Saturday).
Trait Implementations§
Source§impl AddAssign<TimeSpan> for DateTime
impl AddAssign<TimeSpan> for DateTime
Source§fn add_assign(&mut self, rhs: TimeSpan)
fn add_assign(&mut self, rhs: TimeSpan)
+= operation. Read moreimpl Copy for DateTime
Source§impl Display for DateTime
ISO-8601 UTC formatting: YYYY-MM-DDTHH:MM:SS.fffffffZ. The fractional
part is omitted when zero. Year is at least 4 digits, padded with a leading
- for negative years.
impl Display for DateTime
ISO-8601 UTC formatting: YYYY-MM-DDTHH:MM:SS.fffffffZ. The fractional
part is omitted when zero. Year is at least 4 digits, padded with a leading
- for negative years.
impl Eq for DateTime
Source§impl Ord for DateTime
impl Ord for DateTime
1.21.0 (const: unstable) · Source§fn max(self, other: Self) -> Selfwhere
Self: Sized,
fn max(self, other: Self) -> Selfwhere
Self: Sized,
1.21.0 (const: unstable) · Source§fn min(self, other: Self) -> Selfwhere
Self: Sized,
fn min(self, other: Self) -> Selfwhere
Self: Sized,
Source§impl PartialOrd for DateTime
impl PartialOrd for DateTime
impl StructuralPartialEq for DateTime
Source§impl SubAssign<TimeSpan> for DateTime
impl SubAssign<TimeSpan> for DateTime
Source§fn sub_assign(&mut self, rhs: TimeSpan)
fn sub_assign(&mut self, rhs: TimeSpan)
-= operation. Read moreSource§impl TryFrom<SystemTime> for DateTime
Available on crate feature std only.
impl TryFrom<SystemTime> for DateTime
std only.