pub struct UtcDateTime { /* private fields */ }
Expand description
UTC date time exprimed in the proleptic gregorian calendar
Implementations§
Source§impl UtcDateTime
impl UtcDateTime
Sourcepub const fn new(
year: i32,
month: u8,
month_day: u8,
hour: u8,
minute: u8,
second: u8,
nanoseconds: u32,
) -> Result<Self, DateTimeError>
pub const fn new( year: i32, month: u8, month_day: u8, hour: u8, minute: u8, second: u8, nanoseconds: u32, ) -> Result<Self, DateTimeError>
Construct a UTC date time
§Inputs
year
: Yearmonth
: Month in[1, 12]
month_day
: Day of the month in[1, 31]
hour
: Hours since midnight in[0, 23]
minute
: Minutes in[0, 59]
second
: Seconds in[0, 60]
, with a possible leap secondnanoseconds
: Nanoseconds in[0, 999_999_999]
Sourcepub const fn from_timespec(
unix_time: i64,
nanoseconds: u32,
) -> Result<Self, OutOfRangeError>
pub const fn from_timespec( unix_time: i64, nanoseconds: u32, ) -> Result<Self, OutOfRangeError>
Construct a UTC date time from a Unix time in seconds and nanoseconds
Sourcepub const fn from_total_nanoseconds(
total_nanoseconds: i128,
) -> Result<Self, OutOfRangeError>
pub const fn from_total_nanoseconds( total_nanoseconds: i128, ) -> Result<Self, OutOfRangeError>
Construct a UTC date time from total nanoseconds since Unix epoch (1970-01-01T00:00:00Z
)
Sourcepub fn now() -> Result<Self, TzError>
Available on crate feature std
only.
pub fn now() -> Result<Self, TzError>
std
only.Returns the current UTC date time
Sourcepub const fn unix_time(&self) -> i64
pub const fn unix_time(&self) -> i64
Returns the Unix time in seconds associated to the UTC date time
Sourcepub const fn project(
&self,
time_zone_ref: TimeZoneRef<'_>,
) -> Result<DateTime, ProjectDateTimeError>
pub const fn project( &self, time_zone_ref: TimeZoneRef<'_>, ) -> Result<DateTime, ProjectDateTimeError>
Project the UTC date time into a time zone.
Leap seconds are not preserved.
Source§impl UtcDateTime
impl UtcDateTime
Sourcepub const fn nanoseconds(&self) -> u32
pub const fn nanoseconds(&self) -> u32
Returns nanoseconds in [0, 999_999_999]
Sourcepub const fn total_nanoseconds(&self) -> i128
pub const fn total_nanoseconds(&self) -> i128
Returns total nanoseconds since Unix epoch (1970-01-01T00:00:00Z
)
Trait Implementations§
Source§impl Clone for UtcDateTime
impl Clone for UtcDateTime
Source§fn clone(&self) -> UtcDateTime
fn clone(&self) -> UtcDateTime
Returns a copy of the value. Read more
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source
. Read moreSource§impl Debug for UtcDateTime
impl Debug for UtcDateTime
Source§impl Display for UtcDateTime
impl Display for UtcDateTime
Source§impl Ord for UtcDateTime
impl Ord for UtcDateTime
Source§fn cmp(&self, other: &UtcDateTime) -> Ordering
fn cmp(&self, other: &UtcDateTime) -> Ordering
1.21.0 · Source§fn max(self, other: Self) -> Selfwhere
Self: Sized,
fn max(self, other: Self) -> Selfwhere
Self: Sized,
Compares and returns the maximum of two values. Read more
Source§impl PartialEq for UtcDateTime
impl PartialEq for UtcDateTime
Source§impl PartialOrd for UtcDateTime
impl PartialOrd for UtcDateTime
impl Copy for UtcDateTime
impl Eq for UtcDateTime
impl StructuralPartialEq for UtcDateTime
Auto Trait Implementations§
impl Freeze for UtcDateTime
impl RefUnwindSafe for UtcDateTime
impl Send for UtcDateTime
impl Sync for UtcDateTime
impl Unpin for UtcDateTime
impl UnwindSafe for UtcDateTime
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
Mutably borrows from an owned value. Read more