pub struct Time(_, _);
Expand description
Human-readable std::time::Duration
.
The input is always assumed to be in seconds.
The inner fields are (f64, String)
but they are not public.
From
input can be:
The lowest unit is second
, the highest is year
, and week
is skipped in favor of 7 days
.
Examples
Input | String Output |
---|---|
0 | 0 seconds |
1 | 1 second |
59 | 59 seconds |
3599 | 59 minutes, 59 seconds |
86399 | 23 hours, 59 minutes, 59 seconds |
604799 | 6 days, 23 hours, 59 minutes, 59 seconds |
3234815 | 1 month, 6 days, 23 hours, 59 minutes, 59 seconds |
63115200 | 2 years |
Exceptions
Exception | String Output |
---|---|
f32::NAN & f64::NAN | NaN |
f32::INFINITY & f64::INFINITY | ∞ |
f32::NEG_INFINITY & f64::NEG_INFINITY | -∞ |
Credit
This code is forked from https://docs.rs/humantime
, edited to remove sub-second time, change spacing and some words.
Implementations§
source§impl Time
impl Time
sourcepub fn into_string(self) -> String
pub fn into_string(self) -> String
Consumes [Self]
, returning the inner String
.
sourcepub fn inf() -> Self
pub fn inf() -> Self
Returns a Self
with the f64
value of f64::INFINITY
.
The String
is set to ∞
.
Trait Implementations§
source§impl PartialEq<Time> for Time
impl PartialEq<Time> for Time
source§impl PartialOrd<Time> for Time
impl PartialOrd<Time> for Time
1.0.0 · source§fn le(&self, other: &Rhs) -> bool
fn le(&self, other: &Rhs) -> bool
This method tests less than or equal to (for
self
and other
) and is used by the <=
operator. Read more