← Back to team overview

launchpad-reviewers team mailing list archive

[Merge] lp:~cjohnston/launchpad/js-timestamp-fixes into lp:launchpad

 

Chris Johnston has proposed merging lp:~cjohnston/launchpad/js-timestamp-fixes into lp:launchpad.

Commit message:
Minor JS fixes from the earlier diff comments timestamp changes

Requested reviews:
  Launchpad code reviewers (launchpad-reviewers)

For more details, see:
https://code.launchpad.net/~cjohnston/launchpad/js-timestamp-fixes/+merge/226032
-- 
https://code.launchpad.net/~cjohnston/launchpad/js-timestamp-fixes/+merge/226032
Your team Launchpad code reviewers is requested to review the proposed merge of lp:~cjohnston/launchpad/js-timestamp-fixes into lp:launchpad.
=== modified file 'lib/lp/app/javascript/date.js'
--- lib/lp/app/javascript/date.js	2014-07-08 12:32:44 +0000
+++ lib/lp/app/javascript/date.js	2014-07-08 19:55:33 +0000
@@ -7,11 +7,11 @@
 
 namespace.parse_date = function(str) {
     // Parse an ISO-8601 date
-    var re = /^(\d{4})-(\d{2})-(\d{2})T(\d{2}):(\d{2}):(\d{2})(?:\.(\d+))?(Z|\+00:00)$/
-    var bits = re.exec(str).slice(1, 8).map(Number)
+    var re = /^(\d{4})-(\d{2})-(\d{2})T(\d{2}):(\d{2}):(\d{2})(?:\.(\d+))?(Z|\+00:00)$/;
+    var bits = re.exec(str).slice(1, 8).map(Number);
     // Adjusting for the fact that Date.UTC uses 0-11 for months
-    bits[1] -= 1
-    return new Date(Date.UTC.apply(null, bits))
+    bits[1] -= 1;
+    return new Date(Date.UTC.apply(null, bits));
 };
 
 namespace.approximatedate = function(date) {
@@ -19,28 +19,28 @@
     // day ago.
     var now = (new Date).valueOf();
     var timedelta = now - date;
-    var days = timedelta / 86400000
-    var hours = timedelta / 3600000
-    var minutes = timedelta / 60000
-    var amount = 0
-    var unit = ""
+    var days = timedelta / 86400000;
+    var hours = timedelta / 3600000;
+    var minutes = timedelta / 60000;
+    var amount = 0;
+    var unit = "";
     if (days > 1) {
         return 'on ' + Y.Date.format(
             new Date(date), {format: '%Y-%m-%d'});
     } else {
         if (hours >= 1) {
-            amount = hours
-            unit = "hour"
+            amount = hours;
+            unit = "hour";
         } else if (minutes >= 1) {
-            amount = minutes
-            unit = "minute"
+            amount = minutes;
+            unit = "minute";
         } else {
-            return "a moment ago"
+            return "a moment ago";
         }
         if (Math.floor(amount) > 1) {
-            unit = unit + 's'
+            unit = unit + 's';
         }
-        return Math.floor(amount) + ' ' + unit + ' ago'
+        return Math.floor(amount) + ' ' + unit + ' ago';
     }
 };
 }, "0.1", {'requires': ['datatype-date']});

=== modified file 'lib/lp/app/javascript/tests/test_date.js'
--- lib/lp/app/javascript/tests/test_date.js	2014-07-08 12:32:44 +0000
+++ lib/lp/app/javascript/tests/test_date.js	2014-07-08 19:55:33 +0000
@@ -3,7 +3,7 @@
     var tests = Y.namespace('date.test');
     tests.suite = new Y.Test.Suite("date tests");
 
-    var now = (new Date).valueOf()
+    var now = (new Date).valueOf();
     tests.suite.add(new Y.Test.Case({
         name: 'test_approximatedate',
 

=== modified file 'lib/lp/code/javascript/branchmergeproposal.inlinecomments.js'
--- lib/lp/code/javascript/branchmergeproposal.inlinecomments.js	2014-07-08 12:32:44 +0000
+++ lib/lp/code/javascript/branchmergeproposal.inlinecomments.js	2014-07-08 19:55:33 +0000
@@ -187,7 +187,7 @@
         if (typeof comment.date === "string") {
             var comment_date = Y.lp.app.date.parse_date(comment.date);
         } else {
-            var comment_date = comment.date
+            var comment_date = comment.date;
         }
         var date = Y.lp.app.date.approximatedate(comment_date);
         headerspan.one('span').set('text', date);

=== modified file 'lib/lp/code/javascript/tests/test_branchmergeproposal.inlinecomments.js'
--- lib/lp/code/javascript/tests/test_branchmergeproposal.inlinecomments.js	2014-07-08 12:32:44 +0000
+++ lib/lp/code/javascript/tests/test_branchmergeproposal.inlinecomments.js	2014-07-08 19:55:33 +0000
@@ -70,7 +70,7 @@
                 "ws.op=getInlineComments&previewdiff_id=1",
                 mockio.requests[0].config.data);
             mockio.last_request = mockio.requests[0];
-            var now = (new Date).valueOf()
+            var now = (new Date).valueOf();
             published_comments = [
                 {'line_number': '2',
                  'person': person_obj,
@@ -80,7 +80,7 @@
                  'person': person_obj,
                  'text': 'This is great.',
                  'date': (new Date(now - 12600000)),
-                },
+                }
             ];
             mockio.success({
                 responseText: Y.JSON.stringify(published_comments),
@@ -88,7 +88,7 @@
 
             // Published comment is displayed.
             var first_comments = Y.one('#diff-line-2').next().one('div');
-            var first = first_comments.one('div:first-child')
+            var first = first_comments.one('div:first-child');
             Y.Assert.areEqual(
                 'Foo Bar (name16) wrote on 2012-08-12:',
                 first.one('.boardCommentDetails').get('text'));
@@ -107,11 +107,11 @@
 
             // Draft comment for line 3 is displayed.
             var second_comments = Y.one('#diff-line-3').next().one('div');
-            var third = second_comments.one('div:first-child')
+            var third = second_comments.one('div:first-child');
             Y.Assert.areEqual(
                 'Foo Bar (name16) wrote 3 hours ago:',
                 third.one('.boardCommentDetails').get('text'));
-            var fourth = third.next()
+            var fourth = third.next();
             Y.Assert.areEqual(
                 'Unsaved comment',
                 fourth.one('.boardCommentDetails').get('text'));


Follow ups