Automatic Timezone & DST (Daylight Savings Time)

Hi all,

I'm new to the forum, but I've been using Arduino for about 11 years, and programming in C around 25 years.

I have a sketch which is using NTP to sync the clock and uses a specified timezone to get the local time. However, I still haven't been able to find a simple way to get the current timezone and DST. My device may be moved to another timezone and/or DST and I want it to automatically adjust the time for it's current location.

I've read the all the posts in the thread Library for time zone conversions and automatic DST adjustments - Exhibition / Gallery - Arduino Forum regarding Jack Christensen's (jchristensen) library.

I have considered GETting the page at https://whatismytimezone.com/ and parsing it for the offset variable, but then I might as well remove the NTP stuff.

Ideas?

Which board are you using. With ESP8266 that has now built in NTP and timezone support. It requires only few lines of code.

Automatically adjusting the timezone depending on geographical location would be an interesting idea. Cell phones can get this more or less right (sometimes)

Yes, some additional information is needed.
The platform is the most important as it can determine which options are available.

Then, what exactly do you mean by "Automatic Timezone & DST"?
Specifically the word "Automatic"
Are you meaning the device must be capable of determining this without any human interaction or input?
(Except initially configuring WiFi)
Or are you meaning that the human can configure the local timezone and the device must be capable of doing local DST adjustments?

Either can be done depending on your h/w platform.

There are sites (some free some pay) that provide a JSON interface that provides local time as well as the GNU TZ timezone string for your location based on location data provided or IP address.

The other thing that is very important to be clear on is: Do you intend to use any sort of timestamps?
i.e. do you need to store time_t values for future use?
If so, solutions like using the TimeZone library with the TimeLib are out the window and cannot be used.

The esp platform has very good time library support.
It supported the unix time api functions, which sync time using NTP, pretty much out of the box from its initial release.

Do you have or need to support for an RTC?
If so, there are some additional things to consider.

The other big question is: What about y2k38?
Do you need this device (clock s/w) to work after January 2038?

The answer to that will dramatically limit your options as most time libraries out there, particularly for Arduino platforms, will break in 2038.

MANY things are going to break in 2038 due to y2k38 issues. It is a much bigger issue than y2k.

--- bill

This topic was automatically closed 120 days after the last reply. New replies are no longer allowed.