Thursday, 15 April 2010

How to find out the UTC offset of my current location in Qt 5.1? -



How to find out the UTC offset of my current location in Qt 5.1? -

i had write function returning offset utc of current location. greatest surprize, next code returned 0:

const qdatetime = qdatetime::currentdatetime(); homecoming now.toutc().secsto(now) / 60;

this not easy looks, because qdatetime::secsto calculates offset after converting utc. found reply here, didn't conversion string , back. solution is:

const qdatetime datetime1 = qdatetime::currentdatetime(); const qdatetime datetime2 = qdatetime(datetime1.date(), datetime1.time(), qt::utc); homecoming datetime1.secsto(datetime2) / 60;

qt utc timezoneoffset qdatetime

No comments:

Post a Comment