Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Setting timezone with setenv doesn't work properly any more with V 2.7.1 #7353

Open
@ElToberino

Description

@ElToberino

EDIT:
Reference is in shipped examples, namelyNTP-TZ-DST.ino.

Basic Infos

  • This issue complies with theissue POLICY doc.
  • I have read the documentation atreadthedocs 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.1]
  • Development Env:[Arduino IDE]
  • Operating System:[Windows]

Settings in IDE

  • Module: [Nodemcu]
  • Flash Mode:[qio|dio|other]
  • Flash Size: [4MB]
  • lwip Variant: [v2 Lower Memory]
  • Reset Method: [nodemcu]
  • Flash Frequency:[40Mhz]
  • CPU Frequency:[80Mhz]
  • Upload Using: [OTA AND SERIAL]
  • Upload Speed: [115200] (serial upload only)

Problem Description

The follwing two code snippets worked fine with V 2.6.3:

configTime(0, 0, "pool.ntp.org"); setenv("TZ", "CET-1CEST,M3.5.0/02,M10.5.0/03" , 1);

or, in changed order:

setenv("TZ", "CET-1CEST,M3.5.0/02,M10.5.0/03" , 1);configTime(0, 0, "pool.ntp.org");

It always delivered the right local time.
With the current version, this seems to be broken - in a very strange way:Only the first call of the time function delivers the right local time, all following time server calls don't set the local time and the function delivers UTC time only. I read the changelog and searched the issues, but I coludn't find any explanation. Has there been a change regarding the definition of the local timezone or within the setenv function?

If required, here's the complete code of my time function which worked very well with V 2.6.3:

struct tm tm;char timeshow[10];void getTimeFromServer(){  uint8_t  time_retry=0;                                // Counter retry counts time server  setenv("TZ", "CET-1CEST,M3.5.0/02,M10.5.0/03", 1);  struct tm initial;                                         // temp struct for checking if year==1970   initial.tm_year=70;    while (initial.tm_year == 70 && time_retry < 15) {                     configTime(0, 0, "pool.ntp.org");                // get time from NTP server (ESP8266)    delay(500);    time_t now = time(&now);    localtime_r(&now, &initial);    Serial.print("Time Server connection attempt: ");    Serial.println(time_retry + 1);    Serial.print("current year: ");    Serial.println(1900 + initial.tm_year);    time_retry++;  }  if (time_retry >=15) {      Serial.println("Connection to time server failed");  } else {    time_t now = time(&now);    localtime_r(&now, &tm);    strftime (timeshow, sizeof(timeshow), "%H:%M", &tm);    Serial.print("Successfully requested current time from server: ");    Serial.println(timeshow);     }  }}

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


      [8]ページ先頭

      ©2009-2025 Movatter.jp