fix gmt-offset on windows

db4
Doug Coleman 2008-03-18 18:59:37 -05:00
parent 693f3b9193
commit 55a8c991ad
1 changed files with 13 additions and 14 deletions

View File

@ -1,22 +1,21 @@
USING: calendar.backend namespaces alien.c-types USING: calendar.backend namespaces alien.c-types
windows windows.kernel32 kernel math ; windows windows.kernel32 kernel math combinators.cleave
combinators ;
IN: calendar.windows IN: calendar.windows
TUPLE: windows-calendar ; TUPLE: windows-calendar ;
T{ windows-calendar } calendar-backend set-global T{ windows-calendar } calendar-backend set-global
: TIME_ZONE_ID_INVALID HEX: ffffffff ; inline
M: windows-calendar gmt-offset ( -- hours minutes seconds ) M: windows-calendar gmt-offset ( -- hours minutes seconds )
0 0 0 ; "TIME_ZONE_INFORMATION" <c-object>
! "TIME_ZONE_INFORMATION" <c-object> dup GetTimeZoneInformation {
! dup GetTimeZoneInformation { { [ dup TIME_ZONE_ID_INVALID = ] [ win32-error-string throw ] }
! { [ dup TIME_ZONE_ID_INVALID = ] [ win32-error ] } { [ dup [ TIME_ZONE_ID_UNKNOWN = ] [ TIME_ZONE_ID_STANDARD = ] bi or ] [
! { [ dup { TIME_ZONE_ID_UNKNOWN TIME_ZONE_ID_STANDARD } member? ] drop TIME_ZONE_INFORMATION-Bias ] }
! [ TIME_ZONE_INFORMATION-Bias 60 / neg ] } { [ dup TIME_ZONE_ID_DAYLIGHT = ] [
! { [ dup TIME_ZONE_ID_DAYLIGHT = ] [ drop
! [ TIME_ZONE_INFORMATION-Bias 60 / neg ] [ TIME_ZONE_INFORMATION-Bias ]
! [ TIME_ZONE_INFORMATION-DaylightBias ] bi [ TIME_ZONE_INFORMATION-DaylightBias ] bi +
! ] } ] }
! } cond ; } cond neg 60 /mod 0 ;