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.

  • ryannathans@aussie.zone
    link
    fedilink
    arrow-up
    0
    ·
    9 months ago

    I think it blows up because you need the Swedish calendar for the date to be valid, our calendar doesn’t have this day. The date occurred when Sweden used a different calendar

    • snaggen@programming.devOP
      link
      fedilink
      arrow-up
      0
      ·
      9 months ago

      Yes, that was the first that came to my mind when I was 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.

    • SpookyAlex03@lemmy.zip
      link
      fedilink
      English
      arrow-up
      0
      ·
      9 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

  • steventhedev@lemmy.world
    link
    fedilink
    arrow-up
    0
    ·
    9 months ago

    And here I was thinking that adding timezones for mars was going to be the biggest timezone headache in the next 5 years.

    • souperk@reddthat.com
      link
      fedilink
      arrow-up
      0
      ·
      edit-2
      9 months ago

      Reminds me when dayjs decided to change the duration of a month during a random bugfix. I had to update so many tests…

      Now I am going to share a horror story: Multitimezone Operational Calendars

    • snaggen@programming.devOP
      link
      fedilink
      arrow-up
      0
      ·
      9 months ago

      That is wezterm which have builtin Nerd Font fallback, and I actually think WezTerm renders it to wide to fit it better with other fonts. But the rest of the font is JetBrains Mono