dos_date_time/dos_time/consts.rs
1// SPDX-FileCopyrightText: 2025 Shun Sakai
2//
3// SPDX-License-Identifier: Apache-2.0 OR MIT
4
5//! Constants for [`Time`].
6
7use super::Time;
8
9impl Time {
10 /// The smallest value that can be represented by the MS-DOS time.
11 ///
12 /// This is "00:00:00".
13 ///
14 /// # Examples
15 ///
16 /// ```
17 /// # use dos_date_time::{Time, time};
18 /// #
19 /// assert_eq!(Time::MIN, Time::from_time(time::Time::MIDNIGHT));
20 /// ```
21 // SAFETY: the given MS-DOS time is valid as the smallest MS-DOS time.
22 pub const MIN: Self = unsafe { Self::new_unchecked(u16::MIN) };
23
24 /// The largest value that can be represented by the MS-DOS time.
25 ///
26 /// This is "23:59:58".
27 ///
28 /// # Examples
29 ///
30 /// ```
31 /// # use dos_date_time::{Time, time::macros::time};
32 /// #
33 /// assert_eq!(Time::MAX, Time::from_time(time!(23:59:58)));
34 /// ```
35 // SAFETY: the given MS-DOS time is valid as the largest MS-DOS time.
36 pub const MAX: Self = unsafe { Self::new_unchecked(0b1011_1111_0111_1101) };
37}
38
39#[cfg(test)]
40mod tests {
41 use time::macros::time;
42
43 use super::*;
44
45 #[test]
46 fn min() {
47 assert_eq!(Time::MIN, Time::from_time(time::Time::MIDNIGHT));
48 }
49
50 #[test]
51 fn max() {
52 assert_eq!(Time::MAX, Time::from_time(time!(23:59:58)));
53 }
54}