Sign in Join

Live chat for Free Pascal, Lazarus, Delphi and every Pascal programmer.

Mailing lists / fpc-pascal / 2014-10

FileAge and timezone

5 messages · 3 people · –

Reply by email Subscribe to this list Your subscription

Read-only archive. Use j and k to move between messages.

Michael Van Canneyt
to Mattias Gaertner
Mattias Gaertner wrote 7 lines
Hi, The docs of FileAge does not mention if timezone is used or not. http://lazarus-ccr.sourceforge.net/docs/rtl/sysutils/fileage.html Is the returned OS time stamp with or without timezone?

That depends on the OS. FileAge returns whatever the OS returns.

The following is based on memory alone, needs to be checked in code: It doesn't do any transformations, so I expect it actually to be UTC. Only when converting to TDateTime is the timzeone introduced.

Michael.

Mattias Gaertner
to Michael Van Canneyt
Show quoted text 13 lines
On Thu, 30 Oct 2014, Mattias Gaertner wrote: > Hi, > > The docs of FileAge does not mention if timezone is used or not. > > http://lazarus-ccr.sourceforge.net/docs/rtl/sysutils/fileage.html > > Is the returned OS time stamp with or without timezone? That depends on the OS. FileAge returns whatever the OS returns.

Some OS has several functions/options, so there is a choice.

The following is based on memory alone, needs to be checked in code: It doesn't do any transformations, so I expect it actually to be UTC. Only when converting to TDateTime is the timzeone introduced.

Under Linux I see UTC.
But on Windows it seems to return with timezone. See this bug: http://bugs.freepascal.org/view.php?id=26963

Mattias

Michael Van Canneyt
to Mattias Gaertner
Mattias Gaertner wrote 18 lines
On Thu, 30 Oct 2014 14:40:56 +0100 (CET) Michael Van Canneyt wrote: > > > On Thu, 30 Oct 2014, Mattias Gaertner wrote: > >> Hi, >> >> The docs of FileAge does not mention if timezone is used or not. >> >> http://lazarus-ccr.sourceforge.net/docs/rtl/sysutils/fileage.html >> >> Is the returned OS time stamp with or without timezone? > > That depends on the OS. FileAge returns whatever the OS returns. Some OS has several functions/options, so there is a choice.

Not really if you want to follow delphi compatibility.

Show quoted text 9 lines
> The following is based on memory alone, needs to be checked in code: > It doesn't do any transformations, so I expect it actually to be UTC. > Only when converting to TDateTime is the timzeone introduced. Under Linux I see UTC. But on Windows it seems to return with timezone. See this bug: http://bugs.freepascal.org/view.php?id=26963

Quite possible: like I said, it depends on the OS. The change to TDateTime should take care of that by converting it always to local time. If you want it always in UTC for internal reasons, then additional functions need to be developed: On linux that will be a No-op, on windows it will need to take care of some stuff...

For what it is worth:
Delphi has exactly the same problem as in the bug, as well as TortoiseSVN ... (at least it used to have, I remember booting my VM to suddenly see all files marked 'changed')

Michael.

Jürgen Hestermann
to Michael Van Canneyt
Michael Van Canneyt wrote 7 lines
On Thu, 30 Oct 2014, Mattias Gaertner wrote: Under Linux I see UTC. > But on Windows it seems to return with timezone. See this bug: > http://bugs.freepascal.org/view.php?id=26963 Quite possible: like I said, it depends on the OS. The change to TDateTime should take care of that by converting it always to local time. If you want it always in UTC for internal reasons, then additional functions need to be developed: On linux that will be a No-op, on windows it will need to take care of some stuff...

On Windows it's UTC too.
The Windows API function "FindFirstFileW" gives
back a data structure where the dates are UTC times. So to get local times you need to convert with "FileTimeToLocalFileTime".