PDA

View Full Version : SYSTIME and daylight savings time



hcrisp
11-02-2009, 12:43 PM
Does SYSTIME() take Daylight Savings Time into consideration? I think SYSTIME() is giving me the seconds at 1:30 PM even though the time is 12:30 PM. I am using WAVE 8.00 and Windows XP.

I am saving a file to disk and then comparing SYSTIME() to the modified time value returned by the C stat() function (structure element st_mtime). They are about 1 hour off. Which is correct?



; Save the file 'test.txt'. The time is 11/2/09 12:30 PM.

; Show SYSTIME value
print, string(systime(1), format='(F11.0)')
1257186751.

; Show filetime value; filetime() calls C stat function
print, string(filetime('test.txt'), format='(F11.0)')
1257183204.

; Note the difference is 3547 seconds, or about 1 hour.

rwagner
11-03-2009, 12:22 PM
Hi Hcrisp, Yes, The SYSTIME() function does take daylight savings time into account. Windows XP automatically changes the computer's clock according to local daylight savings, and this what the SYSTIME function queries. If you are looking to get the same results in C as in PV-WAVE take a look at the C ftime() function instead of stat().

hcrisp
12-22-2009, 09:44 AM
Still trying to figure out how SYSTIME works. Does it count the number of seconds from 1/1/1970 12:00AM or some other time at that date? The documentation doesn't say what time. I compared the number of seconds elapsed to Excel and timeanddate.com. The two sources agree with each other, but SYSTIME is off by 6 hours. Does that mean SYSTIME counts from an earlier time?



PRINT, STRING(SYSTIME(1), FORMAT='(F20.5)') & PRINT, SYSTIME()
; 1261498720.77200
;Tue Dec 22 10:18:40 2009

; Excel difference calculation from 1/1/1970 12:00AM gives:
; 1261477120

; timeanddate.com (http://www.timeanddate.com/date/durationresult.html?m1=1&d1=1&y1=1970&h1=12am&i1=0&s1=0&m2=12&d2=22&y2=2009&h2=10&i2=18&s2=40) gives:
; 1261477120

PRINT, 1261498720L - 1261477120L
; 21600
; This is exactly 6 hours!


SYSTIME is actually 6 hours longer. That would make it count from 12/31/69 6:00PM! That is not what the documentation says, however.

hcrisp
12-22-2009, 10:23 AM
My co-worker just informed me that we are 6 hours behind Greenwich, UK. Which means SYSTIME probably calculates the elapsed seconds in GMT. That would explain the discrepancy between SYSTIME and Excel. It would also explain the difference between SYSTIME and the C stat() function. Since 2007 DST in North America has run earlier in the spring and later in the fall than GMT. Since the C stat() function returns a time "pre-adjusted" to the local timezone, it will be off compared to the SYSTIME function for three weeks in March and for one week in November.