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

Proposed by Bartosz Kosiorek
Status: Merged
Approved by: Nekhelesh Ramananthan
Approved revision: 417
Merged at revision: 396
Proposed branch: lp://qastaging/~gang65/ubuntu-clock-app/ubuntu-clock-mainclock-runtime-timezone-fix
Merge into: lp://qastaging/ubuntu-clock-app
Diff against target: 820 lines (+227/-158)
23 files modified
README.unittest (+3/-3)
app/MainPage.qml (+12/-4)
app/alarm/AlarmPage.qml (+12/-1)
app/alarm/AlarmSettingsPage.qml (+1/-20)
app/alarm/AlarmUtils.qml (+11/-1)
app/alarm/EditAlarmPage.qml (+6/-6)
app/clock/ClockPage.qml (+35/-11)
app/components/AnalogMode.qml (+17/-3)
app/components/Clock.qml (+8/-5)
app/components/DigitalMode.qml (+7/-7)
app/ubuntu-clock-app.qml (+9/-16)
app/worldclock/UserWorldCityDelegate.qml (+2/-16)
app/worldclock/WorldCityList.qml (+1/-1)
backend/modules/WorldClock/datetime.cpp (+25/-15)
backend/modules/WorldClock/datetime.h (+26/-15)
backend/modules/WorldClock/timezonemodel.cpp (+9/-6)
backend/modules/WorldClock/timezonemodel.h (+3/-2)
debian/changelog (+3/-0)
tests/manual/2014.com.ubuntu.clock:clock-tests/jobs/worldcity.pxu (+27/-0)
tests/unit/CMakeLists.txt (+2/-2)
tests/unit/MockClockApp.qml (+3/-10)
tests/unit/tst_alarm.qml (+0/-11)
tests/unit/tst_alarmUtils.qml (+5/-3)
To merge this branch: bzr merge lp://qastaging/~gang65/ubuntu-clock-app/ubuntu-clock-mainclock-runtime-timezone-fix
Reviewer Review Type Date Requested Status
Nekhelesh Ramananthan Approve
Ubuntu Phone Apps Jenkins Bot continuous-integration Approve
Review via email: mp+271033@code.qastaging.launchpad.net

Commit message

* Fix wrong date and time after changing timezone while clock running (LP: #1447441)

Description of the change

* Fix wrong date and time after changing timezone while clock running (LP: #1447441)

TODO:
Test manually Daylight saving time changing.
List of all switches from/to DST is available at:
https://en.wikipedia.org/wiki/Daylight_saving_time_by_country

To post a comment you must log in.
Revision history for this message
Nekhelesh Ramananthan (nik90) wrote :
Download full text (3.9 KiB)

Preliminary Code Review
-----------------------

1. This MP changes some core stuff of the clock app and has potential to introduce regressions. And so we need to make sure that the changes in this MP are the ones which are absolutely necessary and only fixes one issue. With that in mind, please revert changes made to Stopwatch_placeholder.svg, worldclock_placeholder.svg. This way if we have to revert this MP after it lands in trunk, we don't potentially lose out other improvements that were bundled along.

2. I see two variables clockTimeInMain and clockAnalogTimeInMain. It would be better if you could rename it as analogClockTime and digitalClockTime and drop the "Main" postfix.

3. Why is there a need for 2 variable names clockAnalogTimeInMain and clockAnalogTimeinClockPage? We're essentially passing clockAnalogTimeInMain as an argument to the clock page. Perhaps the variable in the clock page can be named as analogTime and digitalTime. The "InMain" and "InClockPage" seems a bit messy in my opinion.

4. As mentioned during our chat, I would like to see a comment above rotation: (parseInt(analogTime.split(":")[1]) * 6) + (parseInt(analogTime.split(":")[2]) / 10) explaining the input string and how it is split up into mulitple strings for better understandability.

5. I am bit afraid that we're losing out on important code below,

- 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]

The replace() function was used to fix bugs like https://bugs.launchpad.net/ubuntu-clock-app/+bug/1458808. Please again provide a comment above + text: localizedTimeString.split(" ")[0] with the input string format and what is being split. And please test this in the chineese locale to see if it works correctly.

6. In the following code below,

- subText: {
- /*
- FIXME: When the upstream QT bug at
- https://bugreports.qt-project.org/browse/QTBUG-40275 is fixed
- it will be possible to receive a datetime object directly
- instead of using this hack.
- */
- var localTime = new Date
- (
- localTimeSource.localDateString.split(":")[0],
- localTimeSource.localDateString.split(":")[1]-1,
- localTimeSource.localDateString.split(":")[2],
- localTimeSource.localTimeString.split(":")[0],
- localTimeSource.localTimeString.split(":")[1],
- localTimeSource.loca...

Read more...

review: Needs Fixing (preliminary code review)
Revision history for this message
Nekhelesh Ramananthan (nik90) wrote :

Also requires manual tests as we are fixing multiple critical bugs. Please write manual tests for *each* critical bug fixed. Ideally you should start with writing tests before fixing the bug as we follow Test Driven Development (TDD) ;)

review: Needs Fixing (preliminary code review)
Revision history for this message
Ubuntu Phone Apps Jenkins Bot (ubuntu-phone-apps-jenkins-bot) wrote :
review: Approve (continuous-integration)
Revision history for this message
Ubuntu Phone Apps Jenkins Bot (ubuntu-phone-apps-jenkins-bot) wrote :
review: Approve (continuous-integration)
Revision history for this message
Ubuntu Phone Apps Jenkins Bot (ubuntu-phone-apps-jenkins-bot) wrote :
review: Approve (continuous-integration)
Revision history for this message
Nekhelesh Ramananthan (nik90) wrote :
Download full text (5.8 KiB)

A couples of fixed needed,

1. In the Settings Page, the time & date are shown as undefined.

2. The alarm function breaks (like in trunk) when editing alarms. But I guess we can tackle this in more detail in the next MP. So that's fine for now.

3. I would like a dedicated localized datetime property to be used here instead of localTimeString + localDateString analogy. Can you introduce a property in the c++ class called localizedDateTimeString and use that instead.

- subText: {
- /*
- FIXME: When the upstream QT bug at
- https://bugreports.qt-project.org/browse/QTBUG-40275 is fixed
- it will be possible to receive a datetime object directly
- instead of using this hack.
- */
- var localTime = 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]
- )
- return localTime.toLocaleString()
- }
-
+ subText: localTimeSource.localTimeString + " " + localTimeSource.localDateString

4. This code has a logical flaw. For instance let's say the local user date time (in Poland) is 17th September 2015, 00:30. If I change to London, the local date time should be 16th September 2015, 23:30. Notice that the date has changed from 17th to 16th september. However in the code below, the date is obtained using the javascript date object which doesn't work well with timezones and may not be aware of this change leading to bugs in the date.

- localTime: clockTime
+ localTime: {
+ var date = new Date();
+ return new Date
+ (
+ date.getFullYear(),
+ date.getMonth(),
+ date.getDate(),
+ notLocalizedTimeString.split(":")[0],
+ notLocalizedTimeString.split(":")[1],
+ notLocalizedTimeString.split(":")[2],
+ 0
+ )
+ }

5. Same issue as issue #4.

+ var date = new Date();
+ var clockTime = new Date
+ (
+ date.getFullYear(),
+ date.getMonth(),
+ date.getDate(),
+ clockTimeString.split(":")[0],
+ clockTimeString.split(":")[1],
+ clockTimeString.split(":")[2],
+ 0
+ )

6. Same issue as issue #4

+ var date = new Date();
                     return new Date
                             (
- currentTime.localDateString.split(":")[0],
- ...

Read more...

review: Needs Fixing (manual testing + preliminary code review)
Revision history for this message
Nekhelesh Ramananthan (nik90) wrote :

The following code changes are not necessary. Let me explain the reasoning why,

These code changes would add additional roles to *every* world city delegate in the c++ side and cost us performance. Instead, let's stick with the original code that returns the correct timezone info (hh:mm) as expected and just pass the current local time of the user as a property to the worldcitydelegate.qml. So we save one additional role in the QAbsractModel.

Also do note that you added the extra role in the TimeZone Model class which is the base class. This role will be inherited unnecessarily by StaticTimeZoneModel and JsonTimeZoneModel class where this role is useless as we just show the time at that city.

If you want, instead of the hard code "hh:mm" format, you could return the time in Qt::DefaultLocaleShortDate format.

+ RoleTimezoneId,
+ RoleNotLocalizedTimeString,
+ RoleLocalizedTimeString,

- case RoleTimeString:
+ case RoleNotLocalizedTimeString:
         /*
          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 RoleLocalizedTimeString:
+ return worldCityTime.time().toString(Qt::DefaultLocaleShortDate);

review: Needs Fixing (performance regression)
Revision history for this message
Ubuntu Phone Apps Jenkins Bot (ubuntu-phone-apps-jenkins-bot) wrote :
review: Needs Fixing (continuous-integration)
416. By Bartosz Kosiorek

Fix unit tests

Revision history for this message
Ubuntu Phone Apps Jenkins Bot (ubuntu-phone-apps-jenkins-bot) wrote :
review: Approve (continuous-integration)
Revision history for this message
Bartosz Kosiorek (gang65) wrote :

I checked geolocation and after 40 minutes it was autorefreshed automatically:

qml: [LOG]: Starting geolocation update service at UTC time: Mon Nov 16 22:25:17 2015 GMT+0100
UbuntuClipboard - Got invalid serialized mime data. Ignoring it.
qml: [LOG]: Searching online for user location at http://api.geonames.org/findNearbyPlaceNameJSON?lat=51.746&lng=19.5053&username=krnekhelesh&style=full
qml: [LOG]: Stopping geolocation update service

417. By Bartosz Kosiorek

Remove not used variables

Revision history for this message
Ubuntu Phone Apps Jenkins Bot (ubuntu-phone-apps-jenkins-bot) wrote :
review: Approve (continuous-integration)
Revision history for this message
Nekhelesh Ramananthan (nik90) wrote :

lgtm! Nice Work!

review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
The diff is not available at this time. You can reload the page or download it.

Subscribers

People subscribed via source and target branches