[fpc-devel] NowUTC in the RTL

Michael Van Canneyt michael at freepascal.org
Fri Dec 9 10:47:03 CET 2011



On Fri, 9 Dec 2011, Felipe Monteiro de Carvalho wrote:

> Hello,
>
> I would like to add NowUTC to SysUtils as we have already discussed
> previously. I think that the need for adding this should be of common
> knowledge for all after the long discussions about Now, and I
> understand that this was agreed upon, although surely we can discuss
> again.
>
> So ok, now the problem starts. I have never added a new routine to the
> RTL before, so I am totally lost at what exactly to do, because there
> is a pletora of platforms there and I have implementations only for
> the platforms which I use, which are Windows and UNIX (I think it
> should work in all of them)
>
> So what is done in these cases? Should I give some time for
> maintainers of those platforms to come up with implementations?

There are 2 ways:
1. Place an empty routine in all platform sysutils units.

2. Placy a dummy routine which returns 'now' in sysutils.inc
{$IFNDEF FPC_HAS_NOWUTC}
function NowUTC : TDateTime;

begin
   Result:=Now;
end;
{$ENDIF}

Platform maintainers then add a {$DEFINE FPC_HAS_NOWUTC} to the platform
unit as soon as they implement it, and their definition will be used instead.

>
> And if they don't? Just add a stub returning Now or something like that?
>
> Adding a GetTickCount routine would also be good. Lazarus has this:
>
> function GetTickCount64: QWord;
>
> But maybe in the RTL it should have a different name to avoid
> conflicts with the Windows unit... but which name?

I don't think it needs a different name, GetTickCount is OK. 
Why would you need that ? Units are namespaces, after all.

Michael.



More information about the fpc-devel mailing list