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

change static variable time_zone? #6675

Closed
osmtools opened this issue Oct 27, 2019 · 6 comments
Closed

change static variable time_zone? #6675

osmtools opened this issue Oct 27, 2019 · 6 comments

Comments

@osmtools
Copy link

I'm using

void configTime(int timezone_sec, int daylightOffset_sec, const char* server1, const char* server2, const char* server3)

with timezone_sec=0 but wondering about that the time after this call is 8 hours in front.

I'm not a c(++) expert, but could it be, that the following as no affect?

time_zone = timezone;

because of the static declaration of time_zone in
static sint32 time_zone = 8 * (60 * 60); // espressif HQ's default timezone

@devyte
Copy link
Collaborator

devyte commented Oct 27, 2019

line 440 is the declaration of the global, line 103 is making use of it. It's correct. BTW, static means that the variable is private to the file and isn't visible/accesible from other files.
You're supposed to call configTime with the arg timezone_sec as your timezone offset in seconds. E.g. I'm timezone -3, so in my case I'd call with -36060.
The default timezone is Espressif's +8. Calling with 0 makes the timezone 0.
I don't see an issue here, so closing.

@devyte devyte closed this as completed Oct 27, 2019
@osmtools
Copy link
Author

@devyte but why the print out of
time_t now = time(nullptr); Serial.println(ctime(&now)); with configTime(0, 0, ntpServer); is then UTC +8?

@devyte
Copy link
Collaborator

devyte commented Oct 27, 2019

You said 8 hours ahead. That's not the same as utc +8, unless your timezone is 0. Which of the two is it? Is your timezone 0?

@osmtools
Copy link
Author

I'm in GMT (=UTC), so i'm using timezone_sec=0, right?
Just right now it's 15:17:00, but the print out is 23:17:00. So 8 hours ahead and i would interpret this as UTC +8. But i expect the print out of 15:17:00. If i change the static variable to 0 then i get 15:17:00.
It's a little bit confusing to me.

@osmtools
Copy link
Author

And btw. if i'm using timezone_sec=-10800 (UTC -3 hours) the print out is 23:17:00, too...

@devyte
Copy link
Collaborator

devyte commented Oct 27, 2019

Alright, please open a new issue and follow the template instructions, including MCVE, and let's discuss there. Add the above explanations in the description.

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

2 participants