Windows flag for Daylight Saving?

General Macro Scheduler discussion

Moderators: Dorian (MJT support), JRL

Post Reply
Me_again
Automation Wizard
Posts: 1101
Joined: Fri Jan 07, 2005 5:55 pm
Location: Somewhere else on the planet

Windows flag for Daylight Saving?

Post by Me_again » Fri Dec 02, 2005 9:44 pm

Is there any accessible windows function/flag that shows whether the PC time is, or is not, currently adjusted for daylight savings aka DST aka BST?

User avatar
Marcus Tettmar
Site Admin
Posts: 7380
Joined: Thu Sep 19, 2002 3:00 pm
Location: Dorset, UK
Contact:

Post by Marcus Tettmar » Fri Dec 02, 2005 10:02 pm

Go to registy key:

HKEY_LOCAL_MACHINE\System\CurrentControlSet\Control\TimeZoneInformation

Look for value:

DisableAutoDaylightTimeSet

If NOT present or set to zero automatic daylight saving adjustment is enabled. If Present and set to 1 daylight saving adjustment is disabled.
Marcus Tettmar
http://mjtnet.com/blog/ | http://twitter.com/marcustettmar

Did you know we are now offering affordable monthly subscriptions for Macro Scheduler Standard?

Me_again
Automation Wizard
Posts: 1101
Joined: Fri Jan 07, 2005 5:55 pm
Location: Somewhere else on the planet

Post by Me_again » Fri Dec 02, 2005 10:49 pm

Thanks, that's part of the puzzle, but it's not the whole answer. I'm trying to get at whether the system time is currently adjusted, in other words is the PC time offset by one hour because DST is in effect where the PC is located. Need to know for a solar calculation.

I guess the other way would be to ignore the PC time and grab UTC off a time server and adjust it based on the windows time zone setting.

User avatar
JRL
Automation Wizard
Posts: 3501
Joined: Mon Jan 10, 2005 6:22 pm
Location: Iowa

Post by JRL » Fri Dec 02, 2005 11:06 pm

Just a thought.

I understand it will be much simpler if there is a registry key or some other flag the can be read for "DST on" or "DST off". In lieu of that flag's existence, could you convert "now" to Julien date and compare with Julien date for current year's first Sunday in April and Last Sunday in October? If > April and < October it's DST. Actually, for most times all you'd need is the month. If its not October or April you can know immediately by what month it is. This information in conjuction with the registry info from Marcus should be the whole answer.

Hope this was helpful,
Dick

Me_again
Automation Wizard
Posts: 1101
Joined: Fri Jan 07, 2005 5:55 pm
Location: Somewhere else on the planet

Post by Me_again » Fri Dec 02, 2005 11:23 pm

I was thinking globally, there are a lot of places that don't follow the US scheme, and the whole Southern hemisphere is obviously totally different.

User avatar
JRL
Automation Wizard
Posts: 3501
Joined: Mon Jan 10, 2005 6:22 pm
Location: Iowa

Post by JRL » Fri Dec 02, 2005 11:42 pm

Another thought then....

Completely untested and off the wall....

Acquire the setting of the registry flag for DST.
Check the time

If original setting was off..
Turn on the flag
Check the time

If the original setting was on
Turn off the flag
check the time

Reset the flag to original setting and compare time check results.

Me_again
Automation Wizard
Posts: 1101
Joined: Fri Jan 07, 2005 5:55 pm
Location: Somewhere else on the planet

Post by Me_again » Sat Dec 03, 2005 12:14 am

Well that's an interesting idea, I can see how that would almost certainly work, but I'm not sure I have the cojones to give anyone a program that does that to their clock :lol:

User avatar
JRL
Automation Wizard
Posts: 3501
Joined: Mon Jan 10, 2005 6:22 pm
Location: Iowa

Post by JRL » Mon Dec 12, 2005 5:20 am

Me_again,
Dont know if you have already resolved this but after a little Internet searching, I think I have found the answer to your question. The registry key that Marcus referenced:
HKEY_LOCAL_MACHINE\System\CurrentControlSet\Control\TimeZoneInformation
has a couple of values:

ActiveTimeBias = the currently active offset from GMT in minutes.
Bias = the standard offset from GMT in minutes.

I'm in Iowa in the US. My value for ActiveTimeBias is 360 now that we're on standard time. I reset my date and time for April 2, 2006 at 1:59:50 AM and watched my clock roll to 3:00:00 AM after 10 seconds. Checked the registry and ActiveTimeBias had become 300. The value of Bias remained 360 before and after the time change.

If these two values are equal, the computer is on standard time. If they are not equal, the computer is on daylight saving time.

Hope this helped,
Dick
Last edited by JRL on Mon Dec 12, 2005 4:16 pm, edited 2 times in total.

Me_again
Automation Wizard
Posts: 1101
Joined: Fri Jan 07, 2005 5:55 pm
Location: Somewhere else on the planet

Post by Me_again » Mon Dec 12, 2005 4:10 pm

Cool, thanks, I'll play with that later, I was going down a much more convoluted path :)

Update: It works :D

RegistryReadKey>HKEY_LOCAL_MACHINE,System\CurrentControlSet\Control\TimeZoneInformation,ActiveTimeBias,ActiveBias
RegistryReadKey>HKEY_LOCAL_MACHINE,System\CurrentControlSet\Control\TimeZoneInformation,Bias,StdBias
If>%ActiveBias%=%StdBias%,notdst
MessageModal>%ActiveBias% %StdBias% PC Time Is DST
Goto>theend
Label>notdst
MessageModal>%ActiveBias% %StdBias% PC Time Is Not DST
Label>theend

Me_again
Automation Wizard
Posts: 1101
Joined: Fri Jan 07, 2005 5:55 pm
Location: Somewhere else on the planet

Post by Me_again » Mon Dec 12, 2005 6:46 pm

Update 2

The equals/not equals logic holds up, but the number does not appear to be minutes offset from GMT. Pacific Time Zone = 480, looks good, but try New Zealand = 4294966516 huh?

Regardless, thank you very much JRL for the solution to the problem :)

User avatar
JRL
Automation Wizard
Posts: 3501
Joined: Mon Jan 10, 2005 6:22 pm
Location: Iowa

Post by JRL » Mon Dec 12, 2005 7:17 pm

Doesn't that put them about 8171 years ahead of the rest of the world? I always suspected they were a forward thinking nation. :wink:

Glad it works,
Dick

Post Reply
cron
Sign up to our newsletter for free automation tips, tricks & discounts