Skip to content

Commit 4920ee5

Browse files
committed
pal/windows: Implement SystemTime::{MIN, MAX}
This commit implements `SystemTime::MIN` and `SystemTime::MAX` for the Windows platform. Windows is weird. The Win32 documentation makes no statement on a maximum value here. Next to this, there are two conflicting types: `SYSTEMTIME` and `FILETIME`. Rust's Standard Library uses `FILETIME`, whose limit will (probably) be `i64::MAX` packed into two integers. However, `SYSTEMTIME` has a lower-limit.
1 parent 91ac5f5 commit 4920ee5

File tree

1 file changed

+16
-0
lines changed
  • library/std/src/sys/pal/windows

1 file changed

+16
-0
lines changed

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

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -64,6 +64,22 @@ impl Instant {
6464
}
6565

6666
impl SystemTime {
67+
#[unstable(feature = "time_systemtime_limits", issue = "none")]
68+
pub const MAX: SystemTime = SystemTime {
69+
t: c::FILETIME {
70+
dwLowDateTime: (i64::MAX & 0xFFFFFFFF) as u32,
71+
dwHighDateTime: (i64::MAX >> 32) as u32,
72+
},
73+
};
74+
75+
#[unstable(feature = "time_systemtime_limits", issue = "none")]
76+
pub const MIN: SystemTime = SystemTime {
77+
t: c::FILETIME {
78+
dwLowDateTime: (i64::MIN & 0xFFFFFFFF) as u32,
79+
dwHighDateTime: (i64::MIN >> 32) as u32,
80+
},
81+
};
82+
6783
pub fn now() -> SystemTime {
6884
unsafe {
6985
let mut t: SystemTime = mem::zeroed();

0 commit comments

Comments
 (0)