[squeak-dev] Status of date problem

David T. Lewis lewis at mail.msen.com
Sat Mar 19 01:09:08 UTC 2016


On Sat, Mar 19, 2016 at 12:30:19AM +0100, Bert Freudenberg wrote:
> On 18.03.2016, at 18:29, Chris Muller <asqueaker at gmail.com> wrote:
> > 
> >> | a b |
> >> DateAndTime automaticTimezone: true.
> >> a := DateAndTime now asUTC.
> >> DateAndTime automaticTimezone: false.
> >> DateAndTime localOffset: 5 hours.
> >> b := DateAndTime now asUTC.
> >> {a. b}
> >> ==> {2016-03-18T15:50:21.731797+00:00 . 2016-03-18T11:50:21.731797001+00:00}
> > 
> > Interesting. 
> 
> I just fixed this one. By setting the time zone (localOffset) now the local time appears to jump. UTC is continuous, as it should be.
> 
> A side effect is that the clock in our tool bar now shows that adjusted local time.
> 
> To ensure the millisecondClock is continuous, it now follows UTC. 
> 
> All tests are still green so I hope it???s good.
> 
> And Max???s tests might work again, too, without manual preference fiddling.
> 
> >  Do you know whether this bug affects any API besides #now?
> 
> I think the comments in DateAndTime>>offset: and utcOffset: could use updating. They both claim to return an ???equivalent??? but they???re not:
> 
> x := DateAndTime now.
> x = (x offset: 0)
> ==> false
> 
> x = (x utcOffset: 0)
> ==> true
> 
> Since ???utcOffset:" appears to do the right thing I???d actually prefer it to the ???nowAtOffset:??? you just introduced. E.g. to get the current time in LA you could simply use
> 
> DateAndTime now utcOffset: -7 hours
> 
> No need for a new message. Arguably this is what ???offset:??? should do, and it would if the implementation was utc-based (as is David???s) rather than local-time based.
> 

I am not entirely sure what #utcOffset: should do. Presumably it should affect
UTC offset but not magnitude. Here is what I wrote in the method comment a
couple of years ago:

  DateAndTime>>>utcOffset: anOffset

	"Answer a <DateAndTime> equivalent to the receiver but offset from UTC by anOffset"

	self flag: #FIXME. "check the definition of this and of #offset:"
	^self utcMicroseconds: utcMicroseconds offset: anOffset asDuration asSeconds

So based on that #flag comment, my expectation was that #offset: should answer
a new instance with the same magnitude and a different time zone offset. That
still seems right to me.

Dave



More information about the Squeak-dev mailing list