Results 1 to 5 of 5

Thread: QTimeZone

  1. #1
    Join Date
    Jul 2007
    Posts
    121
    Thanks
    38
    Thanked 3 Times in 3 Posts
    Qt products
    Qt4
    Platforms
    Windows

    Default QTimeZone

    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?

  2. #2
    Join Date
    Jun 2007
    Location
    India
    Posts
    1,042
    Thanks
    8
    Thanked 133 Times in 128 Posts
    Qt products
    Qt3 Qt4 Qt/Embedded
    Platforms
    MacOS X Unix/X11 Windows

    Default Re: QTimeZone

    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.

  3. The following user says thank you to nish for this useful post:

    QPlace (24th July 2009)

  4. #3
    Join Date
    Jul 2007
    Posts
    121
    Thanks
    38
    Thanked 3 Times in 3 Posts
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: QTimeZone

    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.

  5. #4
    Join Date
    Apr 2010
    Posts
    9
    Thanked 3 Times in 1 Post
    Qt products
    Qt4 Qt/Embedded
    Platforms
    MacOS X Unix/X11 Windows

    Default Re: QTimeZone

    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:

    Qt Code:
    1. // determine how far off of UTC we are
    2. QDateTime now = QDateTime::currentDateTime();
    3.  
    4. // check if we need to account for UTC being tomorrow relative to us
    5. int dayOffset = 0;
    6. if( now.date() < now.toUTC().date() )
    7. {
    8. dayOffset = 24;
    9. }
    10.  
    11. int timezone = now.time().hour() - ( now.toUTC().time().hour() + dayOffset );
    To copy to clipboard, switch view to plain text mode 
    Regards.
    Last edited by Netheril; 20th May 2011 at 15:02.

  6. #5
    Join Date
    Nov 2009
    Location
    US, Midwest
    Posts
    215
    Thanks
    62
    Thanked 4 Times in 4 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: QTimeZone

    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.

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Digia, Qt and their respective logos are trademarks of Digia Plc in Finland and/or other countries worldwide.