Форуми / Cotonti / Extensions / Support / DST Checking of Timestamps

Hodges
#39450 14.04.2014 11:37

Hi,

I'm in the middle of working on a heavily modified calendar plugin that uses ajax to emulate google calendar. It's all going well but I want to pay special attention to how I present timestamps to users. At this stage I'd like to make it clear that I know it's important to store timestamps in UTC.

Using cotonti's datetime functions, how do I take an historical timestamp and check if DST was in effect at the time (according to the user's timezone selection) and display the time accordingly? I want to ensure that, if DST is currently in effect for the user, I'm not applying DST corrections to a timestamp that refers to a time when DST wasn't in effect.

I hope my question makes sense... Thanks!

I've given examples below:

Create an event for a date outside DST when it is currently DST:

                STORE AS 09:00                 DISPLAY AS 09:00

Create an event for a date outside DST when it is not currently DST:

                STORE AS 09:00                 DISPLAY AS 09:00

Create an event for a date inside DST when it is currently DST:

                STORE AS 08:00                 DISPLAY AS 09:00

Create an event for a date inside DST when it is not currently DST:

                STORE AS 08:00                 DISPLAY AS 09:00

Added 22 minutes later:

My example assumes I'm on the London/Europe timezone.

Added 5 minutes later:

What would be ideal would be a function (and its reciprocal) that could take a UTC timestamp and the user's preferred timezone and output a local timestamp for the user ensuring it includes the DST correction appropriately based on whether the timestamp occurred during that timezone's DST rules.


Відредаговано: Hodges (14.04.2014 12:04, 10 років тому)