R
RDub
I am trying to programmatically set the Device Date and time using
OpenNETCF V1.4 on a PocketPC2003 SE and CF1.0. Here is the code I am using:
Private Sub SetSystemDateTime(ByVal strTimeZoneDisplayName As String, _
ByVal dteUTCDateTime As DateTime)
' Purpose Set the time zone and the UTC time and date using the
pram's passed
Dim TZI As OpenNETCF.Win32.TimeZoneInformation = New _
OpenNETCF.Win32.TimeZoneInformation
Dim tziInfo As New OpenNETCF.Win32.TimeZoneCollection
tziInfo.Initialize()
' Iterate each time zone looking for the one that we want to use
For Each tziItem As OpenNETCF.Win32.TimeZoneInformation In tziInfo
If tziItem.DisplayName = strTimeZoneDisplayName Then
TZI = tziItem
' Set the TimeZone First
OpenNETCF.Win32.DateTimeEx.SetTimeZoneInformation(TZI)
' Then Set the Local Time for that zone
OpenNETCF.Win32.DateTimeEx.SetSystemTime(dteUTCDateTime)
File.Create(Global.SqlDataScriptPath & "NoError.txt")
Exit For
End If
Next
End Sub
For the most part this code works great, Except when attempting to set the
"GMT-5 Eastern US". As often as not when I inspect the device after making
this call the time Zone is set to "GMT-5 Indiana (USA)". I have stepped
through the code and checked the values in TZI just prior and after the line
"OpenNETCF.Win32.DateTimeEx.SetTimeZoneInformation(TZI)", and all appears
OK. Obviously this aint the end of the world as both time zones have the
same offset, and perhaps even the same DST info (not sure though), but it is
"wrong", and I have not tested all of the other likely suspects (same
offsets, different Zone names). The date and time are correct after the
call, its just the Time Zone that's outa' wack.
In my testing I have been passing these two strings to the function.
"GMT-5 Eastern US"
"1/10/2008 10:32:49 PM"
Any and all help would be most appreciated. Thanks
Ron W
OpenNETCF V1.4 on a PocketPC2003 SE and CF1.0. Here is the code I am using:
Private Sub SetSystemDateTime(ByVal strTimeZoneDisplayName As String, _
ByVal dteUTCDateTime As DateTime)
' Purpose Set the time zone and the UTC time and date using the
pram's passed
Dim TZI As OpenNETCF.Win32.TimeZoneInformation = New _
OpenNETCF.Win32.TimeZoneInformation
Dim tziInfo As New OpenNETCF.Win32.TimeZoneCollection
tziInfo.Initialize()
' Iterate each time zone looking for the one that we want to use
For Each tziItem As OpenNETCF.Win32.TimeZoneInformation In tziInfo
If tziItem.DisplayName = strTimeZoneDisplayName Then
TZI = tziItem
' Set the TimeZone First
OpenNETCF.Win32.DateTimeEx.SetTimeZoneInformation(TZI)
' Then Set the Local Time for that zone
OpenNETCF.Win32.DateTimeEx.SetSystemTime(dteUTCDateTime)
File.Create(Global.SqlDataScriptPath & "NoError.txt")
Exit For
End If
Next
End Sub
For the most part this code works great, Except when attempting to set the
"GMT-5 Eastern US". As often as not when I inspect the device after making
this call the time Zone is set to "GMT-5 Indiana (USA)". I have stepped
through the code and checked the values in TZI just prior and after the line
"OpenNETCF.Win32.DateTimeEx.SetTimeZoneInformation(TZI)", and all appears
OK. Obviously this aint the end of the world as both time zones have the
same offset, and perhaps even the same DST info (not sure though), but it is
"wrong", and I have not tested all of the other likely suspects (same
offsets, different Zone names). The date and time are correct after the
call, its just the Time Zone that's outa' wack.
In my testing I have been passing these two strings to the function.
"GMT-5 Eastern US"
"1/10/2008 10:32:49 PM"
Any and all help would be most appreciated. Thanks
Ron W