calendar(1): Rewrite to support Chinese & Julian calendars
authorAaron LI <aly@aaronly.me>
Sun, 2 Aug 2020 14:17:59 +0000 (22:17 +0800)
committerAaron LI <aly@aaronly.me>
Fri, 4 Sep 2020 16:18:56 +0000 (00:18 +0800)
commitd19ef5a274debcb71f2e8cd8dce8b954dc73944b
tree6a8a2297b566da04992060f31f1fa45cb3b0ed21
parent921421caef454cbe78d29996df002c693c6ced71
calendar(1): Rewrite to support Chinese & Julian calendars

I wanted to use Chinese calendar in the calendar(1) utility, so I started
working on it.  The Chinese calendar is a lunisolar calendar and requires
calculations of Sun and Moon positions.  Along the way of implementing the
Chinese calendar support, more and more parts of the old code has been
replaced.  Now, the new calendar(1) code base has been mostly rewritten to
be more extensible to support multiple calendars.  Although only the
Gregorian (the default), Chinese and Julian calendars are currently
supported, more calendars now becomes much easier to add.

Highlights:
* Support Chinese calendar
* Support Julian calendar
* More accurate Sun and Moon calculations
* More extensible
* More calendar files/entries and more accurate information
* Better code base

Major Changes:
* If no user's calendar file, default to '/etc/calendar/default'
* Search calendar files in '/etc/calendar', which allows to override the
  calendar file in '/usr/share/calendar' in a system-wide way
* Add '-s' option to show information of Chinese/Julian calendar or
  Sun/Moon
* Add '-H' option to specify the calendar home directory
* Add '-L' option to specify the location, which should be set to get
  accurate Sun/Moon information
* Add '-T' option to specify the current time for Sun/Moon calculations
* Much Improved calendar file parser
* More clean man page
* More helpful error messages
* Some bug fixes and various cleanups

The new calendar algorithms are implemented by referring to this great
book:
Calendrical Calculations: The Ultimate Edition (4th Edition)
by Edward M. Reingold and Nachum Dershowitz.
Cambridge University Press, 2018.
ISBN: 9781107057623

More information about the development history of this calendar(1) utility
can be found in my GitHub repository:
https://github.com/liweitianux/ccalendar
74 files changed:
etc/Makefile
etc/calendar/Makefile [new file with mode: 0644]
etc/calendar/default [new file with mode: 0644]
etc/mtree/BSD.root.dist
etc/mtree/BSD.usr.dist
usr.bin/calendar/Makefile
usr.bin/calendar/basics.c [new file with mode: 0644]
usr.bin/calendar/basics.h [new file with mode: 0644]
usr.bin/calendar/calendar.1 [deleted file]
usr.bin/calendar/calendar.1.in [new file with mode: 0644]
usr.bin/calendar/calendar.c
usr.bin/calendar/calendar.h
usr.bin/calendar/calendars/calendar.all
usr.bin/calendar/calendars/calendar.birthday
usr.bin/calendar/calendars/calendar.canada
usr.bin/calendar/calendars/calendar.chinese [new file with mode: 0644]
usr.bin/calendar/calendars/calendar.christian
usr.bin/calendar/calendars/calendar.dragonfly
usr.bin/calendar/calendars/calendar.dutch
usr.bin/calendar/calendars/calendar.fictional
usr.bin/calendar/calendars/calendar.history
usr.bin/calendar/calendars/calendar.holiday
usr.bin/calendar/calendars/calendar.misc [new file with mode: 0644]
usr.bin/calendar/calendars/calendar.music
usr.bin/calendar/calendars/calendar.orthodox [new file with mode: 0644]
usr.bin/calendar/calendars/calendar.uk
usr.bin/calendar/calendars/calendar.ushistory
usr.bin/calendar/calendars/calendar.world
usr.bin/calendar/calendars/de_AT.UTF-8/calendar.feiertag
usr.bin/calendar/calendars/de_DE.UTF-8/calendar.feiertag
usr.bin/calendar/calendars/de_DE.UTF-8/calendar.geschichte
usr.bin/calendar/calendars/fr_FR.UTF-8/calendar.fetes
usr.bin/calendar/calendars/hu_HU.UTF-8/calendar.nevnapok
usr.bin/calendar/calendars/hu_HU.UTF-8/calendar.unnepek
usr.bin/calendar/calendars/pt_BR.UTF-8/calendar.mcommemorative
usr.bin/calendar/calendars/ru_RU.UTF-8/calendar.orthodox
usr.bin/calendar/calendars/ru_RU.UTF-8/calendar.primety
usr.bin/calendar/calendars/uk_UA.UTF-8/calendar.holiday
usr.bin/calendar/calendars/uk_UA.UTF-8/calendar.misc
usr.bin/calendar/calendars/uk_UA.UTF-8/calendar.orthodox
usr.bin/calendar/calendars/zh_Hans_CN.UTF-8/calendar.all [new file with mode: 0644]
usr.bin/calendar/calendars/zh_Hans_CN.UTF-8/calendar.chinese [new file with mode: 0644]
usr.bin/calendar/calendars/zh_Hans_CN.UTF-8/calendar.gregorian [new file with mode: 0644]
usr.bin/calendar/calendars/zh_Hant_TW.UTF-8/calendar.all [new file with mode: 0644]
usr.bin/calendar/calendars/zh_Hant_TW.UTF-8/calendar.chinese [new file with mode: 0644]
usr.bin/calendar/calendars/zh_Hant_TW.UTF-8/calendar.gregorian [new file with mode: 0644]
usr.bin/calendar/chinese.c [new file with mode: 0644]
usr.bin/calendar/chinese.h [new file with mode: 0644]
usr.bin/calendar/dates.c
usr.bin/calendar/dates.h [moved from usr.bin/calendar/ostern.c with 56% similarity]
usr.bin/calendar/days.c [new file with mode: 0644]
usr.bin/calendar/days.h [new file with mode: 0644]
usr.bin/calendar/ecclesiastical.c [new file with mode: 0644]
usr.bin/calendar/ecclesiastical.h [new file with mode: 0644]
usr.bin/calendar/events.c [deleted file]
usr.bin/calendar/gregorian.c [new file with mode: 0644]
usr.bin/calendar/gregorian.h [new file with mode: 0644]
usr.bin/calendar/io.c
usr.bin/calendar/io.h [moved from usr.bin/calendar/paskha.c with 55% similarity]
usr.bin/calendar/julian.c [new file with mode: 0644]
usr.bin/calendar/julian.h [new file with mode: 0644]
usr.bin/calendar/locale.c [deleted file]
usr.bin/calendar/moon.c [new file with mode: 0644]
usr.bin/calendar/moon.h [new file with mode: 0644]
usr.bin/calendar/nnames.c [new file with mode: 0644]
usr.bin/calendar/nnames.h [moved from usr.bin/calendar/day.c with 51% similarity]
usr.bin/calendar/parsedata.c
usr.bin/calendar/parsedata.h [new file with mode: 0644]
usr.bin/calendar/pom.c [deleted file]
usr.bin/calendar/sun.c [new file with mode: 0644]
usr.bin/calendar/sun.h [new file with mode: 0644]
usr.bin/calendar/sunpos.c [deleted file]
usr.bin/calendar/utils.c [new file with mode: 0644]
usr.bin/calendar/utils.h [new file with mode: 0644]