[fpc-pascal] DateTimeToFileDate

Ludo Brands ludo.brands at free.fr
Thu May 19 10:23:31 CEST 2011


The other reason for doing so is that unix stores internally all dates as
UTC, including the dates used in the file system.

Ludo

-----Message d'origine-----
De : fpc-pascal-bounces at lists.freepascal.org
[mailto:fpc-pascal-bounces at lists.freepascal.org] De la part de Ludo Brands
Envoyé : jeudi 19 mai 2011 09:36
À : carsten at beas.dk; 'FPC-Pascal users discussions'
Objet : RE : [fpc-pascal] DateTimeToFileDate


Delphi FileDate is UTC time based because the windows API FILETIME structure
is UTC based. Delphi exposes the FileTimeToLocalFileTime API call to get the
local time. The fpc unix implementation uses LocalToEpoch (unixutil.pp)
which has the folloxing comments: {
  Transforms local time (year,month,day,hour,minutes,second) to Epoch time
   (seconds since 00:00, january 1 1970, corrected for local time zone) }

I guess fpc wants to be Delphi compatible as much as possible.  

Ludo


-----Message d'origine-----
De : fpc-pascal-bounces at lists.freepascal.org
[mailto:fpc-pascal-bounces at lists.freepascal.org] De la part de Carsten Bager
Envoyé : jeudi 19 mai 2011 08:58 À : FPC-Pascal users discussions Objet :
[fpc-pascal] DateTimeToFileDate


If I do this on a Linux machine

(Free Pascal Compiler version 2.4.2 [2010/11/08] for i386)

  WriteLn(DateTimeToFileDate(Now));
  WriteLn(trunc((now-EncodeDate(1970,1,1))*86400));

I get this
1305786833
1305794033

There is a difference of 7200= 2 hours. 

Is this correct?

I would not expect a difference of 2 hours (the deference from UTC).

Regards
Carsten

_______________________________________________
fpc-pascal maillist  -  fpc-pascal at lists.freepascal.org
http://lists.freepascal.org/mailman/listinfo/fpc-pascal

_______________________________________________
fpc-pascal maillist  -  fpc-pascal at lists.freepascal.org
http://lists.freepascal.org/mailman/listinfo/fpc-pascal




More information about the fpc-pascal mailing list