pub struct Time { /* private fields */ }Expand description
Represents a time of the day, an offset into the day from midnight.
Corresponds to a UTC of day in section 5.3.3 of ISO8601
Implementations§
source§impl Time
impl Time
sourcepub fn new(
second_of_day: u32,
nanoseconds: u32
) -> Result<Time, GreaterThanEqualToValueError<u32>>
pub fn new( second_of_day: u32, nanoseconds: u32 ) -> Result<Time, GreaterThanEqualToValueError<u32>>
Creates a Time from the specified seconds and nanoseconds,
The valid range of ‘second_of_day’ is 0..86400,
The valid range of ‘nanoseconds’ is 0..1_000_000_000
sourcepub fn from_seconds_f64(
seconds: f64
) -> Result<Time, GreaterThanEqualToValueError<f64>>
pub fn from_seconds_f64( seconds: f64 ) -> Result<Time, GreaterThanEqualToValueError<f64>>
Creates a Time from the specified fractional seconds, valid range 0..86400
pub fn from_hms( hours: u8, minutes: u8, seconds: u8 ) -> Result<Time, GreaterThanEqualToValueError<u8>>
pub fn from_hms_f64( hours: u8, minutes: u8, seconds: f64 ) -> Result<Time, GreaterThanEqualToValueError<f64>>
pub fn from_hms_millis( hours: u8, minutes: u8, seconds: u8, millis: u32 ) -> Result<Time, GreaterThanEqualToValueError<u32>>
sourcepub fn get_seconds(&self) -> u32
pub fn get_seconds(&self) -> u32
Returns the number of seconds into the “current day”
sourcepub fn get_nanoseconds(&self) -> u32
pub fn get_nanoseconds(&self) -> u32
Returns the number of fractional second nanoseconds
sourcepub fn as_duration(&self) -> Duration
pub fn as_duration(&self) -> Duration
Converts this time into a duration
sourcepub fn as_minutes(&self) -> u32
pub fn as_minutes(&self) -> u32
Returns the minute offset into the day represented by this time.
sourcepub fn as_hms(&self) -> (u32, u32, u32)
pub fn as_hms(&self) -> (u32, u32, u32)
Returns a triplet, (hours, minutes, seconds) representing this time
sourcepub fn as_hms_f64(&self) -> (u32, u32, f64)
pub fn as_hms_f64(&self) -> (u32, u32, f64)
Returns a triplet, (hours, minutes, seconds) representing this time, with seconds as f64
sourcepub fn get_secondsfrac(&self) -> f64
pub fn get_secondsfrac(&self) -> f64
Returns ONLY the fractional seconds component of the timestamp
sourcepub fn format<F: Format<Self>>(&self, format: &F) -> String
pub fn format<F: Format<Self>>(&self, format: &F) -> String
Formats this Time using the specified formatter
sourcepub fn parse_from<F: FormatParser<Self>>(
format: &F,
string: &str
) -> Result<Self, FormatError>
pub fn parse_from<F: FormatParser<Self>>( format: &F, string: &str ) -> Result<Self, FormatError>
Tries to parse a Time from the string using the specified Formatter
sourcepub fn wrapping_add(&self, duration: Duration) -> (Time, Duration)
pub fn wrapping_add(&self, duration: Duration) -> (Time, Duration)
Adds the duration to this time, returning a new value of ‘time’. If the duration is longer than a single day, returns the number of days that got consumed in the second ‘duration’ parameter
Example:
let time = Time::new(500, 0)?;
let duration_to_add = Duration::from_seconds(129600); // 1.5 days
let (time, excess) = time.wrapping_add(duration_to_add);
assert_eq!(time, Time::new(43700, 0)?);
assert_eq!(excess, Duration::from_days(1));Trait Implementations§
source§impl Format<Time> for BasicTimeOfDay
impl Format<Time> for BasicTimeOfDay
source§impl Format<Time> for ExtendedTimeFormat
impl Format<Time> for ExtendedTimeFormat
source§impl FormatParser<Time> for BasicTimeOfDay
impl FormatParser<Time> for BasicTimeOfDay
source§impl FormatParser<Time> for ExtendedTimeFormat
impl FormatParser<Time> for ExtendedTimeFormat
source§impl FormatParser<Time> for ISO8601Time
impl FormatParser<Time> for ISO8601Time
source§impl Ord for Time
impl Ord for Time
source§impl PartialEq for Time
impl PartialEq for Time
source§impl PartialOrd for Time
impl PartialOrd for Time
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