Skip to content
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

configTime(TZ,DS,server) gives wrong offset #7319

Closed
2 tasks
Juppit opened this issue May 20, 2020 · 4 comments · Fixed by #7320
Closed
2 tasks

configTime(TZ,DS,server) gives wrong offset #7319

Juppit opened this issue May 20, 2020 · 4 comments · Fixed by #7320
Assignees
Milestone

Comments

@Juppit
Copy link
Contributor

Juppit commented May 20, 2020

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

Platform

  • Hardware: [ESP-12]
  • Core Version: [2.7.0 2.7.1]
  • Development Env: [Arduino IDE]
  • Operating System: [WindowsS]

Settings in IDE

  • Module: [Wemos D1 mini r2]
  • lwip Variant: [v2.1]
  • Upload Using: [OTA or SERIAL]
  • Upload Speed: [19200)
  • all other setings are untached/default, not visible

Problem Description

The old configTime api with timezone and daylight in seconds produces wrong timestamp.
To generate the right timestamps one can use negative timezone an daylight setting.

This appears after core version 2.6.3.
Git version 2.7.0-dev-nightly+20200218 was still correct.

MCVE Sketch

#include "pass.h"  // MY_SSID, MY_PWD
#include <ESP8266WiFi.h>

static int tz = -1; // start with GMT-1
static int ds = 0;  // no daylight time

static time_t now = 0;

void setup() {
  Serial.begin(19200);
  Serial.printf("\nCORE version is %s", ESP.getCoreVersion().c_str());

  WiFi.mode(WIFI_STA);
  WiFi.begin(MY_SSID, MY_PWD);
  while (WiFi.status() != WL_CONNECTED)
    delay(500);

  while (! now )
  {
    now = time(nullptr);
    delay(500);
  }
}

void printTime() {
  struct tm* t;
  now = time(nullptr);
  t = localtime((const time_t*)&now);
  Serial.printf("\nTZ: GMT%+03d DS: %i - %02d:%02d", tz, ds, t->tm_hour, t->tm_min);
}

void loop() {
  configTime ( tz * 3600, ds * 3600, (char*)"pool.ntp.org") ;
  delay(2000);
  printTime();
  if (++tz > 1)
  {
    tz = -1;
    ds = !ds;
    Serial.println();
    delay(5000);
  }
}

Debug Messages

CORE version is 2_6_3

TZ: GMT-01 DS: 0 - 20:20
TZ: GMT+00 DS: 0 - 21:20
TZ: GMT+01 DS: 0 - 22:20

TZ: GMT-01 DS: 1 - 21:20
TZ: GMT+00 DS: 1 - 22:20
TZ: GMT+01 DS: 1 - 23:20

CORE version is 2_7_0

TZ: GMT-01 DS: 0 - 22:25
TZ: GMT+00 DS: 0 - 21:25
TZ: GMT+01 DS: 0 - 20:25

TZ: GMT-01 DS: 1 - 21:25
TZ: GMT+00 DS: 1 - 20:25
TZ: GMT+01 DS: 1 - 19:25

CORE version is 2_7_1
TZ: GMT-01 DS: 0 - 22:28
TZ: GMT+00 DS: 0 - 21:28
TZ: GMT+01 DS: 0 - 20:28

TZ: GMT-01 DS: 1 - 21:28
TZ: GMT+00 DS: 1 - 20:28
TZ: GMT+01 DS: 1 - 19:28
@d-a-v d-a-v added this to the 2.7.2 milestone May 20, 2020
@d-a-v d-a-v self-assigned this May 20, 2020
@d-a-v
Copy link
Collaborator

d-a-v commented May 20, 2020

Thanks for reporting. Sorry for the mistake.
Fix will come with for 2.7.2 second bugfix release.

@Juppit
Copy link
Contributor Author

Juppit commented May 20, 2020

@d-a-v there is a little type in my comment:

To generate the right timestamps one can use negative timezone an daylight setting.

should be:

use negative timezone and daylight setting

It means, the dayligth setting is also wrong.

@d-a-v
Copy link
Collaborator

d-a-v commented May 20, 2020

timezone and daylight are now right with #7320 .
Would you confirm that ? Testing it should be pretty straightforward.

@Juppit
Copy link
Contributor Author

Juppit commented May 20, 2020

Yes I confirm, it's now right with #7320

CORE version is 3_0_0_DEV_NIGHTLY
TZ: GMT-01 DS: 0 - 17:53
TZ: GMT+00 DS: 0 - 18:53
TZ: GMT+01 DS: 0 - 19:53

TZ: GMT-01 DS: 1 - 18:53 #73
TZ: GMT+00 DS: 1 - 19:53
TZ: GMT+01 DS: 1 - 20:53

I overlooked the fact that both parts were solved with one patch.
This issue can be closed after merging #7320

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

Successfully merging a pull request may close this issue.

2 participants