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 PartialOrd for Time
impl PartialOrd for Time
impl Copy for Time
impl Eq for Time
impl StructuralPartialEq for Time
Auto Trait Implementations§
impl Freeze for Time
impl RefUnwindSafe for Time
impl Send for Time
impl Sync for Time
impl Unpin for Time
impl UnwindSafe for Time
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
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§unsafe fn clone_to_uninit(&self, dst: *mut T)
unsafe fn clone_to_uninit(&self, dst: *mut T)
clone_to_uninit)