this post was submitted on 01 Mar 2024
1 points (100.0% liked)

Rust

5778 readers
4 users here now

Welcome to the Rust community! This is a place to discuss about the Rust programming language.

Wormhole

[email protected]

Credits

  • The icon is a modified version of the official rust logo (changing the colors to a gradient and black background)

founded 1 year ago
MODERATORS
1
submitted 6 months ago* (last edited 6 months ago) by [email protected] to c/[email protected]
 

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
[–] [email protected] 0 points 6 months ago

I wasn't clear enough. But in a contry where the sun rise at 20:00, the weekday looks like:

  • day 1: Monday morning to Tuesday evening
  • day 2: Tuesday morning to Wednesday evening
  • day 3: Wednesday morning to Thurday,

And phares like "let's meet on Tuesday“ without hour indication could either mean end of day 1 or start of day 2. Likewise "let's meet the 20th” (assuming the 20th is a Tuesday) could either mean end of day 1 or beggining of day 2.

--

And alternative be to have

  • day 1 == Monday == “end of the 19th” to “the start of the 20th”
  • day 2 == Tuesday == “end of the 20th” to “the start of the 21st”
  • day 3 == Monday == “end of the 21st” to “the start of the 22nd”

Which solve the issue of "let's meet on Tuesday”, but not “let's meet the 20th”.