<div dir="ltr"><div class="gmail_extra"><div class="gmail_quote">On Fri, Jan 15, 2016 at 4:15 AM, Michael Van Canneyt <span dir="ltr"><<a href="mailto:michael@freepascal.org" target="_blank">michael@freepascal.org</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-color:rgb(204,204,204);border-left-style:solid;padding-left:1ex"><span class="">On Thu, 14 Jan 2016, silvioprog wrote:<br></span><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-color:rgb(204,204,204);border-left-style:solid;padding-left:1ex"><span class="">Hello,<br>
<br>
I'm trying to get the datetime from a file, but it seems that the FileAge()<br>
function doesn't work properly. See only the second from the results below:<br>
<br></span>
FPC: 20/05/2014 10:33:*50*<br>
</blockquote>
<br>
It seems like a rounding difference.<br>
<br>
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<br></blockquote><div><br></div><div>Hm... now I did another test avoiding the formater function:</div><div><br></div><div><div>begin</div><div> WriteLn(FileAge('COPYING.txt'));</div><div> WriteLn('Press [ENTER] to exit ...');</div><div> ReadLn;</div><div>end</div></div><div><br></div><div>I got the same integer result on FPC and Delphi, so the FileAge() function works fine.</div><div> </div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-color:rgb(204,204,204);border-left-style:solid;padding-left:1ex">
home: >./testfpc<br>
20-5-14 09:33:50<br>
Press [ENTER] to exit ...<br>
<br>
So the actual timestamp is probably a border case value.</blockquote></div><div><br></div><div>You are right, and it seems more related to the datetime formater function, so I did this change:</div><div><br></div><div>FPC/Delphi:</div><div><br></div><div><div>var</div><div> VDt: TDateTime;</div><div>begin</div><div> FileAge('COPYING.txt', VDt);</div><div> WriteLn(FormatDateTime('mm/dd/yyyy hh:nn:ss.zzz', VDt));</div><div> WriteLn('Press [ENTER] to exit ...');</div><div> ReadLn;</div><div>end</div></div><div><br></div><div>FPC (3.1.1 - trunk): 05/20/2014 10:33:<b>50.000</b><br></div><div><br></div><div>Comparing it with Delphi (using same FPC code) and Node (console.log(stat.mtime.<b>toISOString</b>()):</div><div><br></div><div>Delphi (Seattle): 05/20/2014 10:33:<b>49.646</b></div><div><br></div><div>Node: 2014-05-20T13:33:<b>49.646</b>Z</div><div><br></div><div>--<br></div><div class="gmail_signature"><div dir="ltr"><div>Silvio Clécio</div></div></div>
</div></div>