ropg / ezTime

ezTime — pronounced "Easy Time" — is a very easy to use Arduino time and date library that provides NTP network time lookups, extensive timezone support, formatted time and date strings, user events, millisecond precision and more.
MIT License
327 stars 92 forks source link

wrong day for DST change #11

Closed dobryj closed 5 years ago

dobryj commented 5 years ago

Hi!

today I detect, that time from ezTime library is invalid. After some investigation I found, that problem is that ezTime thing that I need CET time, but today is last day with CEST I am set Olsen format "Europe/Prague" It is converted to POSIX correctly : "CET-1CEST,M3.5.0,M10.5.0/3" This is correct. Problem is that today (27-Oct-2018) is last weekend on October but not .0 ( =Sunday) ezTime show Time: Saturday, 27-Oct-2018 12:08:32 CET

Any idea?

ropg commented 5 years ago

Ouch, see the same problem here. Looks like something is off. I will look into that urgently later today or tomorrow...

chinswain commented 5 years ago

Same for gb timezone:

UTC: Saturday, 27-Oct-2018 12:00:38 UTC New Zealand: Sunday, 28-Oct-2018 01:00:38 NZDT United Kingdom: Saturday, 27-Oct-2018 12:00:38 GMT Local (GeoIP): Saturday, 27-Oct-2018 12:00:38 GMT

dobryj commented 5 years ago

I found reason. Problem is on dst_start and dst_end equations. Hotfix is +1 on "dow" in library (line 741+742) like

time_t dst_start = ezt::makeOrdinalTime(start_time_hr, start_time_min, 0, start_week, start_dow+1, start_month, tm.Year + 1970); time_t dst_end = ezt::makeOrdinalTime(end_time_hr, end_time_min, 0, end_week, end_dow+1, end_month, tm.Year + 1970);

In detal it is problem on weekday numbering. In ezTime function UTC.weekday() return sunday=1. But posix rule use sunday=0.

ropg commented 5 years ago

I found reason. Problem is on dst_start and dst_end equations. Hotfix is +1 on "dow" in library (line 741+742) like

time_t dst_start = ezt::makeOrdinalTime(start_time_hr, start_time_min, 0, start_week, start_dow+1, start_month, tm.Year + 1970); time_t dst_end = ezt::makeOrdinalTime(end_time_hr, end_time_min, 0, end_week, end_dow+1, end_month, tm.Year + 1970);

In detal it is problem on weekday numbering. In ezTime function UTC.weekday() return sunday=1. But posix rule use sunday=0.

You're absolutely right: a bug indeed, and the fix is exactly as you describe. I will release a new version of ezTime later today.

JasXSL commented 5 years ago

I'm getting a DST issue here too. Using tz.setLocation(F("Europe/Stockholm")) it's giving me CEST a week in advance. Maybe because this year there are 5 Sundays in March?

ropg commented 5 years ago

Are you using version 0.7.10 ? It should be fixed there.

JasXSL commented 5 years ago

Yep that update fixed it, thanks