Skip to content

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

Closed
@jyberg

Description

@jyberg

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...

}

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions