Recent

Author Topic: Bug in FormatDateTime with FPC 2.6.4?  (Read 2726 times)

bonmario

  • Sr. Member
  • ****
  • Posts: 346
Bug in FormatDateTime with FPC 2.6.4?
« on: June 03, 2015, 03:56:58 pm »
Hi,
i'm working on Windows, with FPC 2.6.4.
This is my code:
Code: [Select]
  Memo1.Lines.Clear;
  Memo1.Lines.Add(FormatDateTime('hh:nn:ss.zzz', Now()));
  Memo1.Lines.Add(FormatDateTime('hh.nn.ss:zzz', Now()));
  Memo1.Lines.Add(FormatDateTime('hh@nn@ss.zzz', Now()));

This is the output:
Code: [Select]
15.56.01.109
15.56.01.109
15@56@01.109

Seems that FormatDateTime change the ":" with the ".".

Hi, Mario

wp

  • Hero Member
  • *****
  • Posts: 11916
Re: Bug in FormatDateTime with FPC 2.6.4?
« Reply #1 on: June 03, 2015, 04:41:38 pm »
The colon in FormatDatetime is replaced by the TimeSeparator from the FormatSettings, that's by design and very useful when writing international applications. Therefore, if you need the colon in the time string set the TimeSeparator to ':', or use a quoted colon in the format string:

Code: [Select]
s := FormatDateTime('hh":"nn":"ss.zzz', Now());

bonmario

  • Sr. Member
  • ****
  • Posts: 346
Re: Bug in FormatDateTime with FPC 2.6.4?
« Reply #2 on: June 03, 2015, 04:44:18 pm »
Ok.

Thanks, Mario

Zoran

  • Hero Member
  • *****
  • Posts: 1830
    • http://wiki.lazarus.freepascal.org/User:Zoran
Re: Bug in FormatDateTime with FPC 2.6.4?
« Reply #3 on: June 03, 2015, 11:38:31 pm »

 

TinyPortal © 2005-2018