I don't understand why you can't subtract a NaiveDate
from a NaiveDateTime
. Shouldn't this be possible without too much worry? I can't think of an edge case in which it isn't merely subtracting the dates and ignoring the time part.
djc issue comment chronotope/chrono
the trait `Sub<NaiveDate>` is not implemented for `chrono::NaiveDateTime`
I don't think it makes sense to have this. If you want to substract a NaiveDate
from a NaiveDateTime
, you can just call NaiveDate::and_hms()
on the NaiveDate
to turn it into a NaiveDateTime
, which would make it unambiguous what timestamp you're comparing with.
Kinrany issue comment chronotope/chrono
the trait `Sub<NaiveDate>` is not implemented for `chrono::NaiveDateTime`
I don't understand why you can't subtract a NaiveDate
from a NaiveDateTime
. Shouldn't this be possible without too much worry? I can't think of an edge case in which it isn't merely subtracting the dates and ignoring the time part.
Drive by comment: there are at least two possible results that make sense. The date can be interpreted as either the datetime with NaiveTime::from_hms(0, 0, 0)
or the interval between that and the same datetime of the next date. Substitution would be either the difference between datetimes or the distance between the datetime and the interval.
omid issue chronotope/chrono
Chrono panicked with `invalid time` after calling `add_hms(0, 0, 0)` for a `Date`
I found this via a fuzz test. I cannot see the problem in the code below. It works if I change the day, month, or year! It also works if I remove or change the timezone, it even works for Paris for example (same offset as Berlin)
What happened in April 1st, 1893 in Berlin? 😄
use chrono::TimeZone;
fn main() {
let date = chrono_tz::Europe::Berlin.ymd(1893, 4, 1);
let _datetime = date.and_hms(0,0,0);
}
Deps are the latest versions in my case:
chrono = "0.4.19"
chrono-tz = "0.6.1"
Also latest Rust, 1.60
omid issue comment chronotope/chrono
Chrono panicked with `invalid time` after calling `add_hms(0, 0, 0)` for a `Date`
I found this via a fuzz test. I cannot see the problem in the code below. It works if I change the day, month, or year! It also works if I remove or change the timezone, it even works for Paris for example (same offset as Berlin)
What happened in April 1st, 1893 in Berlin? 😄
use chrono::TimeZone;
fn main() {
let date = chrono_tz::Europe::Berlin.ymd(1893, 4, 1);
let _datetime = date.and_hms(0,0,0);
}
Deps are the latest versions in my case:
chrono = "0.4.19"
chrono-tz = "0.6.1"
Also latest Rust, 1.60
I didn't expect this much accuracy from any lib, thanks for the awesome work ❤️ 👍🏼
omid issue comment chronotope/chrono
Chrono panicked with `invalid time` after calling `add_hms(0, 0, 0)` for a `Date`
I found this via a fuzz test. I cannot see the problem in the code below. It works if I change the day, month, or year! It also works if I remove or change the timezone, it even works for Paris for example (same offset as Berlin)
What happened in April 1st, 1893 in Berlin? 😄
use chrono::TimeZone;
fn main() {
let date = chrono_tz::Europe::Berlin.ymd(1893, 4, 1);
let _datetime = date.and_hms(0,0,0);
}
Deps are the latest versions in my case:
chrono = "0.4.19"
chrono-tz = "0.6.1"
Also latest Rust, 1.60
Oh, I found the reason, and exactly the lib works at and_hms(0,6,32)
.
1 Apr 1893 - Time Zone Change (LMT → CET)
When local standard time was about to reach
Saturday, 1 April 1893, 00:00:00 clocks were turned forward 0:06:32 hours to
Saturday, 1 April 1893, 00:06:32 local standard time instead.
https://www.timeanddate.com/time/change/germany/berlin?year=1893
omid issue chronotope/chrono
Chrono panicked with `invalid time` after calling `add_hms(0, 0, 0)` for a `Date`
I found this via a fuzz test. I cannot see the problem in the code below. It works if I change the day, month, or year! It also works if I remove or change the timezone, it even works for Paris for example (same offset as Berlin)
What happened in April 1st, 1893 in Berlin? 😄
use chrono::TimeZone;
fn main() {
let date = chrono::Utc.ymd(1893, 4, 1).with_timezone(&chrono_tz::Tz::Europe__Berlin);
let datetime = date.and_hms(0,0,0);
}
Deps are the latest versions in my case:
chrono = "0.4.19"
chrono-tz = "0.6.1"
Also latest Rust, 1.60
fxredeemer pull request chronotope/chrono
Fix typo in month.rs
Fix a typo in the docs of pred() of month.rs (stumbled over it in reading the docs)
the trait `Sub<NaiveDate>` is not implemented for `chrono::NaiveDateTime`
I don't understand why you can't subtract a
NaiveDate
from aNaiveDateTime
. Shouldn't this be possible without too much worry? I can't think of an edge case in which it isn't merely subtracting the dates and ignoring the time part.