Page 1 of 1
GMT/SummerTime flag
Posted: Mon Mar 13, 2006 11:47 am
by RichardL
Hi,
Can someone kindly point me in the direction of flag that indicates if a PC clock is currently showing GMT or summer time?
RichardL
[/list]
Posted: Mon Mar 13, 2006 12:12 pm
by gnozal
Use GetTimeZoneInformation_(TimeZoneInformation.TIME_ZONE_INFORMATION)
TIME_ZONE_INFORMATION wrote:The GetTimeZoneInformation function retrieves the current time-zone parameters. These parameters control the translations between Coordinated Universal Time (UTC) and local time.
DWORD GetTimeZoneInformation(
LPTIME_ZONE_INFORMATION lpTimeZoneInformation // address of time-zone settings
);
Parameters
lpTimeZoneInformation
Points to a TIME_ZONE_INFORMATION structure to receive the current time-zone parameters.
Return Values
If the function succeeds, the return value is one of the following values:
Value Meaning
TIME_ZONE_ID_UNKNOWN The operating system cannot determine the current time zone. This is usually because a previous call to the SetTimeZoneInformation function supplied only the bias (and no transition dates).
TIME_ZONE_ID_STANDARD The operating system is operating in the range covered by the StandardDate member of the structure pointed to by the lpTimeZoneInformation parameter.
TIME_ZONE_ID_DAYLIGHT The operating system is operating in the range covered by the DaylightDate member of the structure pointed to by the lpTimeZoneInformation parameter.
I think TIME_ZONE_ID_DAYLIGHT is what you are looking for.
Look at
http://www.purebasic.fr/english/viewtop ... hlight=gmt
Posted: Mon Mar 13, 2006 12:56 pm
by PB
@gnozal: Thanks for that, I wrote a little procedure for it:
Code: Select all
Procedure IsSummerTime()
; Fred is aware that these need adding to PureBasic. ;)
#TIME_ZONE_ID_UNKNOWN = 0
#TIME_ZONE_ID_STANDARD = 1
#TIME_ZONE_ID_DAYLIGHT = 2
#TIME_ZONE_ID_INVALID = $FFFFFFFF
Select GetTimeZoneInformation_(tzi.TIME_ZONE_INFORMATION)
Case #TIME_ZONE_ID_UNKNOWN,#TIME_ZONE_ID_INVALID : r=-1
Case #TIME_ZONE_ID_STANDARD : r=0
Case #TIME_ZONE_ID_DAYLIGHT : r=1
EndSelect
ProcedureReturn r
EndProcedure
Debug IsSummerTime() ; 0 = No, 1 = Yes, -1 = Don't know.
Posted: Mon Mar 13, 2006 3:43 pm
by RichardL
Thank you both. Yes, this pushed me in the right directio.
@gnozal. Your 2003 example appears to use the \DaylightBias value incorrectly. This value is the correction to UTC to be made IF within the daylight saving part of the year. The \Bias value should then be added to this.
All teh best...
RichardL
Posted: Mon Mar 13, 2006 4:04 pm
by gnozal
RichardL wrote:@gnozal. Your 2003 example appears to use the \DaylightBias value incorrectly.
Yes, you are right : old post changed
