diff options
author | Byron Jones <glob@mozilla.com> | 2015-05-27 05:57:29 +0200 |
---|---|---|
committer | Byron Jones <glob@mozilla.com> | 2015-05-27 05:57:29 +0200 |
commit | 35aab8c392ac6ad404bb0d902cca6b50480072da (patch) | |
tree | 035f26e0c3151fbd088b07c6e8140ce6412c5f2e /extensions/MozReview/web/js | |
parent | 087f74073fdc81ec5707f2989c99b34770e864eb (diff) | |
download | bugzilla-35aab8c392ac6ad404bb0d902cca6b50480072da.tar.gz bugzilla-35aab8c392ac6ad404bb0d902cca6b50480072da.tar.xz |
Bug 1158010: provide a standard and simple way to render relative dates, in perl and javascript
Diffstat (limited to 'extensions/MozReview/web/js')
-rw-r--r-- | extensions/MozReview/web/js/mozreview.js | 39 |
1 files changed, 1 insertions, 38 deletions
diff --git a/extensions/MozReview/web/js/mozreview.js b/extensions/MozReview/web/js/mozreview.js index 2b9575292..e927d366c 100644 --- a/extensions/MozReview/web/js/mozreview.js +++ b/extensions/MozReview/web/js/mozreview.js @@ -8,43 +8,6 @@ var MozReview = {}; -MozReview.formatElapsedTime = function(s, val) { - val = Math.floor(val); - return val + ' ' + s + (val == 1 ? '' : 's') + ' ago'; -}; - -MozReview.elapsedTime = function(d) { - var ms = Date.now() - d; - - var seconds = ms / 1000; - if (seconds < 60) { - return MozReview.formatElapsedTime('second', seconds); - } - - var minutes = seconds / 60; - if (minutes < 60) { - return MozReview.formatElapsedTime('minute', minutes); - } - - var hours = minutes / 60; - if (hours < 24) { - return MozReview.formatElapsedTime('hour', hours); - } - - var days = hours / 24; - if (days < 30) { - return MozReview.formatElapsedTime("day", days); - } - - var months = days / 30; // enh fudge it - if (months < 12) { - return MozReview.formatElapsedTime("month", months); - } - - var years = months / 12; - return MozReview.formatElapsedTime("year", years); -}; - MozReview.getReviewRequest = function() { var hostUrl = $('.mozreview-requests').data('mozreviewUrl'); var tr = $('<tr/>'); @@ -83,7 +46,7 @@ MozReview.getReviewRequest = function() { td.clone().text(rr.status), td.clone().text(rr.issue_open_count) .addClass('mozreview-open-issues'), - td.clone().text(MozReview.elapsedTime(new Date(rr.last_updated))) + td.clone().text(timeAgo(new Date(rr.last_updated))) ); if (rr.status == "discarded") { |