pub enum TimeUnit {
NanoSecond,
MicroSecond,
MilliSecond,
Second,
Minute,
Hour,
Day,
Week,
Month,
Year,
}
Expand description
The time units the parser can understand and needed to configure the DurationParser
.
Examples
use std::time::Duration;
use fundu::{DurationParser, TimeUnit};
assert_eq!(
DurationParser::with_time_units(&[TimeUnit::NanoSecond])
.parse("42ns")
.unwrap(),
Duration::new(0, 42)
);
Variants§
NanoSecond
Represents the lowest possible time unit. The default id is given by
DEFAULT_ID_NANO_SECOND
= ns
MicroSecond
The default id is given by DEFAULT_ID_MICRO_SECOND
= Ms
MilliSecond
The default id is given by DEFAULT_ID_MILLI_SECOND
= ms
Second
The default if no time unit is given. The default id is given by DEFAULT_ID_SECOND
=
s
Minute
The default id is given by DEFAULT_ID_MINUTE
= m
Hour
The default id is given by DEFAULT_ID_HOUR
= h
Day
The default id is given by DEFAULT_ID_DAY
= d
Week
The default id is given by DEFAULT_ID_WEEK
= w
Month
The default id is given by DEFAULT_ID_MONTH
= M
Year
Represents the hightest possible time unit. The default id is given by DEFAULT_ID_YEAR
= y
Implementations§
source§impl TimeUnit
impl TimeUnit
sourcepub const fn default_identifier(&self) -> &'static str
pub const fn default_identifier(&self) -> &'static str
Return the default identifier
sourcepub const fn multiplier(&self) -> Multiplier
pub const fn multiplier(&self) -> Multiplier
Return the base Multiplier
of this TimeUnit
.
This multiplier is always seconds based so for example:
NanoSecond: Multiplier(1, -9)
Second: Multiplier(1, 0)
Year: Multiplier(31557600, 0)
Trait Implementations§
source§impl Ord for TimeUnit
impl Ord for TimeUnit
source§impl PartialEq<TimeUnit> for TimeUnit
impl PartialEq<TimeUnit> for TimeUnit
source§impl PartialOrd<TimeUnit> for TimeUnit
impl PartialOrd<TimeUnit> for TimeUnit
1.0.0 · source§fn le(&self, other: &Rhs) -> bool
fn le(&self, other: &Rhs) -> bool
self
and other
) and is used by the <=
operator. Read more