- cross-posted to:
- rust@programming.dev
- cross-posted to:
- rust@programming.dev
fjärrinlägg från: https://programming.dev/post/10803496
TIL: Sweden had February 30 in 1712 https://en.wikipedia.org/wiki/1712_in_Sweden , so I decided to see how chrono handled that.
use chrono::TimeZone; use chrono_tz::Europe::Stockholm; fn main() { let feb30 = Stockholm.ymd(1712,2,30); println!("Date: {:?}", feb30); }
target/debug/feb30 thread 'main' panicked at /home/snaggen/.cargo/registry/src/index.crates.io-6f17d22bba15001f/chrono-0.4.34/src/offset/mod.rs:252:40: No such local time note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace
Result (as expected): Not well! 😄
I also tested Java with
ZonedDateTime feb30 = ZonedDateTime.of(1712,2,30, 0,0,0,0, ZoneId.of("Europe/Stockholm"));
with simmilar result
java.time.DateTimeException: Invalid date 'FEBRUARY 30'
So, lets take a minute of silence for all the programmers of history related software, may the spagetti monster have mercy on their souls.
Obligatory Tom Scott https://www.youtube.com/watch?v=-5wpm-gesOY
And then you get a call from a Swedish Wikipedia editor and they say:
https://en.wikipedia.org/wiki/List_of_non-standard_dates#Swedish_calendar
Yes, that was the first that came to my mind when I saw the TIL post… which also was why I felt the need to see if that rant is still valid, or if modern libraries could handle that.
Here is an alternative Piped link(s):
https://www.piped.video/watch?v=-5wpm-gesOY
Piped is a privacy-respecting open-source alternative frontend to YouTube.
I’m open-source; check me out at GitHub.