Definitions of date arithmetic

Paul Eggert eggert at twinsun.com
Sun Oct 11 00:33:41 UTC 1998


   Date: 10 Oct 1998 15:35:05 -0000
   From: "D. J. Bernstein" <djb at cr.yp.to>

   Paul Eggert writes:
   > * 29 February if it's a leap lear, 28 February otherwise.

   If that's 1 month before 31 March, then what's 1 month before 30 March?
   1 month before 29 March?

The same as 1 month before 31 March.

   1 month before 28 March?

28 February.

   And what's 1 month after 28 February? 1 month after 27 February? 1 month
   _before_ 27 February?

28 March, 27 March, and 27 January.

Obviously date arithmetic like this won't have the nice properties of
ordinary arithmetic: e.g. when you add 1 month and then subtract 1
month you may not end up where you started.  Too bad, but that's life.

The real problems occur when people start futzing with UTC offsets,
e.g. the Kiritimati example I mentioned earlier.  Then it becomes much
harder to specify rules that match most people's intuition, since
people don't have as much intuition for those sorts of problems.

And there are also problems when you consider people futzing with
calendars, e.g. what's 1 month before 10 October 1752 in Great
Britain?  But we're starting to stray from the subject....



More information about the tz mailing list