May
19
1 day ago
started
started time in 1 day ago
Activity icon
issue

djc issue chronotope/chrono

djc
djc

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.

Activity icon
issue

djc issue comment chronotope/chrono

djc
djc

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.

djc
djc

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.

Activity icon
issue

Kinrany issue comment chronotope/chrono

Kinrany
Kinrany

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.

Kinrany
Kinrany

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.

Activity icon
issue

omid issue chronotope/chrono

omid
omid

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

Activity icon
issue

omid issue comment chronotope/chrono

omid
omid

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
omid

I didn't expect this much accuracy from any lib, thanks for the awesome work ❤️ 👍🏼

Activity icon
issue

omid issue comment chronotope/chrono

omid
omid

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
omid

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

Activity icon
issue

omid issue chronotope/chrono

omid
omid

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

May
18
2 days ago
pull request

fxredeemer pull request chronotope/chrono

fxredeemer
fxredeemer

Fix typo in month.rs

Fix a typo in the docs of pred() of month.rs (stumbled over it in reading the docs)

Activity icon
fork

fxredeemer forked chronotope/chrono

⚡ Date and time library for Rust
fxredeemer Updated
fork time in 2 days ago
Previous