[Vm-dev] Timezones in LocalePlugin

Andreas Raab andreas.raab at gmx.de
Thu Aug 28 15:58:10 UTC 2008


 > Comments?

We are using these primitives. Let me check with Brad if your 
observations ring a bell (he did most of that work).

Cheers,
   - Andreas

Bert Freudenberg wrote:
> 
> For OLPC I need a UTC time stamp, and found VM's behaviors to differ 
> widely.
> 
> All VMs currently report time as local time. To identify those VMs we 
> need a primitive that answers the offset of the VM time from local time. 
> This could nicely fallback to 0 if no LocalePlugin is available. Then we 
> also need a primitive to determine the offset of local time from UTC.
> 
> The locale plugin currently has three related primitives:
> 
> ====================================
> http://squeakvm.org/svn/squeak/trunk/platforms/Cross/plugins/LocalePlugin/LocalePlugin.h 
> 
> 
> /* return in minutes the offset between thisVM and UTC. */
> sqInt    sqLocGetVMOffsetToUTC(void);
> 
> /* return in minutes the offset between the currenct timezone and UTC */
> sqInt    sqLocGetTimezoneOffset(void);
> 
> /* return true if DST is in use, false otherwise */
> sqInt    sqLocDaylightSavings(void);
> ====================================
> 
> IMHO these are insufficient, besides they do not work the same on all 
> platforms. Here's what I get in Germany with DST in effect:
> 
> platform    Win    Mac    Linux
> vm offset    0    0    -120
> timezone    60    120    -120
> daylight    true    true    true
> 
> So VMOffsetToUTC is reported as 0 by Mac and Win - I think that 
> primitive is simply misnamed, which led to the wrong implementation in 
> Linux. If the VM answers local time this should be 0. (we might simply 
> declare the VM is always in local time and get rid of this prim entirely)
> 
> The TimezoneOffset should be counted EAST of Greenwich, this wasn't 
> really specified in the header so that's why Linux got it wrong (Unix 
> timezones are typically counted West). This *should* include DST 
> adjustment IMHO as Mac and Win do. It really is the offset between local 
> time and UTC.
> 
> So I propose to redefine the primitives as follows:
> 
> ====================================
> 
> /* return in minutes the offset between local time and this VM.
>    this value plus the time reported by the VM gives local time.
>    0 indicates VM answers local time.
>    If VM answers UTC, in Berlin in Summer this would be +120 */
> sqInt    sqLocGetVMOffset(void);
> 
> /* return in minutes the offset between local time and UTC
>    where positive values are East of Greenwich.
>    e.g., Berlin in Summer is +120 in Winter +60 */
> sqInt    sqLocGetUTCOffset(void);
> 
> /* return true if DST is in use, false otherwise */
> sqInt    sqLocDaylightSavings(void);
> ====================================
> 
> As far as I am aware, nobody used these primitives yet. If renaming is 
> too much hassle we could leave the old wrong names but add the comments 
> as I proposed above, and adjust the behavior. Mac then would already be 
> compliant, Windows is only off by an hour (in Summer?), and I'll fix 
> Linux in the OLPC branch.
> 
> Comments?
> 
> - Bert -
> 
> 


More information about the Vm-dev mailing list