Timelib.h and Daylight saving Time

Mike0675

Member
Hi I´m using Teensy 4.1 with PlatformIO

Now playing around with RTC and Timelib.h; I´m confused how to handle Daylight Saving Time.

Is it implemented somewhere? I can set Timezone, but does it switch Time automatic, or do I have to do that at my own?

Thanks
 
I'm re-designing moving from Teensy 3.2 to Teensy 4.1

timeline.h defines a tmElements structure that has no "time zone" or "time zone offset" that I can see.

typedef struct {
uint8_t Second;
uint8_t Minute;
uint8_t Hour;
uint8_t Wday; // day of week, sunday is day 1
uint8_t Day;
uint8_t Month;
uint8_t Year; // offset from 1970;
} tmElements_t, TimeElements, *tmElementsPtr_t;

The solution depends on several things:
- discovering the time - from an external source or via manual entry (or from compiling... see below)
- discovering the time zone - often from the same external source (e.g. a PC or Mac knows the time and time zone)
- saving a timezone offset from GMT. I use 15-minute granularity... that's the smallest time zone offset I can find on earth.
- taking care to use ardor display the time in local or GMT time as appropriate

I re-looking right now for how to discover the time from the compiler/flasher. That's what I counted on in my Teensy3.2 code, and I've not re-found the magic incantation for Teensy 4.1

Please post what you discover, especially around using the time of compilation for setting the clock.

By the way, I'm using VS Code and PlatformIO as well.

Oh wait... I'm seeing you're asking about daily saving time.
I rely on an an external time sync for this (in my case, connection with a Mac, PC or iOS device) and resynch the time when I make such a connection, and allow the time to be off by an hour until that is done.

Since daylight time changes from year to year, and based on periodic changes to local legislation, an external service is likely to be required.
 
Last edited:
Back
Top