PDA

View Full Version : QTimeZone



QPlace
23rd July 2009, 17:19
I am looking for a way to display selection of timezones. Googling "qt timezone" I found out that there is a QTimeZone in QTopia. I am not familiar with QTopia and did not even find out on qtsoftware if it is available for download. My questions are:

Is there support of timezones in Qt (I feel that I know the answer:), but may be I overlooked smth)
Is it possible to use this QTimeZone somehow in standard Qt development and, if yes, then where I can get this class?

nish
24th July 2009, 02:19
QTimeZone is a linux only class (hence only in Qtopia).. if you take a look at its source code.. it uses the zoneInfo database found on every linux machine...

I read somewhere that nokia willl port some classes from qtopia to Qt ... and timezone will be the most important..

for now Qt dont have support for timezones... you have to do it manually.

QPlace
24th July 2009, 12:32
Thank you for the clarification. Boost has very nice support for tzones, but also with the cvs file as a timezone repository. By far the best I encountered was .net framework where you can just traverse through the collection of timezones. How strange that such an important part of GUI interface support was left out of core Qt.

Netheril
20th May 2011, 14:57
Hi People,

I've been looking for getting the Timezone with Qt, and the only thing that I've found was the issue: QTBUG-71 in the bugreports at qt.nokia. the URL is: http://bugreports.qt.nokia.com/browse/QTBUG-71.

I'll copy the manual solution here:


// determine how far off of UTC we are
QDateTime now = QDateTime::currentDateTime();

// check if we need to account for UTC being tomorrow relative to us
int dayOffset = 0;
if( now.date() < now.toUTC().date() )
{
dayOffset = 24;
}

int timezone = now.time().hour() - ( now.toUTC().time().hour() + dayOffset );
Regards.

TorAn
20th May 2011, 15:03
I strongly recommend boost::datetime lib. The only word of caution is that the timezone database is valid only for about last 6 or so years.