Recent

Author Topic: (SOLVED) Date problem  (Read 2035 times)

xinyiman

  • Hero Member
  • *****
  • Posts: 2261
    • Lazarus and Free Pascal italian community
(SOLVED) Date problem
« on: November 08, 2016, 03:01:22 pm »
Hello guys, I made a program for the management of inputs and outputs for employees, and when it does not read the card rfid user shows the current time! Up to the end of October no problem, the date was correct. But from November, which came into use solar time I show the wrong time. It shows me the summer time! A now on. The funny thing is that if a terminal (this is a raspberry) launch the "date" command back to me the correct value. Who tells me what's wrong with this procedure?

Code: Pascal  [Select][+][-]
  1. procedure TFrm_Main.Timer1Timer(Sender: TObject);
  2. Var
  3.   YY,MM,DD : Word;
  4.   HH,Minuti,SS,MS: Word;
  5.   ora_str: string;
  6.   data_str: string;
  7. begin
  8.  
  9.  
  10.           try
  11.              try
  12.  
  13.                if IsRunningResult=false then
  14.                begin
  15.                     DecodeDate(Date,YY,MM,DD);
  16.                     DecodeTime(Time,HH,Minuti,SS,MS);
  17.  
  18.                     data_str:='';
  19.                     if DD<10 then
  20.                        data_str:=data_str + '0';
  21.                     data_str:=data_str + IntToStr(DD) + '/';
  22.  
  23.                     if MM<10 then
  24.                        data_str:=data_str + '0';
  25.                     data_str:=data_str + IntToStr(MM) + '/';
  26.  
  27.                     data_str:=data_str + IntToStr(YY);
  28.  
  29.  
  30.                     ora_str:='';
  31.                     if hh<10 then
  32.                        ora_str:=ora_str + '0';
  33.                     ora_str:=ora_str + IntToStr(hh) + ':';
  34.  
  35.                     if Minuti<10 then
  36.                        ora_str:=ora_str + '0';
  37.                     ora_str:=ora_str + IntToStr(Minuti) + ':';
  38.  
  39.                     if ss<10 then
  40.                        ora_str:=ora_str + '0';
  41.                     ora_str:=ora_str + IntToStr(ss);
  42.  
  43.  
  44.                     Self.Lbl_Data_Ora.Font.Color:=RGBToColor(112,113,115);
  45.                     Self.Lbl_Data_Ora.Visible:=true;
  46.                     Self.Lbl_Data_Ora.Caption:= data_str + ' ' + ora_str;
  47.                     Self.Refresh;
  48.                     Application.ProcessMessages;
  49.                end;
  50.  
  51.  
  52.              finally
  53.                     //codice da effettuare a fine procedura sia che va bene il codice sopra sia che il codice ha sollevato un'eccezzione
  54.             end;
  55.           except
  56.                 on E: Exception do
  57.                 begin
  58.  
  59.                      Self.Log('[Timer1] ' + E.Message);
  60.  
  61.                 end;
  62.           end;
  63. end;  
  64.  


On raspberry in question there is a cron that runs the following script

#!/bin/bash
echo Inizio sincronizzazione attraverso ntpupdate
sudo ntpdate 192.168.27.1
echo Sincronizzazione avvenuta

« Last Edit: November 08, 2016, 03:51:34 pm by xinyiman »
Win10, Ubuntu and Mac
Lazarus: 2.1.0
FPC: 3.3.1

xinyiman

  • Hero Member
  • *****
  • Posts: 2261
    • Lazarus and Free Pascal italian community
Re: Date problem
« Reply #1 on: November 08, 2016, 03:51:20 pm »
I'm sorry, I resolved. It was enough to run the command

sudo ntpdate 192.168.27.1

before launching the lazarus executable. Now it all works. Thank you
Win10, Ubuntu and Mac
Lazarus: 2.1.0
FPC: 3.3.1

 

TinyPortal © 2005-2018