[Interest] QDateTime uses different time zone offset prior to UNIX epoch?

Patrick Stinson patrickkidd at gmail.com
Fri Sep 20 23:20:40 CEST 2019


QDateTime initializes with a different time zone offset when passed a QDate before versus after Jan 1 1970. The following line says it all:

QDateTime(QDate(1969, 10, 14)).offsetFromUtc() != QDateTime(QDate(1970, 10, 14)).offsetFromUtc()

It seems to me that the offsets for these two QDateTime objects should be equal. Otherwise, this makes initializing and storing dates difficult.

I assume this is intentional. What is the rationale for this design decision? Is there a workaround?

Cheers,
-Patrick

P.S. Here is my original inconclusive entry in the qt forum:
https://forum.qt.io/topic/107005/qdatetime-uses-different-time-zone-offset-prior-to-unix-epoch/6 <https://forum.qt.io/topic/107005/qdatetime-uses-different-time-zone-offset-prior-to-unix-epoch/6>



-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.qt-project.org/pipermail/interest/attachments/20190920/c346e828/attachment.html>


More information about the Interest mailing list