On Apr 27, 2013, at 6:33 PM, Nicolas Cellier <nicolas.cellier.aka.n...@gmail.com> wrote:
> Since DateAndTime comment is out of date (sic !) and current implementation > seems not free of bug, here is an effort to summarize and understand the > whole thing, let's call this a review. Thanks this is a great initiative! > Please tell me where my interpretations are wrong. > > 1) The DateAndTime is stored internally as > - a point in UTC time (julianDayNumber, seconds, nanos) > - an offset from UTC (a Duration) denoting the local time zone > > 2) The ticks method returns the UTC part {julianDayNumber. seconds. nanos} > > 3) DateAndTime print themselves in local time using the offset > > 4) other methods (with some exceptions) return the local dateAndTime parts > (year month day hours minutes seconds) > > Exceptions are: > - secondsSinceMidnight (which should be renamed secondsSinceMidnightUTC IMO, > even if the method is classified private) > - julianDayNumberUTC as the name tells > > So far so good (but secondsSinceMidnight which is error prone) > > What I find strange: > - #hash uses the offset... Why ??? > > d1 := DateAndTime now. > d2 := d1 offset: d1 offset + 1 hours. > { > d1 = d2. > d1 hash = d2 hash. > } > gives #(true false), a clue? > > - #< compares julianDayNumber (the UTC inst. var.) with otherDate > julianDayNumber (with otherDate local offset) which seems wrong, it should > better use julianDayNumberUTC or (normalized) ticks. > > - #= could be simplified and accelerated if using #hasEqualTicks: (if the > ticks are correctly normalized though which would be the case since > #ticks:offset: does, unfortunately #setJdn:seconds:nanos:offset: does not). > > Some senders of #setJdn:seconds:nanos:offset: don't normalize the > day/seconds/nanos, though it should be their responsibility (DateAndTime > todayAtMilliSeconds: xxx) (DateAndTime todayAtNanoSeconds: xxx), not counting > year:month:day:hour:minute:second:nanoSecond:offset: which does not either > (many senders...). > Maybe we should better let the normalization responsibility to > #setJdn:seconds:nanos:offset:. > > It remain to analyze the conversion protocol (asYear etc...) which seems to > use the local time year, but I don't understand the whole Timespan thing > right now (why DateAndTime now asYear starts now, and not on january 1st?). > > Nicolas > >