pub struct DateTime { /* private fields */ }Expand description
A date and time value with nanosecond precision. Always in SVTC timezone.
Internally stored as seconds and nanoseconds since Unix epoch.
Implementations§
Source§impl DateTime
impl DateTime
pub fn new( year: i32, month: u32, day: u32, hour: u32, min: u32, sec: u32, nano: u32, ) -> Option<Self>
pub fn from_ymd_hms( year: i32, month: u32, day: u32, hour: u32, min: u32, sec: u32, ) -> Result<Self, String>
pub fn from_timestamp(timestamp: i64) -> Result<Self, String>
pub fn from_timestamp_millis(millis: i64) -> Result<Self, String>
pub fn now() -> Self
pub fn timestamp(&self) -> i64
pub fn timestamp_millis(&self) -> i64
pub fn timestamp_nanos(&self) -> i64
pub fn date(&self) -> Date
pub fn time(&self) -> Time
Sourcepub fn to_nanos_since_epoch(&self) -> i64
pub fn to_nanos_since_epoch(&self) -> i64
Convert to nanoseconds since Unix epoch for storage
Sourcepub fn from_nanos_since_epoch(nanos: i64) -> Self
pub fn from_nanos_since_epoch(nanos: i64) -> Self
Create from nanoseconds since Unix epoch for storage
Sourcepub fn from_parts(seconds: i64, nanos: u32) -> Result<Self, String>
pub fn from_parts(seconds: i64, nanos: u32) -> Result<Self, String>
Create from separate seconds and nanoseconds
Sourcepub fn nanosecond(&self) -> u32
pub fn nanosecond(&self) -> u32
Get nanosecond component (0-999_999_999)
Trait Implementations§
Source§impl<'de> Deserialize<'de> for DateTime
impl<'de> Deserialize<'de> for DateTime
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>,
Deserialize this value from the given Serde deserializer. Read more
Source§impl Ord for DateTime
impl Ord for DateTime
Source§impl PartialOrd for DateTime
impl PartialOrd for DateTime
impl Copy for DateTime
impl Eq for DateTime
impl IsDate for DateTime
impl IsTemporal for DateTime
impl IsTime for DateTime
impl StructuralPartialEq for DateTime
Auto Trait Implementations§
impl Freeze for DateTime
impl RefUnwindSafe for DateTime
impl Send for DateTime
impl Sync for DateTime
impl Unpin for DateTime
impl UnwindSafe for DateTime
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