3.8 and french (and locales)

Lex Spoon lex at cc.gatech.edu
Wed Jun 8 23:28:15 UTC 2005


Like David described, any code that uses the offset primitive will
automatically have a race condition.  If it grabs the offset, the
offset changes (due to daylight savings), and then it grabs the time,
then the offset and time will not match up.  In addition to giving
times that are off by an hour, this can give times that are non-monotonic
even when the OS normally prevents it.  This is not going to be a common
problem, but when it comes up it will be really nasty.  I would hate to be
the guy looking through the logs trying to figure out how A happened
before B but A's timestamp is *after* B's timestamp.

I'd also hate for that guy to shrug and say, "what do you expect,
it's Squeak".

Avoiding this is easy: simply report the time and offset simultaneously.
Have one primitive that fills in an array with the following information:

	local date
	local time
	offset to UTC
	timezone identifier (using the standard id's Mike has dug up)

Many variations are possible.  The point is that since the values are
reported simultaneously, you get an offset that matches the time, neatly
avoiding the race condition.  Perhaps unsurprisingly, this is the approach
used in the Posix C library's gettimeofday() function.

I agree that changing timezones is much less important to support.
Even if Squeak gets wedged, you can just save and restart your
image, and a server (where reliability is more important IMHO) is
unlikely to be changing timezones at runtime (or ever!).  Nevertheless,
it is interesting that the above primitive avoids this race condition as well.


> Where is this code? It might be interesting. How does it find out what 
> the current platform's timezone is?

Hit google on "Dave Lewis timezone" and good pages show up.


For what it's worth, I don't mean to attack any particular author.  I
have simply invested time and code in this issue, and so thought I would
contribute an insight that is frequently overlooked.  In general, it's truly
wonderful to see Squeak starting to pull locale information from the
underlying platform.  It opens a number of possibilities including 
auto-setting of the language and having Celeste finally use timezones
that match the OS.


Lex



More information about the Squeak-dev mailing list