Skip to content

configTime / sntp_set_timezone supports only full hour timezones (+/- 30min) timezones not supported #5823

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
2 of 3 tasks
jyberg opened this issue Feb 26, 2019 · 3 comments
Closed
2 of 3 tasks

Comments

@jyberg
Copy link

jyberg commented Feb 26, 2019

Basic Infos

  • This issue complies with the issue POLICY doc.
  • I have read the documentation at readthedocs and the issue is not addressed there.
  • [ x] I have tested that the issue is present in current master branch (aka latest git).
  • [ x] I have searched the issue tracker for a similar issue.
  • If there is a stack dump, I have decoded it.
  • [ x] I have filled out all fields below.

Platform

  • Hardware: [ESP-12|Esp8266|NodeMcu]
  • Core Version: [2.20500.0]
  • Development Env: [Platformio]
  • Operating System: [Windows]

Settings in IDE

  • Module: [Generic ESP8266 Module|Nodemcu|]
  • Flash Mode: [qio|dio|other]
  • Flash Size: [4MB/1MB]
  • lwip Variant: [v1.4|v2 Lower Memory|Higher Bandwidth]
  • Reset Method: [ck|nodemcu]
  • Flash Frequency: [40Mhz]
  • CPU Frequency: [80Mhz|160MHz]
  • Upload Using: [OTA|SERIAL]
  • Upload Speed: [115200|other] (serial upload only)

Problem Description

configTime function (Time.c) supports timezone definition is given in seconds. But sntp_set_timezone(sint8 timezone) in sntp-lwip2.c requires time zone in hours. This is fault because there exsist other timezones then full hours also.

Please change sntp_set_timezone function to accept second based timezone, and validate zone using second values if(timezone >= -113600 || timezone <= 133600)

Dayligt savint time setup sntp_set_daylight(...) seems to use second values correctrly

MCVE Sketch

#include <Arduino.h>

void setup() {

// Setup Wifi connection

// Set TimeZone 5h 30min
int timeZoneH 5;
int timeZoneM 30;
	configTime((timeZoneH*60+timeZoneM)*60, 0, "pool.ntp.org", "time.nist.gov");
	time(nullptr);
}

void loop() {
		time_t now = time(nullptr);
		tm* t = localtime(&now);
// returned time is not in correct timezone 5h30min...

}
@oddstr13
Copy link
Contributor

List of UTC time offsets

I would like to point out that a few are :45 off the full hour, and that historically there has been instances of higher precision than 15min, for example +01:24, +04:51 and -00:25:21 (second precision no less).
None of the odd non-15min increments are in use today as far as I can tell, but it would probably be best with at least minute precision for time zones.

@jyberg
Copy link
Author

jyberg commented Feb 27, 2019

List of UTC time offsets

I would like to point out that a few are :45 off the full hour, and that historically there has been instances of higher precision than 15min, for example +01:24, +04:51 and -00:25:21 (second precision no less).
None of the odd non-15min increments are in use today as far as I can tell, but it would probably be best with at least minute precision for time zones.

yes that why I suggested to use seconds value like in configTime interface function uses and not convert to hours/minutes

@devyte
Copy link
Collaborator

devyte commented Feb 28, 2019

Please test #5828 , it adds sntp_set_timezone_in_seconds(). You may have to
extern sntp_set_timezone_in_seconds(sint32 timezone);
at the top of your sketch, because the function signature isn't in a .h yet. Also, configTime() isn't updated either.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants