pub struct Time(/* private fields */);Expand description
Time is a type that represents the MS-DOS time.
This is a packed 16-bit unsigned integer value.
It has the following peculiarities:
- It has a resolution of 2 seconds.
- It does not support leap seconds.
See the format specification for Kaitai Struct for more details on the structure of the MS-DOS time.
Implementations§
Source§impl Time
impl Time
Source§impl Time
impl Time
Sourcepub fn new(time: u16) -> Option<Self>
pub fn new(time: u16) -> Option<Self>
Creates a new Time with the given underlying u16 value.
Returns None if the given value is not a valid MS-DOS time.
§Examples
assert_eq!(Time::new(u16::MIN), Some(Time::MIN));
assert_eq!(Time::new(0b1011_1111_0111_1101), Some(Time::MAX));
// The DoubleSeconds field is 30.
assert_eq!(Time::new(0b0000_0000_0001_1110), None);Sourcepub const unsafe fn new_unchecked(time: u16) -> Self
pub const unsafe fn new_unchecked(time: u16) -> Self
Sourcepub fn from_time(time: Time) -> Self
pub fn from_time(time: Time) -> Self
Creates a new Time with the given time::Time.
This method may round towards zero, truncating more precise times that a
Time cannot store.
§Examples
assert_eq!(Time::from_time(time::Time::MIDNIGHT), Time::MIN);
assert_eq!(Time::from_time(time!(23:59:58)), Time::MAX);Sourcepub fn hour(self) -> u8
pub fn hour(self) -> u8
Gets the hour of this Time.
§Examples
assert_eq!(Time::MIN.hour(), 0);
assert_eq!(Time::MAX.hour(), 23);Trait Implementations§
Source§impl From<NaiveTime> for Time
Available on crate feature chrono only.
impl From<NaiveTime> for Time
Available on crate feature
chrono only.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 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