Sign in Join

Live chat for Free Pascal, Lazarus, Delphi and every Pascal programmer.

Mailing lists / fpc-devel / 2016-01

Add {$I %DATETIME%}

1 message · 1 person ·

Reply by email Subscribe to this list Your subscription

Read-only archive. Use j and k to move between messages.

Denis Kozlov

Hello,

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

Denis

Reply by email