[racket] Parsing dates & times

From: Norman Gray (norman at astro.gla.ac.uk)
Date: Tue Jul 15 05:56:29 EDT 2014

Greetings.

On 2014 Jul 15, at 04:39, Neil Van Dyke <neil at neilvandyke.org> wrote:

> BTW, I try to limit my uses of date&time as much as possible, since none of the libraries are that complete, and coding yourself into a corner where you suddenly find you need to fill in a date library gap is a big time-consuming distraction from one's main goal.  (Date math is a surprising mess to get perfect, and even major software companies like MSFT have been found to ship buggy high-profile date math repeatedly.)  For the limited uses I do make, the only real problem I've found with SRFI-19 is that their week-date conversions appear wrong by any of the week-numbering conventions I know.  (Thank you, unit testing, or I would've put incorrect week-number code into production, quite recently.)

All this is regrettably very true.  I find myself implementing date-library logic more often than I suppose I should, precisely because I know enough about dates to know that most libraries are flawed one way or another.

However this (re-implementation) isn't necessarily a bad thing.  Often, I've found this usefully forces me to decide on a canonical date representation for the problem -- such as epoch+seconds, or JD+ms, say -- and code from that back and forth to display strings and other required logic.  It means more coding, but feels less occult.

Or (*grumble, grumble*) perhaps we should all move to a strict TAI count and be done with all this calendar nonsense....

Anyway: this is a preamble to a recommendation of Calendrical Calculations by Dershowitz and Reingold <http://emr.cs.iit.edu/home/reingold/calendar-book/third-edition/>, which includes all one could reasonably want to know about calendars, including test cases and sample lispish implementation code.

The Explanatory Supplement <http://aa.usno.navy.mil/publications/docs/exp_supp.php> is also damn good, but appeals to more... specialised tastes.

All the best,

Norman


-- 
Norman Gray  :  http://nxg.me.uk
SUPA School of Physics and Astronomy, University of Glasgow, UK



Posted on the users mailing list.