mirror of
https://github.com/Llewellynvdm/exa.git
synced 2025-02-14 16:16:31 +00:00
Correct handling of pre-epoch timestamps
Fix an off-by-one on the seconds when subseconds are present, and correct display of nenoseconds, which are of course inverted due to the internal value being negative.
This commit is contained in:
parent
bc830b9158
commit
d2d2e7325f
@ -185,14 +185,23 @@ fn systemtime_epoch(time: SystemTime) -> i64 {
|
||||
time
|
||||
.duration_since(UNIX_EPOCH)
|
||||
.map(|t| t.as_secs() as i64)
|
||||
.unwrap_or_else(|e| -(e.duration().as_secs() as i64))
|
||||
.unwrap_or_else(|e| {
|
||||
-(e.duration().as_secs() as i64) - e.duration().subsec_nanos().min(1) as i64
|
||||
})
|
||||
}
|
||||
|
||||
fn systemtime_nanos(time: SystemTime) -> u32 {
|
||||
time
|
||||
.duration_since(UNIX_EPOCH)
|
||||
.map(|t| t.subsec_nanos())
|
||||
.unwrap_or_else(|e| e.duration().subsec_nanos())
|
||||
.unwrap_or_else(|e| {
|
||||
let nanos = e.duration().subsec_nanos();
|
||||
if nanos == 0 {
|
||||
0
|
||||
} else {
|
||||
1_000_000_000 - nanos
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
#[allow(trivial_numeric_casts)]
|
||||
|
Loading…
x
Reference in New Issue
Block a user