Lyle Fairfield <Mi************@Invalid.Com> wrote in
news:Xn*******************@130.133.1.4:
"Michael \(michka\) Kaplan [MS]" <mi*****@online.microsoft.com> wrote in
news:40********@news.microsoft.com:
Don't you want to know that it is, in fact, daylight savings time when
the code is run?
Not this time.
But if you have a simple procedure for doing so, I'd be happy to add it
to my library, and to say, "Thanks".
OK ... upon further review ... I should allow for Daylight Saving Time,
although I am comparing the dates of two files and am not concerned in this
particular instance with any difference less than a few hours.
So ...
Const TIME_ZONE_ID_INVALID As Long = &HFFFFFFFF
Const TIME_ZONE_ID_UNKNOWN As Long = &H0
Const TIME_ZONE_ID_STANDARD As Long = &H1
Const TIME_ZONE_ID_DAYLIGHT As Long = &H2
Private Type SYSTEMTIME
wYear As Integer
wMonth As Integer
wDayOfWeek As Integer
wDay As Integer
wHour As Integer
wMinute As Integer
wSecond As Integer
wMilliseconds As Integer
End Type
Private Type TIME_ZONE_INFORMATION
Bias As Long
StandardName(32) As Integer
StandardDate As SYSTEMTIME
StandardBias As Long
DaylightName(32) As Integer
DaylightDate As SYSTEMTIME
DaylightBias As Long
End Type
Private Declare Function GetTimeZoneInformation _
Lib "kernel32" _
(lpTimeZoneInformation As TIME_ZONE_INFORMATION) _
As Long
Public Function CompareDateTimes( _
ByVal dtZulu As Date, _
ByVal dtLocal As Date, _
Optional Bias As Long = 300) As Long
' returns difference in seconds
' defaults to Eastern North America Time ... Tronna
Dim TZI As TIME_ZONE_INFORMATION
Select Case GetTimeZoneInformation(TZI)
Case TIME_ZONE_ID_UNKNOWN
If TZI.Bias > Bias Then
Bias = TZI.Bias
End If
Case TIME_ZONE_ID_STANDARD
Bias = TZI.Bias
Case TIME_ZONE_ID_DAYLIGHT
Bias = TZI.DaylightBias
End Select
dtZulu = DateAdd("n", Bias, dtZulu)
CompareDateTimes = DateDiff("s", dtLocal, dtZulu)
End Function
I sort my declarations alphabetically so I may have left some pertinent
declaration out, or included a redundancy.
--
Lyle
(for e-mail refer to
http://ffdba.com/contacts.htm)