From: Tim Wood Date: Wed, 28 Dec 2011 18:51:16 +0000 (-0800) Subject: Trimming some bytes by using moment prototype getters instead of native getters X-Git-Tag: 1.3.0~12 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=a37dd9eefa58f2410f96ffcea964b38fc0f28c62;p=thirdparty%2Fmoment.git Trimming some bytes by using moment prototype getters instead of native getters --- diff --git a/moment.js b/moment.js index af2ecae84..c658baf6e 100644 --- a/moment.js +++ b/moment.js @@ -22,6 +22,11 @@ VERSION = "1.2.0", shortcuts = 'Month|Date|Hours|Minutes|Seconds|Milliseconds'.split('|'); + // Moment prototype object + function Moment(date) { + this._d = date; + } + // left zero fill a number // see http://jsperf.com/left-zero-filling for performance comparison function leftZeroFill(number, targetLength) { @@ -78,14 +83,15 @@ // format date using native date object function formatDate(date, inputString) { - var currentMonth = date.getMonth(), - currentDate = date.getDate(), - currentYear = date.getFullYear(), - currentDay = date.getDay(), - currentHours = date.getHours(), - currentMinutes = date.getMinutes(), - currentSeconds = date.getSeconds(), - currentZone = date.getTimezoneOffset(), + var m = new Moment(date), + currentMonth = m.month(), + currentDate = m.date(), + currentYear = m.year(), + currentDay = m.day(), + currentHours = m.hours(), + currentMinutes = m.minutes(), + currentSeconds = m.seconds(), + currentZone = m.zone(), ordinal = moment.ordinal, meridiem = moment.meridiem; // check if the character is a format @@ -350,11 +356,6 @@ return output; } - // Moment prototype object - function Moment(date) { - this._d = date; - } - moment = function (input, format) { if (input === null) { return null;