CALPAK
Calendar Calculations


CALPAK is a C++ library which computes various simple calendrical quantities.

These include converting from day-number/year to day/month/year format, calculating the time difference between two dates, finding the day of the week of a given date, and other feats.

Some common methods of marking the date include:

While there have been many calendars over the years, it is instructive to contemplate just the crazy story of our current "common" calendar. To this day, people disagree about whether there was a year 0, although the Julian calendar was a Roman invention, and Dionysius Exiguus, who gets the blame for shifting the Julian calendar's starting date to the birth year of Christ four hundred years afterwards, didn't have an accurate idea of when that was.

There was a controversial shift from the Julian to the Gregorian calendar, which took place piecemeal throughout the Catholic world, with several countries actually switching back and forth more than once, and with England holding out on the old system until after George Washington was born (which means he was born on February 11 AND February 22).

People didn't agree on when the year started, so that January and February, in particular, were a little murky about which year they belonged to, and the year sometimes started around March 22, near the vernal equinox.

There are a number of side issues, including

Licensing:

The computer code and data files described and made available on this web page are distributed under the GNU LGPL license.

Languages:

CALPAK is available in a C++ version and a FORTRAN90 version and a MATLAB version.

Related Data and Programs:

ANALEMMA, a C program which evaluates the equation of time, a formula for the difference between the uniform 24 hour day and the actual position of the sun, by Brian Tung.

CALENDAR_NYT, a FORTRAN90 library which shows the correspondence between dates and the New York Times volume and issue number;

CALENDAR_RD, a C++ program which computes the representation of a given date in a number of calendrical systems, by Edward Reingold and Nachum Dershowitz

DATES, a dataset directory which contains lists of dates in various calendar systems.

DOOMSDAY, a C++ library which is given the year, month and day of a date, and uses John Conway's doomsday algorithm to determine the corresponding day of the week.

WEEKDAY, a C++ library which determines the day of the week for a given day.

Reference:

  1. Anonymous,
    A Correction; Welcome to 51,254,
    The New York Times,
    01 January 2000, Volume 149, Issue 51254.
  2. James Barron,
    What's in a Number? 143 Years of News,
    The New York Times,
    14 March 1995, Volume 144, Issue 50000.
  3. Bonnie Blackburn, Leofranc Holford-Stevens,
    The Oxford Companion to the Year,
    Oxford, 1999,
    ISBN: 0192142313,
    LC: CE73.B553.
  4. Lewis Carroll (Charles Dodgson),
    To Find the Day of the Week for Any Given Date,
    Nature, 31 March 1887.
  5. John Conway,
    Tomorrow is the Day After Doomsday,
    Eureka,
    Volume 36, October 1973, pages 28-31.
  6. Peter Duffett-Smith,
    Practical Astronomy With Your Calculator,
    Third Edition,
    Cambridge University Press, 1996,
    ISBN: 0-521-35699-7,
    LC: QB62.5.D83.
  7. Donald Knuth,
    The Art of Computer Programming,
    Volume 1, Fundamental Algorithms,
    Third Edition,
    Addison-Wesley, 1997,
    ISBN: 0201896834,
    LC: QA76.6.K64.
  8. Donald Knuth,
    The Calculation of Easter,
    Communications of the ACM,
    Volume 5, Number 4, April 1962, pages 209-210.
  9. Gary Meisters,
    Lewis Carroll's Day-of-the-Week Algorithm,
    Math Horizons,
    November 2002, pages 24-25.
  10. Lance Latham,
    Standard C Date/Time Library,
    Programming the World's Calendars and Clocks,
    Miller Freeman, 1998,
    ISBN: 0-87930-496-0.
  11. The New York Times,
    Page One, 1896-1996, A Special Commemorative Edition Celebrating the 100th Anniversary of the Purchase of the New York Times by Adolph S Ochs,
    Galahad Books, 1996,
    ISBN: 0-88365-961-1,
    LC: D411.P25.
  12. The New York Times,
    The Complete First Pages, 1851-2008,
    Black Dog & Leventhal Publishers, 2008,
    ISBN13: 978-1-57912-749-7,
    LC: D351.N53.
  13. Thomas OBeirne,
    Puzzles and Paradoxes,
    Oxford University Press, 1965,
    LC: QA95.O2.
  14. Frank Parise, editor,
    The Book of Calendars,
    Gorgias, 2002,
    ISBN: 1931956766,
    LC: CE11.K4.
  15. William Press, Brian Flannery, Saul Teukolsky, William Vetterling,
    Numerical Recipes in FORTRAN: The Art of Scientific Computing,
    Second Edition,
    Cambridge University Press, 1992,
    ISBN: 0-521-43064-X,
    LC: QA297.N866.
  16. Edward Reingold, Nachum Dershowitz,
    Calendrical Calculations: The Millennium Edition,
    Cambridge University Press, 2001,
    ISBN: 0-521-77752-6,
    LC: CE12.R45.
  17. Edward Reingold, Nachum Dershowitz,
    Calendrical Calculations I,
    Software - Practice and Experience,
    Volume 20, Number 9, September 1990, pages 899-928.
  18. Edward Reingold, Nachum Dershowitz, Stewart Clamen,
    Calendrical Calculations, II: Three Historical Calendars,
    Software - Practice and Experience,
    Volume 23, Number 4, pages 383-404, April 1993.
  19. Edward Richards,
    Mapping Time, The Calendar and Its History,
    Oxford, 1999,
    ISBN: 0-19-850413-6,
    LC: CE11.R5.
  20. Ian Stewart,
    Easter is a Quasicrystal,
    Scientific American,
    Volume 284, Number 3, March 2001, pages 80-83.
  21. Daniel Zwillinger, editor,
    CRC Standard Mathematical Tables and Formulae,
    30th Edition,
    CRC Press, 1996,
    ISBN: 0-8493-2479-3,
    LC: QA47.M315.

Source Code:

Examples and Tests:

List of Routines:

You can go up one level to the C++ source codes.


Last revised on 28 June 2010.