pub struct Duration { /* private fields */ }Expand description
A duration value representing a duration between two points in time.
All non-zero components must share the same sign. Nanos are normalized
so that |nanos| < NANOS_PER_DAY, with excess rolling into days.
Implementations§
Source§impl Duration
impl Duration
pub fn new(months: i32, days: i32, nanos: i64) -> Result<Self, TypeError>
pub fn from_seconds(seconds: i64) -> Result<Self, TypeError>
pub fn from_milliseconds(milliseconds: i64) -> Result<Self, TypeError>
pub fn from_microseconds(microseconds: i64) -> Result<Self, TypeError>
pub fn from_nanoseconds(nanoseconds: i64) -> Result<Self, TypeError>
pub fn from_minutes(minutes: i64) -> Result<Self, TypeError>
pub fn from_hours(hours: i64) -> Result<Self, TypeError>
pub fn from_days(days: i64) -> Result<Self, TypeError>
pub fn from_weeks(weeks: i64) -> Result<Self, TypeError>
pub fn from_months(months: i64) -> Result<Self, TypeError>
pub fn from_years(years: i64) -> Result<Self, TypeError>
pub fn zero() -> Self
pub fn seconds(&self) -> i64
pub fn milliseconds(&self) -> i64
pub fn microseconds(&self) -> i64
pub fn nanoseconds(&self) -> i64
pub fn get_months(&self) -> i32
pub fn get_days(&self) -> i32
pub fn get_nanos(&self) -> i64
pub fn as_nanos(&self) -> i64
pub fn is_positive(&self) -> bool
pub fn is_negative(&self) -> bool
pub fn abs(&self) -> Self
pub fn negate(&self) -> Self
Sourcepub fn to_iso_string(&self) -> String
pub fn to_iso_string(&self) -> String
Format as ISO 8601 duration string: P[n]Y[n]M[n]DT[n]H[n]M[n.n]S
Trait Implementations§
Source§impl<'de> Deserialize<'de> for Duration
impl<'de> Deserialize<'de> for Duration
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 Duration
impl Ord for Duration
Source§impl PartialOrd for Duration
impl PartialOrd for Duration
Source§impl TryFromValue for Duration
impl TryFromValue for Duration
Source§fn try_from_value(value: &Value) -> Result<Self, FromValueError>
fn try_from_value(value: &Value) -> Result<Self, FromValueError>
Attempt to extract a value of this type from a Value. Read more
impl Copy for Duration
impl Eq for Duration
impl IsTemporal for Duration
impl StructuralPartialEq for Duration
Auto Trait Implementations§
impl Freeze for Duration
impl RefUnwindSafe for Duration
impl Send for Duration
impl Sync for Duration
impl Unpin for Duration
impl UnsafeUnpin for Duration
impl UnwindSafe for Duration
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