Daylight saving not working in vb .net application
-
My application is written in VB .Net on Windows XP. A part of my program provides a System Configuration Dialog where user can pick a time zone, specify the date (MM/DD/YY) and time (HH:MM:SS AM/PM). Whenever a user changes any of the above fields and selects save, the specified information is saved as followed: 'Save the selected time zone Shell("RUNDLL32.EXE SHELL32.DLL, Control_RunDLL TIMEDATE.CPL,,/Z" & StandardName) where StandardName is the Std value at the HKLM\Software\Microsoft\Windows NT\Current Version\Tim Zones\ 'Save the specified date Today = CDate(StringValue(DateFieldName)) 'Save the specified time TimeOfDay = CDate(StringValue(TimeFieldName)) where Today and TimeOfDay are the members of the Microsoft.VisualBasic.DateAndTime Testing Senario: 1) DayLight saving testing worked fine At the System Configuration Diaglog, enter the following data: - Time Zone: Pacific Standard Time - Specified Date: 3/11/07 - Specified Time: 01:59:40 AM When the time got to 2AM, the system clock was adjust forward to 3AM as expected. 2) Standard time testing NOT WORKING The same selections as above except the date was set to 11/04/07 When the time got to 2AM, the system clock did not fall back to 1AM as expected. It stayed at 2AM and continued on! I use the shell command to set the time zone because i could not get the SetTimeZoneInformation API to work. It created garbages in my registry setting for the daylight saving information. Please help asap since the daylight saving is approaching fast. Thanks a bunch in advance. - Jewel
-
My application is written in VB .Net on Windows XP. A part of my program provides a System Configuration Dialog where user can pick a time zone, specify the date (MM/DD/YY) and time (HH:MM:SS AM/PM). Whenever a user changes any of the above fields and selects save, the specified information is saved as followed: 'Save the selected time zone Shell("RUNDLL32.EXE SHELL32.DLL, Control_RunDLL TIMEDATE.CPL,,/Z" & StandardName) where StandardName is the Std value at the HKLM\Software\Microsoft\Windows NT\Current Version\Tim Zones\ 'Save the specified date Today = CDate(StringValue(DateFieldName)) 'Save the specified time TimeOfDay = CDate(StringValue(TimeFieldName)) where Today and TimeOfDay are the members of the Microsoft.VisualBasic.DateAndTime Testing Senario: 1) DayLight saving testing worked fine At the System Configuration Diaglog, enter the following data: - Time Zone: Pacific Standard Time - Specified Date: 3/11/07 - Specified Time: 01:59:40 AM When the time got to 2AM, the system clock was adjust forward to 3AM as expected. 2) Standard time testing NOT WORKING The same selections as above except the date was set to 11/04/07 When the time got to 2AM, the system clock did not fall back to 1AM as expected. It stayed at 2AM and continued on! I use the shell command to set the time zone because i could not get the SetTimeZoneInformation API to work. It created garbages in my registry setting for the daylight saving information. Please help asap since the daylight saving is approaching fast. Thanks a bunch in advance. - Jewel
I'm having a bit of trouble trying to understand what you're doing with this. Are you trying to change the current state of Daylight Savings Time yourself? You know Windows handles this automatically, right?
Dave Kreskowiak Microsoft MVP - Visual Basic
-
I'm having a bit of trouble trying to understand what you're doing with this. Are you trying to change the current state of Daylight Savings Time yourself? You know Windows handles this automatically, right?
Dave Kreskowiak Microsoft MVP - Visual Basic
Interesting question. Perhaps, your program is working correctly (without regard to the "garbages in my registry"). How do you test the time change? What should happen? The logistics of making the clock jump forward are straightforward. Advance the clock when you hit 2am. What happens when it is time to jump backwards. Obviously, MS has had this function working correctly for years. How should the system clock behave on the switch in November when you are watching it? Should it jump back to 1am when it reaches 2am? This poses a problem when it hits 2am the next time. Dave do you know how to test this function?
-
Interesting question. Perhaps, your program is working correctly (without regard to the "garbages in my registry"). How do you test the time change? What should happen? The logistics of making the clock jump forward are straightforward. Advance the clock when you hit 2am. What happens when it is time to jump backwards. Obviously, MS has had this function working correctly for years. How should the system clock behave on the switch in November when you are watching it? Should it jump back to 1am when it reaches 2am? This poses a problem when it hits 2am the next time. Dave do you know how to test this function?
Windows keeps track of a switch, if it's currently DST or not. The 2AM rollback only occurs if the switch current says it's DST. If it's NOT currently DST, the 2AM rollback doesn't occur. Test it?? I don't even know what the point of all his code is! What's he trying to do with this that Windows doesn't already do?
Dave Kreskowiak Microsoft MVP - Visual Basic
-
I'm having a bit of trouble trying to understand what you're doing with this. Are you trying to change the current state of Daylight Savings Time yourself? You know Windows handles this automatically, right?
Dave Kreskowiak Microsoft MVP - Visual Basic
Hi Dave, I know that Windows handles daylight saving automatically. Our application just provides the testers a function to change the time zone and time/date. The time should sync up with the OS for daylight saving automatically if it's selected from the OS datetime control panel (ie; there is no logic in my program that calculates the daylight saving). The testers need to test that functionality of the program and it did not work when they changed the time/date to 11/4 2AM to test for the fall back time (standard). We converted our program from VB6 to VB .Net. The one from VB6 used all the API calls (ie; RegQueryValueEx, MultiByteToWideCard..) and it worked fine when we tested the same scenario. In the VB .Net program I tried marshalling all the structures (SYSTEMTIME, TIME_ZONES_INFORMATION, OSVERSIONINFO..) I used but still could not get the SetTimeZoneInformation to work every time the date/time changed on my test dialog. My TimeZoneInformation registry contained garbages (StandardName, DaylightName, DaylightStart, StandardStart) whenever I called that API to update the datetime info. I finally gave up and used the Shell command to update the info instead of API's. The data looked correct in the registry now everytime the users modify the zone/date/time from the dialog. However, I could not fall back from daylight to standard time using our test program!!:( - Jewel