Merge lp:~gang65/ubuntu-clock-app/ubuntu-clock-app-alarm-description-fix into lp:ubuntu-clock-app

Proposed by Bartosz Kosiorek
Status: Merged
Approved by: Bartosz Kosiorek
Approved revision: 404
Merged at revision: 420
Proposed branch: lp:~gang65/ubuntu-clock-app/ubuntu-clock-app-alarm-description-fix
Merge into: lp:ubuntu-clock-app
Diff against target: 198 lines (+55/-23)
7 files modified
app/alarm/AlarmDelegate.qml (+2/-2)
app/alarm/AlarmUtils.qml (+17/-3)
app/worldclock/WorldCityList.qml (+1/-1)
debian/changelog (+8/-1)
manifest.json.in (+1/-1)
tests/unit/tst_alarm.qml (+6/-3)
tests/unit/tst_alarmUtils.qml (+20/-12)
To merge this branch: bzr merge lp:~gang65/ubuntu-clock-app/ubuntu-clock-app-alarm-description-fix
Reviewer Review Type Date Requested Status
Jenkins Bot continuous-integration Approve
Ubuntu Phone Apps Jenkins Bot continuous-integration Needs Fixing
Ubuntu Clock Developers Pending
Review via email: mp+275932@code.launchpad.net

Commit message

Fix alarm difference time description, during DST change (LP: #1510694)

Description of the change

Fix alarm difference time description, during DST change (LP: #1510694)

To post a comment you must log in.
Revision history for this message
Jenkins Bot (ubuntu-core-apps-jenkins-bot) wrote :
review: Approve (continuous-integration)
Revision history for this message
Ubuntu Phone Apps Jenkins Bot (ubuntu-phone-apps-jenkins-bot) wrote :

FAILED: Continuous integration, rev:403
http://91.189.93.70:8080/job/ubuntu-clock-app-ci/858/
Executed test runs:

Click here to trigger a rebuild:
http://91.189.93.70:8080/job/ubuntu-clock-app-ci/858/rebuild

review: Needs Fixing (continuous-integration)
404. By Bartosz Kosiorek

Bump version number to 3.7

Revision history for this message
Jenkins Bot (ubuntu-core-apps-jenkins-bot) wrote :
review: Needs Fixing (continuous-integration)
Revision history for this message
Jenkins Bot (ubuntu-core-apps-jenkins-bot) wrote :
review: Approve (continuous-integration)

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'app/alarm/AlarmDelegate.qml'
2--- app/alarm/AlarmDelegate.qml 2015-10-16 07:38:33 +0000
3+++ app/alarm/AlarmDelegate.qml 2015-10-29 22:15:16 +0000
4@@ -88,7 +88,7 @@
5 visible: !(type === Alarm.OneTime && !model.enabled)
6 elide: Text.ElideRight
7 text: type === Alarm.Repeating ? alarmUtils.format_day_string(daysOfWeek, type)
8- : model.enabled ? alarmUtils.get_time_to_next_alarm(model.date - localTime)
9+ : model.enabled ? alarmUtils.get_time_to_alarm(model.date, localTime)
10 : "Alarm Disabled"
11
12 function animateTextChange() {
13@@ -107,7 +107,7 @@
14
15 ScriptAction {
16 script: alarmSubtitle.text = showAlarmFrequency ? alarmUtils.format_day_string(daysOfWeek, type)
17- : alarmUtils.get_time_to_next_alarm(model.date - localTime)
18+ : alarmUtils.get_time_to_alarm(model.date, localTime)
19 }
20
21 PropertyAnimation {
22
23=== modified file 'app/alarm/AlarmUtils.qml'
24--- app/alarm/AlarmUtils.qml 2015-10-08 21:49:48 +0000
25+++ app/alarm/AlarmUtils.qml 2015-10-29 22:15:16 +0000
26@@ -79,12 +79,26 @@
27 return bottom_edge_title
28 }
29
30- bottom_edge_title = i18n.tr("Next Alarm %1").arg(get_time_to_next_alarm(activeAlarmDate - clockTime))
31+ bottom_edge_title = i18n.tr("Next Alarm %1").arg(get_time_to_alarm(activeAlarmDate, clockTime))
32 return bottom_edge_title
33 }
34
35- // Function to format the time to next alarm into a string
36- function get_time_to_next_alarm(totalTime) {
37+ function get_utc_time(dateTime) {
38+ return new Date(dateTime.getUTCFullYear(),
39+ dateTime.getUTCMonth(),
40+ dateTime.getUTCDate(),
41+ dateTime.getUTCHours(),
42+ dateTime.getUTCMinutes(),
43+ dateTime.getUTCSeconds(),
44+ dateTime.getUTCMilliseconds())
45+ }
46+
47+ // Function to format the time to specific alarm into a string
48+ function get_time_to_alarm(alarmDate, currentDateTime) {
49+ // Discard the time and time-zone information, so it will be properly calculate time,
50+ // even with different timezones (eg. during daylight saving change)
51+ var totalTime = get_utc_time(alarmDate) - get_utc_time(currentDateTime);
52+
53 if(totalTime < 0) {
54 return i18n.tr("Alarm Passed")
55 }
56
57=== modified file 'app/worldclock/WorldCityList.qml'
58--- app/worldclock/WorldCityList.qml 2015-09-17 05:36:41 +0000
59+++ app/worldclock/WorldCityList.qml 2015-10-29 22:15:16 +0000
60@@ -124,7 +124,7 @@
61 var url = String("%1%2%3")
62 .arg("http://geoname-lookup.ubuntu.com/?query=")
63 .arg(searchField.text)
64- .arg("&app=com.ubuntu.clock&version=3.6.x")
65+ .arg("&app=com.ubuntu.clock&version=3.7.x")
66 console.log("Online URL: " + url)
67 if (jsonTimeZoneModelLoader.status === Loader.Ready) {
68 jsonTimeZoneModel.source = Qt.resolvedUrl(url)
69
70=== modified file 'debian/changelog'
71--- debian/changelog 2015-10-16 05:58:01 +0000
72+++ debian/changelog 2015-10-29 22:15:16 +0000
73@@ -1,4 +1,11 @@
74-ubuntu-clock-app (3.6) UNRELEASED; urgency=medium
75+ubuntu-clock-app (3.7) UNRELEASED; urgency=medium
76+
77+ [ Bartosz Kosiorek ]
78+ * Fix alarm difference time description, during DST change (LP: #1510694)
79+
80+ -- Bartosz Kosiorek <gang65@poczta.onet.pl> Tue, 27 Oct 2015 23:49:19 +0100
81+
82+ubuntu-clock-app (3.6) vivid; urgency=medium
83
84 [ Nekhelesh Ramananthan ]
85 * Bumped version to 3.6
86
87=== modified file 'manifest.json.in'
88--- manifest.json.in 2015-09-03 21:07:54 +0000
89+++ manifest.json.in 2015-10-29 22:15:16 +0000
90@@ -12,7 +12,7 @@
91 "urls": "share/url-dispatcher/urls/com.ubuntu.clock_clock.url-dispatcher"
92 }
93 },
94- "version": "3.6.@BZR_REVNO@",
95+ "version": "3.7.@BZR_REVNO@",
96 "maintainer": "Ubuntu App Cats <ubuntu-touch-coreapps@lists.launchpad.net>",
97 "x-test": {
98 "autopilot": {
99
100=== modified file 'tests/unit/tst_alarm.qml'
101--- tests/unit/tst_alarm.qml 2015-09-17 06:28:20 +0000
102+++ tests/unit/tst_alarm.qml 2015-10-29 22:15:16 +0000
103@@ -65,13 +65,16 @@
104 //delete all current alarms
105 waitForRendering(alarmPage)
106 var alarmsList = findChild(alarmPage, "alarmListView")
107- verify(alarmsList != null)
108+ verify(alarmsList !== null)
109 print("Found " + alarmsList.count + " pre-existing alarms")
110
111 for (var i=0; i<alarmsList.count; i++) {
112- print("Deleting Alarm " + i)
113+
114 var alarmObject = findChild(alarmsList, "alarm"+i)
115- swipeToDeleteItem(alarmObject)
116+ if (alarmObject !== null) {
117+ print("Deleting Alarm " + i)
118+ swipeToDeleteItem(alarmObject)
119+ }
120 waitForRendering(alarmPage)
121 }
122 }
123
124=== modified file 'tests/unit/tst_alarmUtils.qml'
125--- tests/unit/tst_alarmUtils.qml 2015-10-08 20:17:11 +0000
126+++ tests/unit/tst_alarmUtils.qml 2015-10-29 22:15:16 +0000
127@@ -25,9 +25,7 @@
128 id: alarmUtilsTest
129 name: "AlarmUtilsLibrary"
130
131- property var futureTime: new Date()
132- property var currentTime: new Date()
133- property var mock_notLocalizedDateTimeString: ""
134+ property string mock_notLocalizedDateTimeString: ""
135
136 AlarmUtils {
137 id: alarmUtils
138@@ -45,6 +43,9 @@
139 Alarm1, currentTime+2hrs, not enabled
140 Alarm2, currentTime+7hrs, enabled
141 */
142+
143+ var currentTime = new Date()
144+ var futureTime = new Date()
145 futureTime.setHours((futureTime.getHours() + 2))
146 mockAlarmDatabase.append({"name": "Alarm1", "date": futureTime, "enabled": false})
147 futureTime.setHours((futureTime.getHours() + 5))
148@@ -96,35 +97,42 @@
149 }
150
151 /*
152- This test checks if the get_time_to_next_alarm() function takes a time in
153+ This test checks if the get_time_to_alarm() function takes a time in
154 milliseconds and writtens a user readable string e.g "in 2d 15h 10m" after
155 correct calculation.
156 */
157 function test_timeToNextAlarmStringMustShowAll() {
158- var timeInMilliseconds = 440100000; // 5 days, 2 hrs, 16 mins
159- var result = alarmUtils.get_time_to_next_alarm(timeInMilliseconds)
160+ var currentDateTime = new Date()
161+ var timeInMilliseconds = ((5 * 24 + 2)* 60 + 15) * 60 * 1000; // 5 days, 2 hrs, 16 mins
162+
163+ var alarmDate = new Date(currentDateTime.getTime() + timeInMilliseconds);
164+ var result = alarmUtils.get_time_to_alarm(alarmDate, currentDateTime)
165 compare(result, "in 5d 2h 16m", "Time to next alarm string is incorrect")
166 }
167
168 /*
169- This test checks if the get_time_to_next_alarm() function takes a time in
170+ This test checks if the get_time_to_alarm() function takes a time in
171 milliseconds and writtens a user readable string without days e.g "in 15h 10m"
172 after correct calculation.
173 */
174 function test_timeToNextAlarmStringMustNotShowDays() {
175- var timeInMilliseconds = 36000000 // 10 hours, 1 min
176- var result = alarmUtils.get_time_to_next_alarm(timeInMilliseconds)
177+ var timeInMilliseconds = 10 * 60 * 60 * 1000 // 10 hours, 1 min
178+ var currentDateTime = new Date()
179+ var alarmDate = new Date(currentDateTime.getTime() + timeInMilliseconds);
180+ var result = alarmUtils.get_time_to_alarm(alarmDate, currentDateTime)
181 compare(result, "in 10h 1m", "Time to next alarm string is incorrect")
182 }
183
184 /*
185- This test checks if the get_time_to_next_alarm() function takes a time in
186+ This test checks if the get_time_to_alarm() function takes a time in
187 milliseconds and writtens a user readable string with only mins e.g "in 10m"
188 after correct calculation.
189 */
190 function test_timeToNextAlarmStringMustOnlyShowMinutes() {
191- var timeInMilliseconds = 1080000 // 19 mins
192- var result = alarmUtils.get_time_to_next_alarm(timeInMilliseconds)
193+ var timeInMilliseconds = 18 * 60 * 1000 // 19 mins
194+ var currentDateTime = new Date()
195+ var alarmDate = new Date(currentDateTime.getTime() + timeInMilliseconds);
196+ var result = alarmUtils.get_time_to_alarm(alarmDate, currentDateTime)
197 compare(result, "in 19m", "Time to next alarm string is incorrect")
198 }
199

Subscribers

People subscribed via source and target branches