Can't find the information you are looking for here? Then leave a message over on our WinBatch Tech Support Forum.
keywords:daylight saving day light daylightsavings time dateCompliments of Akreutzer This example uses the Windows API to find out the following...
;******************************************************************************** ; Compute the Nth occurrance of a given weekday in a given month. ;-------------------------------------------------------------------------------- ; Passed Year, Month, Weekday, and Count. (Weekday: 0=Sunday, 1=Monday, ... etc) ; ; Returns the date of the Nth weekday of the month. ; IE... If Weekday = 3 and Count = 2, return the 2nd Tuesday of the month. ; ; If Count is 5 or greater you will get the last such weekday of the month, ; even if there are only 4. ;******************************************************************************** #DefineFunction NthDayOfMonth(Year,Month,Weekday,Count) First = Strcat(Year,":",Month,":01:00:00:00") W1 = (TimeJulianDay(First)+5) mod 7 if Weekday < W1 then Weekday = Weekday + 7 Begin = TimeAdd(First,StrCat("0:0:",Weekday-W1,":0:0:0")) if Count < 2 then return Begin if Count > 5 then Count = 5 Begin = TimeAdd(Begin,StrCat("0:0:",(Count-1)*7,":0:0:0")) if ItemExtract(2,Begin,":") != Month then Begin = TimeSubtract(Begin,"0:0:7:0:0:0") return Begin #EndFunction ;******************************************************************************** ; Get the starting and ending dates of Dayligt time. ; ; Sets DstToday... 0 & 1 = Standard Time ; 2 = Daylight Time ; ; If DstToday > 0, Set DstBegins = Date (this year) that Daylight Time begins ; DstEnds = Date (this year) that Daylight Time ends. ;******************************************************************************** Buffer = BinaryAlloc(180) DstToday = dllCall(strcat(dirWindows(1),"Kernel32.DLL"),long:"GetTimeZoneInformation",lpbinary:Buffer) if DstToday ThisYear = ItemExtract(1,TimeYmdHms(),":") Mx = BinaryPeek2(Buffer,70) Wx = BinaryPeek2(Buffer,72) Dx = BinaryPeek2(Buffer,74) Hx = BinaryPeek2(Buffer,76) DstEnds = ItemReplace(StrFixLeft(Hx,"0",2),4,NthDayOfMonth(ThisYear,Mx,Wx,Dx),":") Mx = BinaryPeek2(Buffer,154) Wx = BinaryPeek2(Buffer,156) Dx = BinaryPeek2(Buffer,158) Hx = BinaryPeek2(Buffer,160) DstBegins = ItemReplace(StrFixLeft(Hx,"0",2),4,NthDayOfMonth(ThisYear,Mx,Wx,Dx),":") else DstBegins = "" DstEnds = "" endif BinaryFree(Buffer) ;******************************************************************************** ; To test the program, display the values returned. ;******************************************************************************** #DefineFunction DisplayTime(Time) Yr = ItemExtract(1,Time,":") Mo = ItemExtract(ItemExtract(2,Time,":"),"Jan Feb Mar Apr May Jun Jul Aug Sep Oct Nov Dec"," ") Dy = ItemExtract(3,Time,":") Hr = ItemExtract(4,Time,":") Mn = ItemExtract(5,Time,":") return StrCat(Mo," ",Dy,", ",Yr," @ ",Hr,":",Mn) #Endfunction if DstToday == 0 || 1 Header = "Today is Standard Time" else Header = "Today is Daylight Time" endif Text = StrCat("Daylight Time Begins..... ",DisplayTime(DstBegins),@CRLF) Text = StrCat(Text,"Daylight Time Ends....... ",DisplayTime(DstEnds)) Message(Header,Text)
Article ID: W16184
File Created: 2004:03:30:15:43:12
Last Updated: 2004:03:30:15:43:12