FormatDateTime with [fdoInterval] does not display an initial 0 lazarus / 21-General ---------------------------------------------------------------------- Joek · 2021-03-03 12:05 When using [fdoInterval] in FormatDateTime, the initial 0 is not displayed. This behaves [hh] and [nn] and [ss]. For example: writeln (FormatDateTime ('hh: nn: ss: zzz', t)); ... returns correctly 08: 58: 32: 255 writeln (FormatDateTime ('[hh]: nn: ss: zzz', t, [fdoInterval])); ... returns 8: 58: 32: 255 If the number of hours exceeds 23, it behaves OK (displays days as hours) Does anyone know what I'm doing wrong? ---------------------------------------------------------------------- MarkMLl · 2021-03-03 12:24 Probably nothing, it's probably "Delphi compatible". Sorry, I lost patience with that mantra when I discovered that milliseconds don't have leading zeroes either. Feel free to pick over https://github.com/MarkMLl/Contec_cms50dplus/bl ob/main/common/inifilesabout.pas MarkMLl ---------------------------------------------------------------------- wp · 2021-03-03 13:03 Definitely nothing related to "Delphi compatible" because Delphi does not have this option. It is easy to fix (however, requires recompilation of the FCL): Open the file dati.inc in folder (fpc)/rtl/objpas/sysutls, find procedure DateTimeToString and the nested procedure StoreFormat. In the large "case Token of" find the cases 'H', 'N', and 'S'. They always begin with Code: Text  [Select][+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i             if isInterval then                StoreInt(Hour + trunc(abs(DateTime))*24, 0)    // <--- Replace the "0" by "Count"(this is for 'H', but 'N' and 'S' are similar. The last parameter, 0, of the StoreInt call should be replaced by 'Count' which is the number of H, N or S in the format string. Is this a bug? Looks like... Or is it intentional? An argument could be that your format string can contain as many 'H' as you want, and the output string will have as many digits for the hours as you like. But maybe at some time in the future, the function may be extended to 'D', days, -- in this case the function FormatDateTime will allow two meanings for 'DDDD': in the normal format strings it will be the long weekday name, but in the interval case it will mean "four-digit days". This could lead to some confusion, and maybe this was the reason why no leading zeros were allowed here. I don't know... ---------------------------------------------------------------------- Joek · 2021-03-03 15:02 Thank you for the explanation. I do not consider it appropriate to interfere in the FCL in this way. Inifilesabout.pas is an inspiration! For my purposes, a short procedure will suffice, it was just not clear to me whether I am not making a mistake in calling FormatDateTime. ---------------------------------------------------------------------- wp · 2021-03-03 15:53 Nevertheless, I posted a bug report (https://bugs.freepascal.org/view.php?id=38577). Let's the FPC devs decide whether this is a bug or a feature. ---------------------------------------------------------------------- MarkMLl · 2021-03-04 20:11 Quote from: Joek on March 03, 2021, 04:02:30 pmInifilesabout.pas is an inspiration! You can tell how long I've been tinkering with that by the fact that I started off using Modula-2 style uppercase keywords :-) MarkMLl