Recent

Author Topic: [SOLVED] System.Now gives timestamp which is eight hours back  (Read 551 times)

alpine

  • Hero Member
  • *****
  • Posts: 1108
Today I have installed a program written in FPC on a Debian 12 bookworm (32-bit) and to my surprise it logs all of its events with a timestamp which is 8 hours back in the past. Those stamps are result from calling the System.Now function.
The program runs properly on a several other Linux machines. I don't have a clue where the problem lies with that particular Debian machine.

Here is the output from timedatectl:
Code: [Select]
# timedatectl
               Local time: Wed 2024-04-24 19:47:15 EEST
           Universal time: Wed 2024-04-24 16:47:15 UTC
                 RTC time: Wed 2024-04-24 16:47:15
                Time zone: Europe/Sofia (EEST, +0300)
System clock synchronized: yes
              NTP service: active
          RTC in local TZ: no
and it is quite correct.

The printout from the program:
Code: [Select]
TimeLogNow: 135843986499, TimeLogToDateTime(TimeLogNow): 2024.04.24 11:49
Now: 2024.04.24 11:49, TimeLogFromDateTime(Now): 135843986499
The difference is exactly -8 hrs, (+2 min not relevant, execution difference)

Traced back the Now function until found an external:
Now -> GetLocalTime -> DoGetLocalDateTime -> fpgettimeofday -> external name 'FPC_SYSC_GETTIMEOFDAY'

Anybody have a clue?



« Last Edit: April 24, 2024, 08:29:55 pm by alpine »
"I'm sorry Dave, I'm afraid I can't do that."
—HAL 9000

Thaddy

  • Hero Member
  • *****
  • Posts: 14572
  • Sensorship about opinions does not belong here.
Re: System.Now gives timestamp which is eight hours back
« Reply #1 on: April 24, 2024, 07:59:53 pm »
now relies on the system clock, so check the system clock.
it does not rely on a time sever, only indirect if the system clock is syncronized,
« Last Edit: April 24, 2024, 08:01:48 pm by Thaddy »
bitrate is always calculated like this:sample rate * bitdepth * number of channels.

Kays

  • Hero Member
  • *****
  • Posts: 586
  • Whasup!?
    • KaiBurghardt.de
Re: System.Now gives timestamp which is eight hours back
« Reply #2 on: April 24, 2024, 08:14:04 pm »
Ensure that now writes to tDateTime variables, not any other real type. Unfortunately they are assignment‑compatible so no error reporting, but strange results.
Yours Sincerely
Kai Burghardt

alpine

  • Hero Member
  • *****
  • Posts: 1108
Re: System.Now gives timestamp which is eight hours back
« Reply #3 on: April 24, 2024, 08:29:19 pm »
Thanks for the replies!

It actually was due to some OS misconfiguration, I don't know how it happened...
Despite the right printout from the timedatectl, the command:
Code: [Select]
#cat /etc/timezone printed:
Code: [Select]
US/Central
and after dpkg-reconfigure tzdata with the right location, which was also preselected (?!) as it was set correctly (it wasn't) now it prints:
 
Code: [Select]
#cat /etc/timezone
Europe/Sofia

After the reboot it now seems to be OK.
Sorry for the noise.
"I'm sorry Dave, I'm afraid I can't do that."
—HAL 9000

Thaddy

  • Hero Member
  • *****
  • Posts: 14572
  • Sensorship about opinions does not belong here.
Re: [SOLVED] System.Now gives timestamp which is eight hours back
« Reply #4 on: April 25, 2024, 05:04:45 pm »
Don't worry, this is a quite common oversight. Glad it works now. :D
bitrate is always calculated like this:sample rate * bitdepth * number of channels.

 

TinyPortal © 2005-2018