3 ms·
> As well as keeping track of the gregorian correction in (depending on country) October 1582 (skipping over 10 days in the calendar!), when calculating histori
by burntsushi 2y ago
> 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#handling-unusual-dates-leap-days-leap-months-and-skipped-or-repeated-periods https://tc39.es/proposal-temporal/docs/calendars.html#handli...
- jrochkind1 2y agoAh, 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.html#class-DateTime-label-When+should+you+use+DateTime+and+when+should+you+use+Time-3F 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)
- burntsushi 2y agoAh yeah, those look like opt-in calendars to me I think. Definitely other datetime libraries do that. They just also require opt-in AFAIK.
- jrochkind1 2y agoRuby 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!
- burntsushi 2y agoI 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.)