2021-03-11 12:11:53 +02:00
|
|
|
// Copyright 2015-2016 Espressif Systems (Shanghai) PTE LTD
|
2017-01-24 04:07:27 +02:00
|
|
|
//
|
|
|
|
|
// Licensed under the Apache License, Version 2.0 (the "License");
|
|
|
|
|
// you may not use this file except in compliance with the License.
|
|
|
|
|
// You may obtain a copy of the License at
|
|
|
|
|
|
|
|
|
|
// http://www.apache.org/licenses/LICENSE-2.0
|
|
|
|
|
//
|
|
|
|
|
// Unless required by applicable law or agreed to in writing, software
|
|
|
|
|
// distributed under the License is distributed on an "AS IS" BASIS,
|
|
|
|
|
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
|
|
|
// See the License for the specific language governing permissions and
|
|
|
|
|
// limitations under the License.
|
|
|
|
|
|
|
|
|
|
#include "esp32-hal.h"
|
2018-09-21 08:39:36 +02:00
|
|
|
#include "lwip/apps/sntp.h"
|
2021-04-05 14:23:58 +03:00
|
|
|
//#include "tcpip_adapter.h"
|
|
|
|
|
#include "esp_netif.h"
|
2017-01-24 04:07:27 +02:00
|
|
|
|
|
|
|
|
static void setTimeZone(long offset, int daylight)
|
|
|
|
|
{
|
2018-11-28 00:35:43 +01:00
|
|
|
char cst[17] = {0};
|
|
|
|
|
char cdt[17] = "DST";
|
|
|
|
|
char tz[33] = {0};
|
2017-01-24 04:07:27 +02:00
|
|
|
|
|
|
|
|
if(offset % 3600){
|
2017-10-01 10:19:00 +08:00
|
|
|
sprintf(cst, "UTC%ld:%02u:%02u", offset / 3600, abs((offset % 3600) / 60), abs(offset % 60));
|
2017-01-24 04:07:27 +02:00
|
|
|
} else {
|
2017-10-01 10:19:00 +08:00
|
|
|
sprintf(cst, "UTC%ld", offset / 3600);
|
2017-01-24 04:07:27 +02:00
|
|
|
}
|
|
|
|
|
if(daylight != 3600){
|
|
|
|
|
long tz_dst = offset - daylight;
|
|
|
|
|
if(tz_dst % 3600){
|
2017-10-01 10:19:00 +08:00
|
|
|
sprintf(cdt, "DST%ld:%02u:%02u", tz_dst / 3600, abs((tz_dst % 3600) / 60), abs(tz_dst % 60));
|
2017-01-24 04:07:27 +02:00
|
|
|
} else {
|
2017-10-01 10:19:00 +08:00
|
|
|
sprintf(cdt, "DST%ld", tz_dst / 3600);
|
2017-01-24 04:07:27 +02:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
sprintf(tz, "%s%s", cst, cdt);
|
|
|
|
|
setenv("TZ", tz, 1);
|
|
|
|
|
tzset();
|
|
|
|
|
}
|
|
|
|