pub struct DateTime(i64);
Expand description
DateTime represents the milliseconds elapsed since “1970-01-01 00:00:00 UTC” (UNIX Epoch).
Tuple Fields§
§0: i64
Implementations§
source§impl DateTime
impl DateTime
sourcepub fn from_str_system(s: &str) -> Result<Self>
pub fn from_str_system(s: &str) -> Result<Self>
Try parsing a string into DateTime
with the system timezone.
See DateTime::from_str
.
sourcepub fn from_str(s: &str, timezone: Option<&Timezone>) -> Result<Self>
pub fn from_str(s: &str, timezone: Option<&Timezone>) -> Result<Self>
Try parsing a string into DateTime
with the given timezone.
Supported format:
- RFC3339 in the naive UTC timezone.
%F %T
with the given timezone%F %T%z
with the timezone in string
sourcepub fn new(millis: i64) -> Self
pub fn new(millis: i64) -> Self
Create a new DateTime from milliseconds elapsed since “1970-01-01 00:00:00 UTC” (UNIX Epoch).
sourcepub fn val(&self) -> i64
pub fn val(&self) -> i64
Get the milliseconds elapsed since “1970-01-01 00:00:00 UTC” (UNIX Epoch).
sourcepub fn to_chrono_datetime(&self) -> Option<NaiveDateTime>
pub fn to_chrono_datetime(&self) -> Option<NaiveDateTime>
Convert to NaiveDateTime.
sourcepub fn as_formatted_string(
self,
pattern: &str,
timezone: Option<&Timezone>,
) -> Result<Option<String>>
pub fn as_formatted_string( self, pattern: &str, timezone: Option<&Timezone>, ) -> Result<Option<String>>
Format DateTime for given format and timezone.
If tz==None
, the server default timezone will used.
pub fn to_chrono_datetime_with_timezone( &self, tz: Option<&Timezone>, ) -> Option<NaiveDateTime>
sourcepub fn add_year_month(&self, interval: IntervalYearMonth) -> Option<Self>
pub fn add_year_month(&self, interval: IntervalYearMonth) -> Option<Self>
Adds given IntervalYearMonth to the current datetime.
sourcepub fn add_day_time(&self, interval: IntervalDayTime) -> Option<Self>
pub fn add_day_time(&self, interval: IntervalDayTime) -> Option<Self>
Adds given IntervalDayTime to the current datetime.
sourcepub fn add_month_day_nano(&self, interval: IntervalMonthDayNano) -> Option<Self>
pub fn add_month_day_nano(&self, interval: IntervalMonthDayNano) -> Option<Self>
Adds given IntervalMonthDayNano to the current datetime.
sourcepub fn sub_year_month(&self, interval: IntervalYearMonth) -> Option<Self>
pub fn sub_year_month(&self, interval: IntervalYearMonth) -> Option<Self>
Subtracts given IntervalYearMonth to the current datetime.
sourcepub fn sub_day_time(&self, interval: IntervalDayTime) -> Option<Self>
pub fn sub_day_time(&self, interval: IntervalDayTime) -> Option<Self>
Subtracts given IntervalDayTime to the current datetime.
sourcepub fn sub_month_day_nano(&self, interval: IntervalMonthDayNano) -> Option<Self>
pub fn sub_month_day_nano(&self, interval: IntervalMonthDayNano) -> Option<Self>
Subtracts given IntervalMonthDayNano to the current datetime.
pub fn negative(&self) -> Self
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>,
source§impl From<NaiveDateTime> for DateTime
impl From<NaiveDateTime> for DateTime
source§fn from(value: NaiveDateTime) -> Self
fn from(value: NaiveDateTime) -> Self
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
§impl<T> CallHasher for T
impl<T> CallHasher for T
source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
source§unsafe fn clone_to_uninit(&self, dst: *mut T)
unsafe fn clone_to_uninit(&self, dst: *mut T)
clone_to_uninit
)§impl<Q, K> Comparable<K> for Q
impl<Q, K> Comparable<K> for Q
§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
key
and return true
if they are equal.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.§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
§impl<T> Instrument for T
impl<T> Instrument for T
§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
source§impl<T> IntoRequest<T> for T
impl<T> IntoRequest<T> for T
source§fn into_request(self) -> Request<T>
fn into_request(self) -> Request<T>
T
in a tonic::Request