[Interest] Working with QDateTime's timezone information
Jan Kundrát
jkt at flaska.net
Tue Jun 12 17:48:14 CEST 2012
Hi Thiago,
On 06/12/12 17:31, Thiago Macieira wrote:
> There isn't a way. The QTimezone feature has been pending for years.
Right, it seems that the utcOffset won't survive a serialization to
QDataStream (using Qt 4.8.1):
QDateTime blah = QDateTime::fromString("1997-07-16T19:20:30+09:45",
Qt::ISODate);
qDebug() << blah << blah.toLocalTime() << blah.toUTC();
QByteArray buf;
QDataStream writing(&buf, QIODevice::ReadWrite);
writing << blah;
QDataStream reading(&buf, QIODevice::ReadOnly);
QDateTime anotherDate;
reading >> anotherDate;
qDebug() << anotherDate << anotherDate.toLocalTime() <<
anotherDate.toUTC();
$ TZ=Europe/Prague ./myapp
QDateTime("Wed Jul 16 19:20:30 1997") QDateTime("Wed Jul 16 19:20:30
1997") QDateTime("Wed Jul 16 09:35:30 1997")
QDateTime("Wed Jul 16 19:20:30 1997") QDateTime("Wed Jul 16 19:20:30
1997") QDateTime("Wed Jul 16 19:20:30 1997")
Weird thing is that the output doesn't change regardless if I set TZ to
America/Chicago, Europe/Prague or Asia/Tehran. Weird, and a bug, I guess.
Looks like I'm really out of luck here.
> You're entirely on your own if you touch the internals. Behaviour might change
> in any release.
Fair enough. The better question is then "any chances of making these
two functions public in a 4.x release"?
With kind regards,
Jan
--
Trojita, a fast e-mail client -- http://trojita.flaska.net/
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 262 bytes
Desc: OpenPGP digital signature
URL: <http://lists.qt-project.org/pipermail/interest/attachments/20120612/9fa80a3a/attachment.sig>
More information about the Interest
mailing list