Library for time zone conversions and automatic DST adjustments

americo1977:
I would like to be able to select a timezone (with switches on the Arduino board).
At this moment I am stuck with the CET (Central European Time) showing on the LCD.

Hello!

Rather than using a hard-coded Timezone to convert to local time, e.g.

    time_t localTime = CET.toLocal(DCFtime, &tcr);

instead declare a pointer to Timezone and set it to point to the desired Timezone object. Then use the pointer variable to do the conversion to local time:

    Timezone *tz;
    tz = &UK;
    time_t localTime = (*tz).toLocal(DCFtime, &tcr);

I don't see any logic in the sketch to actually read the switches, obviously that will be needed, and it will just need to set the pointer variable to the desired timezone. I think you're just asking about how to handle the timezone, so I'll assume you've got working with the switches figured out.

Here is a comprehensive example that works similarly. It uses US timezones rather than European but still should illustrate the technique :wink:

HTH ... jc