Daylight saving issue
SOLVED- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
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
Solved! Go to Solution.
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
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"); }
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hey so this function is no longer valid for some reason.
I migrated TC to a Windows 2008 computer so that might be the reason.
Any ideas on how to change it so it works again?
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
What's failing? Have you stepped through the function to see if it's picking up a value at all?
From what I can see, that reg key should still be valid on a Win Server 2008 install?
(assume you mean Win Server 2008 when you say Windows 2008?)
Other thing that springs to mind is that Server installs tend to be a little more "protective" than desktop ones. So maybe it's a rights issue for reading the registry via script or something? I'm not familiar enough with Server installs to say for sure ...
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Works OK for me? (But I'm on a Win7 Pro x64 VM)
Two questions ...
1. Did you search the registry for the key and check the path? Mine was slightly different. Mine was located at:
Storages["Registry"]("SYSTEM\\ControlSet001\\Control\\TimeZoneInformation", HKEY_LOCAL_MACHINE, 1, true)
So "CurrentControlSet" was changed to "ControlSet001" for me.
2. Is the Server 2008 box 32 or 64 bit? The third parameter in the call specifies the architecture. 64 bit machine for me so changed to 1. (Set to 0 in the example)
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
DST is currently not active in Auckland. It starts up again on Sep 25.
http://www.timeanddate.com/worldclock/new-zealand/auckland
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hahaha that confirms then we've got a bug here in our product.
Very helpful thank you!
I'm going to answer some questions anyways for the sake of having the information here in one post.
Colin:
1. Yes I did search in registry but I didn't realized the change to "ControlSet001"
2. The third parameter doesn't seem to change anything here.
Joseph:
I was totally convinced it was detecting if DST is enabled in the OS or not... not the actual value
Thanks again!
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Ha ha!
I never thought to check the time zone in you image. Assumed you were getting a wrong result!
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hi Colin,
I just realised it wasn't a bug at all, it wasn't a problem in that function at all it's a logical problem (and we might need a different post after all)
The situation is this: I'm retrieving a date/time value from the DB, getting local time against UCT time and calculating the time difference (usually 12 or 13 hours here in Auckland depending on DST as discussed earlier).
So far so good but the problem is I need to determine if that date in the DB is inside the DST (13 hs difference) or not (12 hours difference)
So for example:
A. Date in DB is in DST: 10/01/2010 00:00 UTC
It's in DST, so local time for that date is: 10/01/2010 13:00
B. Date in DB is NOT in DST: 10/06/2010 00:00 UTC
It's NOT in DST, so local time for that date is: 10/06/2010 12:00
Does it make sense?
So in order to determine if date is 12 or 13 difference with local time I need to determine somehow if the date itself is in DST and if we're now in DST (or not)
