Recent

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

bonmario

  • Sr. Member
  • ****
  • Posts: 308
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: 7353
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());
Mainly Lazarus trunk / fpc 3.2.0 / all 32-bit on Win-10, but many more...

bonmario

  • Sr. Member
  • ****
  • Posts: 308
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: 1573
    • 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