Hacker News new | past | comments | ask | show | jobs | submit login

> As well as keeping track of the gregorian correction in (depending on country) October 1582 (skipping over 10 days in the calendar!), when calculating historical intervals. They really do this, already!

Which libraries do this? Libraries usually implement proleptic calendars, including Temporal[1], which specifically do not account for shifts like this. And indeed, the Temporal docs even call out this specific example.

(I agree with the rest of your comment!)

[1]: https://tc39.es/proposal-temporal/docs/calendars.html#handli...




Ah, I guess not as many as I thought!

Ruby DateTime does it, I hadn't realized it was unusual, if it is!

Here it is particularly called out in documentation with example taking account that April 23rd 1616 in England was not the same day as April 23rd 1616 in Italy, and DateTime knows that! https://ruby-doc.org/stdlib-2.6.1/libdoc/date/rdoc/DateTime....

(That class however is using weird "Date::ENGLAND" constants for locale instead of ISO timezone locales, which is a legacy mistake!)

(I work in archiving cultural history, so probably deal with pre-19th century dates a lot more than the average coder)

update: I was curious what would happen if I gave DateTime a non-existent date...

DateTime.iso8601('1752-09-05', Date::ENGLAND) => invalid date (Date::Error)

it knows! (England skipped some days in September 1752 as part of Gregorian adjustment)


Ah yeah, those look like opt-in calendars to me I think. Definitely other datetime libraries do that. They just also require opt-in AFAIK.


Ruby date/time handling is confusing, with too many overlapping classes, developed at different times with odd interfaces and/or semantic edge cases (not unusual on other platforms either), but I believe the things people use as default/recommended standard these days on ruby actually do support gregorian/julian changeover!

But I guess ruby is unusual there! Or I'm wrong.

But good to know most have it as opt-in, anyway!


I would need to see the APIs and examples to be able to evaluate it honestly.

(FWIW, I'm the author of a datetime library in Rust called Jiff.)




Join us for AI Startup School this June 16-17 in San Francisco!

Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: