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 that specify the time an MS-DOS file was last written to, and is used as timestamps such as FAT or ZIP file format.
The resolution of MS-DOS time is 2 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 MS-DOS time.
Returns None if the given MS-DOS time 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.
The resolution of MS-DOS time is 2 seconds. So this method rounds towards zero, truncating any fractional part of the exact result of dividing seconds by 2.
§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
chrono only.Source§fn from(time: NaiveTime) -> Self
fn from(time: NaiveTime) -> Self
Converts a NaiveTime to a Time.
The resolution of MS-DOS time is 2 seconds. So this method rounds towards zero, truncating any fractional part of the exact result of dividing seconds by 2.
§Examples
assert_eq!(Time::from(NaiveTime::MIN), Time::MIN);
assert_eq!(
Time::from("23:59:58".parse::<NaiveTime>().unwrap()),
Time::MAX
);Source§impl From<Time> for Time
impl From<Time> for Time
Source§fn from(time: Time) -> Self
fn from(time: Time) -> Self
Converts a time::Time to a Time.
The resolution of MS-DOS time is 2 seconds. So this method rounds towards zero, truncating any fractional part of the exact result of dividing seconds by 2.
§Examples
assert_eq!(Time::from(time::Time::MIDNIGHT), Time::MIN);
assert_eq!(Time::from(time!(23:59:58)), Time::MAX);Source§impl From<Time> for Time
Available on crate feature jiff only.
impl From<Time> for Time
jiff only.Source§fn from(time: Time) -> Self
fn from(time: Time) -> Self
Converts a civil::Time to a Time.
The resolution of MS-DOS time is 2 seconds. So this method rounds towards zero, truncating any fractional part of the exact result of dividing seconds by 2.
§Examples
assert_eq!(Time::from(civil::Time::MIN), Time::MIN);
assert_eq!(Time::from(civil::time(23, 59, 58, 0)), Time::MAX);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§
§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
§unsafe fn clone_to_uninit(&self, dest: *mut u8)
unsafe fn clone_to_uninit(&self, dest: *mut u8)
clone_to_uninit)