this post was submitted on 01 Mar 2024
249 points (99.2% liked)

Programmer Humor

19171 readers
1511 users here now

Welcome to Programmer Humor!

This is a place where you can post jokes, memes, humor, etc. related to programming!

For sharing awful code theres also Programming Horror.

Rules

founded 1 year ago
MODERATORS
 

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.

you are viewing a single comment's thread
view the rest of the comments
[–] onion@feddit.de 45 points 6 months ago (2 children)
[–] WeirdAlex03@lemmy.zip 26 points 6 months ago

And then you get a call from a Swedish Wikipedia editor and they say:

February 30 was a day that happened in Sweden, 1712.[4] This occurred because, instead of changing from the Julian calendar to the Gregorian calendar by omitting a block of consecutive days, as had been done in other countries, the Swedish Empire planned to change gradually by omitting all leap days from 1700 to 1740, inclusive. Although the leap day was omitted in February 1700, the Great Northern War began later that year, diverting the attention of the Swedes from their calendar so that they did not omit leap days on the next two occasions; 1704 and 1708 remained leap years.[5]

To avoid confusion and further mistakes, the Julian calendar was restored in 1712 by adding an extra leap day, thus giving that year the only known actual use of February 30 in a calendar. That day corresponded to February 29 in the Julian calendar and to March 11 in the Gregorian calendar.[5][6] The Swedish conversion to the Gregorian calendar was finally accomplished in 1753, when February 17 was followed by March 1.[5]

https://en.wikipedia.org/wiki/List_of_non-standard_dates#Swedish_calendar

[–] snaggen@programming.dev 17 points 6 months ago* (last edited 6 months ago)

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.