Trait product_os_async_executor::Timelike
source · pub trait Timelike: Sized {
// Required methods
fn hour(&self) -> u32;
fn minute(&self) -> u32;
fn second(&self) -> u32;
fn nanosecond(&self) -> u32;
fn with_hour(&self, hour: u32) -> Option<Self>;
fn with_minute(&self, min: u32) -> Option<Self>;
fn with_second(&self, sec: u32) -> Option<Self>;
fn with_nanosecond(&self, nano: u32) -> Option<Self>;
// Provided methods
fn hour12(&self) -> (bool, u32) { ... }
fn num_seconds_from_midnight(&self) -> u32 { ... }
}
Expand description
The common set of methods for time component.
Required Methods§
sourcefn nanosecond(&self) -> u32
fn nanosecond(&self) -> u32
Returns the number of nanoseconds since the whole non-leap second. The range from 1,000,000,000 to 1,999,999,999 represents the leap second.
sourcefn with_hour(&self, hour: u32) -> Option<Self>
fn with_hour(&self, hour: u32) -> Option<Self>
Makes a new value with the hour number changed.
Returns None
when the resulting value would be invalid.
sourcefn with_minute(&self, min: u32) -> Option<Self>
fn with_minute(&self, min: u32) -> Option<Self>
Makes a new value with the minute number changed.
Returns None
when the resulting value would be invalid.
sourcefn with_second(&self, sec: u32) -> Option<Self>
fn with_second(&self, sec: u32) -> Option<Self>
Makes a new value with the second number changed.
Returns None
when the resulting value would be invalid.
As with the second
method,
the input range is restricted to 0 through 59.
sourcefn with_nanosecond(&self, nano: u32) -> Option<Self>
fn with_nanosecond(&self, nano: u32) -> Option<Self>
Makes a new value with nanoseconds since the whole non-leap second changed.
Returns None
when the resulting value would be invalid.
As with the nanosecond
method,
the input range can exceed 1,000,000,000 for leap seconds.
Provided Methods§
sourcefn hour12(&self) -> (bool, u32)
fn hour12(&self) -> (bool, u32)
Returns the hour number from 1 to 12 with a boolean flag, which is false for AM and true for PM.
sourcefn num_seconds_from_midnight(&self) -> u32
fn num_seconds_from_midnight(&self) -> u32
Returns the number of non-leap seconds past the last midnight.
Every value in 00:00:00-23:59:59 maps to an integer in 0-86399.
This method is not intended to provide the real number of seconds since midnight on a given day. It does not take things like DST transitions into account.