Fix spilling of exceeding `tm_sec` into `tm_nsec` in `tm_to_datetime()`.
This commit is contained in:
parent
f41de9b41f
commit
a5be5cc592
|
@ -22,8 +22,8 @@ use super::fixed::FixedOffset;
|
||||||
/// This assumes that `time` is working correctly, i.e. any error is fatal.
|
/// This assumes that `time` is working correctly, i.e. any error is fatal.
|
||||||
fn tm_to_datetime(mut tm: stdtime::Tm) -> DateTime<Local> {
|
fn tm_to_datetime(mut tm: stdtime::Tm) -> DateTime<Local> {
|
||||||
if tm.tm_sec >= 60 {
|
if tm.tm_sec >= 60 {
|
||||||
tm.tm_sec = 59;
|
|
||||||
tm.tm_nsec += (tm.tm_sec - 59) * 1_000_000_000;
|
tm.tm_nsec += (tm.tm_sec - 59) * 1_000_000_000;
|
||||||
|
tm.tm_sec = 59;
|
||||||
}
|
}
|
||||||
|
|
||||||
// from_yo is more efficient than from_ymd (since it's the internal representation).
|
// from_yo is more efficient than from_ymd (since it's the internal representation).
|
||||||
|
|
Loading…
Reference in New Issue