DateTimeToFileDate

classic Classic list List threaded Threaded
3 messages Options
Reply | Threaded
Open this post in threaded view
|

DateTimeToFileDate

Carsten Bager
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  -  [hidden email]
http://lists.freepascal.org/mailman/listinfo/fpc-pascal
Reply | Threaded
Open this post in threaded view
|

RE : [fpc-pascal] DateTimeToFileDate

Ludo Brands
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 : [hidden email]
[mailto:[hidden email]] 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  -  [hidden email]
http://lists.freepascal.org/mailman/listinfo/fpc-pascal

_______________________________________________
fpc-pascal maillist  -  [hidden email]
http://lists.freepascal.org/mailman/listinfo/fpc-pascal
Reply | Threaded
Open this post in threaded view
|

RE : RE : [fpc-pascal] DateTimeToFileDate

Ludo Brands
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 : [hidden email]
[mailto:[hidden email]] De la part de Ludo Brands
Envoyé : jeudi 19 mai 2011 09:36
À : [hidden email]; '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 : [hidden email]
[mailto:[hidden email]] 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  -  [hidden email]
http://lists.freepascal.org/mailman/listinfo/fpc-pascal

_______________________________________________
fpc-pascal maillist  -  [hidden email]
http://lists.freepascal.org/mailman/listinfo/fpc-pascal

_______________________________________________
fpc-pascal maillist  -  [hidden email]
http://lists.freepascal.org/mailman/listinfo/fpc-pascal