<html><head></head><body><div><br></div><div>On Fri, 2015-11-20 at 14:03 +0100, Paul Gevers wrote:</div><blockquote type="cite"><pre>Now including the patch...

On 20-11-15 14:02, Paul Gevers wrote:
<blockquote type="cite">
Hi all,

On 19-11-15 23:06, Abou Al Montacir wrote:
<blockquote type="cite">
Your patch looks fine, but I don't know if upstream will like adding
this unit in the dependency of the compiler. Can't you pass the date
into another format?
</blockquote>

In the mean time I managed to get a patch working which indeed did just
that. However, I still would like to get SOURCE_DATE_EPOCH to be
supported, because that is what is spec'ed, so I think that it is the
only variable that makes a chance of being accepted by upstream.

For review, I added my current patch. I saw somewhere¹ that you can
change the date reported by Date via a "With TS do" construction. So I
think it would be great if we can convert SOURCE_DATE_EPOCH in
fpcsrc/compiler/scanner.pas to fpc time before calling getdatestr.

I haven't tried if I have the same issue with the DateUtils unit in this
file, but I expect the underlaying problem to be the same. I will still
try to figure this out, so thank Abou for the idea.

Paul
¹ <a href="http://www.freepascal.org/docs-html/rtl/sysutils/timestamptodatetime.html">http://www.freepascal.org/docs-html/rtl/sysutils/timestamptodatetime.html</a></blockquote></pre></blockquote><div><pre>For sure this patch is ugly compared to the first one. It definitely affects the compiler when compiling other programs also.</pre><pre><br></pre><div>I'd prefer some thing like similar to your first path but where your variable contains the SOURCE_DATE_EPOCH in the format of <span style="color: rgb(141, 144, 145); font-family: monospace;">Date</span> function output.</div><pre>Function UnixToDateTime(const AValue: Int64): TDateTime;</pre><pre>begin</pre><pre>  Result:=IncSecond(UnixEpoch, AValue);</pre><pre>end;</pre><pre>Function IncSecond(const AValue: TDateTime; const ANumberOfSeconds: Int64): TDateTime;</pre><pre>begin</pre><pre>  Result:=AValue+ANumberOfSeconds / SecsPerDay;</pre><pre>  MaybeSkipTimeWarp(AValue,Result);</pre><pre>end;</pre><pre>Procedure MaybeSkipTimeWarp(OldDate: TDateTime; var NewDate: TDateTime);</pre><pre>begin</pre><pre>  if (OldDate>0) and (NewDate<0) then</pre><pre>    NewDate:=NewDate-0.5</pre><pre>  else if (OldDate<-1.0) and (NewDate>-1.0) then</pre><pre>    NewDate:=NewDate+0.5;</pre><pre>end;</pre><div>You can also put all this code in makefile or in a function that you add it in your patch. We are talking about 3 lines of code here.</div><pre>-- 
Cheers,
Abou Al Montacir</pre></div></body></html>