qdatetime

How to force QDateTime::fromString to read UTC time.

I have some input containing UTC time formatted according to iso8601. I try to parse it using QDateTime: const char* s = "2009-11-05T03:54:00"; d.setTimeSpec(Qt::UTC); d = QDateTime::fromString(s, Qt::ISODate); Qt::TimeSpec ts = d.timeSpec(); When this fragment ends, ts is set to localTime and d contains 3 hours 54 minutes. Do...

Qt QDateTime nanoseconds from 1/1/1970

I am about to read data From a File which has stored it's time in nanoseconds from 1/1/1970. My problem is I want to read it to a QDateTime object, but it simply does not work as I want it to and the Qt Documentation did not help me either. Note: milliseconds raster is enough for my purposes Here my current approach: void setDateTime(q...

Preferred way to handle UTC/local time in Qt's QDateTime?

I have some code where I write a QDateTime to a file... someQDateTime.toUTC().toString(Qt::ISODate) and when I read it back using QDateTime::fromString(), I get the time interpreted as being in the system's time zone. I can manually append "Z" to the string when I write it out, or use setTimeSpec() after I read it, and then everything...