pub struct Time {
value: i64,
unit: TimeUnit,
}
Expand description
Time value, represents the elapsed time since midnight in the unit of TimeUnit
.
Fields§
§value: i64
§unit: TimeUnit
Implementations§
source§impl Time
impl Time
sourcepub fn new_nanosecond(value: i64) -> Self
pub fn new_nanosecond(value: i64) -> Self
Creates the time in nanosecond.
sourcepub fn new_second(value: i64) -> Self
pub fn new_second(value: i64) -> Self
Creates the time in second.
sourcepub fn new_millisecond(value: i64) -> Self
pub fn new_millisecond(value: i64) -> Self
Creates the time in millisecond.
sourcepub fn new_microsecond(value: i64) -> Self
pub fn new_microsecond(value: i64) -> Self
Creates the time in microsecond.
sourcepub fn convert_to(&self, unit: TimeUnit) -> Option<Time>
pub fn convert_to(&self, unit: TimeUnit) -> Option<Time>
Convert a time to given time unit.
Return None
if conversion causes overflow.
sourcefn split(&self) -> (i64, u32)
fn split(&self) -> (i64, u32)
Split a Time into seconds part and nanoseconds part. Notice the seconds part of split result is always rounded down to floor.
sourcepub fn to_iso8601_string(&self) -> String
pub fn to_iso8601_string(&self) -> String
Format Time to ISO8601 string. If the time exceeds what chrono time can represent, this function simply print the time unit and value in plain string.
sourcepub fn to_system_tz_string(&self) -> String
pub fn to_system_tz_string(&self) -> String
Format Time for system timeszone.
sourcepub fn to_timezone_aware_string(&self, tz: Option<&Timezone>) -> String
pub fn to_timezone_aware_string(&self, tz: Option<&Timezone>) -> String
Format Time for given timezone. When timezone is None, using system timezone by default.
fn as_formatted_string( self, pattern: &str, timezone: Option<&Timezone>, ) -> String
sourcepub fn to_chrono_time(&self) -> Option<NaiveTime>
pub fn to_chrono_time(&self) -> Option<NaiveTime>
Cast the Time into chrono NaiveDateTime
pub fn negative(self) -> Self
Trait Implementations§
source§impl<'de> Deserialize<'de> for Time
impl<'de> Deserialize<'de> for Time
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 Time
impl Ord for Time
source§impl PartialOrd for Time
impl PartialOrd for Time
impl Copy for Time
impl Eq for Time
Auto Trait Implementations§
impl Freeze for Time
impl RefUnwindSafe for Time
impl Send for Time
impl Sync for Time
impl Unpin for Time
impl UnwindSafe for Time
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
§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)
🔬This is a nightly-only experimental API. (
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
Compare self to
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
Compare self to
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
Checks if this value is equivalent to the given key. Read more
§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>
Wrap the input message
T
in a tonic::Request