Why timezone is inverted ?

eliott
Posts: 18
Joined: Sat Mar 28, 2020 11:57 am

Why timezone is inverted ?

Postby eliott » Sat Jan 30, 2021 6:35 pm

Hello,

there is my function to set my timezone for ntp:

Code: Select all

void update_system_timezone(int8_t zone)
{
	char timezone[10];
	if(zone<0) sprintf(timezone,"UTC%i",zone);
	else sprintf(timezone,"UTC+%i",zone);
		
	setenv("TZ", timezone, 1);
	tzset();
		
	ESP_LOGI(TAG,"Timezone set to %s",timezone);
}
and init:

Code: Select all

void update_system_ntp()
{
	if(sntpinit==0)
	{
		sntp_setoperatingmode(SNTP_OPMODE_POLL);
		sntp_setservername(0, "pool.ntp.org");
		sntp_init();
		sntpinit=1;		
	}
	else
	{
		//sntp_restart();
	}
}
I'm in UTC+1 timezone, windows give me the for exemple: 19h29.

If I set update_system_timezone(1) the ESP give me 17h29, but If I set update_system_timezone(-1), I get the good time.

https://ibb.co/Gpm1JvG
https://ibb.co/fkwJbyN

Image
Image

Thank you.

WiFive
Posts: 3529
Joined: Tue Dec 01, 2015 7:35 am

Re: Why timezone is inverted ?

Postby WiFive » Sat Jan 30, 2021 8:49 pm


eliott
Posts: 18
Joined: Sat Mar 28, 2020 11:57 am

Re: Why timezone is inverted ?

Postby eliott » Tue Feb 02, 2021 8:16 pm

Thank you.

Who is online

Users browsing this forum: No registered users and 118 guests