Results 1 to 2 of 2

Thread: Worldtimeclock and timezones issue

  1. #1
    Join Date
    Sep 2012
    Posts
    31
    Thanks
    15
    Qt products
    Qt4
    Platforms
    Windows

    Default Worldtimeclock and timezones issue

    Hi, I have a project that involves making a clock plugin using Qt. I utilized the basic clock example from Qt where you put the offset hours to display the times of other countries namely USA and India. My current system time is the Philippines. Here is the code:

    void ClockPanel::setTimer()
    {

    QTimer *timer = new QTimer(ui->digital_clock);
    connect(timer,SIGNAL(timeout()),this,SLOT(displayD ate()));
    timer->start(1000);

    displayDate();


    }
    void ClockPanel::displayDate()
    {

    QDateTime date_time = QDateTime::currentDateTime();
    date_time.addSecs(hoursOffset);
    QString dateString = date_time.toString("dddd MMM d yy");

    QTime time = QTime::currentTime();
    time = time.addSecs(hoursOffset);
    QString time_in_text = time.toString("hh mm ap");


    if((time.second()%2) == 0)
    {
    time_in_text[2]=':';
    }
    ui->digital_clock->display(time_in_text);

    ui->label_date->setText(dateString);

    }



    i have a function that sets the hoursOffset to get the USA and India times. Problem is I later realized that if the program is used with another time zone/country, the time displayed will be wrong. How do I go about making the program flexible if it is used in another timezone. The times I display are PHIL, USA and India.

  2. #2
    Join Date
    Mar 2008
    Location
    Kraków, Poland
    Posts
    1,536
    Thanked 284 Times in 279 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: Worldtimeclock and timezones issue


Similar Threads

  1. How to get the List of TimeZones in qt
    By pradeepreddyg95 in forum Qt Programming
    Replies: 1
    Last Post: 5th October 2012, 11:34
  2. Qt 4.7.1 VNC issue?
    By djstava in forum Newbie
    Replies: 0
    Last Post: 14th March 2011, 04:34
  3. XML issue
    By jbpvr in forum Qt Programming
    Replies: 1
    Last Post: 25th August 2008, 14:01
  4. UI issue.
    By kaushal_gaurav in forum Qt Programming
    Replies: 2
    Last Post: 13th August 2008, 12:41
  5. ui_....h issue
    By stevey in forum Qt Programming
    Replies: 5
    Last Post: 27th November 2007, 05:54

Tags for this Thread

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.