Recent

Author Topic: Trying to show compile time in the caption  (Read 274 times)

QEnnay

  • Full Member
  • ***
  • Posts: 125
Trying to show compile time in the caption
« on: September 19, 2024, 09:02:04 pm »
Hi, I'd like the main caption to display the FileAge of the current program when it was compiled. Tried the code below, but I get "12:00am" all he time. Is this possible in Linux Mint-22 and laz-3.4?

Code: Pascal  [Select][+][-]
  1.   Caption:=TimeToStr(fileAge(Application.Params[0]));
  2.  
Linux-Mint 20.1 x64 + Cinnamon; Lenovo Flex 5 Ryzen 5 4500, 16GB memory
FPC: 3.2.0-1, Lazarus 2.0.12-0, all 64bit

PascalDragon

  • Hero Member
  • *****
  • Posts: 5759
  • Compiler Developer
Re: Trying to show compile time in the caption
« Reply #1 on: September 19, 2024, 09:16:16 pm »
FileAge returns the modified time which might be changed by some user. Instead use {$I %DATE%} and {$I %TIME%}:

Code: Pascal  [Select][+][-]
  1. Caption := {$I %DATE%} + ' - ' + {$I %TIME%};

Note: that is the time/date the unit is compiled as, so if you have this inside a unit and that unit isn't changed for some time then the date/time will stay the same. So best collect that information inside the main program file cause that is compiled always.

QEnnay

  • Full Member
  • ***
  • Posts: 125
Re: Trying to show compile time in the caption
« Reply #2 on: September 19, 2024, 09:38:24 pm »
So best collect that information inside the main program file cause that is compiled always.

Thanks, yup it is the main-form Caption.
Linux-Mint 20.1 x64 + Cinnamon; Lenovo Flex 5 Ryzen 5 4500, 16GB memory
FPC: 3.2.0-1, Lazarus 2.0.12-0, all 64bit

 

TinyPortal © 2005-2018