Recent

Author Topic: Datetime functions return incorrect values if time zone changes  (Read 4693 times)

zakiwi

  • New Member
  • *
  • Posts: 28
Hi there,

I have a Daemon Application that runs forever ... in theory ... but when the OS (Linux) changes the date due to daylight savings or something, then the lazarus application returns the wrong date and time (by the variation amount).  I've written a test application that simply prints the date time on the screen every second, and if the date and time are altered, then the value changes to reflect the alteration, but if the time zone is altered, then the change does not reflect.

If the daemon is restarted, then it gets the correct value again, but that is obviously not an acceptable solution.

Any comments or advice would be greatly valued.

Kind regards

Zakiwi

zakiwi

  • New Member
  • *
  • Posts: 28
Re: Datetime functions return incorrect values if time zone changes
« Reply #1 on: July 20, 2010, 07:05:21 am »
I've managed to find a solution that works.

Adding the following code to my application on a timed event (say once every minute) sorts it all out:

ReadTimezoneFile(GetTimezoneFile);
GetLocalTimezone(fptime);

Cheers

Zakiwi

 

TinyPortal © 2005-2018