I have a legacy application that uses the windows time zone information for calculating dates. For example, 35 = East Coast, 20 = central, 15=mountain. Here is the current function. It takes a date with a timezone and converts it to the timezone passed in. This works just fine on xp, but it crashes on Windows 7. I am guessing it has to do with the win32 portion of it or Windows 7 handles time zones differently.
I would prefer not to change the format of the time zone as that could cause some issues. The code is vb.net and I did not write it.
Public Shared Function ConvertTime(ByVal time As Date, ByVal timeZone As Integer) As Date
Dim UtcNow As Date = time.ToUniversalTime
Dim selectedTimeZone As TimeZones.Win32.Win32TimeZone = TimeZones.Win32.TimeZones.GetTimeZone(timeZone)
Return selectedTimeZone.ToLocalTime(UtcNow)
End Function
Anyone have this issue before?
In VB.NET you should be using the following class to replace
Win32TimeZoneMSDN TimeZone Class (System)
Refer to the link i provided above to see the correct way of using the TimeZone Class in VB.NET.
It appears to not wont work due to
TimZones.Win32.Win32TimeZonenot being a valid class of .NET