r-lib / clock

A Date-Time Library for R
https://clock.r-lib.org
Other
97 stars 4 forks source link

Non-Gregorian calendars? #182

Closed joeroe closed 3 years ago

joeroe commented 3 years ago

R currently has almost no support for dates in systems other than the standard Gregorian calendar, for example the Islamic, Persian, and other regional and historic calendars, Gregorian variants, and astronomical Julian dates. chron and oce have functions for converting Julian day numbers from/to POSIXt, era has classes for other calendars but only handles fractional years not dates, and ConvCalendar did a range of conversions but was removed from CRAN several years ago. To my knowledge that's about it. Representations of other calendars has been said to be out of the scope of lubridate in tidyverse/lubridate/issues/151 and tidyverse/lubridate/issues/756.

Would non-Gregorian calendars be in the scope of this package? I noticed that the underlying date library includes functionality for Julian and Tabular Islamic dates, and it seems the calendar system could be extended to many non-Gregorian systems?

DavisVaughan commented 3 years ago

Non-Gregorian calendars are generally in scope for this package, but not for the first release.

As you've seen, the underlying date library has calendar implementations for Julian, Islamic, and Solar Hijri / Persian calendars. There is also a Jewish calendar implemented elsewhere, but I have not evaluated it for correctness in any way.

Adding new calendars requires a decent bit of effort, but I hope to slowly start adding the 3 in the date library for sure.

joeroe commented 3 years ago

Thanks, that's good to know. I ask because I had been considering extending era to handle dates in the calendars it implements (as opposed to years), but this package seems like a much sounder foundation. If you are open for pull requests when it comes time to implement this, I'd be happy to contribute.

DavisVaughan commented 3 years ago

Sounds good. For now, I'll close this in favor of 3 explicit issues for the calendars I do plan to implement, #183, #184, #185