DateAndTime>>offset: returns different instant

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
1 message Options
Reply | Threaded
Open this post in threaded view
|

DateAndTime>>offset: returns different instant

Jakob Reschke-2
Hi all,

the comment in DateAndTime>>offset: reads:

> Answer a <DateAndTime> equivalent to the receiver but with its local time
> being offset from UTC by offset.

But the result of #offset: does not represent the same instant of time:

dt := DateAndTime now.
dt " 2016-10-22T22:18:12.003779+02:00"
dt offset: 3 hours " 2016-10-22T22:18:12.003779+03:00"
dt = (dt offset: 3 hours) "false"

In Pharo, things behave differently:

dt := DateAndTime now. "2016-10-22T22:21:07.097583+02:00"
dt offset: 3 hours. "2016-10-22T23:21:07.097583+03:00"
dt = (dt offset: 3 hours) "true"

...thus portability is broken.

Looks like #utcOffset: does what #offset: seemed to promise in my understanding:

dt = (dt utcOffset: 3 hours) "true"

So, in my effort of porting some code from Pharo to Squeak, I have to
replace offset: by utcOffset:.

Is the comment in #offset: inaccurate, or did I misunderstand it?
Would you agree that a clarification would be helpful? Was DateAndTime
handling ever portable?

Best regards,
Jakob