is this a bug? or am I doing something wrong?

VioBiscu
Posts: 1
Joined: Wed Aug 19, 2020 11:12 am

is this a bug? or am I doing something wrong?

Postby VioBiscu » Wed Aug 19, 2020 11:46 am

  1. void app_main(){
  2.     struct tm  tsEpoch;
  3.     struct tm  tsRTC;
  4.     struct timeval now;
  5.     struct timeval newt;
  6.     char LineClock[20] ={""};
  7.  
  8.     int flag = 1;
  9.     unsigned int epoch = 1597833218;
  10.  
  11.     newt.tv_sec= epoch;
  12.     tsEpoch = *localtime(&newt.tv_sec);
  13.     settimeofday(&newt, NULL);
  14.     gettimeofday(&now, NULL);
  15.  
  16.     tsRTC = *localtime(&now.tv_sec);
  17.  
  18.     ESP_LOGI(TAG,"Epoch    %X", (int)epoch);
  19.     ESP_LOGI(TAG,"Local    %X", (int)newt.tv_sec);
  20.     ESP_LOGI(TAG,"RTC      %X", (int)now.tv_sec);
  21.  
  22.     if (flag){
  23.         strftime(LineClock, sizeof(LineClock),  "%H:%M:%S", &tsEpoch);
  24.         ESP_LOGI(TAG,"Epoch %s",  LineClock);
  25.  
  26.  
  27.         strftime(LineClock, sizeof(LineClock),  "%H:%M:%S", &tsRTC);
  28.         ESP_LOGI(TAG,"RTC   %s", LineClock);
  29.     }
  30. }


with flag = 0
=============
I (357) Main: Epoch 5F3D0002
I (357) Main: Local 5F3D0002
I (357) Main: RTC 5F3D0002


with flag = 1
=============
I (357) Main: Epoch 5F3D0002
I (357) Main: Local 5F3D0002
I (357) Main: RTC 5F3D0433
I (367) Main: Epoch 10:33:38
I (367) Main: RTC 10:51:31

Who is online

Users browsing this forum: No registered users and 2 guests