[Qt-interest] QDateTime daylight saving parsing time offset
Konrad Rosenbaum
konrad at silmor.de
Wed Mar 30 20:48:49 CEST 2011
On Wednesday 30 March 2011, K. Frank wrote:
> And what about when the government gets involved?
Ohh, they have bad habits about this. Don't they? ;-)
> How about this use case:
>
> I have some kind of calendar or appointment application. I enter
> a date for lunch for 12:00 noon, ET, April 1, 2012. (That's "Eastern
> Time" for the east coast of the U.S.)
Unfortunately there are several Eastern Times around the world. Which one
will it be?
Also I just found that some US time zone names changed in 1988...
> Now how should the application store the time? Presumably it
> goes in as 12:00 noon EDT ("Eastern Daylight Time") because,
> according to current law, daylight saving time goes into effect
> in March. But between now (when I enter the appointment)
> and then (my lunch date), our esteemed legislators, in their
> wisdom, change daylight saving time back to its April onset.
> That is, on April 1, 2012, standard time (i.e., not daylight time)
> is in effect.
>
> For when should my application display my appointment?
> For 12:00 noon (EST), or for 11:00 AM (EST) (which is the
> 12:00 noon EDT that the application originally stored)?
>
> If the application says 11:00 AM, I go to lunch at 11:00 AM,
> wait around until 11:30 AM, leave in a huff because my friend
> stood me up, get mad at my (former) friend, and never speak
> to him again. (My friend comes at noon, gets mad at me
> for standing him up, and so on...)
>
> But actually my friend is right. We made a date for lunch at
> noon on April 1.
Fortunately this problem has already been solved by the Olson DB: store it
as "2012 April 1st 12:00 America/New_York". The "America/New_York" part is
the Olson-DB name of the time zone - those names are usually one of the
biggest cities inside the zone. You could also use "US/Eastern" if you feel
lucky.
Then use the Olson DB code to convert the stored data into system time and
make sure you receive the updates to the database (you usually do on Linux
and most other Unixoid systems).
If your program is under GPL you can use this code:
http://silmor.de/77
Konrad
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 198 bytes
Desc: This is a digitally signed message part.
Url : http://lists.qt-project.org/pipermail/qt-interest-old/attachments/20110330/c313abbd/attachment.bin
More information about the Qt-interest-old
mailing list