[fpc-devel] Add {$I %DATETIME%}

Michal Wallace michal.wallace at gmail.com
Tue Feb 23 15:22:52 CET 2016


Just add something like this to your compile process:

 echo \'`date`\'  > fpc_timestamp.inc

Then:

begin
  WriteLn({$i fpc_timestamp});
end.


On Tue, Feb 23, 2016 at 5:57 AM, Michael Van Canneyt <michael at freepascal.org
> wrote:

>
>
> I don't think this is a good idea.
>
> 1. The TDateTime format is not a basic format of the language.
>    It is an agreement on how to encode date/time information in a double.
>
>    You now make the compiler dependent on this "agreement", promoting
>    TDateTime to a compiler-recognized type.
>
> 2. Some targets do not even have floats. That will cause problems as well.
>
>
> Michael.
>
>
>
>
> On Tue, 23 Feb 2016, Denis Kozlov wrote:
>
> Can someone apply the patch for adding %DATETIME%, if there are no
>> objections?
>>
>> Denis
>>
>>
>> On 15 January 2016 at 21:23, Denis Kozlov wrote:
>>
>> I'm proposing addition of {$I %DATETIME%} directive. A trivial patch is
>>> attached.
>>>
>>> The following will be possible:
>>> const
>>>   T = {$I %DATETIME%};
>>> begin
>>>   WriteLn(DateTimeToStr(T));
>>> end.
>>>
>>> Benefits of this directive:
>>> 1) Access to build date/time in native TDateTime format. Existing {$I
>>> %DATE%} and {$I %TIME%} are inserted as strings in predefined format,
>>> parsing is required to extract date/time components or to reformat it.
>>> 2) Atomic access to build date/time. Use of {$I %DATE%} and {$I %TIME%}
>>> can have undesired effect if {$I %DATE%} is executed at 2016-01-15
>>> 23:59:59.999 and 1 ms later {$I %TIME%} is executed at 2016-01-16
>>> 00:00:00.000. Resulting combination of two directive is 2016-01-15
>>> 00:00:00, a day out of date.
>>> 3) Search and replace of build date/time is no longer a trivial text
>>> editor operation.
>>>
>>> The following ticket can then be resolved:
>>> http://bugs.freepascal.org/view.php?id=26472
>>>
>>>
>> _______________________________________________
> fpc-devel maillist  -  fpc-devel at lists.freepascal.org
> http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-devel
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.freepascal.org/pipermail/fpc-devel/attachments/20160223/41032d2b/attachment.html>


More information about the fpc-devel mailing list