is this a bug? or am I doing something wrong?
Posted: Wed Aug 19, 2020 11:46 am
- void app_main(){
- struct tm tsEpoch;
- struct tm tsRTC;
- struct timeval now;
- struct timeval newt;
- char LineClock[20] ={""};
- int flag = 1;
- unsigned int epoch = 1597833218;
- newt.tv_sec= epoch;
- tsEpoch = *localtime(&newt.tv_sec);
- settimeofday(&newt, NULL);
- gettimeofday(&now, NULL);
- tsRTC = *localtime(&now.tv_sec);
- ESP_LOGI(TAG,"Epoch %X", (int)epoch);
- ESP_LOGI(TAG,"Local %X", (int)newt.tv_sec);
- ESP_LOGI(TAG,"RTC %X", (int)now.tv_sec);
- if (flag){
- strftime(LineClock, sizeof(LineClock), "%H:%M:%S", &tsEpoch);
- ESP_LOGI(TAG,"Epoch %s", LineClock);
- strftime(LineClock, sizeof(LineClock), "%H:%M:%S", &tsRTC);
- ESP_LOGI(TAG,"RTC %s", LineClock);
- }
- }
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