Skip to content

Commit 0bcba14

Browse files
committed
pal/hermit: Implement SystemTime::{MIN, MAX}
This commit implements `SystemTime::MIN` and `SystemTime::MAX` for for HermitOS, which itself is more or less identical to the Unix implementation.
1 parent e53a3c3 commit 0bcba14

File tree

1 file changed

+12
-0
lines changed
  • library/std/src/sys/pal/hermit

1 file changed

+12
-0
lines changed

library/std/src/sys/pal/hermit/time.rs

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,12 @@ struct Timespec {
1515
}
1616

1717
impl Timespec {
18+
#[unstable(feature = "time_systemtime_limits", issue = "none")]
19+
const MAX: Timespec = Self::new(i64::MAX, 1_000_000_000 - 1);
20+
21+
#[unstable(feature = "time_systemtime_limits", issue = "none")]
22+
const MIN: Timespec = Self::new(i64::MIN, 0);
23+
1824
const fn zero() -> Timespec {
1925
Timespec { t: timespec { tv_sec: 0, tv_nsec: 0 } }
2026
}
@@ -209,6 +215,12 @@ pub struct SystemTime(Timespec);
209215
pub const UNIX_EPOCH: SystemTime = SystemTime(Timespec::zero());
210216

211217
impl SystemTime {
218+
#[unstable(feature = "time_systemtime_limits", issue = "none")]
219+
pub const MAX: SystemTime = SystemTime { t: Timespec::MAX };
220+
221+
#[unstable(feature = "time_systemtime_limits", issue = "none")]
222+
pub const MIN: SystemTime = SystemTime { t: Timespec::MIN };
223+
212224
pub fn new(tv_sec: i64, tv_nsec: i32) -> SystemTime {
213225
SystemTime(Timespec::new(tv_sec, tv_nsec))
214226
}

0 commit comments

Comments
 (0)