pub struct Time {
pub hour: u8,
pub minute: u8,
pub second: u8,
pub nanosecond: u32,
/* private fields */
}Expand description
Represents the time of day portion of a TOML datetime value.
Field ranges are validated during parsing:
hour: 0–23minute: 0–59second: 0–60 (60 is permitted for leap seconds)nanosecond: 0–999999999
When seconds are omitted in the source (e.g. 12:30), second defaults
to 0. Use has_seconds to distinguish this from an
explicit :00.
§Examples
use toml_spanner::DateTime;
let dt: DateTime = "14:30:05.123".parse().unwrap();
let time = dt.time().unwrap();
assert_eq!(time.hour, 14);
assert_eq!(time.minute, 30);
assert_eq!(time.second, 5);
assert_eq!(time.nanosecond, 123000000);
assert_eq!(time.subsecond_precision(), 3);Fields§
§hour: u8Hour of the day (0–23).
minute: u8Minute of the hour (0–59).
second: u8Second of the minute (0–60).
nanosecond: u32Sub-second component in nanoseconds (0–999999999).
Implementations§
Source§impl Time
impl Time
Sourcepub fn subsecond_precision(&self) -> u8
pub fn subsecond_precision(&self) -> u8
Returns the number of fractional-second digits present in the source.
Returns 0 when no fractional part was written (e.g. 12:30:00),
and 1–9 for .1 through .123456789.
Sourcepub fn has_seconds(&self) -> bool
pub fn has_seconds(&self) -> bool
Returns true if seconds were explicitly written in the source.
When the input omits seconds (e.g. 12:30), second
is set to 0 but this method returns false.
Trait Implementations§
impl Copy for Time
impl Eq 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 UnsafeUnpin 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
Mutably borrows from an owned value. Read more