]> git.ipfire.org Git - thirdparty/moment.git/commitdiff
Trimming some bytes now that we have `sod` and `eod`
authorTim Wood <washwithcare@gmail.com>
Thu, 19 Jan 2012 16:49:53 +0000 (08:49 -0800)
committerTim Wood <washwithcare@gmail.com>
Thu, 19 Jan 2012 16:49:53 +0000 (08:49 -0800)
#136

moment.js

index b8f0db6c48cd0f53821814df6f86f1d9d0a7672b..9a93b5d62c44c745e6ac190b6b76c01439cc9d94 100644 (file)
--- a/moment.js
+++ b/moment.js
         },
 
         calendar : function () {
-            var today = moment(),
-                todayAtZeroHour = moment([today.year(), today.month(), today.date()]),
-                diff = this.diff(todayAtZeroHour, 'days', true),
+            var diff = this.diff(moment().sod(), 'days', true),
                 calendar = moment.calendar,
                 allElse = calendar.sameElse,
                 format = diff < -6 ? allElse :
         },
 
         eod: function () {
-            return this.clone()
-                .hours(23)
-                .minutes(59)
-                .seconds(59)
-                .milliseconds(999);
+            // end of day = start of day plus 1 day, minus 1 millisecond
+            return this.sod().add({
+                d : 1,
+                ms : -1
+            });
         }
     };