git: calendar(1): Rewrite to support Chinese & Julian calendars

Aaron LI aly at crater.dragonflybsd.org
Fri Sep 4 09:22:15 PDT 2020


commit d19ef5a274debcb71f2e8cd8dce8b954dc73944b
Author: Aaron LI <aly at aaronly.me>
Date:   Sun Aug 2 22:17:59 2020 +0800

    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

Summary of changes:
 etc/Makefile                                       |    2 +
 etc/calendar/Makefile                              |    8 +
 etc/calendar/default                               |   18 +
 etc/mtree/BSD.root.dist                            |    2 +
 etc/mtree/BSD.usr.dist                             |    4 +
 usr.bin/calendar/Makefile                          |   41 +-
 usr.bin/calendar/basics.c                          |  421 ++++++
 usr.bin/calendar/basics.h                          |  101 ++
 usr.bin/calendar/calendar.1                        |  354 -----
 usr.bin/calendar/calendar.1.in                     |  565 ++++++++
 usr.bin/calendar/calendar.c                        |  569 ++++++--
 usr.bin/calendar/calendar.h                        |  208 +--
 usr.bin/calendar/calendars/calendar.all            |    1 +
 usr.bin/calendar/calendars/calendar.birthday       |   14 +-
 usr.bin/calendar/calendars/calendar.canada         |    3 +-
 usr.bin/calendar/calendars/calendar.chinese        |   11 +
 usr.bin/calendar/calendars/calendar.christian      |   45 +-
 usr.bin/calendar/calendars/calendar.dragonfly      |   88 +-
 usr.bin/calendar/calendars/calendar.dutch          |   80 +-
 usr.bin/calendar/calendars/calendar.fictional      |    2 +-
 usr.bin/calendar/calendars/calendar.history        |  289 +---
 usr.bin/calendar/calendars/calendar.holiday        |   21 +-
 usr.bin/calendar/calendars/calendar.misc           |   23 +
 usr.bin/calendar/calendars/calendar.music          |   16 +-
 usr.bin/calendar/calendars/calendar.orthodox       |   53 +
 usr.bin/calendar/calendars/calendar.uk             |    2 +-
 usr.bin/calendar/calendars/calendar.ushistory      |   67 +-
 usr.bin/calendar/calendars/calendar.world          |    2 +
 .../calendars/de_AT.UTF-8/calendar.feiertag        |    4 +-
 .../calendars/de_DE.UTF-8/calendar.feiertag        |    4 +-
 .../calendars/de_DE.UTF-8/calendar.geschichte      |    9 +-
 .../calendar/calendars/fr_FR.UTF-8/calendar.fetes  |   15 +-
 .../calendars/hu_HU.UTF-8/calendar.nevnapok        |   10 +-
 .../calendars/hu_HU.UTF-8/calendar.unnepek         |    4 +-
 .../calendars/pt_BR.UTF-8/calendar.mcommemorative  |    2 +-
 .../calendars/ru_RU.UTF-8/calendar.orthodox        |   24 +-
 .../calendars/ru_RU.UTF-8/calendar.primety         |   13 +-
 .../calendars/uk_UA.UTF-8/calendar.holiday         |   16 +-
 .../calendar/calendars/uk_UA.UTF-8/calendar.misc   |    4 +-
 .../calendars/uk_UA.UTF-8/calendar.orthodox        |   29 +-
 .../calendars/zh_Hans_CN.UTF-8/calendar.all        |   11 +
 .../calendars/zh_Hans_CN.UTF-8/calendar.chinese    |   34 +
 .../calendars/zh_Hans_CN.UTF-8/calendar.gregorian  |   38 +
 .../calendars/zh_Hant_TW.UTF-8/calendar.all        |   11 +
 .../calendars/zh_Hant_TW.UTF-8/calendar.chinese    |   39 +
 .../calendars/zh_Hant_TW.UTF-8/calendar.gregorian  |   41 +
 usr.bin/calendar/chinese.c                         |  572 ++++++++
 usr.bin/calendar/chinese.h                         |   75 +
 usr.bin/calendar/dates.c                           |  537 +++----
 usr.bin/calendar/{ostern.c => dates.h}             |   62 +-
 usr.bin/calendar/days.c                            |  448 ++++++
 usr.bin/calendar/days.h                            |   79 +
 usr.bin/calendar/ecclesiastical.c                  |  109 ++
 usr.bin/calendar/ecclesiastical.h                  |   44 +
 usr.bin/calendar/events.c                          |  120 --
 usr.bin/calendar/gregorian.c                       |  165 +++
 usr.bin/calendar/gregorian.h                       |   52 +
 usr.bin/calendar/io.c                              |  858 ++++++-----
 usr.bin/calendar/{paskha.c => io.h}                |   68 +-
 usr.bin/calendar/julian.c                          |  281 ++++
 usr.bin/calendar/julian.h                          |   55 +
 usr.bin/calendar/locale.c                          |  165 ---
 usr.bin/calendar/moon.c                            |  922 ++++++++++++
 usr.bin/calendar/moon.h                            |   62 +
 usr.bin/calendar/nnames.c                          |  174 +++
 usr.bin/calendar/{day.c => nnames.h}               |  101 +-
 usr.bin/calendar/parsedata.c                       | 1527 ++++++++------------
 usr.bin/calendar/parsedata.h                       |   65 +
 usr.bin/calendar/pom.c                             |  259 ----
 usr.bin/calendar/sun.c                             |  415 ++++++
 usr.bin/calendar/sun.h                             |   58 +
 usr.bin/calendar/sunpos.c                          |  445 ------
 usr.bin/calendar/utils.c                           |  214 +++
 usr.bin/calendar/utils.h                           |  271 ++++
 74 files changed, 7683 insertions(+), 3838 deletions(-)
 create mode 100644 etc/calendar/Makefile
 create mode 100644 etc/calendar/default
 create mode 100644 usr.bin/calendar/basics.c
 create mode 100644 usr.bin/calendar/basics.h
 delete mode 100644 usr.bin/calendar/calendar.1
 create mode 100644 usr.bin/calendar/calendar.1.in
 create mode 100644 usr.bin/calendar/calendars/calendar.chinese
 create mode 100644 usr.bin/calendar/calendars/calendar.misc
 create mode 100644 usr.bin/calendar/calendars/calendar.orthodox
 create mode 100644 usr.bin/calendar/calendars/zh_Hans_CN.UTF-8/calendar.all
 create mode 100644 usr.bin/calendar/calendars/zh_Hans_CN.UTF-8/calendar.chinese
 create mode 100644 usr.bin/calendar/calendars/zh_Hans_CN.UTF-8/calendar.gregorian
 create mode 100644 usr.bin/calendar/calendars/zh_Hant_TW.UTF-8/calendar.all
 create mode 100644 usr.bin/calendar/calendars/zh_Hant_TW.UTF-8/calendar.chinese
 create mode 100644 usr.bin/calendar/calendars/zh_Hant_TW.UTF-8/calendar.gregorian
 create mode 100644 usr.bin/calendar/chinese.c
 create mode 100644 usr.bin/calendar/chinese.h
 rename usr.bin/calendar/{ostern.c => dates.h} (56%)
 create mode 100644 usr.bin/calendar/days.c
 create mode 100644 usr.bin/calendar/days.h
 create mode 100644 usr.bin/calendar/ecclesiastical.c
 create mode 100644 usr.bin/calendar/ecclesiastical.h
 delete mode 100644 usr.bin/calendar/events.c
 create mode 100644 usr.bin/calendar/gregorian.c
 create mode 100644 usr.bin/calendar/gregorian.h
 rename usr.bin/calendar/{paskha.c => io.h} (55%)
 create mode 100644 usr.bin/calendar/julian.c
 create mode 100644 usr.bin/calendar/julian.h
 delete mode 100644 usr.bin/calendar/locale.c
 create mode 100644 usr.bin/calendar/moon.c
 create mode 100644 usr.bin/calendar/moon.h
 create mode 100644 usr.bin/calendar/nnames.c
 rename usr.bin/calendar/{day.c => nnames.h} (51%)
 create mode 100644 usr.bin/calendar/parsedata.h
 delete mode 100644 usr.bin/calendar/pom.c
 create mode 100644 usr.bin/calendar/sun.c
 create mode 100644 usr.bin/calendar/sun.h
 delete mode 100644 usr.bin/calendar/sunpos.c
 create mode 100644 usr.bin/calendar/utils.c
 create mode 100644 usr.bin/calendar/utils.h

http://gitweb.dragonflybsd.org/dragonfly.git/commitdiff/d19ef5a274debcb71f2e8cd8dce8b954dc73944b


-- 
DragonFly BSD source repository



More information about the Commits mailing list