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.

  • TehPers@beehaw.org
    link
    fedilink
    English
    arrow-up
    36
    ·
    edit-2
    9 months ago

    I know you’re joking about the bug report, but you could open an issue about it anyway if it genuinely is a thing. I did a quick search though and it looks like it was a transition period between two different calendars. Maybe chrono intentionally assumes Gregorian calendar, or some simplified version of it at least?

    Edit: found this in chrono’s readme:

    Only the proleptic Gregorian calendar (i.e. extended to support older dates) is supported.

    I wouldn’t open an issue actually since this is specifically called out already.

    • snaggen@programming.devOP
      link
      fedilink
      English
      arrow-up
      11
      arrow-down
      1
      ·
      edit-2
      9 months ago

      I think there are so much issues with historical dates, that it is probably not worth fixing it in general purpose libraries. Not only do you need to special case everything like this in relation to dates, but you would also need to keep track of all historical territories (like Prussia and such) and what was part of what. In this particular case, I think that the timezone Europe::Helsinki was part of Sweden and should be included (possibly some cities from current Poland). There is no need to add that kind of complexity to general purpose libraries, that should probably be in some special historical date / region library if needed.

      Also, there was not really a concept of time zones before the railway, then the time was floating. The time was not the same in the whole country, because that was not a problem before people started to travel faster and in a way that needed time tables. So, that also fits poorly in a modern general purpose date/time library.