[fpc-pascal] Problem with DateTimeToStr at midnight?

fpc at xgelb.de fpc at xgelb.de
Fri Apr 20 16:42:30 CEST 2007


Hello,

i use DateTimeToStr from unit sysutils.

At midnight the Date and Time format is wrong (time is missing), is n't?

For example:
20-4-07 23:57
20-4-07 23:58
20-4-07 23:59
21-4-07
21-4-07 00:00
21-4-07 00:01
21-4-07 00:02

The line "21-4-07" ist at 00:00:00 and the line "21-4-07 00:00" is later or equal then 00:00:01!

Is this ok?

Here is same sample source to demonstrate:

---

program error_datetimetostr;

uses 
  crt,sysutils;

var
  timeroffset:TDateTime;

begin
  (* I will add an offset thru now-function so it is 5 seconds before midnight *)
  timeroffset:=1-frac(now)-5/86400;

  while not(keypressed) do
  begin
    writeln(DateTimeToStr(now+timeroffset)); (* Write the time by adding some offset-seconds*)
  end;

end.




More information about the fpc-pascal mailing list