[Qt-interest] QDateTime daylight saving parsing time offset

Paul Drummond paul.drummond at iode.co.uk
Wed Mar 30 14:52:14 CEST 2011


Hi,

For a project I am working on I get a date time string in the following format:

Tue, 29 Mar 2011 09:00:00 +0100

Unless I'm mistaken (which happens a lot with me when working with
date/time conversions!) the above string is in UTC format. When
converted to a QDateTime the time should be 10:00:00, right?  Or have
I got that completely wrong?  I hate date/time hacking :-(

If I try to convert this to a QDateTime using
QDateTime::fromString("ddd, dd MM yyyy HH:mm:ss") it doesn't work
because of the time offset.

In Java you can specify the offset using the "z" format specifier but
there is no format specifier for timezone in QDateTime unless I am
mistaken?

I know QDateTime is supposed to handle daylight savings internally but
I'm still not sure what to do with the +0100.  Is it okay to just
remove it from the string?

Thank you,
Paul Drummond



More information about the Qt-interest-old mailing list