On Fri, Jan 15, 2016 at 4:15 AM, Michael Van Canneyt <mich...@freepascal.org > wrote:
> On Thu, 14 Jan 2016, silvioprog wrote: > >> Hello, >> >> I'm trying to get the datetime from a file, but it seems that the >> FileAge() >> function doesn't work properly. See only the second from the results >> below: >> >> FPC: 20/05/2014 10:33:*50* >> > > It seems like a rounding difference. > > home: >ls -l --time-style=+'%Y-%m-%d %H:%M:%S' COPYING.txt -rw-r--r-- 1 > michael michael 1579 2014-05-20 10:33:50 COPYING.txt > Hm... now I did another test avoiding the formater function: begin WriteLn(FileAge('COPYING.txt')); WriteLn('Press [ENTER] to exit ...'); ReadLn; end I got the same integer result on FPC and Delphi, so the FileAge() function works fine. > home: >./testfpc > 20-5-14 09:33:50 > Press [ENTER] to exit ... > > So the actual timestamp is probably a border case value. You are right, and it seems more related to the datetime formater function, so I did this change: FPC/Delphi: var VDt: TDateTime; begin FileAge('COPYING.txt', VDt); WriteLn(FormatDateTime('mm/dd/yyyy hh:nn:ss.zzz', VDt)); WriteLn('Press [ENTER] to exit ...'); ReadLn; end FPC (3.1.1 - trunk): 05/20/2014 10:33:*50.000* Comparing it with Delphi (using same FPC code) and Node (console.log(stat.mtime.*toISOString*()): Delphi (Seattle): 05/20/2014 10:33:*49.646* Node: 2014-05-20T13:33:*49.646*Z -- Silvio Clécio
_______________________________________________ fpc-pascal maillist - fpc-pascal@lists.freepascal.org http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal