staudtlex.de/libcalendar

Computing and converting dates from 11 calendars in Go.


License
GPL-3.0
Install
go get staudtlex.de/libcalendar

Documentation

libcalendar - Calendrical calculations in Go

About

libcalendar is a translation into Go of the Lisp code described and presented in:

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 and DaylightSavingsEnd 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).