-
Notifications
You must be signed in to change notification settings - Fork 58
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Off-by-one-hour error for some far-future dates #135
Labels
Comments
Interesting! I have no idea yet... Some more example code: use chrono::{FixedOffset, Offset, TimeZone};
use chrono_tz::America::Chicago;
fn main() {
let date1 = Chicago.timestamp_opt(236246216400, 0).single().unwrap();
println!("{:?} {}", date1, date1.offset().fix());
let date2 = Chicago.timestamp_opt(236266869600, 0).single().unwrap();
println!("{:?} {}", date2, date2.offset().fix());
let dst_offset = FixedOffset::east_opt(-5 * 60 * 60).unwrap();
let date3 = date1.with_timezone(&dst_offset);
println!("{:?} {}", date3, date3.offset().fix());
assert_eq!((date2 - date1).num_hours(), 239*24 + 1);
} Output:
It seems we forget DST somewhere. |
So the problem here is that chrono-tz only includes data for a fixed set of years, with the end of this century as the limit. We should at least document that limitation. |
So this is probably a duplicate then? |
We have to keep at least one issue open 😄. I think it can be this one for now. |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
PHP's strtotime and WolframAlpha agree that the timestamp
236246216400
is midnight on05/06/9456
in"America/Chicago"
(US Central Time).However, this code:
yields
"9456-05-05T23:00:00CST"
, which is an hour earlier than it should be.However, a later date,
12/31/9456
(from236266869600
), works correctly.Is the issue that the date is too far in the future? PHP's strtotime is using the same IANA TZDB under the hood.
The text was updated successfully, but these errors were encountered: