libcalendar - Calendrical calculations in Go
About
libcalendar is a translation into Go of the Lisp code described and presented in:
- Dershowitz, Nachum, and Edward Reingold. 1990. "Calendrical Calculations", Software - Practice and Experience, 20 (9), 899-928.
- Reingold, Edward, Nachum Dershowitz, and Stewart Clamen. 1993. "Calendrical Calculations, II: Three Historical Calendars", Software - Practice & Experience, 23 (4), 383-404. The Lisp source code can be found at https://www.cs.tau.ac.il/~nachum/calendar-book/papers/.
libcalendar allows the computation of and conversion between dates from 11 calendars: Gregorian, ISO, Julian, Islamic, Hebrew, Mayan (long count, haab, tzolkin), French Revolutionary, and Old Hindu (solar, lunar).
Installing
Install the latest version of libcalendar via go get
go get staudtlex.de/libcalendar
Import libcalendar in your application
import staudtlex.de/libcalendar
Examples
Basic examples can be found in utility_test.go
, further examples may be added in the future.
Limitations
The primary motivation for writing libcalendar was to take first steps in understanding calendar-related algorithms and Go programming.
-
libcalendar does not implement the code discussed in: Reingold, Edward, and Nachum Dershowitz. 2018. Calendrical Calculations: The Ultimate Edition. 4th edition. Cambridge: Cambridge University Press.
-
The functions implemented in libcalendar do not generally work for absolute dates smaller than 1 (except the Mayan calendars).
-
Furthermore, the Islamic and French Revolutionary calendar functions do not work with dates prior to their respective epochs. If provided with such dates, the functions may return invalid results.
-
DaylightSavingsStart
andDaylightSavingsEnd
use the US rules for determining start and end of DST which are in place since 2007, whereas the corresponding Lisp-functions use the pre-2007 rules. -
For some dates, the Old Hindu solar and lunar calendar functions return results that are off by one day compared to those produced by the (more recent) Lisp-Code in Reingold/Dershowitz (2018).