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
=== modified file 'Storage.qml'
--- Storage.qml 2013-03-20 16:28:57 +0000
+++ Storage.qml 2013-04-04 20:26:20 +0000
@@ -77,24 +77,18 @@
77 * returns a string based on how much time has passed77 * returns a string based on how much time has passed
78 */78 */
79 function fromDateToString(time) {79 function fromDateToString(time) {
80 // TODO: see in settings if user wants AM/PM or 24h
81 // Now all strings are in AM/PM
82 // Below every string there is a comment with string in 24h
80 time = new Date(time);83 time = new Date(time);
81 var now = new Date();84 var now = new Date();
82 var string;85 var string;
8386
84 // Create a string with minutes :MM AM/PM
85 var minutes = ":";
86 minutes += time.getMinutes() < 10 ? "0" : "";
87 minutes += time.getMinutes() + " "
88 minutes += time.getHours() > 12 ? "PM" : "AM";
89
90 var weekdays = ["Sun","Mon","Tue", "Wed", "Thu", "Fry", "Sat"];
91 var months = ["Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug", "Sep", "Oct", "Nov", "Dec"];
92
93 // Today87 // Today
94 if (now.getDate() - time.getDate() === 0 && now.getMonth() === time.getMonth()) {88 if (now.getDate() - time.getDate() === 0 && now.getMonth() === time.getMonth()) {
95 // Between 0 & 59 minutes89 // Between 0 & 59 minutes
96 if (now.getHours() - time.getHours() < 1 || (now.getHours() - time.getHours() === 1 && time.getMinutes() > now.getMinutes())) {90 if (now.getHours() - time.getHours() < 1 || (now.getHours() - time.getHours() === 1 && time.getMinutes() > now.getMinutes())) {
97 // This is for different hours ex datestamp 11:58 now 12:0291 // This is for different hours e.g. datestamp 11:58 now 12:02 prints "4 minutes ago"
98 string = now.getMinutes() - time.getMinutes() > 0 ? now.getMinutes() - time.getMinutes() : now.getMinutes() - time.getMinutes() + 60;92 string = now.getMinutes() - time.getMinutes() > 0 ? now.getMinutes() - time.getMinutes() : now.getMinutes() - time.getMinutes() + 60;
99 string += " minutes ago";93 string += " minutes ago";
10094
@@ -106,27 +100,24 @@
106 }100 }
107101
108 // > 1 hour ago102 // > 1 hour ago
109 string = now.getHours() - time.getHours() + " hour";103 string = now.getHours() - time.getHours();
110 string += now.getHours() - time.getHours() > 1 ? "s" : "";104 string += now.getHours() - time.getHours() > 1 ? "hours" : "hour";
111 return string + " ago";105 return string + " ago";
112 } // End today106 } // End today
113107
114 // Between yesterday and one week ago108 // Between two days and one week ago
115 if (now.getDate() - time.getDate() > 0 && now.getDate() - time.getDate() < 7 && now.getMonth() === time.getMonth()) {109 if (now.getDate() - time.getDate() > 1 && now.getDate() - time.getDate() < 7 && now.getMonth() === time.getMonth())
116 string = now.getDate() - time.getDate() === 1 ? "Yesterday" : weekdays[time.getDay()];110 return Qt.formatDateTime(time, "ddd, hh:mm AP"); // E.g. Mon, 05:55 PM
117 string += ", ";111 // return Qt.formatDateTime(time, "ddd, hh:mm"); // E.g. Mon, 17:55
118 string += time.getHours() > 12 ? time.getHours() - 12 : time.getHours();
119 string += minutes;
120112
121 return string;113 // Yesterday
122 }114 if (now.getDate() - time.getDate() === 1 && now.getMonth() === time.getMonth())
115 return "Yesterday, " + Qt.formatDateTime(time, "hh:mm AP") // E.g. Yesterday, 05:55 PM
116 // return "Yesterday, " + Qt.formatDateTime(time, "hh:mm") // E.g. Yesterday, 17:55
123117
124 // More than one week ago118 // More than one week ago
125 string = months[time.getMonth()];119 return Qt.formatDateTime(time, "MMM dd, hh:mm AP"); // E.g. Jan 03, 05:55 PM
126 string += " " + weekdays[time.getDay()] + ", ";120 // return Qt.formatDateTime(time, "MMM dd, hh:mm"); // E.g. Jan 03, 17:55
127 string += time.getHours() > 12 ? time.getHours() - 12 : time.getHours();
128 string += minutes;
129 return string;
130 }121 }
131122
132 // Function to have time from an ID123 // Function to have time from an ID

Subscribers

People subscribed via source and target branches