Page 1 of 1

Why timezone is inverted ?

Posted: Sat Jan 30, 2021 6:35 pm
by eliott
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.

Re: Why timezone is inverted ?

Posted: Sat Jan 30, 2021 8:49 pm
by WiFive

Re: Why timezone is inverted ?

Posted: Tue Feb 02, 2021 8:16 pm
by eliott
Thank you.