Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

DateAndTime offset incorrect during DST

9 views
Skip to first unread message

Chad Hall

unread,
Apr 20, 2006, 9:43:36 AM4/20/06
to
Has anyone come up with a solution for the incorrect behavior of
DateAndTime during daylight savings time?

In 6.0.2:
DateAndTime now asUTC --> 2006-04-20T14:39:47.265+00:00
(when UTC is currently 13:39:47)

Thanks,
Chad

Marten Feldtmann

unread,
Apr 20, 2006, 2:07:09 PM4/20/06
to
Chad Hall schrieb:

The reason is here:

primitiveSystemOffset
"Answer an <Integer> representing the westward displacement of system
local time
from UTC in seconds. The value can be betwen 0 and 86400 minutes."

<primitive: TzOffset>
^self primitiveFailed

This primitive does not consider the DST settings of the
operating system ...

Looking up the Windows API one could exchange the method (under
Windows) with:

primitiveSystemOffset
| daylightSavingInAction baseOffset dstOffset timezoneInformation |

"
<primitive: TzOffset>
^self primitiveFailed
"
timezoneInformation := OSTimeZoneInformation calloc: 1.
daylightSavingInAction := timezoneInformation getTimeZoneInformation.

baseOffset := timezoneInformation Bias.
dstOffset := timezoneInformation DaylightBias.

timezoneInformation free.

^(baseOffset
+ (daylightSavingInAction= PlatformConstants::TimeZoneIdDaylight
ifTrue:[ dstOffset]
ifFalse:[ 0 ])) * 60


which of course brings problems when packaging under different
operating systems ....

Marten

Chad Hall

unread,
Apr 21, 2006, 8:55:36 AM4/21/06
to
>
> primitiveSystemOffset
> | daylightSavingInAction baseOffset dstOffset timezoneInformation |
>
> "
> <primitive: TzOffset>
> ^self primitiveFailed
> "
> timezoneInformation := OSTimeZoneInformation calloc: 1.
> daylightSavingInAction := timezoneInformation getTimeZoneInformation.
>
> baseOffset := timezoneInformation Bias.
> dstOffset := timezoneInformation DaylightBias.
>
> timezoneInformation free.
>
> ^(baseOffset
> + (daylightSavingInAction= PlatformConstants::TimeZoneIdDaylight
> ifTrue:[ dstOffset]
> ifFalse:[ 0 ])) * 60
>
>

Thanks, Marten. Works like a champ.

-Chad


Solveig Viste

unread,
Apr 24, 2006, 11:11:38 AM4/24/06
to
We'll fix this in the next major release.

Thanks,
Solveig Viste
Instantiations Smalltalk Support
"Chad Hall" <irc...@yahoo.com> wrote in message
news:e2akvl$2gc7c$1...@news.boulder.ibm.com...

0 new messages