[LEAPSECS] Lets get REAL about time.
scolebourne at joda.org
Fri Jan 27 07:01:20 EST 2012
On 27 January 2012 10:50, Clive D.W. Feather <clive at davros.org> wrote:
> Stephen Colebourne said:
>> Interestingly, in JSR-310 I may end up representing a date as a packed
>> form of day-of-month (5 bits) and epoch-months (59 bits). Month
>> calculations are then easy.
> Oh? When is a month from Monday coming? What day is 4 months after the last
> day of next month? What about the antepenultimate day of next month?
> Explain your working in each case.
Each of those three examples requires the day-of-week, thus can't be
calculated from month alone (it needs the whole date). Calculating the
day-of-week involves calculating a day-count, and then going from
The point of storing data in this form is that most queries of a date
are for year, month and day-of-month. Similarly, most sets/adds, like
2012-01-31 + 1month require the year, month and day-of-month. In the
format above, those calculations are easy. The trade off is that some
other calculations are harder. Design is always about trade-offs.
More information about the LEAPSECS