GMT/SummerTime flag

Just starting out? Need help? Post your questions and find answers here.
RichardL
Enthusiast
Enthusiast
Posts: 532
Joined: Sat Sep 11, 2004 11:54 am
Location: UK

GMT/SummerTime flag

Post 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]
gnozal
PureBasic Expert
PureBasic Expert
Posts: 4229
Joined: Sat Apr 26, 2003 8:27 am
Location: Strasbourg / France
Contact:

Post 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
Last edited by gnozal on Mon Mar 13, 2006 4:07 pm, edited 1 time in total.
For free libraries and tools, visit my web site (also home of jaPBe V3 and PureFORM).
PB
PureBasic Expert
PureBasic Expert
Posts: 7581
Joined: Fri Apr 25, 2003 5:24 pm

Post 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.
I compile using 5.31 (x86) on Win 7 Ultimate (64-bit).
"PureBasic won't be object oriented, period" - Fred.
RichardL
Enthusiast
Enthusiast
Posts: 532
Joined: Sat Sep 11, 2004 11:54 am
Location: UK

Post 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
gnozal
PureBasic Expert
PureBasic Expert
Posts: 4229
Joined: Sat Apr 26, 2003 8:27 am
Location: Strasbourg / France
Contact:

Post by gnozal »

RichardL wrote:@gnozal. Your 2003 example appears to use the \DaylightBias value incorrectly.
Yes, you are right : old post changed :oops:
For free libraries and tools, visit my web site (also home of jaPBe V3 and PureFORM).
Post Reply