Daylight saving issue
Hi all!
Just a question regarding daylight saving and the time difference between UTC and local time.
Every time we have to add (or substract) one hour because of that it causes the test's run to stop becuase it finds there's an 'error' on the date/time displayed in the application.
The question is if there's any function in C# script similar to
bool isDaylight = TimeZoneInfo.Local.IsDaylightSavingTime(thisTime);
in C# that can be used on TestComplete scripts to determine if I should be happy with the date/time retreived from the DB (stored in UTC, of course) or I should add/substract one hour.
As you can see in the second file attached the daylight saving day changes every year, so it's rather annoying to build a custom function that needs to be updated every year.
Cheers,
Leandro
I just receive this from support and it's quite useful. Thanks guys!
function DST() { var key, valueName, i; key = Storages["Registry"]("System\\CurrentControlSet\\Control\\TimeZoneInformation", HKEY_LOCAL_MACHINE, 0, true); ActiveTimeBias = key["GetOption"]("ActiveTimeBias", ""); Bias = key["GetOption"]("Bias", ""); if (ActiveTimeBias == Bias) Log.Message("DST is inactive"); else Log.Message("DST is active"); }
leandropoblet wrote:
The question is if there's any function in C# script similar to
bool isDaylight = TimeZoneInfo.Local.IsDaylightSavingTime(thisTime);
You can access .NET classes via the dotNET object, so the TestComplete version of this code would be:
var thisTime = dotNET.System.DateTime.zctor_6(2010, 1, 10, 0, 0, 0, dotNET.System.DateTimeKind.Utc); var isDaylight = dotNET.System.TimeZoneInfo.Local.IsDaylightSavingTime(thisTime));