On Sun, 27 Oct 2013, David Taylor wrote:

I noticed that over the clock change in the Autumn my wall clock continued to display summer time rather than winter time - my guess is that the Now function doesn't check for a change in the minutes offset very frequently, if at all since it was first called. Restarting the program fixed the problem, but it would be nice to have the fix in the code.

It is a known problem.

Doing this 100% correctly involves re-reading the timezone file at every call 
of Now() or Date().
Clearly, this is a huge performance impact, severely skewing the time 
information.

So this is not done.

The "unix" unit contains

Procedure ReReadLocalTime;

which will re-initialize the necessary variables. You can call this routine at 
regular intervals as you see fit.

In your case, you may want to insert a call to this after every clock update, 
which would be once a second.

Michael.


This with FPC for the Raspberry Pi.

Source:
 http://www.satsignal.eu/raspberry-pi/DigitalClock.html

Code extract:

procedure TClockForm.TimerClockTimer (Sender: TObject);
var
 when: TDateTime;
 hours, minutes, seconds, th: Word;
begin
 when := Now;
 DecodeTime (when, hours, minutes, seconds, th);
 if seconds <> FOldSeconds then
   begin
   FOldSeconds := seconds;
   LabelHHMM.Caption := FormatDateTime ('hh:mm', when);
   LabelHHMM.Update;
   LabelSS.Caption := FormatDateTime (' ss', when);
   LabelSS.Update;
   if hours <> FOldHours then
     begin
     FOldHours := hours;
     LabelDate.Caption := FormatDateTime ('yyyy-mmm-dd', when);
     LabelDay.Caption := FormatDateTime ('dddd', when);
     LabelDate.Left := (ClientWidth - LabelDate.Width) div 2;
     LabelDay.Left := (ClientWidth - LabelDay.Width) div 2;
     end;
   end;
end;


Thanks.
--
David
Web: http://www.satsignal.eu


--
_______________________________________________
Lazarus mailing list
[email protected]
http://lists.lazarus.freepascal.org/mailman/listinfo/lazarus


--
_______________________________________________
Lazarus mailing list
[email protected]
http://lists.lazarus.freepascal.org/mailman/listinfo/lazarus

Reply via email to