pub struct DateTime(/* private fields */);
Expand description
DateTime in litedb bson
This can represent same value as C# DateTime.
This represents number of 100 nano seconds since 0001-01-01 00:00:00 UTC This can represent 0001-01-01 00:00:00 ~ 9999-12-31 23:59:59.99999999
Implementations§
Source§impl DateTime
impl DateTime
Sourcepub const MIN: DateTime
pub const MIN: DateTime
The Minimum value of DateTime. This represents 0001-01-01T00:00:00.00000000 UTC in Proleptic Gregorian Calender.
Sourcepub const MAX: DateTime
pub const MAX: DateTime
The Maximum value of DateTime. This represents 9999-12-31 23:59:59.99999999 UTC in Proleptic Gregorian Calender.
pub fn today() -> Self
Sourcepub fn from_system(system: SystemTime) -> Option<Self>
pub fn from_system(system: SystemTime) -> Option<Self>
Creates new DateTime represents exactly the same time as the SystemTime
Precision smaller than 100 nanoseconds will be discarded.
If the time cannot be represented with this type, like before 0001 year or after 9999 year,
this function will return None
.
Sourcepub const fn from_ticks(ticks: u64) -> Option<DateTime>
pub const fn from_ticks(ticks: u64) -> Option<DateTime>
Create new DateTime from ticks
If the tick is larger than Self::MAX, returns None
.
pub fn from_ymd(year: u32, month: u32, day: u32) -> Option<DateTime>
Sourcepub fn ticks(&self) -> u64
pub fn ticks(&self) -> u64
Get the total ticks since 0001-01-01 00:00:00
One tick is 100 nanoseconds
Sourcepub fn to_system_time(&self) -> Option<SystemTime>
pub fn to_system_time(&self) -> Option<SystemTime>
Get the SystemTime that represents the same time as this DateTime
If the time cannot be represented with SystemTime
, this will return None
.
pub fn as_unix_milliseconds(&self) -> i64
pub const fn parse_rfc3339(s: &str) -> Option<DateTime>
pub fn add_ticks(&self, diff: i64) -> DateTime
pub fn year(&self) -> u32
pub fn month(&self) -> u32
pub fn day(&self) -> u32
pub fn hour(&self) -> u32
pub fn minute(&self) -> u32
pub fn second(&self) -> u32
Source§impl DateTime
impl DateTime
pub fn add_years(&self, diff: i32) -> Option<DateTime>
pub fn add_months(&self, diff: i32) -> Option<DateTime>
pub fn add_days(&self, diff: i32) -> Option<DateTime>
pub fn add_hours(&self, diff: i32) -> Option<DateTime>
pub fn add_minutes(&self, diff: i32) -> Option<DateTime>
pub fn add_seconds(&self, diff: i32) -> Option<DateTime>
Trait Implementations§
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 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
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<Q, K> Comparable<K> for Q
impl<Q, K> Comparable<K> for Q
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
key
and return true
if they are equal.Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
self
into a Left
variant of Either<Self, Self>
if into_left
is true
.
Converts self
into a Right
variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
self
into a Left
variant of Either<Self, Self>
if into_left(&self)
returns true
.
Converts self
into a Right
variant of Either<Self, Self>
otherwise. Read more