~nik90/ubuntu-clock-app/custom-swipe-delete

« back to all changes in this revision

Viewing changes to backend/modules/Timezone/zone.cpp

  • Committer: Michael Zanetti
  • Date: 2014-07-13 14:45:39 UTC
  • mto: (20.1.4 10-world-clocks)
  • mto: This revision was merged to the branch mainline in revision 23.
  • Revision ID: michael.zanetti@canonical.com-20140713144539-q204tshktb06fjxo
fix, explain the Zone class

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
1
#include "zone.h"
2
2
 
 
3
// This is the constructor
 
4
// It will only be called once, when a new "Zone" object is created.
 
5
// If you read currentDateTime in here, it'll stick to the time when the
 
6
// Object is created and not reflect the current time when getLocalTime is called.
3
7
Zone::Zone(QObject *parent) :
4
8
    QObject(parent),
5
 
    m_time(QDateTime::currentDateTime())
 
9
    m_time(QDateTime::currentDateTime()) // delete this
6
10
{
7
11
 
8
12
}
11
15
 
12
16
}
13
17
 
14
 
QDateTime Zone::getLocalTime(QByteArray *timezoneID) {
15
 
    // Create a QTimeZone object and initiate it with the timezone ID provided
16
 
    QTimeZone zone = QTimeZone(*timezoneID);
17
 
 
18
 
    // Convert the QDateTime object to the timezone provided
19
 
    m_time.toTimeZone(zone);
20
 
 
21
 
    qDebug() << m_time;
22
 
 
23
 
    return m_time;
 
18
//QDateTime Zone::getLocalTime(QByteArray *timezoneID) {
 
19
//    // Create a QTimeZone object and initiate it with the timezone ID provided
 
20
//    QTimeZone zone = QTimeZone(*timezoneID);
 
21
 
 
22
//    // Convert the QDateTime object to the timezone provided
 
23
//    m_time.toTimeZone(zone);
 
24
 
 
25
//    qDebug() << m_time;
 
26
 
 
27
//    return m_time;
 
28
//}
 
29
 
 
30
// In my opinion this should work but it doesn't will ask some other people
 
31
// and report a bug if m suspicion turns out to be true.
 
32
QDateTime Zone::getLocalTime(const QByteArray &timeZoneId) const
 
33
{
 
34
    QTimeZone zone(timeZoneId);
 
35
    return QDateTime::currentDateTime().toTimeZone(zone);
 
36
}
 
37
 
 
38
// So. let's use this instead:
 
39
QString Zone::getCurrentTimeString(const QByteArray &timeZoneId) const
 
40
{
 
41
    return getLocalTime(timeZoneId).toString();
24
42
}