From: Tim Wood Date: Thu, 19 Jan 2012 16:49:53 +0000 (-0800) Subject: Trimming some bytes now that we have `sod` and `eod` X-Git-Tag: 1.4.0~26 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=605dcb5c5e512f8e8582518b4ee464d092ae6757;p=thirdparty%2Fmoment.git Trimming some bytes now that we have `sod` and `eod` #136 --- diff --git a/moment.js b/moment.js index b8f0db6c4..9a93b5d62 100644 --- a/moment.js +++ b/moment.js @@ -564,9 +564,7 @@ }, 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 : @@ -602,11 +600,11 @@ }, 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 + }); } };