[squeak-dev] Re: [Pharo-project] Epoch returns local offset

Sean P. DeNigris sean at clipperadams.com
Fri May 18 17:56:30 UTC 2012


Eliot Miranda-2 wrote
> 
> This seems pretty clear to me.  The epoch is the start of the 20th century
> in GMT

If that is the definition, "DateAndTime epoch" has a bug. It simply tacks on
the local offset (e.g "1901-01-01T00:00:00-04:00" on my machine). It should
return "1901-01-01T00:00:00+00:00" or "1900-12-31T20:00:00-04:00", but
"1901-01-01T00:00:00-04:00" is clearly wrong.

Also, "DateAndTime fromSeconds: 0" returns the same value. This is useless
because a DateAndTime that is encoded as an offset must be relative to a
fixed reference. The offset is not encoded, so if I "aDateAndTime asSeconds"
(which also gives the incorrect result above), store it somewhere, go to a
different timezone, and "DateAndTime fromSeconds: savedSeconds", I get a
different result. For example:
	dt := '1/15/2012 0000+00:00' asDateAndTime. 

	DateAndTime localTimeZone: (TimeZone timeZones detect: [ :e | e
abbreviation = 'PDT' ]). 
	s := dt asSeconds. "3504013200" 

	"Now I move to Greenwich" 
	DateAndTime localTimeZone: (TimeZone timeZones detect: [ :e | e
abbreviation = 'UTC' ]). 
	DateAndTime fromSeconds: s. "2012-01-14T17:00:00+00:00" "Oops!"

--
View this message in context: http://forum.world.st/Re-Pharo-project-Epoch-returns-local-offset-tp4630581p4630811.html
Sent from the Squeak - Dev mailing list archive at Nabble.com.


More information about the Squeak-dev mailing list