]> git.ipfire.org Git - thirdparty/moment.git/commitdiff
Trimming some bytes by using moment prototype getters instead of native getters
authorTim Wood <washwithcare@gmail.com>
Wed, 28 Dec 2011 18:51:16 +0000 (10:51 -0800)
committerTim Wood <washwithcare@gmail.com>
Wed, 28 Dec 2011 18:51:16 +0000 (10:51 -0800)
moment.js

index af2ecae8402ca7be484b07eb6792d0d976af586c..c658baf6ea51bf47590e8929c724c62c8dd2d533 100644 (file)
--- a/moment.js
+++ b/moment.js
         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) {
 
     // 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
         return output;
     }
 
-    // Moment prototype object
-    function Moment(date) {
-        this._d = date;
-    }
-
     moment = function (input, format) {
         if (input === null) {
             return null;