[Lazarus] Possible error with Now function over summer/winter time change?

David Taylor david-taylor at blueyonder.co.uk
Sun Oct 27 16:12:48 CET 2013


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.

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





More information about the Lazarus mailing list