Merge lp:~rpadovani/ubuntu-calculator-app/fromDateToString into lp:~ubuntu-calculator-dev/ubuntu-calculator-app/old_trunk

Proposed by Riccardo Padovani
Status: Merged
Approved by: Dalius
Approved revision: 43
Merged at revision: 43
Proposed branch: lp:~rpadovani/ubuntu-calculator-app/fromDateToString
Merge into: lp:~ubuntu-calculator-dev/ubuntu-calculator-app/old_trunk
Diff against target: 72 lines (+16/-25)
1 file modified
Storage.qml (+16/-25)
To merge this branch: bzr merge lp:~rpadovani/ubuntu-calculator-app/fromDateToString
Reviewer Review Type Date Requested Status
Ubuntu Phone Apps Jenkins Bot continuous-integration Approve
Dalius (community) Approve
Review via email: mp+157222@code.launchpad.net

Commit message

Modified function fromDateToString using Qt.formatDateTime for internationalization

Description of the change

Modified function fromDateToString using Qt.formatDateTime for internationalization.
TODO: when there will system settings understand when use AM/PM and when use 24hours format

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

FAILED: Autolanding.
No commit message was specified in the merge proposal. Hit 'Add commit message' on the merge proposal web page or follow the link below. You can approve the merge proposal yourself to rerun.
https://code.launchpad.net/~rpadovani/ubuntu-calculator-app/fromDateToString/+merge/157222/+edit-commit-message

review: Needs Fixing (continuous-integration)
Revision history for this message
Ubuntu Phone Apps Jenkins Bot (ubuntu-phone-apps-jenkins-bot) :
review: Approve (continuous-integration)

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'Storage.qml'
2--- Storage.qml 2013-03-20 16:28:57 +0000
3+++ Storage.qml 2013-04-04 20:26:20 +0000
4@@ -77,24 +77,18 @@
5 * returns a string based on how much time has passed
6 */
7 function fromDateToString(time) {
8+ // TODO: see in settings if user wants AM/PM or 24h
9+ // Now all strings are in AM/PM
10+ // Below every string there is a comment with string in 24h
11 time = new Date(time);
12 var now = new Date();
13 var string;
14
15- // Create a string with minutes :MM AM/PM
16- var minutes = ":";
17- minutes += time.getMinutes() < 10 ? "0" : "";
18- minutes += time.getMinutes() + " "
19- minutes += time.getHours() > 12 ? "PM" : "AM";
20-
21- var weekdays = ["Sun","Mon","Tue", "Wed", "Thu", "Fry", "Sat"];
22- var months = ["Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug", "Sep", "Oct", "Nov", "Dec"];
23-
24 // Today
25 if (now.getDate() - time.getDate() === 0 && now.getMonth() === time.getMonth()) {
26 // Between 0 & 59 minutes
27 if (now.getHours() - time.getHours() < 1 || (now.getHours() - time.getHours() === 1 && time.getMinutes() > now.getMinutes())) {
28- // This is for different hours ex datestamp 11:58 now 12:02
29+ // This is for different hours e.g. datestamp 11:58 now 12:02 prints "4 minutes ago"
30 string = now.getMinutes() - time.getMinutes() > 0 ? now.getMinutes() - time.getMinutes() : now.getMinutes() - time.getMinutes() + 60;
31 string += " minutes ago";
32
33@@ -106,27 +100,24 @@
34 }
35
36 // > 1 hour ago
37- string = now.getHours() - time.getHours() + " hour";
38- string += now.getHours() - time.getHours() > 1 ? "s" : "";
39+ string = now.getHours() - time.getHours();
40+ string += now.getHours() - time.getHours() > 1 ? "hours" : "hour";
41 return string + " ago";
42 } // End today
43
44- // Between yesterday and one week ago
45- if (now.getDate() - time.getDate() > 0 && now.getDate() - time.getDate() < 7 && now.getMonth() === time.getMonth()) {
46- string = now.getDate() - time.getDate() === 1 ? "Yesterday" : weekdays[time.getDay()];
47- string += ", ";
48- string += time.getHours() > 12 ? time.getHours() - 12 : time.getHours();
49- string += minutes;
50+ // Between two days and one week ago
51+ if (now.getDate() - time.getDate() > 1 && now.getDate() - time.getDate() < 7 && now.getMonth() === time.getMonth())
52+ return Qt.formatDateTime(time, "ddd, hh:mm AP"); // E.g. Mon, 05:55 PM
53+ // return Qt.formatDateTime(time, "ddd, hh:mm"); // E.g. Mon, 17:55
54
55- return string;
56- }
57+ // Yesterday
58+ if (now.getDate() - time.getDate() === 1 && now.getMonth() === time.getMonth())
59+ return "Yesterday, " + Qt.formatDateTime(time, "hh:mm AP") // E.g. Yesterday, 05:55 PM
60+ // return "Yesterday, " + Qt.formatDateTime(time, "hh:mm") // E.g. Yesterday, 17:55
61
62 // More than one week ago
63- string = months[time.getMonth()];
64- string += " " + weekdays[time.getDay()] + ", ";
65- string += time.getHours() > 12 ? time.getHours() - 12 : time.getHours();
66- string += minutes;
67- return string;
68+ return Qt.formatDateTime(time, "MMM dd, hh:mm AP"); // E.g. Jan 03, 05:55 PM
69+ // return Qt.formatDateTime(time, "MMM dd, hh:mm"); // E.g. Jan 03, 17:55
70 }
71
72 // Function to have time from an ID

Subscribers

People subscribed via source and target branches