[fpc-devel] Problem with Now() and time changed by ntpd

Sven Barth pascaldragon at googlemail.com
Thu Nov 3 12:36:17 CET 2011


Am 03.11.2011 02:39, schrieb Hans-Peter Diettrich:
> IMO we have to face a problem very similar to Ansi/UTF-8/16: A TDateTime
> variable can contain local time in a number of timezones (Ansi), or UTC
> values (UTF), which must be interpreted accordingly, e.g. in
> DateTimeToStr().
>
> When Delphi compatible Now() provides local time TDateTime (including
> DST, as is on Windows), and DateTimeToStr() etc. expect a local time
> argument, a full emulation of these functions has to be provided on
> other platforms as well.

But even in Delphi the programmer has to keep track whether a TDateTime 
contains a local or UTC based time value (e.g. if he converted the local 
time returned by Now to UTC).
And functions like DateTimeToStr don't care whether a time value is 
local or UTC and in my opinion they even MUST NOT. If I use such a 
function I want the value of the given TDateTime printed to a string no 
matter what timezone I'm currently in.

Regards,
Sven



More information about the fpc-devel mailing list