Why reinvent the wheel?

I wanted calendar software that:

  • Was written in C

  • Could be freely used and redistributed under the GPL licence

  • Was extensible, so I could add routines for climate model calendars

  • Unfortunately I could not find such a package. Read on for specific comments on what's out there.


    Dershowitz and Reingold's Calendrical Calculations

    This is a book and associated software covering all sorts of calendar calculations. Unfortunately it seems to include a very restrictive license, so I did not use anything from this source.

    One of the authors of Calendrical Calculations, Edward M. Reingold, is also an author of the GNU Emacs calendar code. That code is released under GPL, but it's written in LISP, which was not directly useful for me.

    Reingold also has a C++ version of some of the basic calendar calculations available at his web site. This C++ code is in the public domain. I used a couple of algorithms from this public domain code. However, most of the coding effort in CalCalcs involved handling the way our calendar transitioned from the Julian calendar to the Gregorian calendar. Reingold's public domain C++ code did not address this issue, and so was of limited use to me.

    However if you just want a single quick calendar conversion, there is a handy web-based interface to the Calendrical Calculations available.


    Lance Latham's Standard C Date/Time Library

    Another commonly cited reference is Lance Latham's Standard C Date/Time Library (SCDTL). Here is what the license for these routines says:

    "No part of this publication may be reproduced or distributed in any form or by any means, or stored in a database or retrieval system, without the prior written permission of the publisher; with the exception that the program listings may be entered, stored, and executed in a computer system, but they many not be reproduced for publication."

    If I use this code in one of my programs, and then put my source code up on the web for anyone to access, is it the same as "reproducing it for publication"? It seems at the least that it would violate the copyright. Overall I decided this was not the way I wanted to go, so I have not used any code, algorithms, or information from SCDTL. Other people have decided differently; for example, there is a Javascript port of SCDTL available.


    Jon Ahlquist's calndr.f routine

    Jon Ahlquist of Florida State University has a nice web site with calendar information available, along with a GPL'd calendar routine written in Fortran. This is quite useful if you have Fortran, but that has become rather uncommon nowadays.

    The algorithms in Ahlquist's code are similar to those used in the udunits library, which references a Fortran90 nagware implementation. I did not use the nagware code or algorithms to avoid any possibility of falling under NAG's software license.

    (C) 2010 David W. Pierce