Time since the epoch

Peter Thiemann thiemann@informatik.uni-freiburg.de
11 Feb 2003 13:14:26 -0800


    George> OK, what TimeExts does, I hope, is add the appropriate amount of the appropriate
    George> time unit (whatever it is) directly, then rely on the CalendarTime conversions to
    George> resolve any overflows.  This probably isn't very clear,
    George> so I'll give some examples of what I think ought to
    George> happen.

I see. You propose to always add the duration of the current
entity. IE, a month rooted in January has 31 days, and a year rooted
in a leap year has 366 days. How do you define subtraction, given that
your addition is not monotonic and that you (probably) want addition
and subtraction be inverses?

Actually, you could equally well argue that you should always take the
duration of the next following entity (in seconds, but I won't go into
that detail). While this means that  (in a non-leap year)
January 1 + 1 month = January 29
it preserves monotonicity:
January 31 + 1 month = February 28
so that you could define subtraction (although at some expense).

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

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

    George> Note that in this case "Add 1 month" is not a monotonic operation. 

    George> Add 1 minute to 23:59:60 31st December 2003.  I assume
    George> that this is a valid time and that it 
    George> will be a leap second; if not choose some other year.

[... long calculation ...]

    George> 2004 January 1st 00:01:00

I would argue that adding one minute might be interpreted either
* as an absolute minute (add 60 seconds)
* or as the duration of the next calendar minute (which happens to be
  60 seconds, too).
(both resulting in 00:00:59)

In any case, it is merely a matter of interpreting the amount in terms
of seconds, and then let the translation inside of calendartime do its
work for you. 

-Peter