Jump to content

_Now and DST changes


Recommended Posts

Has anyone noticed an issue with _Now() and the daylight savings time changes for 2009?

#Include <Date.au3>
;...
dim $PC ;host name of a PC
;...
$Lbl_CurrentSystem = GUICtrlCreateEdit("", 270, 61, 190, 20)
;...
GUICtrlSetData($Lbl_CurrentSystem, StringUpper($PC) & " @ " & _NowTime())

The _Now() and @HOUR and other time functions are one hour behind. I am in EDT. It doesn't matter if $PC is a local or remote PC, the time is always off by an hour.

Using AutoIT v3.2.10.0--could that be an issue?

Any thoughts?

Link to comment
Share on other sites

#include <Date.au3>

MsgBox( 4096, "", "Todays date/Time: " & _Now() )

Shows the correct time for me...

MST

Autoit v3.3.0.0

[u]Helpful tips:[/u]If you want better answers to your questions, take the time to reproduce your issue in a small "stand alone" example script whenever possible. Also, make sure you tell us 1) what you tried, 2) what you expected to happen, and 3) what happened instead.[u]Useful links:[/u]BrettF's update to LxP's "How to AutoIt" pdfValuater's Autoit 1-2-3 Download page for the latest versions of Autoit and SciTE[quote]<glyph> For example - if you came in here asking "how do I use a jackhammer" we might ask "why do you need to use a jackhammer"<glyph> If the answer to the latter question is "to knock my grandmother's head off to let out the evil spirits that gave her cancer", then maybe the problem is actually unrelated to jackhammers[/quote]

Link to comment
Share on other sites

The time is always an hour behind as compared to the PC you're on? Or something else? I had a similar problem with PCs that were in either Arizona or Indiana. Some areas in those states don't have a DST setting. That might be messing with your time...if the PC is set to Indiana Eastern?

April 5-6th would be the pre-2007 Daylight Savings Start, try moving your system date forward to shortly after that date then see if the time is still wrong.

Good Luck :D

Link to comment
Share on other sites

Since @Hour is also wrong then it could be that your system was never patched for the daylight saving time change.

Run this and when the message box opens, press Ctrl + c and paste the results into a reply.

;
#Include<Date.au3>
$iOffset = RegRead("HKEY_LOCAL_MACHINE\SYSTEM\ControlSet004\Control\TimeZoneInformation", "Bias")/60
$iCurr = RegRead("HKEY_LOCAL_MACHINE\SYSTEM\ControlSet004\Control\TimeZoneInformation", "ActiveTimeBias")/60

MsgBox(0, "RESULTS", _NowTime() & @CRLF & $iOffset - $iCurr)
;

George

Question about decompiling code? Read the decompiling FAQ and don't bother posting the question in the forums.

Be sure to read and follow the forum rules. -AKA the AutoIt Reading and Comprehension Skills test.***

The PCRE (Regular Expression) ToolKit for AutoIT - (Updated Oct 20, 2011 ver:3.0.1.13) - Please update your current version before filing any bug reports. The installer now includes both 32 and 64 bit versions. No change in version number.

Visit my Blog .. currently not active but it will soon be resplendent with news and views. Also please remove any links you may have to my website. it is soon to be closed and replaced with something else.

"Old age and treachery will always overcome youth and skill!"

Link to comment
Share on other sites

I'm having a similar problem with DST. I'm in the UK, so we've just moved to BST (British Summer Time) and I'd only just implemented my first time related script a few days before. I used example code from the help file to base my code on, which before the time change was working fine.

I'm running the script on XP Pro SP3 and Vista Ultimate SP1, and receiving the same result. I'm not sure where it gets the time from, but it's not the Windows time.

#Include <Date.au3>

$tSystem = _Date_Time_GetSystemTime()
MsgBox(0, "Test", "The time is " & _Date_Time_SystemTimeToTimeStr($tSystem))

I've not done anything special, but is there another function I could be using which would return a better, correct result? The script works perfectly! :D Except the time's wrong. :o

Any suggestions? Cheers,

Al

Link to comment
Share on other sites

I'm having a similar problem with DST. I'm in the UK, so we've just moved to BST (British Summer Time) and I'd only just implemented my first time related script a few days before. I used example code from the help file to base my code on, which before the time change was working fine.

I'm running the script on XP Pro SP3 and Vista Ultimate SP1, and receiving the same result. I'm not sure where it gets the time from, but it's not the Windows time.

#Include <Date.au3>

$tSystem = _Date_Time_GetSystemTime()
MsgBox(0, "Test", "The time is " & _Date_Time_SystemTimeToTimeStr($tSystem))

I've not done anything special, but is there another function I could be using which would return a better, correct result? The script works perfectly! :D Except the time's wrong. :o

Any suggestions? Cheers,

Al

One of these days I'll get around to writing a function to do this. The basic idea is to get 2 registry values and add the difference to the time. My concept is along these lines so you might be able to work it out from this.

$iOffset = RegRead("HKEY_LOCAL_MACHINE\SYSTEM\ControlSet004\Control\TimeZoneInformation", "Bias")/60;; Standard Bias
$iCurr = RegRead("HKEY_LOCAL_MACHINE\SYSTEM\ControlSet004\Control\TimeZoneInformation", "ActiveTimeBias")/60;; Current bias
If $iOffset <> $iCurrent Then
    $iHour = @Hour + ($iOffset - $iCurr)
EndIf

That won't be the correct solution but you can get the idea from it. This should probably be somehow built into the _Now() function.

Edited by GEOSoft

George

Question about decompiling code? Read the decompiling FAQ and don't bother posting the question in the forums.

Be sure to read and follow the forum rules. -AKA the AutoIt Reading and Comprehension Skills test.***

The PCRE (Regular Expression) ToolKit for AutoIT - (Updated Oct 20, 2011 ver:3.0.1.13) - Please update your current version before filing any bug reports. The installer now includes both 32 and 64 bit versions. No change in version number.

Visit my Blog .. currently not active but it will soon be resplendent with news and views. Also please remove any links you may have to my website. it is soon to be closed and replaced with something else.

"Old age and treachery will always overcome youth and skill!"

Link to comment
Share on other sites

Ok, a VERY quick and probably dirty solution that works. Here's my new code;

$timeNow = @HOUR & ":" & @MIN & ":" & @SEC
MsgBox(0, "Time test", $timeNow)

The @HOUR, @MIN and @SEC thingies (I'm not sure what they're called) seem to do the trick! I don't know where they get the time from, but it's correct. HTH someone else.

Al,

Edited by lightwave
Link to comment
Share on other sites

lightwave, you're original script is using _Date_Time_GetSystemTime(). This is always UTC as documented here : http://msdn.microsoft.com/en-us/library/ms724390(VS.85).aspx

If you want to take account of BST then you need to use _Date_Time_GetLocalTime()

HTH

WBD

Link to comment
Share on other sites

  • Developers

I've not done anything special, but is there another function I could be using which would return a better, correct result? The script works perfectly! :D Except the time's wrong. :o

This is what the helpfile states:

_Date_Time_GetSystemTime

--------------------------------------------------------------------------------

Retrieves the current system date and time expressed in UTC

The @Hour macro should shown the correct Local time.

Edited by Jos

SciTE4AutoIt3 Full installer Download page   - Beta files       Read before posting     How to post scriptsource   Forum etiquette  Forum Rules 
 
Live for the present,
Dream of the future,
Learn from the past.
  :)

Link to comment
Share on other sites

The time is always an hour behind as compared to the PC you're on? Or something else? I had a similar problem with PCs that were in either Arizona or Indiana. Some areas in those states don't have a DST setting. That might be messing with your time...if the PC is set to Indiana Eastern?

April 5-6th would be the pre-2007 Daylight Savings Start, try moving your system date forward to shortly after that date then see if the time is still wrong.

Good Luck :o

Just for info sake: I do a regular phone conference with some people in that state, and Indiana is now Eastern US time zone (including use of DST), except for a couple of counties, since September 2007. Those last few counties may have complied since then, I'm not sure. The fact that it's a confusing and uncertain thing makes your point though!

:D

Valuater's AutoIt 1-2-3, Class... Is now in Session!For those who want somebody to write the script for them: RentACoder"Any technology distinguishable from magic is insufficiently advanced." -- Geek's corollary to Clarke's law
Link to comment
Share on other sites

Just for info sake: I do a regular phone conference with some people in that state, and Indiana is now Eastern US time zone (including use of DST), except for a couple of counties, since September 2007. Those last few counties may have complied since then, I'm not sure. The fact that it's a confusing and uncertain thing makes your point though!

:D

We have hundreds of clients that still use Windows NT machines, each of which are networked to several other Windows 95 or 98 machines within a LAN. The NT machine was main server and also the time server, but the Win95/98 machines wouldn't pick up the correct time, they would always be an hour ahead or behind. Fixing all of these machines was a pain in the arse to say the least. It involved a lot of reg changes and testing before we got everything to work again. The clients in Arizona were easy since they don't observe DST so we just had to change the time manually on the main server (none of these machines had access to internet). They have all been upgraded since...finally!

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...