Fix error which crept in due to daylight savings and me trying to be
clever about it.
This commit is contained in:
parent
8c6e15a0c3
commit
2d3f5ab718
1 changed files with 3 additions and 3 deletions
|
@ -177,7 +177,7 @@ impl From<i64> for DateTime {
|
|||
let seconds = ts % SECS_PER_DAY;
|
||||
let minutes = seconds / 60;
|
||||
let second = seconds % 60;
|
||||
let hour = minutes / 60 + 1;
|
||||
let hour = minutes / 60;
|
||||
let minute = minutes % 60;
|
||||
DateTime {
|
||||
year: year as u32,
|
||||
|
@ -195,7 +195,7 @@ impl From<DateTime> for i64 {
|
|||
fn from(dt: DateTime) -> Self {
|
||||
let mut seconds = dt.second.unwrap_or(0).into();
|
||||
seconds += dt.minute.unwrap_or(0) as i64 * 60;
|
||||
seconds += (dt.hour.unwrap_or(1) - 1) as i64 * 3600;
|
||||
seconds += (dt.hour.unwrap_or(1)) as i64 * 3600;
|
||||
seconds += SECS_PER_DAY * (dt.day as i64 - 1);
|
||||
let mut m = 1;
|
||||
while m < dt.month {
|
||||
|
@ -374,7 +374,7 @@ mod test {
|
|||
assert_eq!(dt.year, 2023);
|
||||
assert_eq!(dt.month, 6);
|
||||
assert_eq!(dt.day, 11);
|
||||
assert_eq!(dt.hour, Some(6));
|
||||
assert_eq!(dt.hour, Some(5));
|
||||
assert_eq!(dt.minute, Some(41));
|
||||
assert_eq!(dt.second, Some(8));
|
||||
assert_eq!(ts, dt.into());
|
||||
|
|
Loading…
Add table
Reference in a new issue