Time since the epoch

Jonathan Coxhead jonathan@doves.demon.co.uk
Tue, 11 Feb 2003 13:33:26 -0800


    On 11 Feb 2003, at 18:23, George Russell wrote:

> Add 1 month to 1st February 2003.  This produces 1st March 2003.  (with no
> overflow.)

   Here, you add 28 days, which is the number of days in (this) February. Fair 
enough.

> Add 1 month to 31st January 2003.  Then we get 31st February 2003.  This 
clearly
> requires an overflow; we note that February 2003 has 28 days, and so roll over
> to 3rd March 2003.

   Here, you add 31 days, which is the number of days in January. Also fair 
enough.

> Note that in this case "Add 1 month" is not a monotonic operation. 
>
> Add 1 minute to 23:59:60 31st December 2003.  I assume that this is a valid 
time
> and that it will be a leap second; if not choose some other year.
> 
> This is complicated since we have multiple overflows.  First stage you get the
> invalid time
> 
> 23:60:60 31st December 2003.

   But **HERE**, you add 60 seconds. Why? If you want to add "1 minute" to 
23:59:60 31st December 2003, and assuming still that it is a leap minute, then 
to be consistent with the rule for months, I think you ought to add **61** 
seconds---the number of seconds in *this* minute.

   If the problem had been to add "60 seconds", I would agree, but if the 
problem is to add "1 minute", I think there's a flaw here.

        /|
 . . . (_|/ o n a t h a n
        /|
       (_/