← Back to team overview

ubuntu-touch-coreapps-reviewers team mailing list archive

[Merge] lp:~gang65/ubuntu-clock-app/ubuntu-clock-mainclock-runtime-timezone-fix into lp:ubuntu-clock-app

 

Bartosz Kosiorek has proposed merging lp:~gang65/ubuntu-clock-app/ubuntu-clock-mainclock-runtime-timezone-fix into lp:ubuntu-clock-app.

Commit message:
* Fix wrong date and time after changing timezone while clock running (LP: #1480546)
* Fix Daylight Saving Time issues (LP: #1437805)

Requested reviews:
  Ubuntu Clock Developers (ubuntu-clock-dev)
Related bugs:
  Bug #1437805 in Ubuntu Clock App: "Time didn't change itself after Daylight Saving Time started in Edinburgh"
  https://bugs.launchpad.net/ubuntu-clock-app/+bug/1437805
  Bug #1447441 in Ubuntu Clock App: "Clock-App: Wrong time is displayed with digit display mode, if change timezone when app launched. "
  https://bugs.launchpad.net/ubuntu-clock-app/+bug/1447441

For more details, see:
https://code.launchpad.net/~gang65/ubuntu-clock-app/ubuntu-clock-mainclock-runtime-timezone-fix/+merge/271033

* Fix wrong date and time after changing timezone while clock running (LP: #1480546)
* Fix Daylight Saving Time issues (LP: #1437805)
-- 
Your team Ubuntu Clock Developers is requested to review the proposed merge of lp:~gang65/ubuntu-clock-app/ubuntu-clock-mainclock-runtime-timezone-fix into lp:ubuntu-clock-app.
=== modified file 'app/MainPage.qml'
--- app/MainPage.qml	2015-09-11 13:29:07 +0000
+++ app/MainPage.qml	2015-09-14 21:26:19 +0000
@@ -31,7 +31,10 @@
     objectName: "mainPage"
 
     // Property to keep track of the clock time
-    property var clockTime: new Date()
+    property var clockAnalogTimeInMain
+    property var clockTimeInMain
+
+    property var clockDateInMain
 
     // Property to keep track of an app cold start status
     property alias isColdStart: clockPage.isColdStart
@@ -43,7 +46,7 @@
     property var alarmModel
 
     flickable: null
-    bottomEdgeTitle: _mainPage.visible ? alarmUtils.set_bottom_edge_title(alarmModel, clockTime)
+    bottomEdgeTitle: _mainPage.visible ? alarmUtils.set_bottom_edge_title(alarmModel, clockTimeInMain)
                                        : i18n.tr("No active alarms")
 
     Component.onCompleted: {
@@ -64,7 +67,9 @@
         id: navigationModel
         ClockPage {
             id: clockPage
-            clockTime: _mainPage.clockTime
+            clockAnalogTimeInClockPage: _mainPage.clockAnalogTimeInMain
+            clockTimeInClockPage: _mainPage.clockTimeInMain
+            clockDateInClockPage: _mainPage.clockDateInMain
             width: clockApp.width
             height: listview.height
         }

=== modified file 'app/alarm/AlarmPage.qml'
--- app/alarm/AlarmPage.qml	2015-08-23 00:53:57 +0000
+++ app/alarm/AlarmPage.qml	2015-09-14 21:26:19 +0000
@@ -120,7 +120,7 @@
         id: alarmListView
         model: alarmModel
         anchors.fill: parent
-        localTime: clockTime
+        localTime: clockTimeInMain
     }
 
     Loader {

=== modified file 'app/clock/ClockPage.qml'
--- app/clock/ClockPage.qml	2015-08-26 23:30:10 +0000
+++ app/clock/ClockPage.qml	2015-09-14 21:26:19 +0000
@@ -32,7 +32,9 @@
     property alias isDigital: clock.isDigital
 
     // Property to keep track of the clock time
-    property var clockTime: new Date()
+    property var clockAnalogTimeInClockPage
+    property var clockTimeInClockPage
+    property var clockDateInClockPage
 
     // Property to keep track of app cold start status
     property alias isColdStart: clock.isColdStart
@@ -106,7 +108,7 @@
              If Clock App is brought from background after more than 30 mins,
              query the user location to ensure it is up to date.
             */
-            if(applicationState
+            /*if(applicationState
                     && Math.abs(clock.analogTime - geoposition.lastUpdate) > 1800000) {
                 if(!geoposition.active)
                     geoposition.start()
@@ -114,7 +116,7 @@
 
             else if (!applicationState) {
                 geoposition.lastUpdate = clock.analogTime
-            }
+            }*/
         }
     }
 
@@ -164,7 +166,9 @@
             geoposition.lastUpdate = analogTime
         }
 
-        analogTime: clockTime
+        analogTime: clockAnalogTimeInClockPage
+        localizedTimeString: clockTimeInClockPage
+        localizedDateString: clockDateInClockPage
 
         anchors {
             verticalCenter: parent.top
@@ -182,7 +186,7 @@
             horizontalCenter: parent.horizontalCenter
         }
 
-        text: clock.analogTime.toLocaleDateString()
+        text: clock.localizedDateString
 
         opacity: 0
         color: locationRow.visible ? Theme.palette.normal.baseText : UbuntuColors.midAubergine

=== modified file 'app/components/AnalogMode.qml'
--- app/components/AnalogMode.qml	2015-08-14 05:34:49 +0000
+++ app/components/AnalogMode.qml	2015-09-14 21:26:19 +0000
@@ -53,7 +53,7 @@
         smooth: true
         source: "../graphics/Hour_Hand.png"
         fillMode: Image.PreserveAspectFit
-        rotation: (analogTime.getHours() * 30) + (analogTime.getMinutes() / 2)
+        rotation: (parseInt(analogTime.split(":")[0]) * 30) + (parseInt(analogTime.split(":")[1]) / 2)
     }
 
     Image {
@@ -65,7 +65,7 @@
         smooth: true
         source: "../graphics/Minute_Hand.png"
         fillMode: Image.PreserveAspectFit
-        rotation: (analogTime.getMinutes() * 6) + (analogTime.getSeconds() / 10)
+        rotation: (parseInt(analogTime.split(":")[1]) * 6) + (parseInt(analogTime.split(":")[2]) / 10)
     }
 
     Image {
@@ -78,7 +78,7 @@
         visible: showSeconds
         source: "../graphics/Second_Hand.png"
         fillMode: Image.PreserveAspectFit
-        rotation: visible ? analogTime.getSeconds() * 6 : 0
+        rotation: visible ? parseInt(analogTime.split(":")[2]) * 6 : 0
     }
 
     Image {

=== modified file 'app/components/Clock.qml'
--- app/components/Clock.qml	2015-08-14 05:34:49 +0000
+++ app/components/Clock.qml	2015-09-14 21:26:19 +0000
@@ -43,9 +43,8 @@
 
     // Property to set the analog time
     property var analogTime
-
-    // Property to set the digital time label
-    property string time: Qt.formatTime(analogTime)
+    property var localizedTimeString
+    property var localizedDateString
 
     // Property to keep track of the clock mode
     property alias isDigital: clockModeFlipable.isDigital

=== modified file 'app/components/DigitalMode.qml'
--- app/components/DigitalMode.qml	2015-08-14 05:34:49 +0000
+++ app/components/DigitalMode.qml	2015-09-14 21:26:19 +0000
@@ -55,20 +55,7 @@
 
         color: UbuntuColors.midAubergine
         font.pixelSize: units.dp(1)
-        text: {
-            if (time.search(Qt.locale().amText) !== -1) {
-                // 12 hour format detected with the localised AM text
-                return time.replace(Qt.locale().amText, "").trim()
-            }
-            else if (time.search(Qt.locale().pmText) !== -1) {
-                // 12 hour format detected with the localised PM text
-                return time.replace(Qt.locale().pmText, "").trim()
-            }
-            else {
-                // 24-hour format detected, return full time string
-                return time
-            }
-        }
+        text: localizedTimeString.split(" ")[0]
     }
 
     Label {
@@ -80,20 +67,7 @@
         color: UbuntuColors.midAubergine
         font.pixelSize: units.dp(1)
         visible: text !== ""
-        text: {
-            if (time.search(Qt.locale().amText) !== -1) {
-                // 12 hour format detected with the localised AM text
-                return Qt.locale().amText
-            }
-            else if (time.search(Qt.locale().pmText) !== -1) {
-                // 12 hour format detected with the localised PM text
-                return Qt.locale().pmText
-            }
-            else {
-                // 24-hour format detected
-                return ""
-            }
-        }
+        text: localizedTimeString.split(" ").length > 1 ? localizedTimeString.split(" ")[1] : ""
     }
 
     SequentialAnimation {

=== modified file 'app/ubuntu-clock-app.qml'
--- app/ubuntu-clock-app.qml	2015-08-26 23:35:50 +0000
+++ app/ubuntu-clock-app.qml	2015-09-14 21:26:19 +0000
@@ -143,16 +143,11 @@
 
             alarmModel: alarmModelLoader.item
             bottomEdgeEnabled: alarmModelLoader.status === Loader.Ready && alarmModelLoader.item.isReady && isClockPage
-            clockTime: new Date
-                       (
-                           localTimeSource.localDateString.split(":")[0],
-                           localTimeSource.localDateString.split(":")[1]-1,
-                           localTimeSource.localDateString.split(":")[2],
-                           localTimeSource.localTimeString.split(":")[0],
-                           localTimeSource.localTimeString.split(":")[1],
-                           localTimeSource.localTimeString.split(":")[2],
-                           localTimeSource.localTimeString.split(":")[3]
-                       )
+
+            clockAnalogTimeInMain: localTimeSource.localAnalogTimeString
+            clockTimeInMain: localTimeSource.localTimeString
+            clockDateInMain: localTimeSource.localDateString
+
         }
     }
 }

=== modified file 'app/worldclock/UserWorldCityDelegate.qml'
--- app/worldclock/UserWorldCityDelegate.qml	2015-08-29 01:45:19 +0000
+++ app/worldclock/UserWorldCityDelegate.qml	2015-09-14 21:26:19 +0000
@@ -81,6 +81,7 @@
                  into a time object here.
                 */
             function getTime(timeString) {
+
                 var properTime = new Date()
                 properTime.setHours(timeString.split(":")[0])
                 properTime.setMinutes(timeString.split(":")[1])
@@ -93,7 +94,8 @@
             innerCircleWidth: units.gu(5)
             width: units.gu(7)
 
-            analogTime: getTime(model.localTime)
+            analogTime: model.localAnalogTime
+            localizedTimeString: model.localTime
 
             anchors.centerIn: parent
 

=== modified file 'backend/modules/WorldClock/datetime.cpp'
--- backend/modules/WorldClock/datetime.cpp	2015-08-25 16:04:13 +0000
+++ backend/modules/WorldClock/datetime.cpp	2015-09-14 21:26:19 +0000
@@ -24,8 +24,10 @@
     QObject(parent)
 {
     // Initialise the date and time at start rather than wait for a sec to do so.
-    m_localtime = QDateTime::currentDateTime().toString("hh:mm:ss:z");
-    m_localdate = QDateTime::currentDateTime().toString("yyyy:M:d");
+
+    m_localanalogtime = QTime::currentTime().toString("hh:mm:ss");
+    m_localtime = QTime::currentTime().toString(Qt::DefaultLocaleShortDate);
+    m_localdate = QDate::currentDate().toString(Qt::DefaultLocaleLongDate);
 
     m_updateTimer.setInterval(1000);
     connect(&m_updateTimer, &QTimer::timeout, this, &DateTime::update);
@@ -33,6 +35,11 @@
     m_updateTimer.start();
 }
 
+QString DateTime::localAnalogTimeString() const
+{
+    return m_localanalogtime;
+}
+
 QString DateTime::localTimeString() const
 {
     return m_localtime;
@@ -45,10 +52,13 @@
 
 void DateTime::update()
 {
-    m_localtime = QDateTime::currentDateTime().toString("hh:mm:ss:z");
+    m_localanalogtime = QTime::currentTime().toString("hh:mm:ss");
+    emit localAnalogTimeStringChanged();
+
+    m_localtime = QTime::currentTime().toString(Qt::DefaultLocaleShortDate);
     emit localTimeStringChanged();
 
-    m_localdate = QDateTime::currentDateTime().toString("yyyy:M:d");
+    m_localdate = QDate::currentDate().toString(Qt::DefaultLocaleLongDate);
     emit localDateStringChanged();
 }
 

=== modified file 'backend/modules/WorldClock/datetime.h'
--- backend/modules/WorldClock/datetime.h	2015-08-25 16:04:13 +0000
+++ backend/modules/WorldClock/datetime.h	2015-09-14 21:26:19 +0000
@@ -42,11 +42,16 @@
     */
 
     // Property to determine the local time string (format hh:mm:ss)
+    Q_PROPERTY(QString localAnalogTimeString
+               READ localAnalogTimeString
+               NOTIFY localAnalogTimeStringChanged)
+
+    // Property to determine the local time string (format Qt::DefaultLocaleShortDate)
     Q_PROPERTY(QString localTimeString
                READ localTimeString
                NOTIFY localTimeStringChanged)
 
-    // Property to determine the local date string (format yyyy:M:d)
+    // Property to determine the local date string (format Qt::DefaultLocaleLongDate)
     Q_PROPERTY(QString localDateString
                READ localDateString
                NOTIFY localDateStringChanged)
@@ -59,6 +64,8 @@
     // Function to set the update interval
     void setUpdateInterval(int updateInterval);
 
+    QString localAnalogTimeString() const;
+
     // Function to read the local time string
     QString localTimeString() const;
 
@@ -66,6 +73,9 @@
     QString localDateString() const;
 
 signals:
+
+    void localAnalogTimeStringChanged();
+
     // Signal to notify the local time string change to QML
     void localTimeStringChanged();
 
@@ -84,6 +94,7 @@
 
 private:
     // Private copies of the local time and date
+    QString m_localanalogtime;
     QString m_localtime;
     QString m_localdate;
 

=== modified file 'backend/modules/WorldClock/timezonemodel.cpp'
--- backend/modules/WorldClock/timezonemodel.cpp	2015-08-25 16:11:38 +0000
+++ backend/modules/WorldClock/timezonemodel.cpp	2015-09-14 21:26:19 +0000
@@ -82,12 +82,14 @@
     QDateTime worldCityTime(currentDateTime.toTimeZone(m_citiesData.at(row).timeZone));
 
     switch (role) {
-    case RoleTimeString:
+    case RoleAnalogTimeString:
         /*
          FIXME: Until https://bugreports.qt-project.org/browse/QTBUG-40275
          is fixed, we will have to return a string.
         */
-        return worldCityTime.toString("hh:mm");
+        return worldCityTime.toString("hh:mm:ss");
+    case RoleTimeString:
+        return worldCityTime.time().toString(Qt::DefaultLocaleShortDate);
     case RoleTimeTo:
         /*
          FIXME: Workaround for currentDateTime.secsTo(worldCityTime) which returns
@@ -110,6 +112,7 @@
     roles.insert(RoleCityName, "cityName");
     roles.insert(RoleCountryName, "countryName");
     roles.insert(RoleTimeZoneId, "timezoneID");
+    roles.insert(RoleAnalogTimeString, "localAnalogTime");
     roles.insert(RoleTimeString, "localTime");
     roles.insert(RoleTimeTo, "timeTo");
     return roles;
@@ -150,7 +153,7 @@
     QModelIndex startIndex = index(0);
     QModelIndex endIndex = index(m_citiesData.count() - 1);
     QVector<int> roles;
-    roles << RoleTimeString << RoleTimeTo;
+    roles << RoleTimeString << RoleAnalogTimeString << RoleTimeTo;
     emit dataChanged(startIndex, endIndex, roles);
 }
 

=== modified file 'backend/modules/WorldClock/timezonemodel.h'
--- backend/modules/WorldClock/timezonemodel.h	2015-08-25 16:11:38 +0000
+++ backend/modules/WorldClock/timezonemodel.h	2015-09-14 21:26:19 +0000
@@ -53,6 +53,7 @@
         RoleCityName,
         RoleCountryName,
         RoleTimeZoneId,
+        RoleAnalogTimeString,
         RoleTimeString,
         RoleTimeTo,
     };

=== modified file 'debian/changelog'
--- debian/changelog	2015-09-12 11:29:50 +0000
+++ debian/changelog	2015-09-14 21:26:19 +0000
@@ -12,7 +12,9 @@
   * Fix wrong time after changing timezone, when stopwatch is running (LP: #1491024)
   * Reduce size of images (with tinypng.com) to decrease click image size (LP: #1492057)
   * Fix Czech Republic country name (LP: #1494004) 
+  * Fix wrong date and time after changing timezone while clock running (LP: #1480546)
   * Fix stopwatch issue appering during changing timezone during runtime (LP: #1493358)
+  * Fix Daylight Saving Time issues (LP: #1437805)
 
  -- Bartosz Kosiorek <gang65@xxxxxxxxxxxxxx>  Wed, 02 Sep 2015 15:16:29 +0200
 


References