PDA

View Full Version : How do I get if today is daylight savings time?



steinie
05-09-2011, 20:36
In VBasic it's:

Dim DST as Boolean

DST=DateTime.Now.IsDaylightSavingsTime()


Thanks......

ErosOlmi
05-09-2011, 21:42
Not so clear approach but here an example using API:




TYPE SYSTEMTIME
wYear As Word
wMonth As Word
wDayOfWeek As Word
wDay As Word
wHour As Word
wMinute As Word
wSecond As Word
wMilliseconds As Word
End Type




Type TIME_ZONE_INFORMATION
Bias As Long
StandardName As String * 64
StandardDate As SYSTEMTIME
StandardBias As Long
DaylightName As String * 64
DaylightDate As SYSTEMTIME
DaylightBias As Long
End Type


%TIME_ZONE_ID_INVALID = &HFFFFFFFF As DWord
%TIME_ZONE_ID_UNKNOWN = 0
%TIME_ZONE_ID_STANDARD = 1
%TIME_ZONE_ID_DAYLIGHT = 2




Declare Function GetTimeZoneInformation Lib "KERNEL32.DLL" Alias "GetTimeZoneInformation" (lpTimeZoneInformation As TIME_ZONE_INFORMATION) As DWord


Dim MyTZ As TIME_ZONE_INFORMATION
Dim lRet As Long


lret = GetTimeZoneInformation(MyTZ)


If lRet = %TIME_ZONE_ID_DAYLIGHT Then
MsgBox 0, "GetTimeZoneInformation returned %TIME_ZONE_ID_DAYLIGHT"
Else
MsgBox 0, "GetTimeZoneInformation returned " & lRet
End If

ErosOlmi
05-09-2011, 22:11
Reference for GetTimeZoneInformation API fucntion:

http://msdn.microsoft.com/en-us/library/ms724421(VS.85).aspx

steinie
06-09-2011, 22:34
Man-O-Man.... all that?:eek:
Thanks for the help - it works.

How about adding that to "DT"

ErosOlmi
06-09-2011, 22:40
How about adding that to "DT"
Yes, sure.

Can you be so kind to open a request into support are under thinBasic feature requests?
http://www.thinbasic.com/community/project.php?do=issuelist&projectid=1&issuetypeid=feature

If not I will create for you.

Thanks
Eros