Page 1 of 1

SetFileDate Timezone

Posted: Mon Nov 09, 2015 3:01 pm
by mariosk8s
I've come across peculiar behaviour with the SetFileDate function.
I'm currently in Central European Time (Winter Time).

The following code

Code: Select all

file.s = "/some/file"
modDate = ParseDate("%yyyy-%mm-%dd %hh:%ii:%ss", "2015-03-29 01:59:59")
Debug "initial " + modDate
SetFileDate(file, #PB_Date_Modified, modDate)
date.s = FormatDate("%yyyy-%mm-%dd %hh:%ii:%ss", modDate)
Debug "initial formatted " + date
modDate = GetFileDate(file, #PB_Date_Modified)
Debug "retrieved " + modDate
Debug "retrieved formatted " + FormatDate("%yyyy-%mm-%dd %hh:%ii:%ss", modDate)

modDate = ParseDate("%yyyy-%mm-%dd %hh:%ii:%ss", "2015-03-29 02:00:00")
Debug "initial " + modDate
SetFileDate(file, #PB_Date_Modified, modDate)
date.s = FormatDate("%yyyy-%mm-%dd %hh:%ii:%ss", modDate)
Debug "initial formatted " + date
modDate = GetFileDate(file, #PB_Date_Modified)
Debug "retrieved " + modDate
Debug "retrieved formatted " + FormatDate("%yyyy-%mm-%dd %hh:%ii:%ss", modDate)
produces on Mac and Linux

Code: Select all

initial 1427594399
initial formatted 2015-03-29 01:59:59
retrieved 1427594399
retrieved formatted 2015-03-29 01:59:59
initial 1427594400
initial formatted 2015-03-29 02:00:00
retrieved 1427598000
retrieved formatted 2015-03-29 03:00:00
and on Windows the following

Code: Select all

initial 1427594399
initial formatted 2015-03-29 01:59:59
retrieved 1427594399
retrieved formatted 2015-03-29 01:59:59
initial 1427594400
initial formatted 2015-03-29 02:00:00
retrieved 1427594400
retrieved formatted 2015-03-29 02:00:00
Is this a bug in Mac/Lin or a feature in Win?
It is also not clear to me what role locale plays in these functions.
I also assume if i set a winter time and my clock is in summer time similar thing would happen the other way around.

Re: SetFileDate Timezone

Posted: Mon Nov 09, 2015 3:05 pm
by mariosk8s
While someone could argue that 2:00-2:59 is an impossible time, then a bug in windows, the same happens for any time during summer time.

Re: SetFileDate Timezone

Posted: Wed Nov 11, 2015 4:41 pm
by mariosk8s
To add to the madness, on Windows Get and SetFileDate hold true as noted above.
initial 1427594400
initial formatted 2015-03-29 02:00:00
retrieved 1427594400
retrieved formatted 2015-03-29 02:00:00
But the actual file date in the explorer is 2015-03-29 03:00:00
I never thought setting a file date could be such a production. :?: