]> git.ipfire.org Git - thirdparty/moment.git/commitdiff
Renaming the library to 'moment'
authorTim Wood <washwithcare@gmail.com>
Sat, 15 Oct 2011 00:17:53 +0000 (17:17 -0700)
committerTim Wood <washwithcare@gmail.com>
Sat, 15 Oct 2011 00:17:53 +0000 (17:17 -0700)
18 files changed:
build.js
lang/all.min.js
lang/fr.js
lang/fr.min.js
lang/it.js
lang/it.min.js
lang/pt.js
lang/pt.min.js
moment.js [moved from underscore.date.js with 89% similarity]
moment.min.js [moved from underscore.date.min.js with 52% similarity]
test.js
test/date.js
test/index.html
test/lang.js
test/lang/en.js
test/lang/fr.js
test/lang/it.js
test/lang/pt.js

index 119cbf253b91afeb42ee8337b0fd72a889549b65..f7fc8917a36878a4fab7a4a0e0894d6fcd22fba2 100755 (executable)
--- a/build.js
+++ b/build.js
@@ -37,9 +37,9 @@ var JSHINT_CONFIG = {
 };
 var LANG_MINIFY = "fr it pt".split(" ");
 var LANG_TEST = "en fr it pt".split(" ");
-var LANG_PREFIX = "var _date;if (typeof window === 'undefined') {_date = require('../underscore.date.js');module = QUnit.module;}";
-var VERSION = '0.6.1';
-var MINIFY_COMMENT = '/* underscore.date | version : ' + VERSION + ' | author : Tim Wood | license : MIT */\n';
+var LANG_PREFIX = "var moment;if (typeof window === 'undefined') {moment = require('../moment.js');module = QUnit.module;}";
+var VERSION = '0.7.0';
+var MINIFY_COMMENT = '/* moment | version : ' + VERSION + ' | author : Tim Wood | license : MIT */\n';
 
 
 /*********************************************
@@ -155,8 +155,8 @@ function hint(source, name) {
 
 
 (function(){
-    var source = fs.readFileSync('./underscore.date.js', 'utf8');
-    if (hint(source, 'underscore.date')) {
-        minifyToFile(source, 'underscore.date', MINIFY_COMMENT);
+    var source = fs.readFileSync('./moment.js', 'utf8');
+    if (hint(source, 'moment')) {
+        minifyToFile(source, 'moment', MINIFY_COMMENT);
     }
 })();
\ No newline at end of file
index e97fec765a3e6e9f0e19033b9be80c4295a68908..514701834295091f4ef4223b2f3488720ee385ba 100644 (file)
@@ -1 +1 @@
-(function(){var a={months:"Janvier_Février_Mars_Avril_Mai_Juin_Juillet_Aout_Septembre_Octobre_Novembre_Décembre".split("_"),monthsShort:"Jan_Fev_Mar_Avr_Mai_Juin_Juil_Aou_Sep_Oct_Nov_Dec".split("_"),weekdays:"Dimanche_Lundi_Mardi_Mercredi_Jeudi_Vendredi_Samedi".split("_"),weekdaysShort:"Dim_Lun_Mar_Mer_Jeu_Ven_Sam".split("_"),relativeTime:{future:"in %s",past:"il y a %s",s:"secondes",m:"une minute",mm:"%d minutes",h:"une heure",hh:"%d heures",d:"un jour",dd:"%d jours",M:"un mois",MM:"%d mois",y:"une année",yy:"%d années"},ordinal:function(a){return~~(a%100/10)===1?"er":"ème"}};typeof module!="undefined"&&(module.exports=a),typeof window!="undefined"&&this._date&&this._date.lang&&this._date.lang("fr",a)})(),function(){var a={months:"Gennaio_Febbraio_Marzo_Aprile_Maggio_Giugno_Luglio_Agosto_Settebre_Ottobre_Novembre_Dicembre".split("_"),monthsShort:"Gen_Feb_Mar_Apr_Mag_Giu_Lug_Ago_Set_Ott_Nov_Dic".split("_"),weekdays:"Domenica_Lunedi_Martedi_Mercoledi_Giovedi_Venerdi_Sabato".split("_"),weekdaysShort:"Dom_Lun_Mar_Mer_Gio_Ven_Sab".split("_"),relativeTime:{future:"in %s",past:"%s fa",s:"secondi",m:"un minuto",mm:"%d minuti",h:"un ora",hh:"%d ore",d:"un giorno",dd:"%d giorni",M:"un mese",MM:"%d mesi",y:"un anno",yy:"%d anni"},ordinal:function(){return"º"}};typeof module!="undefined"&&(module.exports=a),typeof window!="undefined"&&this._date&&this._date.lang&&this._date.lang("it",a)}(),function(){var a={months:"Janeiro_Fevereiro_Março_Abril_Maio_Junho_Julho_Agosto_Setembro_Outubro_Novembro_Dezembro".split("_"),monthsShort:"Jan_Feb_Mar_Abr_Mai_Jun_Jul_Ago_Set_Out_Nov_Dez".split("_"),weekdays:"Domingo_Segunda-feira_Terça-feira_Quarta-feira_Quinta-feira_Sexta-feira_Sábado".split("_"),weekdaysShort:"Dom_Seg_Ter_Qua_Qui_Sex_Sáb".split("_"),relativeTime:{future:"em %s",past:"%s atrás",s:"segundos",m:"um minuto",mm:"%d minutos",h:"uma hora",hh:"%d horas",d:"um dia",dd:"%d dias",M:"um mês",MM:"%d meses",y:"um ano",yy:"%d anos"},ordinal:function(a){return"º"}};typeof module!="undefined"&&(module.exports=a),typeof window!="undefined"&&this._date&&this._date.lang&&this._date.lang("pt",a)}()
\ No newline at end of file
+(function(){var a={months:"Janvier_Février_Mars_Avril_Mai_Juin_Juillet_Aout_Septembre_Octobre_Novembre_Décembre".split("_"),monthsShort:"Jan_Fev_Mar_Avr_Mai_Juin_Juil_Aou_Sep_Oct_Nov_Dec".split("_"),weekdays:"Dimanche_Lundi_Mardi_Mercredi_Jeudi_Vendredi_Samedi".split("_"),weekdaysShort:"Dim_Lun_Mar_Mer_Jeu_Ven_Sam".split("_"),relativeTime:{future:"in %s",past:"il y a %s",s:"secondes",m:"une minute",mm:"%d minutes",h:"une heure",hh:"%d heures",d:"un jour",dd:"%d jours",M:"un mois",MM:"%d mois",y:"une année",yy:"%d années"},ordinal:function(a){return~~(a%100/10)===1?"er":"ème"}};typeof module!="undefined"&&(module.exports=a),typeof window!="undefined"&&this.moment&&this.moment.lang&&this.moment.lang("fr",a)})(),function(){var a={months:"Gennaio_Febbraio_Marzo_Aprile_Maggio_Giugno_Luglio_Agosto_Settebre_Ottobre_Novembre_Dicembre".split("_"),monthsShort:"Gen_Feb_Mar_Apr_Mag_Giu_Lug_Ago_Set_Ott_Nov_Dic".split("_"),weekdays:"Domenica_Lunedi_Martedi_Mercoledi_Giovedi_Venerdi_Sabato".split("_"),weekdaysShort:"Dom_Lun_Mar_Mer_Gio_Ven_Sab".split("_"),relativeTime:{future:"in %s",past:"%s fa",s:"secondi",m:"un minuto",mm:"%d minuti",h:"un ora",hh:"%d ore",d:"un giorno",dd:"%d giorni",M:"un mese",MM:"%d mesi",y:"un anno",yy:"%d anni"},ordinal:function(){return"º"}};typeof module!="undefined"&&(module.exports=a),typeof window!="undefined"&&this.moment&&this.moment.lang&&this.moment.lang("it",a)}(),function(){var a={months:"Janeiro_Fevereiro_Março_Abril_Maio_Junho_Julho_Agosto_Setembro_Outubro_Novembro_Dezembro".split("_"),monthsShort:"Jan_Feb_Mar_Abr_Mai_Jun_Jul_Ago_Set_Out_Nov_Dez".split("_"),weekdays:"Domingo_Segunda-feira_Terça-feira_Quarta-feira_Quinta-feira_Sexta-feira_Sábado".split("_"),weekdaysShort:"Dom_Seg_Ter_Qua_Qui_Sex_Sáb".split("_"),relativeTime:{future:"em %s",past:"%s atrás",s:"segundos",m:"um minuto",mm:"%d minutos",h:"uma hora",hh:"%d horas",d:"um dia",dd:"%d dias",M:"um mês",MM:"%d meses",y:"um ano",yy:"%d anos"},ordinal:function(a){return"º"}};typeof module!="undefined"&&(module.exports=a),typeof window!="undefined"&&this.moment&&this.moment.lang&&this.moment.lang("pt",a)}()
\ No newline at end of file
index 60d3f7818f16c222092852279b7e3d43c5150e54..62b468f9ce97fe209a0ec61e388d8f813234bfa6 100644 (file)
@@ -29,7 +29,7 @@
         module.exports = lang;
     }
     // Browser
-    if (typeof window !== 'undefined' && this._date && this._date.lang) {
-        this._date.lang('fr', lang);
+    if (typeof window !== 'undefined' && this.moment && this.moment.lang) {
+        this.moment.lang('fr', lang);
     }
 }());
\ No newline at end of file
index c9ee738a8d4249b5ade36a78db37d41f9cab445f..fe92c145420b6a6038bb1fcb43b2e363f8a2c233 100644 (file)
@@ -1 +1 @@
-(function(){var a={months:"Janvier_Février_Mars_Avril_Mai_Juin_Juillet_Aout_Septembre_Octobre_Novembre_Décembre".split("_"),monthsShort:"Jan_Fev_Mar_Avr_Mai_Juin_Juil_Aou_Sep_Oct_Nov_Dec".split("_"),weekdays:"Dimanche_Lundi_Mardi_Mercredi_Jeudi_Vendredi_Samedi".split("_"),weekdaysShort:"Dim_Lun_Mar_Mer_Jeu_Ven_Sam".split("_"),relativeTime:{future:"in %s",past:"il y a %s",s:"secondes",m:"une minute",mm:"%d minutes",h:"une heure",hh:"%d heures",d:"un jour",dd:"%d jours",M:"un mois",MM:"%d mois",y:"une année",yy:"%d années"},ordinal:function(a){return~~(a%100/10)===1?"er":"ème"}};typeof module!="undefined"&&(module.exports=a),typeof window!="undefined"&&this._date&&this._date.lang&&this._date.lang("fr",a)})()
\ No newline at end of file
+(function(){var a={months:"Janvier_Février_Mars_Avril_Mai_Juin_Juillet_Aout_Septembre_Octobre_Novembre_Décembre".split("_"),monthsShort:"Jan_Fev_Mar_Avr_Mai_Juin_Juil_Aou_Sep_Oct_Nov_Dec".split("_"),weekdays:"Dimanche_Lundi_Mardi_Mercredi_Jeudi_Vendredi_Samedi".split("_"),weekdaysShort:"Dim_Lun_Mar_Mer_Jeu_Ven_Sam".split("_"),relativeTime:{future:"in %s",past:"il y a %s",s:"secondes",m:"une minute",mm:"%d minutes",h:"une heure",hh:"%d heures",d:"un jour",dd:"%d jours",M:"un mois",MM:"%d mois",y:"une année",yy:"%d années"},ordinal:function(a){return~~(a%100/10)===1?"er":"ème"}};typeof module!="undefined"&&(module.exports=a),typeof window!="undefined"&&this.moment&&this.moment.lang&&this.moment.lang("fr",a)})()
\ No newline at end of file
index 8d040bbda509f5b5ddff2f4d0f9d6d9210545764..e94423bc7d71b510dca2574ef732e206056e0d0b 100644 (file)
@@ -29,7 +29,7 @@
         module.exports = lang;
     }
     // Browser
-    if (typeof window !== 'undefined' && this._date && this._date.lang) {
-        this._date.lang('it', lang);
+    if (typeof window !== 'undefined' && this.moment && this.moment.lang) {
+        this.moment.lang('it', lang);
     }
 }());
\ No newline at end of file
index ae9bc0d8c66779128b20ad55071c9c9834f921d5..6c9fb3490f82a560934a2f3f77534ff5b7714c33 100644 (file)
@@ -1 +1 @@
-(function(){var a={months:"Gennaio_Febbraio_Marzo_Aprile_Maggio_Giugno_Luglio_Agosto_Settebre_Ottobre_Novembre_Dicembre".split("_"),monthsShort:"Gen_Feb_Mar_Apr_Mag_Giu_Lug_Ago_Set_Ott_Nov_Dic".split("_"),weekdays:"Domenica_Lunedi_Martedi_Mercoledi_Giovedi_Venerdi_Sabato".split("_"),weekdaysShort:"Dom_Lun_Mar_Mer_Gio_Ven_Sab".split("_"),relativeTime:{future:"in %s",past:"%s fa",s:"secondi",m:"un minuto",mm:"%d minuti",h:"un ora",hh:"%d ore",d:"un giorno",dd:"%d giorni",M:"un mese",MM:"%d mesi",y:"un anno",yy:"%d anni"},ordinal:function(){return"º"}};typeof module!="undefined"&&(module.exports=a),typeof window!="undefined"&&this._date&&this._date.lang&&this._date.lang("it",a)})()
\ No newline at end of file
+(function(){var a={months:"Gennaio_Febbraio_Marzo_Aprile_Maggio_Giugno_Luglio_Agosto_Settebre_Ottobre_Novembre_Dicembre".split("_"),monthsShort:"Gen_Feb_Mar_Apr_Mag_Giu_Lug_Ago_Set_Ott_Nov_Dic".split("_"),weekdays:"Domenica_Lunedi_Martedi_Mercoledi_Giovedi_Venerdi_Sabato".split("_"),weekdaysShort:"Dom_Lun_Mar_Mer_Gio_Ven_Sab".split("_"),relativeTime:{future:"in %s",past:"%s fa",s:"secondi",m:"un minuto",mm:"%d minuti",h:"un ora",hh:"%d ore",d:"un giorno",dd:"%d giorni",M:"un mese",MM:"%d mesi",y:"un anno",yy:"%d anni"},ordinal:function(){return"º"}};typeof module!="undefined"&&(module.exports=a),typeof window!="undefined"&&this.moment&&this.moment.lang&&this.moment.lang("it",a)})()
\ No newline at end of file
index 006180bd5b8b283ce417a8919554fce70a47a164..227e2efc310bfbfb166fef241c7cab02fb4bce2f 100644 (file)
@@ -29,7 +29,7 @@
         module.exports = lang;
     }
     // Browser
-    if (typeof window !== 'undefined' && this._date && this._date.lang) {
-        this._date.lang('pt', lang);
+    if (typeof window !== 'undefined' && this.moment && this.moment.lang) {
+        this.moment.lang('pt', lang);
     }
 }());
\ No newline at end of file
index 0909f9b3e2d43e2374e641baec5b360f10f340c1..8f9dea67bd6609ff8cb575f104367a32b82e8330 100644 (file)
@@ -1 +1 @@
-(function(){var a={months:"Janeiro_Fevereiro_Março_Abril_Maio_Junho_Julho_Agosto_Setembro_Outubro_Novembro_Dezembro".split("_"),monthsShort:"Jan_Feb_Mar_Abr_Mai_Jun_Jul_Ago_Set_Out_Nov_Dez".split("_"),weekdays:"Domingo_Segunda-feira_Terça-feira_Quarta-feira_Quinta-feira_Sexta-feira_Sábado".split("_"),weekdaysShort:"Dom_Seg_Ter_Qua_Qui_Sex_Sáb".split("_"),relativeTime:{future:"em %s",past:"%s atrás",s:"segundos",m:"um minuto",mm:"%d minutos",h:"uma hora",hh:"%d horas",d:"um dia",dd:"%d dias",M:"um mês",MM:"%d meses",y:"um ano",yy:"%d anos"},ordinal:function(a){return"º"}};typeof module!="undefined"&&(module.exports=a),typeof window!="undefined"&&this._date&&this._date.lang&&this._date.lang("pt",a)})()
\ No newline at end of file
+(function(){var a={months:"Janeiro_Fevereiro_Março_Abril_Maio_Junho_Julho_Agosto_Setembro_Outubro_Novembro_Dezembro".split("_"),monthsShort:"Jan_Feb_Mar_Abr_Mai_Jun_Jul_Ago_Set_Out_Nov_Dez".split("_"),weekdays:"Domingo_Segunda-feira_Terça-feira_Quarta-feira_Quinta-feira_Sexta-feira_Sábado".split("_"),weekdaysShort:"Dom_Seg_Ter_Qua_Qui_Sex_Sáb".split("_"),relativeTime:{future:"em %s",past:"%s atrás",s:"segundos",m:"um minuto",mm:"%d minutos",h:"uma hora",hh:"%d horas",d:"um dia",dd:"%d dias",M:"um mês",MM:"%d meses",y:"um ano",yy:"%d anos"},ordinal:function(a){return"º"}};typeof module!="undefined"&&(module.exports=a),typeof window!="undefined"&&this.moment&&this.moment.lang&&this.moment.lang("pt",a)})()
\ No newline at end of file
similarity index 89%
rename from underscore.date.js
rename to moment.js
index 589a11365a1a6472b4d17be661e0fe9f45b2b609..b214fdd6f9c019203dbf0cbf1bb3cb36bc4eca2c 100644 (file)
+++ b/moment.js
@@ -7,7 +7,7 @@
 
 (function (Date, undefined) {
 
-    var _date,
+    var moment,
         round = Math.round,
         languages = {},
         isNode = (typeof window === 'undefined' && typeof module !== 'undefined'),
             case 'M' :
                 return currentMonth + 1;
             case 'Mo' :
-                return (currentMonth + 1) + _date.ordinal(currentMonth + 1);
+                return (currentMonth + 1) + moment.ordinal(currentMonth + 1);
             case 'MM' :
                 return leftZeroFill(currentMonth + 1, 2);
             case 'MMM' :
-                return _date.monthsShort[currentMonth];
+                return moment.monthsShort[currentMonth];
             case 'MMMM' :
-                return _date.months[currentMonth];
+                return moment.months[currentMonth];
             // DAY OF MONTH
             case 'D' :
                 return currentDate;
             case 'Do' :
-                return currentDate + _date.ordinal(currentDate);
+                return currentDate + moment.ordinal(currentDate);
             case 'DD' :
                 return leftZeroFill(currentDate, 2);
             // DAY OF YEAR
                 return ~~ (((a - b) / 864e5) + 1.5);
             case 'DDDo' :
                 a = replaceFunction('DDD');
-                return a + _date.ordinal(a);
+                return a + moment.ordinal(a);
             case 'DDDD' :
                 return leftZeroFill(replaceFunction('DDD'), 3);
             // WEEKDAY
             case 'd' :
                 return currentDay;
             case 'do' :
-                return currentDay + _date.ordinal(currentDay);
+                return currentDay + moment.ordinal(currentDay);
             case 'ddd' :
-                return _date.weekdaysShort[currentDay];
+                return moment.weekdaysShort[currentDay];
             case 'dddd' :
-                return _date.weekdays[currentDay];
+                return moment.weekdays[currentDay];
             // WEEK OF YEAR
             case 'w' :
                 a = new Date(currentYear, currentMonth, currentDate - currentDay + 5);
                 return ~~ ((a - b) / 864e5 / 7 + 1.5);
             case 'wo' :
                 a = replaceFunction('w');
-                return a + _date.ordinal(a);
+                return a + moment.ordinal(a);
             case 'ww' :
                 return leftZeroFill(replaceFunction('w'), 2);
             // YEAR
         return output;
     }
 
-    // UnderscoreDate prototype object
-    function UnderscoreDate(input, format) {
+    // Moment prototype object
+    function Moment(date) {
+        this._d = date;
+    }
+
+    moment = function (input, format) {
+        var date;
         // parse UnderscoreDate object
         if (input && input._d instanceof Date) {
-            this._d = input._d;
+            date = input._d;
         // parse string and format
         } else if (format) {
             if (isArray(format)) {
-                this._d = makeDateFromStringAndArray(input, format);
+                date = makeDateFromStringAndArray(input, format);
             } else {
-                this._d = makeDateFromStringAndFormat(input, format);
+                date = makeDateFromStringAndFormat(input, format);
             }
         // parse everything else
         } else {
-            this._d = input === undefined ? new Date() :
+            date = input === undefined ? new Date() :
                 input instanceof Date ? input :
                 isArray(input) ? dateFromArray(input) :
                 new Date(input);
         }
-    }
-
-    _date = function (input, format) {
-        return new UnderscoreDate(input, format);
+        return new Moment(date);
     };
 
     // language switching and caching
-    _date.lang = function (key, values) {
+    moment.lang = function (key, values) {
         var i, param, req;
         if (values) {
             languages[key] = values;
         if (languages[key]) {
             for (i = 0; i < paramsToParse.length; i++) {
                 param = paramsToParse[i];
-                _date[param] = languages[key][param] || _date[param];
+                moment[param] = languages[key][param] || moment[param];
             }
         } else {
             if (isNode) {
                 req = require('./lang/' + key);
-                _date.lang(key, req);
+                console.log(req);
+                moment.lang(key, req);
             }
         }
+        console.log(languages);
     };
 
     // set default language
-    _date.lang('en', {
+    moment.lang('en', {
         months : "January_February_March_April_May_June_July_August_September_October_November_December".split("_"),
         monthsShort : "Jan_Feb_Mar_Apr_May_Jun_Jul_Aug_Sep_Oct_Nov_Dec".split("_"),
         weekdays : "Sunday_Monday_Tuesday_Wednesday_Thursday_Friday_Saturday".split("_"),
 
     // helper function for _date.from() and _date.fromNow()
     function substituteTimeAgo(string, number) {
-        return _date.relativeTime[string].replace(/%d/i, number || 1);
+        return moment.relativeTime[string].replace(/%d/i, number || 1);
     }
 
     function relativeTime(milliseconds) {
     }
 
     // shortcut for prototype
-    _date.fn = UnderscoreDate.prototype = {
+    moment.fn = Moment.prototype = {
 
         valueOf : function () {
             return +this._d;
         },
 
         diff : function (input, format) {
-            return this._d - _date(input, format)._d;
+            return this._d - moment(input, format)._d;
         },
 
         from : function (time, withoutSuffix) {
             var difference = this.diff(time),
-                string = difference < 0 ? _date.relativeTime.past : _date.relativeTime.future,
+                string = difference < 0 ? moment.relativeTime.past : moment.relativeTime.future,
                 output = relativeTime(difference);
             return withoutSuffix ? output : string.replace(/%s/i, output);
         },
 
         fromNow : function (withoutSuffix) {
-            return this.from(new UnderscoreDate(), withoutSuffix);
+            return this.from(moment(), withoutSuffix);
         },
 
         isLeapYear : function () {
 
     // helper for adding shortcuts
     function makeShortcut(name, key) {
-        _date.fn[name] = function (input) {
+        moment.fn[name] = function (input) {
             if (input) {
                 this._d['set' + key](input);
                 return this;
     makeShortcut('year', 'FullYear');
 
     // add shortcut for day (no setter)
-    _date.fn.day = function () {
+    moment.fn.day = function () {
         return this._d.getDay();
     };
 
     // CommonJS module is defined
     if (isNode) {
-        module.exports = _date;
+        module.exports = moment;
     } else {
-        // Integrate with Underscore.js if it exists
-        if (this._ !== undefined && this._.mixin !== undefined) {
-            this._.mixin({date : _date});
-        }
-        this._date = _date;
+        this.moment = moment;
     }
 
 })(Date);
\ No newline at end of file
similarity index 52%
rename from underscore.date.min.js
rename to moment.min.js
index 33cf9a9028cf532fe30f29653ecc5ca5bbfcaf08..fa7dfcedea7f3c1ca73feefb7ff996db6dd7211e 100755 (executable)
@@ -1,2 +1,2 @@
-/* underscore.date | version : 0.6.1 | author : Tim Wood | license : MIT */
-(function(a,b){function j(a,b){var c=a+"";while(c.length<b)c="0"+c;return c}function k(b,c,d,e){var f=typeof c=="string",g=f?{}:c,h,i,j;return f&&e&&(g[c]=e),h=(g.ms||g.milliseconds||0)+(g.s||g.seconds||0)*1e3+(g.m||g.minutes||0)*6e4+(g.h||g.hours||0)*36e5+(g.d||g.days||0)*864e5+(g.w||g.weeks||0)*6048e5,i=(g.M||g.months||0)+(g.y||g.years||0)*12,h&&b.setMilliseconds(b.getMilliseconds()+h*d),i&&(j=b.getDate(),b.setDate(1),b.setMonth(b.getMonth()+i*d),b.setDate(Math.min((new a(b.getFullYear(),b.getMonth()+1,0)).getDate(),j))),b}function l(a){return Object.prototype.toString.call(a)==="[object Array]"}function m(b){return new a(b[0],b[1]||0,b[2]||1,b[3]||0,b[4]||0,b[5]||0,b[6]||0)}function n(b,d){function p(d){var m,q;switch(d){case"M":return e+1;case"Mo":return e+1+c.ordinal(e+1);case"MM":return j(e+1,2);case"MMM":return c.monthsShort[e];case"MMMM":return c.months[e];case"D":return f;case"Do":return f+c.ordinal(f);case"DD":return j(f,2);case"DDD":return m=new a(g,e,f),q=new a(g,0,1),~~((m-q)/864e5+1.5);case"DDDo":return m=p("DDD"),m+c.ordinal(m);case"DDDD":return j(p("DDD"),3);case"d":return h;case"do":return h+c.ordinal(h);case"ddd":return c.weekdaysShort[h];case"dddd":return c.weekdays[h];case"w":return m=new a(g,e,f-h+5),q=new a(m.getFullYear(),0,4),~~((m-q)/864e5/7+1.5);case"wo":return m=p("w"),m+c.ordinal(m);case"ww":return j(p("w"),2);case"YY":return(g+"").slice(-2);case"YYYY":return g;case"a":return i>11?"pm":"am";case"A":return i>11?"PM":"AM";case"H":return i;case"HH":return j(i,2);case"h":return i%12||12;case"hh":return j(i%12||12,2);case"m":return k;case"mm":return j(k,2);case"s":return l;case"ss":return j(l,2);case"zz":case"z":return(b.toString().match(o)||[""])[0].replace(n,"");default:return d.replace("\\","")}}var e=b.getMonth(),f=b.getDate(),g=b.getFullYear(),h=b.getDay(),i=b.getHours(),k=b.getMinutes(),l=b.getSeconds(),m=/(\\)?(Mo|MM?M?M?|Do|DDDo|DD?D?D?|dddd?|do?|w[o|w]?|YYYY|YY|a|A|hh?|HH?|mm?|ss?|zz?)/g,n=/[^A-Z]/g,o=/\([A-Za-z ]+\)|:[0-9]{2} [A-Z]{3} /g;return d.replace(m,p)}function o(a,b){function i(a,b){switch(a){case"M":case"MM":c[1]=~~b-1;break;case"D":case"DD":case"DDD":case"DDDD":c[2]=~~b;break;case"YY":b=~~b,c[0]=b+(b>70?1900:2e3);break;case"YYYY":c[0]=~~b;break;case"a":case"A":h=b.toLowerCase()==="pm";break;case"H":case"HH":case"h":case"hh":c[3]=~~b;break;case"m":case"mm":c[4]=~~b;break;case"s":case"ss":c[5]=~~b}}var c=[0],d=/[0-9a-zA-Z]+/g,e=a.match(d),f=b.match(d),g,h;for(g=0;g<f.length;g++)i(f[g],e[g]);return h&&c[3]<12&&(c[3]+=12),m(c)}function p(a,b){var c=Math.min(a.length,b.length),d=Math.abs(a.length-b.length),e=0,f;for(f=0;f<c;f++)~~a[f]!==~~b[f]&&e++;return e+d}function q(a,b){var c,d=/[0-9a-zA-Z]+/g,e=a.match(d),f=[],g=99,h,i,j;for(h=0;h<b.length;h++)i=o(a,b[h]),j=p(e,n(i,b[h]).match(d)),j<g&&(g=j,c=i);return c}function r(c,d){c&&c._d instanceof a?this._d=c._d:d?l(d)?this._d=q(c,d):this._d=o(c,d):this._d=c===b?new a:c instanceof a?c:l(c)?m(c):new a(c)}function s(a,b){return c.relativeTime[a].replace(/%d/i,b||1)}function t(a){var b=Math.abs(a)/1e3,c=b/60,e=c/60,f=e/24,g=f/365;return b<45&&s("s",d(b))||d(c)===1&&s("m")||c<45&&s("mm",d(c))||d(e)===1&&s("h")||e<22&&s("hh",d(e))||d(f)===1&&s("d")||f<25&&s("dd",d(f))||f<45&&s("M")||f<345&&s("MM",d(f/30))||d(g)===1&&s("y")||s("yy",d(g))}function u(a,b){c.fn[a]=function(a){return a?(this._d["set"+b](a),this):this._d["get"+b]()}}var c,d=Math.round,e={},f=typeof window=="undefined"&&typeof module!="undefined",g="months|monthsShort|weekdays|weekdaysShort|relativeTime|ordinal".split("|"),h,i="Month|Date|Hours|Minutes|Seconds".split("|");c=function(a,b){return new r(a,b)},c.lang=function(a,b){var d,h,i;b&&(e[a]=b);if(e[a])for(d=0;d<g.length;d++)h=g[d],c[h]=e[a][h]||c[h];else f&&(i=require("./lang/"+a),c.lang(a,i))},c.lang("en",{months:"January_February_March_April_May_June_July_August_September_October_November_December".split("_"),monthsShort:"Jan_Feb_Mar_Apr_May_Jun_Jul_Aug_Sep_Oct_Nov_Dec".split("_"),weekdays:"Sunday_Monday_Tuesday_Wednesday_Thursday_Friday_Saturday".split("_"),weekdaysShort:"Sun_Mon_Tue_Wed_Thu_Fri_Sat".split("_"),relativeTime:{future:"in %s",past:"%s ago",s:"seconds",m:"a minute",mm:"%d minutes",h:"an hour",hh:"%d hours",d:"a day",dd:"%d days",M:"a month",MM:"%d months",y:"a year",yy:"%d years"},ordinal:function(a){var b=a%10;return~~(a%100/10)===1?"th":b===1?"st":b===2?"nd":b===3?"rd":"th"}}),c.fn=r.prototype={valueOf:function(){return+this._d},"native":function(){return this._d},format:function(a){return n(this._d,a)},add:function(a,b){return this._d=k(this._d,a,1,b),this},subtract:function(a,b){return this._d=k(this._d,a,-1,b),this},diff:function(a,b){return this._d-c(a,b)._d},from:function(a,b){var d=this.diff(a),e=d<0?c.relativeTime.past:c.relativeTime.future,f=t(d);return b?f:e.replace(/%s/i,f)},fromNow:function(a){return this.from(new r,a)},isLeapYear:function(){var a=this._d.getFullYear();return a%4===0&&a%100!==0||a%400===0}};for(h=0;h<i.length;h++)u(i[h].toLowerCase(),i[h]);u("year","FullYear"),c.fn.day=function(){return this._d.getDay()},f?module.exports=c:(this._!==b&&this._.mixin!==b&&this._.mixin({date:c}),this._date=c)})(Date)
\ No newline at end of file
+/* moment | version : 0.7.0 | author : Tim Wood | license : MIT */
+(function(a,b){function j(a,b){var c=a+"";while(c.length<b)c="0"+c;return c}function k(b,c,d,e){var f=typeof c=="string",g=f?{}:c,h,i,j;return f&&e&&(g[c]=e),h=(g.ms||g.milliseconds||0)+(g.s||g.seconds||0)*1e3+(g.m||g.minutes||0)*6e4+(g.h||g.hours||0)*36e5+(g.d||g.days||0)*864e5+(g.w||g.weeks||0)*6048e5,i=(g.M||g.months||0)+(g.y||g.years||0)*12,h&&b.setMilliseconds(b.getMilliseconds()+h*d),i&&(j=b.getDate(),b.setDate(1),b.setMonth(b.getMonth()+i*d),b.setDate(Math.min((new a(b.getFullYear(),b.getMonth()+1,0)).getDate(),j))),b}function l(a){return Object.prototype.toString.call(a)==="[object Array]"}function m(b){return new a(b[0],b[1]||0,b[2]||1,b[3]||0,b[4]||0,b[5]||0,b[6]||0)}function n(b,d){function p(d){var m,q;switch(d){case"M":return e+1;case"Mo":return e+1+c.ordinal(e+1);case"MM":return j(e+1,2);case"MMM":return c.monthsShort[e];case"MMMM":return c.months[e];case"D":return f;case"Do":return f+c.ordinal(f);case"DD":return j(f,2);case"DDD":return m=new a(g,e,f),q=new a(g,0,1),~~((m-q)/864e5+1.5);case"DDDo":return m=p("DDD"),m+c.ordinal(m);case"DDDD":return j(p("DDD"),3);case"d":return h;case"do":return h+c.ordinal(h);case"ddd":return c.weekdaysShort[h];case"dddd":return c.weekdays[h];case"w":return m=new a(g,e,f-h+5),q=new a(m.getFullYear(),0,4),~~((m-q)/864e5/7+1.5);case"wo":return m=p("w"),m+c.ordinal(m);case"ww":return j(p("w"),2);case"YY":return(g+"").slice(-2);case"YYYY":return g;case"a":return i>11?"pm":"am";case"A":return i>11?"PM":"AM";case"H":return i;case"HH":return j(i,2);case"h":return i%12||12;case"hh":return j(i%12||12,2);case"m":return k;case"mm":return j(k,2);case"s":return l;case"ss":return j(l,2);case"zz":case"z":return(b.toString().match(o)||[""])[0].replace(n,"");default:return d.replace("\\","")}}var e=b.getMonth(),f=b.getDate(),g=b.getFullYear(),h=b.getDay(),i=b.getHours(),k=b.getMinutes(),l=b.getSeconds(),m=/(\\)?(Mo|MM?M?M?|Do|DDDo|DD?D?D?|dddd?|do?|w[o|w]?|YYYY|YY|a|A|hh?|HH?|mm?|ss?|zz?)/g,n=/[^A-Z]/g,o=/\([A-Za-z ]+\)|:[0-9]{2} [A-Z]{3} /g;return d.replace(m,p)}function o(a,b){function i(a,b){switch(a){case"M":case"MM":c[1]=~~b-1;break;case"D":case"DD":case"DDD":case"DDDD":c[2]=~~b;break;case"YY":b=~~b,c[0]=b+(b>70?1900:2e3);break;case"YYYY":c[0]=~~b;break;case"a":case"A":h=b.toLowerCase()==="pm";break;case"H":case"HH":case"h":case"hh":c[3]=~~b;break;case"m":case"mm":c[4]=~~b;break;case"s":case"ss":c[5]=~~b}}var c=[0],d=/[0-9a-zA-Z]+/g,e=a.match(d),f=b.match(d),g,h;for(g=0;g<f.length;g++)i(f[g],e[g]);return h&&c[3]<12&&(c[3]+=12),m(c)}function p(a,b){var c=Math.min(a.length,b.length),d=Math.abs(a.length-b.length),e=0,f;for(f=0;f<c;f++)~~a[f]!==~~b[f]&&e++;return e+d}function q(a,b){var c,d=/[0-9a-zA-Z]+/g,e=a.match(d),f=[],g=99,h,i,j;for(h=0;h<b.length;h++)i=o(a,b[h]),j=p(e,n(i,b[h]).match(d)),j<g&&(g=j,c=i);return c}function r(a){this._d=a}function s(a,b){return c.relativeTime[a].replace(/%d/i,b||1)}function t(a){var b=Math.abs(a)/1e3,c=b/60,e=c/60,f=e/24,g=f/365;return b<45&&s("s",d(b))||d(c)===1&&s("m")||c<45&&s("mm",d(c))||d(e)===1&&s("h")||e<22&&s("hh",d(e))||d(f)===1&&s("d")||f<25&&s("dd",d(f))||f<45&&s("M")||f<345&&s("MM",d(f/30))||d(g)===1&&s("y")||s("yy",d(g))}function u(a,b){c.fn[a]=function(a){return a?(this._d["set"+b](a),this):this._d["get"+b]()}}var c,d=Math.round,e={},f=typeof window=="undefined"&&typeof module!="undefined",g="months|monthsShort|weekdays|weekdaysShort|relativeTime|ordinal".split("|"),h,i="Month|Date|Hours|Minutes|Seconds".split("|");c=function(c,d){var e;return c&&c._d instanceof a?e=c._d:d?l(d)?e=q(c,d):e=o(c,d):e=c===b?new a:c instanceof a?c:l(c)?m(c):new a(c),new r(e)},c.lang=function(a,b){var d,h,i;b&&(e[a]=b);if(e[a])for(d=0;d<g.length;d++)h=g[d],c[h]=e[a][h]||c[h];else f&&(i=require("./lang/"+a),console.log(i),c.lang(a,i));console.log(e)},c.lang("en",{months:"January_February_March_April_May_June_July_August_September_October_November_December".split("_"),monthsShort:"Jan_Feb_Mar_Apr_May_Jun_Jul_Aug_Sep_Oct_Nov_Dec".split("_"),weekdays:"Sunday_Monday_Tuesday_Wednesday_Thursday_Friday_Saturday".split("_"),weekdaysShort:"Sun_Mon_Tue_Wed_Thu_Fri_Sat".split("_"),relativeTime:{future:"in %s",past:"%s ago",s:"seconds",m:"a minute",mm:"%d minutes",h:"an hour",hh:"%d hours",d:"a day",dd:"%d days",M:"a month",MM:"%d months",y:"a year",yy:"%d years"},ordinal:function(a){var b=a%10;return~~(a%100/10)===1?"th":b===1?"st":b===2?"nd":b===3?"rd":"th"}}),c.fn=r.prototype={valueOf:function(){return+this._d},"native":function(){return this._d},format:function(a){return n(this._d,a)},add:function(a,b){return this._d=k(this._d,a,1,b),this},subtract:function(a,b){return this._d=k(this._d,a,-1,b),this},diff:function(a,b){return this._d-c(a,b)._d},from:function(a,b){var d=this.diff(a),e=d<0?c.relativeTime.past:c.relativeTime.future,f=t(d);return b?f:e.replace(/%s/i,f)},fromNow:function(a){return this.from(c(),a)},isLeapYear:function(){var a=this._d.getFullYear();return a%4===0&&a%100!==0||a%400===0}};for(h=0;h<i.length;h++)u(i[h].toLowerCase(),i[h]);u("year","FullYear"),c.fn.day=function(){return this._d.getDay()},f?module.exports=c:this.moment=c})(Date)
\ No newline at end of file
diff --git a/test.js b/test.js
index aba6636a81a1d2d1a417907c1fd31d555f28f918..986bcf2de82eb93f4bb138d80f62c8b8a82ff893 100755 (executable)
--- a/test.js
+++ b/test.js
@@ -3,11 +3,11 @@ var testrunner = require('qunit');
 testrunner.options.errorsOnly = true;\r
 \r
 testrunner.run({\r
-    code: "./underscore.date.js",\r
+    code: "./moment.js",\r
     tests: ["./test/date.js", "./test/lang.js"]\r
 });\r
 \r
 testrunner.run({\r
-    code: "./underscore.date.min.js",\r
+    code: "./moment.min.js",\r
     tests: ["./test/date.js", "./test/lang.js"]\r
 });
\ No newline at end of file
index 4f321e98cf0ffead39a09f7f3d2d65f990cb7718..1a73af1ed160a050c89dfd69735e176e65048852 100755 (executable)
@@ -2,11 +2,10 @@
   Node
  *************************************************/
 
-var _date, _;
+var moment;
 if (typeof window === 'undefined') {
-    _date = require('../underscore.date.js');
+    moment = require('../moment');
     module = QUnit.module;
-    _ = { date : _date };
 }
 
 
@@ -19,40 +18,40 @@ module("create");
 
 
 test("array", 8, function() {
-    ok(_date([2010]).native() instanceof Date, "[2010]");
-    ok(_date([2010, 1]).native() instanceof Date, "[2010, 1]");
-    ok(_date([2010, 1, 12]).native() instanceof Date, "[2010, 1, 12]");
-    ok(_date([2010, 1, 12, 1]).native() instanceof Date, "[2010, 1, 12, 1]");
-    ok(_date([2010, 1, 12, 1, 1]).native() instanceof Date, "[2010, 1, 12, 1, 1]");
-    ok(_date([2010, 1, 12, 1, 1, 1]).native() instanceof Date, "[2010, 1, 12, 1, 1, 1]");
-    ok(_date([2010, 1, 12, 1, 1, 1, 1]).native() instanceof Date, "[2010, 1, 12, 1, 1, 1, 1]");
-    deepEqual(_date(new Date(2010, 1, 14, 15, 25, 50, 125)), _date([2010, 1, 14, 15, 25, 50, 125]), "constructing with array === constructing with new Date()");
+    ok(moment([2010]).native() instanceof Date, "[2010]");
+    ok(moment([2010, 1]).native() instanceof Date, "[2010, 1]");
+    ok(moment([2010, 1, 12]).native() instanceof Date, "[2010, 1, 12]");
+    ok(moment([2010, 1, 12, 1]).native() instanceof Date, "[2010, 1, 12, 1]");
+    ok(moment([2010, 1, 12, 1, 1]).native() instanceof Date, "[2010, 1, 12, 1, 1]");
+    ok(moment([2010, 1, 12, 1, 1, 1]).native() instanceof Date, "[2010, 1, 12, 1, 1, 1]");
+    ok(moment([2010, 1, 12, 1, 1, 1, 1]).native() instanceof Date, "[2010, 1, 12, 1, 1, 1, 1]");
+    deepEqual(moment(new Date(2010, 1, 14, 15, 25, 50, 125)), moment([2010, 1, 14, 15, 25, 50, 125]), "constructing with array === constructing with new Date()");
 });
 
 
 test("number", 2, function() {
-    ok(_date(1000).native() instanceof Date, "1000");
-    ok((_date(1000).valueOf() === 1000), "testing valueOf");
+    ok(moment(1000).native() instanceof Date, "1000");
+    ok((moment(1000).valueOf() === 1000), "testing valueOf");
 });
 
 
 test("date", 1, function() {
-    ok(_date(new Date()).native() instanceof Date, "new Date()");
+    ok(moment(new Date()).native() instanceof Date, "new Date()");
 });
 
-test("_date", 2, function() {
-    ok(_date(_date()).native() instanceof Date, "_date(_date())");
-    ok(_date(_date(_date())).native() instanceof Date, "_date(_date(_date()))");
+test("moment", 2, function() {
+    ok(moment(moment()).native() instanceof Date, "moment(moment())");
+    ok(moment(moment(moment())).native() instanceof Date, "moment(moment(moment()))");
 });
 
 test("undefined", 1, function() {
-    ok(_date().native() instanceof Date, "undefined");
+    ok(moment().native() instanceof Date, "undefined");
 });
 
 
 test("string without format", 2, function() {
-    ok(_date("Aug 9, 1995").native() instanceof Date, "Aug 9, 1995");
-    ok(_date("Mon, 25 Dec 1995 13:30:00 GMT").native() instanceof Date, "Mon, 25 Dec 1995 13:30:00 GMT");
+    ok(moment("Aug 9, 1995").native() instanceof Date, "Aug 9, 1995");
+    ok(moment("Mon, 25 Dec 1995 13:30:00 GMT").native() instanceof Date, "Mon, 25 Dec 1995 13:30:00 GMT");
 });
 
 
@@ -72,19 +71,19 @@ test("string with format", 11, function() {
         ],
         i;
     for (i = 0; i < a.length; i++) {
-        equal(_date(a[i][1], a[i][0]).format(a[i][0]), a[i][1], a[i][0] + ' ---> ' + a[i][1]);
+        equal(moment(a[i][1], a[i][0]).format(a[i][0]), a[i][1], a[i][0] + ' ---> ' + a[i][1]);
     }
 });
 
 test("string with array of formats", 3, function() {
-    equal(_date('13-02-1999', ['MM-DD-YYYY', 'DD-MM-YYYY']).format('MM DD YYYY'), '02 13 1999', 'switching month and day');
-    equal(_date('02-13-1999', ['MM/DD/YYYY', 'YYYY-MM-DD', 'MM-DD-YYYY']).format('MM DD YYYY'), '02 13 1999', 'year last');
-    equal(_date('1999-02-13', ['MM/DD/YYYY', 'YYYY-MM-DD', 'MM-DD-YYYY']).format('MM DD YYYY'), '02 13 1999', 'year first');
+    equal(moment('13-02-1999', ['MM-DD-YYYY', 'DD-MM-YYYY']).format('MM DD YYYY'), '02 13 1999', 'switching month and day');
+    equal(moment('02-13-1999', ['MM/DD/YYYY', 'YYYY-MM-DD', 'MM-DD-YYYY']).format('MM DD YYYY'), '02 13 1999', 'year last');
+    equal(moment('1999-02-13', ['MM/DD/YYYY', 'YYYY-MM-DD', 'MM-DD-YYYY']).format('MM DD YYYY'), '02 13 1999', 'year first');
 });
 
 test("string with format - years", 2, function() {
-    equal(_date('71', 'YY').format('YYYY'), '1971', '71 > 1971');
-    equal(_date('69', 'YY').format('YYYY'), '2069', '69 > 2069');
+    equal(moment('71', 'YY').format('YYYY'), '1971', '71 > 1971');
+    equal(moment('69', 'YY').format('YYYY'), '2069', '69 > 2069');
 });
 
 
@@ -92,7 +91,7 @@ module("add and subtract");
 
 
 test("add and subtract short", 11, function() {
-    var a = _date();
+    var a = moment();
     a.year(2011);
     a.month(9);
     a.date(12);
@@ -108,8 +107,8 @@ test("add and subtract short", 11, function() {
     equal(a.add({M:1}).month(), 10, 'Add month');
     equal(a.add({y:1}).year(), 2012, 'Add year');
 
-    var b = _date([2010, 0, 31]).add({M:1});
-    var c = _date([2010, 1, 28]).subtract({M:1});
+    var b = moment([2010, 0, 31]).add({M:1});
+    var c = moment([2010, 1, 28]).subtract({M:1});
 
     equal(b.month(), 1, 'add month, jan 31st to feb 28th');
     equal(b.date(), 28, 'add month, jan 31st to feb 28th');
@@ -118,7 +117,7 @@ test("add and subtract short", 11, function() {
 });
 
 test("add and subtract long", 7, function() {
-    var a = _date();
+    var a = moment();
     a.year(2011);
     a.month(9);
     a.date(12);
@@ -136,7 +135,7 @@ test("add and subtract long", 7, function() {
 });
 
 test("add and subtract string short", 7, function() {
-    var a = _date();
+    var a = moment();
     a.year(2011);
     a.month(9);
     a.date(12);
@@ -154,7 +153,7 @@ test("add and subtract string short", 7, function() {
 });
 
 test("add and subtract string short", 7, function() {
-    var a = _date();
+    var a = moment();
     a.year(2011);
     a.month(9);
     a.date(12);
@@ -175,14 +174,14 @@ module("diff");
 
 
 test("diff", 5, function() {
-    equal(_date(1000).diff(0), 1000, "1 second - 0 = 1000");
-    equal(_date(1000).diff(500), 500, "1 second - .5 second = -500");
-    equal(_date(0).diff(1000), -1000, "0 - 1 second = -1000");
-    equal(_date(new Date(1000)).diff(1000), 0, "1 second - 1 second = 0");
+    equal(moment(1000).diff(0), 1000, "1 second - 0 = 1000");
+    equal(moment(1000).diff(500), 500, "1 second - .5 second = -500");
+    equal(moment(0).diff(1000), -1000, "0 - 1 second = -1000");
+    equal(moment(new Date(1000)).diff(1000), 0, "1 second - 1 second = 0");
     var oneHourDate = new Date(),
     nowDate = new Date();
     oneHourDate.setHours(oneHourDate.getHours() + 1);
-    equal(_date(oneHourDate).diff(nowDate), 60 * 60 * 1000, "1 hour from now = 360000");
+    equal(moment(oneHourDate).diff(nowDate), 60 * 60 * 1000, "1 hour from now = 360000");
 });
 
 
@@ -190,10 +189,10 @@ module("leap year");
 
 
 test("leap year", 4, function() {
-    equal(_date([2010, 0, 1]).isLeapYear(), false, '2010');
-    equal(_date([2100, 0, 1]).isLeapYear(), false, '2100');
-    equal(_date([2008, 0, 1]).isLeapYear(), true, '2008');
-    equal(_date([2000, 0, 1]).isLeapYear(), true, '2000');
+    equal(moment([2010, 0, 1]).isLeapYear(), false, '2010');
+    equal(moment([2100, 0, 1]).isLeapYear(), false, '2100');
+    equal(moment([2008, 0, 1]).isLeapYear(), true, '2008');
+    equal(moment([2000, 0, 1]).isLeapYear(), true, '2000');
 });
 
 
@@ -201,7 +200,7 @@ module("getters and setters");
 
 
 test("getters", 7, function() {
-    var a = _date([2011, 9, 12, 6, 7, 8]);
+    var a = moment([2011, 9, 12, 6, 7, 8]);
     equal(a.year(), 2011, 'year');
     equal(a.month(), 9, 'month');
     equal(a.date(), 12, 'date');
@@ -212,7 +211,7 @@ test("getters", 7, function() {
 });
 
 test("setters", 7, function() {
-    var a = _date();
+    var a = moment();
     a.year(2011);
     a.month(9);
     a.date(12);
@@ -229,7 +228,7 @@ test("setters", 7, function() {
 });
 
 test("chaining setters", 7, function() {
-    var a = _date();
+    var a = moment();
     a.year(2011)
      .month(9)
      .date(12)
@@ -245,16 +244,3 @@ test("chaining setters", 7, function() {
     equal(a.seconds(), 8, 'second');
 });
 
-
-module("underscore mixin");
-
-
-test("underscore mixin", 6, function() {
-    ok(_.date([2010, 1, 12]).native() instanceof Date, "[2010, 1, 12]");
-    ok(_.date([2010, 1, 12, 1]).native() instanceof Date, "[2010, 1, 12, 1]");
-    ok(_.date().native() instanceof Date, "undefined");
-    ok(_.date("Aug 9, 1995").native() instanceof Date, "Aug 9, 1995");
-    ok(_.date("Mon, 25 Dec 1995 13:30:00 GMT").native() instanceof Date, "Mon, 25 Dec 1995 13:30:00 GMT");
-    deepEqual(_.date(new Date(2010, 1, 14, 15, 25, 50, 125)), _.date([2010, 1, 14, 15, 25, 50, 125]), "constructing with array === constructing with new Date()");
-});
-
index f574f2d624a5e31924111f023d586de49b7a264d..7474512d0f18c53d75513451b6d0972b6ebab0c0 100755 (executable)
@@ -1,20 +1,21 @@
 <!doctype html>
 <html>
     <head>
-        <title>underscore.date unit test suite</title>
+        <meta charset='utf-8'>
+        <title>moment unit test suite</title>
         <link rel="stylesheet" href="http://fonts.googleapis.com/css?family=Oswald&v1" />
         <link rel="stylesheet" href="test.css" />
         <script src="vendor/jquery.js"></script>
         <script src="vendor/underscore.js"></script>
         <script src="vendor/qunit.js"></script>
-        <script src="../underscore.date.js"></script>
+        <script src="../moment.js"></script>
         <script src="../lang/all.min.js"></script>
         <script src="date.js"></script>
         <script src="lang.js"></script>
     </head>
     <body>
         <div id="container">
-            <h1 class="logo">underscore.date unit test suite</h1>
+            <h1 class="logo">moment unit test suite</h1>
             <h2 id="qunit-banner"></h2>
             <h4 id="qunit-userAgent"></h4>
             <ol id="qunit-tests"></ol>
index 3c94578f6f86f76f268953addeb8e9f4158778af..c92e2e1e0b2f6a0503c9a4625ddbbf345162d94f 100644 (file)
@@ -1,4 +1,4 @@
-var _date;if (typeof window === 'undefined') {_date = require('../underscore.date.js');module = QUnit.module;}
+var moment;if (typeof window === 'undefined') {moment = require('../moment.js');module = QUnit.module;}
 /**************************************************
   English
  *************************************************/
@@ -6,7 +6,7 @@ var _date;if (typeof window === 'undefined') {_date = require('../underscore.dat
 module("lang:en");
 
 test("format", 15, function() {
-    _date.lang('en');
+    moment.lang('en');
     var a = [
             ['dddd, MMMM Do YYYY, h:mm:ss a',      'Sunday, February 14th 2010, 3:25:50 pm'],
             ['ddd, hA',                            'Sun, 3PM'],
@@ -24,7 +24,7 @@ test("format", 15, function() {
             ['z zz',                               'PST PST'],
             ['t\\he DDDo \\d\\ay of t\\he ye\\ar', 'the 45th day of the year']
         ],
-        b = _date(new Date(2010, 1, 14, 15, 25, 50, 125)),
+        b = moment(new Date(2010, 1, 14, 15, 25, 50, 125)),
         i;
     for (i = 0; i < a.length; i++) {
         equal(b.format(a[i][0]), a[i][1], a[i][0] + ' ---> ' + a[i][1]);
@@ -32,106 +32,106 @@ test("format", 15, function() {
 });
 
 test("format ordinal", 31, function() {
-    _date.lang('en');
-    equal(_date([2011, 0, 1]).format('DDDo'), '1st', '1st');
-    equal(_date([2011, 0, 2]).format('DDDo'), '2nd', '2nd');
-    equal(_date([2011, 0, 3]).format('DDDo'), '3rd', '3rd');
-    equal(_date([2011, 0, 4]).format('DDDo'), '4th', '4th');
-    equal(_date([2011, 0, 5]).format('DDDo'), '5th', '5th');
-    equal(_date([2011, 0, 6]).format('DDDo'), '6th', '6th');
-    equal(_date([2011, 0, 7]).format('DDDo'), '7th', '7th');
-    equal(_date([2011, 0, 8]).format('DDDo'), '8th', '8th');
-    equal(_date([2011, 0, 9]).format('DDDo'), '9th', '9th');
-    equal(_date([2011, 0, 10]).format('DDDo'), '10th', '10th');
-
-    equal(_date([2011, 0, 11]).format('DDDo'), '11th', '11th');
-    equal(_date([2011, 0, 12]).format('DDDo'), '12th', '12th');
-    equal(_date([2011, 0, 13]).format('DDDo'), '13th', '13th');
-    equal(_date([2011, 0, 14]).format('DDDo'), '14th', '14th');
-    equal(_date([2011, 0, 15]).format('DDDo'), '15th', '15th');
-    equal(_date([2011, 0, 16]).format('DDDo'), '16th', '16th');
-    equal(_date([2011, 0, 17]).format('DDDo'), '17th', '17th');
-    equal(_date([2011, 0, 18]).format('DDDo'), '18th', '18th');
-    equal(_date([2011, 0, 19]).format('DDDo'), '19th', '19th');
-    equal(_date([2011, 0, 20]).format('DDDo'), '20th', '20th');
-
-    equal(_date([2011, 0, 21]).format('DDDo'), '21st', '21st');
-    equal(_date([2011, 0, 22]).format('DDDo'), '22nd', '22nd');
-    equal(_date([2011, 0, 23]).format('DDDo'), '23rd', '23rd');
-    equal(_date([2011, 0, 24]).format('DDDo'), '24th', '24th');
-    equal(_date([2011, 0, 25]).format('DDDo'), '25th', '25th');
-    equal(_date([2011, 0, 26]).format('DDDo'), '26th', '26th');
-    equal(_date([2011, 0, 27]).format('DDDo'), '27th', '27th');
-    equal(_date([2011, 0, 28]).format('DDDo'), '28th', '28th');
-    equal(_date([2011, 0, 29]).format('DDDo'), '29th', '29th');
-    equal(_date([2011, 0, 30]).format('DDDo'), '30th', '30th');
-
-    equal(_date([2011, 0, 31]).format('DDDo'), '31st', '31st');
+    moment.lang('en');
+    equal(moment([2011, 0, 1]).format('DDDo'), '1st', '1st');
+    equal(moment([2011, 0, 2]).format('DDDo'), '2nd', '2nd');
+    equal(moment([2011, 0, 3]).format('DDDo'), '3rd', '3rd');
+    equal(moment([2011, 0, 4]).format('DDDo'), '4th', '4th');
+    equal(moment([2011, 0, 5]).format('DDDo'), '5th', '5th');
+    equal(moment([2011, 0, 6]).format('DDDo'), '6th', '6th');
+    equal(moment([2011, 0, 7]).format('DDDo'), '7th', '7th');
+    equal(moment([2011, 0, 8]).format('DDDo'), '8th', '8th');
+    equal(moment([2011, 0, 9]).format('DDDo'), '9th', '9th');
+    equal(moment([2011, 0, 10]).format('DDDo'), '10th', '10th');
+
+    equal(moment([2011, 0, 11]).format('DDDo'), '11th', '11th');
+    equal(moment([2011, 0, 12]).format('DDDo'), '12th', '12th');
+    equal(moment([2011, 0, 13]).format('DDDo'), '13th', '13th');
+    equal(moment([2011, 0, 14]).format('DDDo'), '14th', '14th');
+    equal(moment([2011, 0, 15]).format('DDDo'), '15th', '15th');
+    equal(moment([2011, 0, 16]).format('DDDo'), '16th', '16th');
+    equal(moment([2011, 0, 17]).format('DDDo'), '17th', '17th');
+    equal(moment([2011, 0, 18]).format('DDDo'), '18th', '18th');
+    equal(moment([2011, 0, 19]).format('DDDo'), '19th', '19th');
+    equal(moment([2011, 0, 20]).format('DDDo'), '20th', '20th');
+
+    equal(moment([2011, 0, 21]).format('DDDo'), '21st', '21st');
+    equal(moment([2011, 0, 22]).format('DDDo'), '22nd', '22nd');
+    equal(moment([2011, 0, 23]).format('DDDo'), '23rd', '23rd');
+    equal(moment([2011, 0, 24]).format('DDDo'), '24th', '24th');
+    equal(moment([2011, 0, 25]).format('DDDo'), '25th', '25th');
+    equal(moment([2011, 0, 26]).format('DDDo'), '26th', '26th');
+    equal(moment([2011, 0, 27]).format('DDDo'), '27th', '27th');
+    equal(moment([2011, 0, 28]).format('DDDo'), '28th', '28th');
+    equal(moment([2011, 0, 29]).format('DDDo'), '29th', '29th');
+    equal(moment([2011, 0, 30]).format('DDDo'), '30th', '30th');
+
+    equal(moment([2011, 0, 31]).format('DDDo'), '31st', '31st');
 });
 
 test("format month", 12, function() {
-    _date.lang('en');
+    moment.lang('en');
     var expected = 'January Jan_February Feb_March Mar_April Apr_May May_June Jun_July Jul_August Aug_September Sep_October Oct_November Nov_December Dec'.split("_");
     var i;
     for (i = 0; i < expected.length; i++) {
-        equal(_date([2011, i, 0]).format('MMMM MMM'), expected[i], expected[i]);
+        equal(moment([2011, i, 0]).format('MMMM MMM'), expected[i], expected[i]);
     }
 });
 
 test("format week", 7, function() {
-    _date.lang('en');
+    moment.lang('en');
     var expected = 'Sunday Sun_Monday Mon_Tuesday Tue_Wednesday Wed_Thursday Thu_Friday Fri_Saturday Sat'.split("_");
     var i;
     for (i = 0; i < expected.length; i++) {
-        equal(_date([2011, 0, 2 + i]).format('dddd ddd'), expected[i], expected[i]);
+        equal(moment([2011, 0, 2 + i]).format('dddd ddd'), expected[i], expected[i]);
     }
 });
 
 test("from", 30, function() {
-    _date.lang('en');
-    var start = _date([2007, 1, 28]);
-    equal(start.from(_date([2007, 1, 28]).add({s:44}), true),  "seconds",    "44 seconds = seconds");
-    equal(start.from(_date([2007, 1, 28]).add({s:45}), true),  "a minute",   "45 seconds = a minute");
-    equal(start.from(_date([2007, 1, 28]).add({s:89}), true),  "a minute",   "89 seconds = a minute");
-    equal(start.from(_date([2007, 1, 28]).add({s:90}), true),  "2 minutes",  "90 seconds = 2 minutes");
-    equal(start.from(_date([2007, 1, 28]).add({m:44}), true),  "44 minutes", "44 minutes = 44 minutes");
-    equal(start.from(_date([2007, 1, 28]).add({m:45}), true),  "an hour",    "45 minutes = an hour");
-    equal(start.from(_date([2007, 1, 28]).add({m:89}), true),  "an hour",    "89 minutes = an hour");
-    equal(start.from(_date([2007, 1, 28]).add({m:90}), true),  "2 hours",    "90 minutes = 2 hours");
-    equal(start.from(_date([2007, 1, 28]).add({h:5}), true),   "5 hours",    "5 hours = 5 hours");
-    equal(start.from(_date([2007, 1, 28]).add({h:21}), true),  "21 hours",   "21 hours = 21 hours");
-    equal(start.from(_date([2007, 1, 28]).add({h:22}), true),  "a day",      "22 hours = a day");
-    equal(start.from(_date([2007, 1, 28]).add({h:35}), true),  "a day",      "35 hours = a day");
-    equal(start.from(_date([2007, 1, 28]).add({h:36}), true),  "2 days",     "36 hours = 2 days");
-    equal(start.from(_date([2007, 1, 28]).add({d:1}), true),   "a day",      "1 day = a day");
-    equal(start.from(_date([2007, 1, 28]).add({d:5}), true),   "5 days",     "5 days = 5 days");
-    equal(start.from(_date([2007, 1, 28]).add({d:25}), true),  "25 days",    "25 days = 25 days");
-    equal(start.from(_date([2007, 1, 28]).add({d:26}), true),  "a month",    "26 days = a month");
-    equal(start.from(_date([2007, 1, 28]).add({d:30}), true),  "a month",    "30 days = a month");
-    equal(start.from(_date([2007, 1, 28]).add({d:45}), true),  "a month",    "45 days = a month");
-    equal(start.from(_date([2007, 1, 28]).add({d:46}), true),  "2 months",   "46 days = 2 months");
-    equal(start.from(_date([2007, 1, 28]).add({d:75}), true),  "2 months",   "75 days = 2 months");
-    equal(start.from(_date([2007, 1, 28]).add({d:76}), true),  "3 months",   "76 days = 3 months");
-    equal(start.from(_date([2007, 1, 28]).add({M:1}), true),   "a month",    "1 month = a month");
-    equal(start.from(_date([2007, 1, 28]).add({M:5}), true),   "5 months",   "5 months = 5 months");
-    equal(start.from(_date([2007, 1, 28]).add({d:344}), true), "11 months",  "344 days = 11 months");
-    equal(start.from(_date([2007, 1, 28]).add({d:345}), true), "a year",     "345 days = a year");
-    equal(start.from(_date([2007, 1, 28]).add({d:547}), true), "a year",     "547 days = a year");
-    equal(start.from(_date([2007, 1, 28]).add({d:548}), true), "2 years",    "548 days = 2 years");
-    equal(start.from(_date([2007, 1, 28]).add({y:1}), true),   "a year",     "1 year = a year");
-    equal(start.from(_date([2007, 1, 28]).add({y:5}), true),   "5 years",    "5 years = 5 years");
+    moment.lang('en');
+    var start = moment([2007, 1, 28]);
+    equal(start.from(moment([2007, 1, 28]).add({s:44}), true),  "seconds",    "44 seconds = seconds");
+    equal(start.from(moment([2007, 1, 28]).add({s:45}), true),  "a minute",   "45 seconds = a minute");
+    equal(start.from(moment([2007, 1, 28]).add({s:89}), true),  "a minute",   "89 seconds = a minute");
+    equal(start.from(moment([2007, 1, 28]).add({s:90}), true),  "2 minutes",  "90 seconds = 2 minutes");
+    equal(start.from(moment([2007, 1, 28]).add({m:44}), true),  "44 minutes", "44 minutes = 44 minutes");
+    equal(start.from(moment([2007, 1, 28]).add({m:45}), true),  "an hour",    "45 minutes = an hour");
+    equal(start.from(moment([2007, 1, 28]).add({m:89}), true),  "an hour",    "89 minutes = an hour");
+    equal(start.from(moment([2007, 1, 28]).add({m:90}), true),  "2 hours",    "90 minutes = 2 hours");
+    equal(start.from(moment([2007, 1, 28]).add({h:5}), true),   "5 hours",    "5 hours = 5 hours");
+    equal(start.from(moment([2007, 1, 28]).add({h:21}), true),  "21 hours",   "21 hours = 21 hours");
+    equal(start.from(moment([2007, 1, 28]).add({h:22}), true),  "a day",      "22 hours = a day");
+    equal(start.from(moment([2007, 1, 28]).add({h:35}), true),  "a day",      "35 hours = a day");
+    equal(start.from(moment([2007, 1, 28]).add({h:36}), true),  "2 days",     "36 hours = 2 days");
+    equal(start.from(moment([2007, 1, 28]).add({d:1}), true),   "a day",      "1 day = a day");
+    equal(start.from(moment([2007, 1, 28]).add({d:5}), true),   "5 days",     "5 days = 5 days");
+    equal(start.from(moment([2007, 1, 28]).add({d:25}), true),  "25 days",    "25 days = 25 days");
+    equal(start.from(moment([2007, 1, 28]).add({d:26}), true),  "a month",    "26 days = a month");
+    equal(start.from(moment([2007, 1, 28]).add({d:30}), true),  "a month",    "30 days = a month");
+    equal(start.from(moment([2007, 1, 28]).add({d:45}), true),  "a month",    "45 days = a month");
+    equal(start.from(moment([2007, 1, 28]).add({d:46}), true),  "2 months",   "46 days = 2 months");
+    equal(start.from(moment([2007, 1, 28]).add({d:75}), true),  "2 months",   "75 days = 2 months");
+    equal(start.from(moment([2007, 1, 28]).add({d:76}), true),  "3 months",   "76 days = 3 months");
+    equal(start.from(moment([2007, 1, 28]).add({M:1}), true),   "a month",    "1 month = a month");
+    equal(start.from(moment([2007, 1, 28]).add({M:5}), true),   "5 months",   "5 months = 5 months");
+    equal(start.from(moment([2007, 1, 28]).add({d:344}), true), "11 months",  "344 days = 11 months");
+    equal(start.from(moment([2007, 1, 28]).add({d:345}), true), "a year",     "345 days = a year");
+    equal(start.from(moment([2007, 1, 28]).add({d:547}), true), "a year",     "547 days = a year");
+    equal(start.from(moment([2007, 1, 28]).add({d:548}), true), "2 years",    "548 days = 2 years");
+    equal(start.from(moment([2007, 1, 28]).add({y:1}), true),   "a year",     "1 year = a year");
+    equal(start.from(moment([2007, 1, 28]).add({y:5}), true),   "5 years",    "5 years = 5 years");
 });
 
 test("suffix", 2, function() {
-    _date.lang('en');
-    equal(_date(30000).from(0), "in seconds", "prefix");
-    equal(_date(0).from(30000), "seconds ago", "suffix");
+    moment.lang('en');
+    equal(moment(30000).from(0), "in seconds", "prefix");
+    equal(moment(0).from(30000), "seconds ago", "suffix");
 });
 
 test("fromNow", 2, function() {
-    _date.lang('en');
-    equal(_date().add({s:30}).fromNow(), "in seconds", "in seconds");
-    equal(_date().add({d:5}).fromNow(), "in 5 days", "in 5 days");
+    moment.lang('en');
+    equal(moment().add({s:30}).fromNow(), "in seconds", "in seconds");
+    equal(moment().add({d:5}).fromNow(), "in 5 days", "in 5 days");
 });
 
 /**************************************************
@@ -141,7 +141,7 @@ test("fromNow", 2, function() {
 module("lang:fr");
 
 test("format", 15, function() {
-    _date.lang('fr');
+    moment.lang('fr');
     var a = [
             ['dddd, MMMM Do YYYY, h:mm:ss a',      'Dimanche, Février 14er 2010, 3:25:50 pm'],
             ['ddd, hA',                            'Dim, 3PM'],
@@ -159,7 +159,7 @@ test("format", 15, function() {
             ['z zz',                               'PST PST'],
             ['t\\he DDDo \\d\\ay of t\\he ye\\ar', 'the 45ème day of the year']
         ],
-        b = _date(new Date(2010, 1, 14, 15, 25, 50, 125)),
+        b = moment(new Date(2010, 1, 14, 15, 25, 50, 125)),
         i;
     for (i = 0; i < a.length; i++) {
         equal(b.format(a[i][0]), a[i][1], a[i][0] + ' ---> ' + a[i][1]);
@@ -167,106 +167,106 @@ test("format", 15, function() {
 });
 
 test("format ordinal", 31, function() {
-    _date.lang('fr');
-    equal(_date([2011, 0, 1]).format('DDDo'), '1ème', '1ème');
-    equal(_date([2011, 0, 2]).format('DDDo'), '2ème', '2ème');
-    equal(_date([2011, 0, 3]).format('DDDo'), '3ème', '3ème');
-    equal(_date([2011, 0, 4]).format('DDDo'), '4ème', '4ème');
-    equal(_date([2011, 0, 5]).format('DDDo'), '5ème', '5ème');
-    equal(_date([2011, 0, 6]).format('DDDo'), '6ème', '6ème');
-    equal(_date([2011, 0, 7]).format('DDDo'), '7ème', '7ème');
-    equal(_date([2011, 0, 8]).format('DDDo'), '8ème', '8ème');
-    equal(_date([2011, 0, 9]).format('DDDo'), '9ème', '9ème');
-    equal(_date([2011, 0, 10]).format('DDDo'), '10er', '10er');
-
-    equal(_date([2011, 0, 11]).format('DDDo'), '11er', '11er');
-    equal(_date([2011, 0, 12]).format('DDDo'), '12er', '12er');
-    equal(_date([2011, 0, 13]).format('DDDo'), '13er', '13er');
-    equal(_date([2011, 0, 14]).format('DDDo'), '14er', '14er');
-    equal(_date([2011, 0, 15]).format('DDDo'), '15er', '15er');
-    equal(_date([2011, 0, 16]).format('DDDo'), '16er', '16er');
-    equal(_date([2011, 0, 17]).format('DDDo'), '17er', '17er');
-    equal(_date([2011, 0, 18]).format('DDDo'), '18er', '18er');
-    equal(_date([2011, 0, 19]).format('DDDo'), '19er', '19er');
-    equal(_date([2011, 0, 20]).format('DDDo'), '20ème', '20ème');
-
-    equal(_date([2011, 0, 21]).format('DDDo'), '21ème', '21ème');
-    equal(_date([2011, 0, 22]).format('DDDo'), '22ème', '22ème');
-    equal(_date([2011, 0, 23]).format('DDDo'), '23ème', '23ème');
-    equal(_date([2011, 0, 24]).format('DDDo'), '24ème', '24ème');
-    equal(_date([2011, 0, 25]).format('DDDo'), '25ème', '25ème');
-    equal(_date([2011, 0, 26]).format('DDDo'), '26ème', '26ème');
-    equal(_date([2011, 0, 27]).format('DDDo'), '27ème', '27ème');
-    equal(_date([2011, 0, 28]).format('DDDo'), '28ème', '28ème');
-    equal(_date([2011, 0, 29]).format('DDDo'), '29ème', '29ème');
-    equal(_date([2011, 0, 30]).format('DDDo'), '30ème', '30ème');
-
-    equal(_date([2011, 0, 31]).format('DDDo'), '31ème', '31ème');
+    moment.lang('fr');
+    equal(moment([2011, 0, 1]).format('DDDo'), '1ème', '1ème');
+    equal(moment([2011, 0, 2]).format('DDDo'), '2ème', '2ème');
+    equal(moment([2011, 0, 3]).format('DDDo'), '3ème', '3ème');
+    equal(moment([2011, 0, 4]).format('DDDo'), '4ème', '4ème');
+    equal(moment([2011, 0, 5]).format('DDDo'), '5ème', '5ème');
+    equal(moment([2011, 0, 6]).format('DDDo'), '6ème', '6ème');
+    equal(moment([2011, 0, 7]).format('DDDo'), '7ème', '7ème');
+    equal(moment([2011, 0, 8]).format('DDDo'), '8ème', '8ème');
+    equal(moment([2011, 0, 9]).format('DDDo'), '9ème', '9ème');
+    equal(moment([2011, 0, 10]).format('DDDo'), '10er', '10er');
+
+    equal(moment([2011, 0, 11]).format('DDDo'), '11er', '11er');
+    equal(moment([2011, 0, 12]).format('DDDo'), '12er', '12er');
+    equal(moment([2011, 0, 13]).format('DDDo'), '13er', '13er');
+    equal(moment([2011, 0, 14]).format('DDDo'), '14er', '14er');
+    equal(moment([2011, 0, 15]).format('DDDo'), '15er', '15er');
+    equal(moment([2011, 0, 16]).format('DDDo'), '16er', '16er');
+    equal(moment([2011, 0, 17]).format('DDDo'), '17er', '17er');
+    equal(moment([2011, 0, 18]).format('DDDo'), '18er', '18er');
+    equal(moment([2011, 0, 19]).format('DDDo'), '19er', '19er');
+    equal(moment([2011, 0, 20]).format('DDDo'), '20ème', '20ème');
+
+    equal(moment([2011, 0, 21]).format('DDDo'), '21ème', '21ème');
+    equal(moment([2011, 0, 22]).format('DDDo'), '22ème', '22ème');
+    equal(moment([2011, 0, 23]).format('DDDo'), '23ème', '23ème');
+    equal(moment([2011, 0, 24]).format('DDDo'), '24ème', '24ème');
+    equal(moment([2011, 0, 25]).format('DDDo'), '25ème', '25ème');
+    equal(moment([2011, 0, 26]).format('DDDo'), '26ème', '26ème');
+    equal(moment([2011, 0, 27]).format('DDDo'), '27ème', '27ème');
+    equal(moment([2011, 0, 28]).format('DDDo'), '28ème', '28ème');
+    equal(moment([2011, 0, 29]).format('DDDo'), '29ème', '29ème');
+    equal(moment([2011, 0, 30]).format('DDDo'), '30ème', '30ème');
+
+    equal(moment([2011, 0, 31]).format('DDDo'), '31ème', '31ème');
 });
 
 test("format month", 12, function() {
-    _date.lang('fr');
+    moment.lang('fr');
     var expected = 'Janvier Jan_Février Fev_Mars Mar_Avril Avr_Mai Mai_Juin Juin_Juillet Juil_Aout Aou_Septembre Sep_Octobre Oct_Novembre Nov_Décembre Dec'.split("_");
     var i;
     for (i = 0; i < expected.length; i++) {
-        equal(_date([2011, i, 0]).format('MMMM MMM'), expected[i], expected[i]);
+        equal(moment([2011, i, 0]).format('MMMM MMM'), expected[i], expected[i]);
     }
 });
 
 test("format week", 7, function() {
-    _date.lang('fr');
+    moment.lang('fr');
     var expected = 'Dimanche Dim_Lundi Lun_Mardi Mar_Mercredi Mer_Jeudi Jeu_Vendredi Ven_Samedi Sam'.split("_");
     var i;
     for (i = 0; i < expected.length; i++) {
-        equal(_date([2011, 0, 2 + i]).format('dddd ddd'), expected[i], expected[i]);
+        equal(moment([2011, 0, 2 + i]).format('dddd ddd'), expected[i], expected[i]);
     }
 });
 
 test("from", 30, function() {
-    _date.lang('fr');
-    var start = _date([2007, 1, 28]);
-    equal(start.from(_date([2007, 1, 28]).add({s:44}), true),  "secondes",    "44 seconds = seconds");
-    equal(start.from(_date([2007, 1, 28]).add({s:45}), true),  "une minute",   "45 seconds = a minute");
-    equal(start.from(_date([2007, 1, 28]).add({s:89}), true),  "une minute",   "89 seconds = a minute");
-    equal(start.from(_date([2007, 1, 28]).add({s:90}), true),  "2 minutes",  "90 seconds = 2 minutes");
-    equal(start.from(_date([2007, 1, 28]).add({m:44}), true),  "44 minutes", "44 minutes = 44 minutes");
-    equal(start.from(_date([2007, 1, 28]).add({m:45}), true),  "une heure",    "45 minutes = an hour");
-    equal(start.from(_date([2007, 1, 28]).add({m:89}), true),  "une heure",    "89 minutes = an hour");
-    equal(start.from(_date([2007, 1, 28]).add({m:90}), true),  "2 heures",    "90 minutes = 2 hours");
-    equal(start.from(_date([2007, 1, 28]).add({h:5}), true),   "5 heures",    "5 hours = 5 hours");
-    equal(start.from(_date([2007, 1, 28]).add({h:21}), true),  "21 heures",   "21 hours = 21 hours");
-    equal(start.from(_date([2007, 1, 28]).add({h:22}), true),  "un jour",      "22 hours = a day");
-    equal(start.from(_date([2007, 1, 28]).add({h:35}), true),  "un jour",      "35 hours = a day");
-    equal(start.from(_date([2007, 1, 28]).add({h:36}), true),  "2 jours",     "36 hours = 2 days");
-    equal(start.from(_date([2007, 1, 28]).add({d:1}), true),   "un jour",      "1 day = a day");
-    equal(start.from(_date([2007, 1, 28]).add({d:5}), true),   "5 jours",     "5 days = 5 days");
-    equal(start.from(_date([2007, 1, 28]).add({d:25}), true),  "25 jours",    "25 days = 25 days");
-    equal(start.from(_date([2007, 1, 28]).add({d:26}), true),  "un mois",    "26 days = a month");
-    equal(start.from(_date([2007, 1, 28]).add({d:30}), true),  "un mois",    "30 days = a month");
-    equal(start.from(_date([2007, 1, 28]).add({d:45}), true),  "un mois",    "45 days = a month");
-    equal(start.from(_date([2007, 1, 28]).add({d:46}), true),  "2 mois",   "46 days = 2 months");
-    equal(start.from(_date([2007, 1, 28]).add({d:75}), true),  "2 mois",   "75 days = 2 months");
-    equal(start.from(_date([2007, 1, 28]).add({d:76}), true),  "3 mois",   "76 days = 3 months");
-    equal(start.from(_date([2007, 1, 28]).add({M:1}), true),   "un mois",    "1 month = a month");
-    equal(start.from(_date([2007, 1, 28]).add({M:5}), true),   "5 mois",   "5 months = 5 months");
-    equal(start.from(_date([2007, 1, 28]).add({d:344}), true), "11 mois",  "344 days = 11 months");
-    equal(start.from(_date([2007, 1, 28]).add({d:345}), true), "une année",     "345 days = a year");
-    equal(start.from(_date([2007, 1, 28]).add({d:547}), true), "une année",     "547 days = a year");
-    equal(start.from(_date([2007, 1, 28]).add({d:548}), true), "2 années",    "548 days = 2 years");
-    equal(start.from(_date([2007, 1, 28]).add({y:1}), true),   "une année",     "1 year = a year");
-    equal(start.from(_date([2007, 1, 28]).add({y:5}), true),   "5 années",    "5 years = 5 years");
+    moment.lang('fr');
+    var start = moment([2007, 1, 28]);
+    equal(start.from(moment([2007, 1, 28]).add({s:44}), true),  "secondes",    "44 seconds = seconds");
+    equal(start.from(moment([2007, 1, 28]).add({s:45}), true),  "une minute",   "45 seconds = a minute");
+    equal(start.from(moment([2007, 1, 28]).add({s:89}), true),  "une minute",   "89 seconds = a minute");
+    equal(start.from(moment([2007, 1, 28]).add({s:90}), true),  "2 minutes",  "90 seconds = 2 minutes");
+    equal(start.from(moment([2007, 1, 28]).add({m:44}), true),  "44 minutes", "44 minutes = 44 minutes");
+    equal(start.from(moment([2007, 1, 28]).add({m:45}), true),  "une heure",    "45 minutes = an hour");
+    equal(start.from(moment([2007, 1, 28]).add({m:89}), true),  "une heure",    "89 minutes = an hour");
+    equal(start.from(moment([2007, 1, 28]).add({m:90}), true),  "2 heures",    "90 minutes = 2 hours");
+    equal(start.from(moment([2007, 1, 28]).add({h:5}), true),   "5 heures",    "5 hours = 5 hours");
+    equal(start.from(moment([2007, 1, 28]).add({h:21}), true),  "21 heures",   "21 hours = 21 hours");
+    equal(start.from(moment([2007, 1, 28]).add({h:22}), true),  "un jour",      "22 hours = a day");
+    equal(start.from(moment([2007, 1, 28]).add({h:35}), true),  "un jour",      "35 hours = a day");
+    equal(start.from(moment([2007, 1, 28]).add({h:36}), true),  "2 jours",     "36 hours = 2 days");
+    equal(start.from(moment([2007, 1, 28]).add({d:1}), true),   "un jour",      "1 day = a day");
+    equal(start.from(moment([2007, 1, 28]).add({d:5}), true),   "5 jours",     "5 days = 5 days");
+    equal(start.from(moment([2007, 1, 28]).add({d:25}), true),  "25 jours",    "25 days = 25 days");
+    equal(start.from(moment([2007, 1, 28]).add({d:26}), true),  "un mois",    "26 days = a month");
+    equal(start.from(moment([2007, 1, 28]).add({d:30}), true),  "un mois",    "30 days = a month");
+    equal(start.from(moment([2007, 1, 28]).add({d:45}), true),  "un mois",    "45 days = a month");
+    equal(start.from(moment([2007, 1, 28]).add({d:46}), true),  "2 mois",   "46 days = 2 months");
+    equal(start.from(moment([2007, 1, 28]).add({d:75}), true),  "2 mois",   "75 days = 2 months");
+    equal(start.from(moment([2007, 1, 28]).add({d:76}), true),  "3 mois",   "76 days = 3 months");
+    equal(start.from(moment([2007, 1, 28]).add({M:1}), true),   "un mois",    "1 month = a month");
+    equal(start.from(moment([2007, 1, 28]).add({M:5}), true),   "5 mois",   "5 months = 5 months");
+    equal(start.from(moment([2007, 1, 28]).add({d:344}), true), "11 mois",  "344 days = 11 months");
+    equal(start.from(moment([2007, 1, 28]).add({d:345}), true), "une année",     "345 days = a year");
+    equal(start.from(moment([2007, 1, 28]).add({d:547}), true), "une année",     "547 days = a year");
+    equal(start.from(moment([2007, 1, 28]).add({d:548}), true), "2 années",    "548 days = 2 years");
+    equal(start.from(moment([2007, 1, 28]).add({y:1}), true),   "une année",     "1 year = a year");
+    equal(start.from(moment([2007, 1, 28]).add({y:5}), true),   "5 années",    "5 years = 5 years");
 });
 
 test("suffix", 2, function() {
-    _date.lang('fr');
-    equal(_date(30000).from(0), "in secondes", "prefix");
-    equal(_date(0).from(30000), "il y a secondes", "suffix");
+    moment.lang('fr');
+    equal(moment(30000).from(0), "in secondes", "prefix");
+    equal(moment(0).from(30000), "il y a secondes", "suffix");
 });
 
 test("fromNow", 2, function() {
-    _date.lang('fr');
-    equal(_date().add({s:30}).fromNow(), "in secondes", "in seconds");
-    equal(_date().add({d:5}).fromNow(), "in 5 jours", "in 5 days");
+    moment.lang('fr');
+    equal(moment().add({s:30}).fromNow(), "in secondes", "in seconds");
+    equal(moment().add({d:5}).fromNow(), "in 5 jours", "in 5 days");
 });
 /**************************************************
   Italian
@@ -275,7 +275,7 @@ test("fromNow", 2, function() {
 module("lang:it");
 
 test("format", 15, function() {
-    _date.lang('it');
+    moment.lang('it');
     var a = [
             ['dddd, MMMM Do YYYY, h:mm:ss a',      'Domenica, Febbraio 14º 2010, 3:25:50 pm'],
             ['ddd, hA',                            'Dom, 3PM'],
@@ -293,7 +293,7 @@ test("format", 15, function() {
             ['z zz',                               'PST PST'],
             ['t\\he DDDo \\d\\ay of t\\he ye\\ar', 'the 45º day of the year']
         ],
-        b = _date(new Date(2010, 1, 14, 15, 25, 50, 125)),
+        b = moment(new Date(2010, 1, 14, 15, 25, 50, 125)),
         i;
     for (i = 0; i < a.length; i++) {
         equal(b.format(a[i][0]), a[i][1], a[i][0] + ' ---> ' + a[i][1]);
@@ -301,106 +301,106 @@ test("format", 15, function() {
 });
 
 test("format ordinal", 31, function() {
-    _date.lang('it');
-    equal(_date([2011, 0, 1]).format('DDDo'), '1º', '1º');
-    equal(_date([2011, 0, 2]).format('DDDo'), '2º', '2º');
-    equal(_date([2011, 0, 3]).format('DDDo'), '3º', '3º');
-    equal(_date([2011, 0, 4]).format('DDDo'), '4º', '4º');
-    equal(_date([2011, 0, 5]).format('DDDo'), '5º', '5º');
-    equal(_date([2011, 0, 6]).format('DDDo'), '6º', '6º');
-    equal(_date([2011, 0, 7]).format('DDDo'), '7º', '7º');
-    equal(_date([2011, 0, 8]).format('DDDo'), '8º', '8º');
-    equal(_date([2011, 0, 9]).format('DDDo'), '9º', '9º');
-    equal(_date([2011, 0, 10]).format('DDDo'), '10º', '10º');
-
-    equal(_date([2011, 0, 11]).format('DDDo'), '11º', '11º');
-    equal(_date([2011, 0, 12]).format('DDDo'), '12º', '12º');
-    equal(_date([2011, 0, 13]).format('DDDo'), '13º', '13º');
-    equal(_date([2011, 0, 14]).format('DDDo'), '14º', '14º');
-    equal(_date([2011, 0, 15]).format('DDDo'), '15º', '15º');
-    equal(_date([2011, 0, 16]).format('DDDo'), '16º', '16º');
-    equal(_date([2011, 0, 17]).format('DDDo'), '17º', '17º');
-    equal(_date([2011, 0, 18]).format('DDDo'), '18º', '18º');
-    equal(_date([2011, 0, 19]).format('DDDo'), '19º', '19º');
-    equal(_date([2011, 0, 20]).format('DDDo'), '20º', '20º');
-
-    equal(_date([2011, 0, 21]).format('DDDo'), '21º', '21º');
-    equal(_date([2011, 0, 22]).format('DDDo'), '22º', '22º');
-    equal(_date([2011, 0, 23]).format('DDDo'), '23º', '23º');
-    equal(_date([2011, 0, 24]).format('DDDo'), '24º', '24º');
-    equal(_date([2011, 0, 25]).format('DDDo'), '25º', '25º');
-    equal(_date([2011, 0, 26]).format('DDDo'), '26º', '26º');
-    equal(_date([2011, 0, 27]).format('DDDo'), '27º', '27º');
-    equal(_date([2011, 0, 28]).format('DDDo'), '28º', '28º');
-    equal(_date([2011, 0, 29]).format('DDDo'), '29º', '29º');
-    equal(_date([2011, 0, 30]).format('DDDo'), '30º', '30º');
-
-    equal(_date([2011, 0, 31]).format('DDDo'), '31º', '31º');
+    moment.lang('it');
+    equal(moment([2011, 0, 1]).format('DDDo'), '1º', '1º');
+    equal(moment([2011, 0, 2]).format('DDDo'), '2º', '2º');
+    equal(moment([2011, 0, 3]).format('DDDo'), '3º', '3º');
+    equal(moment([2011, 0, 4]).format('DDDo'), '4º', '4º');
+    equal(moment([2011, 0, 5]).format('DDDo'), '5º', '5º');
+    equal(moment([2011, 0, 6]).format('DDDo'), '6º', '6º');
+    equal(moment([2011, 0, 7]).format('DDDo'), '7º', '7º');
+    equal(moment([2011, 0, 8]).format('DDDo'), '8º', '8º');
+    equal(moment([2011, 0, 9]).format('DDDo'), '9º', '9º');
+    equal(moment([2011, 0, 10]).format('DDDo'), '10º', '10º');
+
+    equal(moment([2011, 0, 11]).format('DDDo'), '11º', '11º');
+    equal(moment([2011, 0, 12]).format('DDDo'), '12º', '12º');
+    equal(moment([2011, 0, 13]).format('DDDo'), '13º', '13º');
+    equal(moment([2011, 0, 14]).format('DDDo'), '14º', '14º');
+    equal(moment([2011, 0, 15]).format('DDDo'), '15º', '15º');
+    equal(moment([2011, 0, 16]).format('DDDo'), '16º', '16º');
+    equal(moment([2011, 0, 17]).format('DDDo'), '17º', '17º');
+    equal(moment([2011, 0, 18]).format('DDDo'), '18º', '18º');
+    equal(moment([2011, 0, 19]).format('DDDo'), '19º', '19º');
+    equal(moment([2011, 0, 20]).format('DDDo'), '20º', '20º');
+
+    equal(moment([2011, 0, 21]).format('DDDo'), '21º', '21º');
+    equal(moment([2011, 0, 22]).format('DDDo'), '22º', '22º');
+    equal(moment([2011, 0, 23]).format('DDDo'), '23º', '23º');
+    equal(moment([2011, 0, 24]).format('DDDo'), '24º', '24º');
+    equal(moment([2011, 0, 25]).format('DDDo'), '25º', '25º');
+    equal(moment([2011, 0, 26]).format('DDDo'), '26º', '26º');
+    equal(moment([2011, 0, 27]).format('DDDo'), '27º', '27º');
+    equal(moment([2011, 0, 28]).format('DDDo'), '28º', '28º');
+    equal(moment([2011, 0, 29]).format('DDDo'), '29º', '29º');
+    equal(moment([2011, 0, 30]).format('DDDo'), '30º', '30º');
+
+    equal(moment([2011, 0, 31]).format('DDDo'), '31º', '31º');
 });
 
 test("format month", 12, function() {
-    _date.lang('it');
+    moment.lang('it');
     var expected = 'Gennaio Gen_Febbraio Feb_Marzo Mar_Aprile Apr_Maggio Mag_Giugno Giu_Luglio Lug_Agosto Ago_Settebre Set_Ottobre Ott_Novembre Nov_Dicembre Dic'.split("_");
     var i;
     for (i = 0; i < expected.length; i++) {
-        equal(_date([2011, i, 0]).format('MMMM MMM'), expected[i], expected[i]);
+        equal(moment([2011, i, 0]).format('MMMM MMM'), expected[i], expected[i]);
     }
 });
 
 test("format week", 7, function() {
-    _date.lang('it');
+    moment.lang('it');
     var expected = 'Domenica Dom_Lunedi Lun_Martedi Mar_Mercoledi Mer_Giovedi Gio_Venerdi Ven_Sabato Sab'.split("_");
     var i;
     for (i = 0; i < expected.length; i++) {
-        equal(_date([2011, 0, 2 + i]).format('dddd ddd'), expected[i], expected[i]);
+        equal(moment([2011, 0, 2 + i]).format('dddd ddd'), expected[i], expected[i]);
     }
 });
 
 test("from", 30, function() {
-    _date.lang('it');
-    var start = _date([2007, 1, 28]);
-    equal(start.from(_date([2007, 1, 28]).add({s:44}), true),  "secondi",    "44 seconds = seconds");
-    equal(start.from(_date([2007, 1, 28]).add({s:45}), true),  "un minuto",   "45 seconds = a minute");
-    equal(start.from(_date([2007, 1, 28]).add({s:89}), true),  "un minuto",   "89 seconds = a minute");
-    equal(start.from(_date([2007, 1, 28]).add({s:90}), true),  "2 minuti",  "90 seconds = 2 minutes");
-    equal(start.from(_date([2007, 1, 28]).add({m:44}), true),  "44 minuti", "44 minutes = 44 minutes");
-    equal(start.from(_date([2007, 1, 28]).add({m:45}), true),  "un ora",    "45 minutes = an hour");
-    equal(start.from(_date([2007, 1, 28]).add({m:89}), true),  "un ora",    "89 minutes = an hour");
-    equal(start.from(_date([2007, 1, 28]).add({m:90}), true),  "2 ore",    "90 minutes = 2 hours");
-    equal(start.from(_date([2007, 1, 28]).add({h:5}), true),   "5 ore",    "5 hours = 5 hours");
-    equal(start.from(_date([2007, 1, 28]).add({h:21}), true),  "21 ore",   "21 hours = 21 hours");
-    equal(start.from(_date([2007, 1, 28]).add({h:22}), true),  "un giorno",      "22 hours = a day");
-    equal(start.from(_date([2007, 1, 28]).add({h:35}), true),  "un giorno",      "35 hours = a day");
-    equal(start.from(_date([2007, 1, 28]).add({h:36}), true),  "2 giorni",     "36 hours = 2 days");
-    equal(start.from(_date([2007, 1, 28]).add({d:1}), true),   "un giorno",      "1 day = a day");
-    equal(start.from(_date([2007, 1, 28]).add({d:5}), true),   "5 giorni",     "5 days = 5 days");
-    equal(start.from(_date([2007, 1, 28]).add({d:25}), true),  "25 giorni",    "25 days = 25 days");
-    equal(start.from(_date([2007, 1, 28]).add({d:26}), true),  "un mese",    "26 days = a month");
-    equal(start.from(_date([2007, 1, 28]).add({d:30}), true),  "un mese",    "30 days = a month");
-    equal(start.from(_date([2007, 1, 28]).add({d:45}), true),  "un mese",    "45 days = a month");
-    equal(start.from(_date([2007, 1, 28]).add({d:46}), true),  "2 mesi",   "46 days = 2 months");
-    equal(start.from(_date([2007, 1, 28]).add({d:75}), true),  "2 mesi",   "75 days = 2 months");
-    equal(start.from(_date([2007, 1, 28]).add({d:76}), true),  "3 mesi",   "76 days = 3 months");
-    equal(start.from(_date([2007, 1, 28]).add({M:1}), true),   "un mese",    "1 month = a month");
-    equal(start.from(_date([2007, 1, 28]).add({M:5}), true),   "5 mesi",   "5 months = 5 months");
-    equal(start.from(_date([2007, 1, 28]).add({d:344}), true), "11 mesi",  "344 days = 11 months");
-    equal(start.from(_date([2007, 1, 28]).add({d:345}), true), "un anno",     "345 days = a year");
-    equal(start.from(_date([2007, 1, 28]).add({d:547}), true), "un anno",     "547 days = a year");
-    equal(start.from(_date([2007, 1, 28]).add({d:548}), true), "2 anni",    "548 days = 2 years");
-    equal(start.from(_date([2007, 1, 28]).add({y:1}), true),   "un anno",     "1 year = a year");
-    equal(start.from(_date([2007, 1, 28]).add({y:5}), true),   "5 anni",    "5 years = 5 years");
+    moment.lang('it');
+    var start = moment([2007, 1, 28]);
+    equal(start.from(moment([2007, 1, 28]).add({s:44}), true),  "secondi",    "44 seconds = seconds");
+    equal(start.from(moment([2007, 1, 28]).add({s:45}), true),  "un minuto",   "45 seconds = a minute");
+    equal(start.from(moment([2007, 1, 28]).add({s:89}), true),  "un minuto",   "89 seconds = a minute");
+    equal(start.from(moment([2007, 1, 28]).add({s:90}), true),  "2 minuti",  "90 seconds = 2 minutes");
+    equal(start.from(moment([2007, 1, 28]).add({m:44}), true),  "44 minuti", "44 minutes = 44 minutes");
+    equal(start.from(moment([2007, 1, 28]).add({m:45}), true),  "un ora",    "45 minutes = an hour");
+    equal(start.from(moment([2007, 1, 28]).add({m:89}), true),  "un ora",    "89 minutes = an hour");
+    equal(start.from(moment([2007, 1, 28]).add({m:90}), true),  "2 ore",    "90 minutes = 2 hours");
+    equal(start.from(moment([2007, 1, 28]).add({h:5}), true),   "5 ore",    "5 hours = 5 hours");
+    equal(start.from(moment([2007, 1, 28]).add({h:21}), true),  "21 ore",   "21 hours = 21 hours");
+    equal(start.from(moment([2007, 1, 28]).add({h:22}), true),  "un giorno",      "22 hours = a day");
+    equal(start.from(moment([2007, 1, 28]).add({h:35}), true),  "un giorno",      "35 hours = a day");
+    equal(start.from(moment([2007, 1, 28]).add({h:36}), true),  "2 giorni",     "36 hours = 2 days");
+    equal(start.from(moment([2007, 1, 28]).add({d:1}), true),   "un giorno",      "1 day = a day");
+    equal(start.from(moment([2007, 1, 28]).add({d:5}), true),   "5 giorni",     "5 days = 5 days");
+    equal(start.from(moment([2007, 1, 28]).add({d:25}), true),  "25 giorni",    "25 days = 25 days");
+    equal(start.from(moment([2007, 1, 28]).add({d:26}), true),  "un mese",    "26 days = a month");
+    equal(start.from(moment([2007, 1, 28]).add({d:30}), true),  "un mese",    "30 days = a month");
+    equal(start.from(moment([2007, 1, 28]).add({d:45}), true),  "un mese",    "45 days = a month");
+    equal(start.from(moment([2007, 1, 28]).add({d:46}), true),  "2 mesi",   "46 days = 2 months");
+    equal(start.from(moment([2007, 1, 28]).add({d:75}), true),  "2 mesi",   "75 days = 2 months");
+    equal(start.from(moment([2007, 1, 28]).add({d:76}), true),  "3 mesi",   "76 days = 3 months");
+    equal(start.from(moment([2007, 1, 28]).add({M:1}), true),   "un mese",    "1 month = a month");
+    equal(start.from(moment([2007, 1, 28]).add({M:5}), true),   "5 mesi",   "5 months = 5 months");
+    equal(start.from(moment([2007, 1, 28]).add({d:344}), true), "11 mesi",  "344 days = 11 months");
+    equal(start.from(moment([2007, 1, 28]).add({d:345}), true), "un anno",     "345 days = a year");
+    equal(start.from(moment([2007, 1, 28]).add({d:547}), true), "un anno",     "547 days = a year");
+    equal(start.from(moment([2007, 1, 28]).add({d:548}), true), "2 anni",    "548 days = 2 years");
+    equal(start.from(moment([2007, 1, 28]).add({y:1}), true),   "un anno",     "1 year = a year");
+    equal(start.from(moment([2007, 1, 28]).add({y:5}), true),   "5 anni",    "5 years = 5 years");
 });
 
 test("suffix", 2, function() {
-    _date.lang('it');
-    equal(_date(30000).from(0), "in secondi", "prefix");
-    equal(_date(0).from(30000), "secondi fa", "suffix");
+    moment.lang('it');
+    equal(moment(30000).from(0), "in secondi", "prefix");
+    equal(moment(0).from(30000), "secondi fa", "suffix");
 });
 
 test("fromNow", 2, function() {
-    _date.lang('it');
-    equal(_date().add({s:30}).fromNow(), "in secondi", "in seconds");
-    equal(_date().add({d:5}).fromNow(), "in 5 giorni", "in 5 days");
+    moment.lang('it');
+    equal(moment().add({s:30}).fromNow(), "in secondi", "in seconds");
+    equal(moment().add({d:5}).fromNow(), "in 5 giorni", "in 5 days");
 });
 
 /**************************************************
@@ -410,7 +410,7 @@ test("fromNow", 2, function() {
 module("lang:pt");
 
 test("format", 15, function() {
-    _date.lang('pt');
+    moment.lang('pt');
     var a = [
             ['dddd, MMMM Do YYYY, h:mm:ss a',      'Domingo, Fevereiro 14º 2010, 3:25:50 pm'],
             ['ddd, hA',                            'Dom, 3PM'],
@@ -428,7 +428,7 @@ test("format", 15, function() {
             ['z zz',                               'PST PST'],
             ['t\\he DDDo \\d\\ay of t\\he ye\\ar', 'the 45º day of the year']
         ],
-        b = _date(new Date(2010, 1, 14, 15, 25, 50, 125)),
+        b = moment(new Date(2010, 1, 14, 15, 25, 50, 125)),
         i;
     for (i = 0; i < a.length; i++) {
         equal(b.format(a[i][0]), a[i][1], a[i][0] + ' ---> ' + a[i][1]);
@@ -436,104 +436,104 @@ test("format", 15, function() {
 });
 
 test("format ordinal", 31, function() {
-    _date.lang('pt');
-    equal(_date([2011, 0, 1]).format('DDDo'), '1º', '1º');
-    equal(_date([2011, 0, 2]).format('DDDo'), '2º', '2º');
-    equal(_date([2011, 0, 3]).format('DDDo'), '3º', '3º');
-    equal(_date([2011, 0, 4]).format('DDDo'), '4º', '4º');
-    equal(_date([2011, 0, 5]).format('DDDo'), '5º', '5º');
-    equal(_date([2011, 0, 6]).format('DDDo'), '6º', '6º');
-    equal(_date([2011, 0, 7]).format('DDDo'), '7º', '7º');
-    equal(_date([2011, 0, 8]).format('DDDo'), '8º', '8º');
-    equal(_date([2011, 0, 9]).format('DDDo'), '9º', '9º');
-    equal(_date([2011, 0, 10]).format('DDDo'), '10º', '10º');
-
-    equal(_date([2011, 0, 11]).format('DDDo'), '11º', '11º');
-    equal(_date([2011, 0, 12]).format('DDDo'), '12º', '12º');
-    equal(_date([2011, 0, 13]).format('DDDo'), '13º', '13º');
-    equal(_date([2011, 0, 14]).format('DDDo'), '14º', '14º');
-    equal(_date([2011, 0, 15]).format('DDDo'), '15º', '15º');
-    equal(_date([2011, 0, 16]).format('DDDo'), '16º', '16º');
-    equal(_date([2011, 0, 17]).format('DDDo'), '17º', '17º');
-    equal(_date([2011, 0, 18]).format('DDDo'), '18º', '18º');
-    equal(_date([2011, 0, 19]).format('DDDo'), '19º', '19º');
-    equal(_date([2011, 0, 20]).format('DDDo'), '20º', '20º');
-
-    equal(_date([2011, 0, 21]).format('DDDo'), '21º', '21º');
-    equal(_date([2011, 0, 22]).format('DDDo'), '22º', '22º');
-    equal(_date([2011, 0, 23]).format('DDDo'), '23º', '23º');
-    equal(_date([2011, 0, 24]).format('DDDo'), '24º', '24º');
-    equal(_date([2011, 0, 25]).format('DDDo'), '25º', '25º');
-    equal(_date([2011, 0, 26]).format('DDDo'), '26º', '26º');
-    equal(_date([2011, 0, 27]).format('DDDo'), '27º', '27º');
-    equal(_date([2011, 0, 28]).format('DDDo'), '28º', '28º');
-    equal(_date([2011, 0, 29]).format('DDDo'), '29º', '29º');
-    equal(_date([2011, 0, 30]).format('DDDo'), '30º', '30º');
-
-    equal(_date([2011, 0, 31]).format('DDDo'), '31º', '31º');
+    moment.lang('pt');
+    equal(moment([2011, 0, 1]).format('DDDo'), '1º', '1º');
+    equal(moment([2011, 0, 2]).format('DDDo'), '2º', '2º');
+    equal(moment([2011, 0, 3]).format('DDDo'), '3º', '3º');
+    equal(moment([2011, 0, 4]).format('DDDo'), '4º', '4º');
+    equal(moment([2011, 0, 5]).format('DDDo'), '5º', '5º');
+    equal(moment([2011, 0, 6]).format('DDDo'), '6º', '6º');
+    equal(moment([2011, 0, 7]).format('DDDo'), '7º', '7º');
+    equal(moment([2011, 0, 8]).format('DDDo'), '8º', '8º');
+    equal(moment([2011, 0, 9]).format('DDDo'), '9º', '9º');
+    equal(moment([2011, 0, 10]).format('DDDo'), '10º', '10º');
+
+    equal(moment([2011, 0, 11]).format('DDDo'), '11º', '11º');
+    equal(moment([2011, 0, 12]).format('DDDo'), '12º', '12º');
+    equal(moment([2011, 0, 13]).format('DDDo'), '13º', '13º');
+    equal(moment([2011, 0, 14]).format('DDDo'), '14º', '14º');
+    equal(moment([2011, 0, 15]).format('DDDo'), '15º', '15º');
+    equal(moment([2011, 0, 16]).format('DDDo'), '16º', '16º');
+    equal(moment([2011, 0, 17]).format('DDDo'), '17º', '17º');
+    equal(moment([2011, 0, 18]).format('DDDo'), '18º', '18º');
+    equal(moment([2011, 0, 19]).format('DDDo'), '19º', '19º');
+    equal(moment([2011, 0, 20]).format('DDDo'), '20º', '20º');
+
+    equal(moment([2011, 0, 21]).format('DDDo'), '21º', '21º');
+    equal(moment([2011, 0, 22]).format('DDDo'), '22º', '22º');
+    equal(moment([2011, 0, 23]).format('DDDo'), '23º', '23º');
+    equal(moment([2011, 0, 24]).format('DDDo'), '24º', '24º');
+    equal(moment([2011, 0, 25]).format('DDDo'), '25º', '25º');
+    equal(moment([2011, 0, 26]).format('DDDo'), '26º', '26º');
+    equal(moment([2011, 0, 27]).format('DDDo'), '27º', '27º');
+    equal(moment([2011, 0, 28]).format('DDDo'), '28º', '28º');
+    equal(moment([2011, 0, 29]).format('DDDo'), '29º', '29º');
+    equal(moment([2011, 0, 30]).format('DDDo'), '30º', '30º');
+
+    equal(moment([2011, 0, 31]).format('DDDo'), '31º', '31º');
 });
 
 test("format month", 12, function() {
-    _date.lang('pt');
+    moment.lang('pt');
     var expected = 'Janeiro Jan_Fevereiro Feb_Março Mar_Abril Abr_Maio Mai_Junho Jun_Julho Jul_Agosto Ago_Setembro Set_Outubro Out_Novembro Nov_Dezembro Dez'.split("_");
     var i;
     for (i = 0; i < expected.length; i++) {
-        equal(_date([2011, i, 0]).format('MMMM MMM'), expected[i], expected[i]);
+        equal(moment([2011, i, 0]).format('MMMM MMM'), expected[i], expected[i]);
     }
 });
 
 test("format week", 7, function() {
-    _date.lang('pt');
+    moment.lang('pt');
     var expected = 'Domingo Dom_Segunda-feira Seg_Terça-feira Ter_Quarta-feira Qua_Quinta-feira Qui_Sexta-feira Sex_Sábado Sáb'.split("_");
     var i;
     for (i = 0; i < expected.length; i++) {
-        equal(_date([2011, 0, 2 + i]).format('dddd ddd'), expected[i], expected[i]);
+        equal(moment([2011, 0, 2 + i]).format('dddd ddd'), expected[i], expected[i]);
     }
 });
 
 test("from", 30, function() {
-    _date.lang('pt');
-    var start = _date([2007, 1, 28]);
-    equal(start.from(_date([2007, 1, 28]).add({s:44}), true),  "segundos",    "44 seconds = seconds");
-    equal(start.from(_date([2007, 1, 28]).add({s:45}), true),  "um minuto",   "45 seconds = a minute");
-    equal(start.from(_date([2007, 1, 28]).add({s:89}), true),  "um minuto",   "89 seconds = a minute");
-    equal(start.from(_date([2007, 1, 28]).add({s:90}), true),  "2 minutos",  "90 seconds = 2 minutes");
-    equal(start.from(_date([2007, 1, 28]).add({m:44}), true),  "44 minutos", "44 minutes = 44 minutes");
-    equal(start.from(_date([2007, 1, 28]).add({m:45}), true),  "uma hora",    "45 minutes = an hour");
-    equal(start.from(_date([2007, 1, 28]).add({m:89}), true),  "uma hora",    "89 minutes = an hour");
-    equal(start.from(_date([2007, 1, 28]).add({m:90}), true),  "2 horas",    "90 minutes = 2 hours");
-    equal(start.from(_date([2007, 1, 28]).add({h:5}), true),   "5 horas",    "5 hours = 5 hours");
-    equal(start.from(_date([2007, 1, 28]).add({h:21}), true),  "21 horas",   "21 hours = 21 hours");
-    equal(start.from(_date([2007, 1, 28]).add({h:22}), true),  "um dia",      "22 hours = a day");
-    equal(start.from(_date([2007, 1, 28]).add({h:35}), true),  "um dia",      "35 hours = a day");
-    equal(start.from(_date([2007, 1, 28]).add({h:36}), true),  "2 dias",     "36 hours = 2 days");
-    equal(start.from(_date([2007, 1, 28]).add({d:1}), true),   "um dia",      "1 day = a day");
-    equal(start.from(_date([2007, 1, 28]).add({d:5}), true),   "5 dias",     "5 days = 5 days");
-    equal(start.from(_date([2007, 1, 28]).add({d:25}), true),  "25 dias",    "25 days = 25 days");
-    equal(start.from(_date([2007, 1, 28]).add({d:26}), true),  "um mês",    "26 days = a month");
-    equal(start.from(_date([2007, 1, 28]).add({d:30}), true),  "um mês",    "30 days = a month");
-    equal(start.from(_date([2007, 1, 28]).add({d:45}), true),  "um mês",    "45 days = a month");
-    equal(start.from(_date([2007, 1, 28]).add({d:46}), true),  "2 meses",   "46 days = 2 months");
-    equal(start.from(_date([2007, 1, 28]).add({d:75}), true),  "2 meses",   "75 days = 2 months");
-    equal(start.from(_date([2007, 1, 28]).add({d:76}), true),  "3 meses",   "76 days = 3 months");
-    equal(start.from(_date([2007, 1, 28]).add({M:1}), true),   "um mês",    "1 month = a month");
-    equal(start.from(_date([2007, 1, 28]).add({M:5}), true),   "5 meses",   "5 months = 5 months");
-    equal(start.from(_date([2007, 1, 28]).add({d:344}), true), "11 meses",  "344 days = 11 months");
-    equal(start.from(_date([2007, 1, 28]).add({d:345}), true), "um ano",     "345 days = a year");
-    equal(start.from(_date([2007, 1, 28]).add({d:547}), true), "um ano",     "547 days = a year");
-    equal(start.from(_date([2007, 1, 28]).add({d:548}), true), "2 anos",    "548 days = 2 years");
-    equal(start.from(_date([2007, 1, 28]).add({y:1}), true),   "um ano",     "1 year = a year");
-    equal(start.from(_date([2007, 1, 28]).add({y:5}), true),   "5 anos",    "5 years = 5 years");
+    moment.lang('pt');
+    var start = moment([2007, 1, 28]);
+    equal(start.from(moment([2007, 1, 28]).add({s:44}), true),  "segundos",    "44 seconds = seconds");
+    equal(start.from(moment([2007, 1, 28]).add({s:45}), true),  "um minuto",   "45 seconds = a minute");
+    equal(start.from(moment([2007, 1, 28]).add({s:89}), true),  "um minuto",   "89 seconds = a minute");
+    equal(start.from(moment([2007, 1, 28]).add({s:90}), true),  "2 minutos",  "90 seconds = 2 minutes");
+    equal(start.from(moment([2007, 1, 28]).add({m:44}), true),  "44 minutos", "44 minutes = 44 minutes");
+    equal(start.from(moment([2007, 1, 28]).add({m:45}), true),  "uma hora",    "45 minutes = an hour");
+    equal(start.from(moment([2007, 1, 28]).add({m:89}), true),  "uma hora",    "89 minutes = an hour");
+    equal(start.from(moment([2007, 1, 28]).add({m:90}), true),  "2 horas",    "90 minutes = 2 hours");
+    equal(start.from(moment([2007, 1, 28]).add({h:5}), true),   "5 horas",    "5 hours = 5 hours");
+    equal(start.from(moment([2007, 1, 28]).add({h:21}), true),  "21 horas",   "21 hours = 21 hours");
+    equal(start.from(moment([2007, 1, 28]).add({h:22}), true),  "um dia",      "22 hours = a day");
+    equal(start.from(moment([2007, 1, 28]).add({h:35}), true),  "um dia",      "35 hours = a day");
+    equal(start.from(moment([2007, 1, 28]).add({h:36}), true),  "2 dias",     "36 hours = 2 days");
+    equal(start.from(moment([2007, 1, 28]).add({d:1}), true),   "um dia",      "1 day = a day");
+    equal(start.from(moment([2007, 1, 28]).add({d:5}), true),   "5 dias",     "5 days = 5 days");
+    equal(start.from(moment([2007, 1, 28]).add({d:25}), true),  "25 dias",    "25 days = 25 days");
+    equal(start.from(moment([2007, 1, 28]).add({d:26}), true),  "um mês",    "26 days = a month");
+    equal(start.from(moment([2007, 1, 28]).add({d:30}), true),  "um mês",    "30 days = a month");
+    equal(start.from(moment([2007, 1, 28]).add({d:45}), true),  "um mês",    "45 days = a month");
+    equal(start.from(moment([2007, 1, 28]).add({d:46}), true),  "2 meses",   "46 days = 2 months");
+    equal(start.from(moment([2007, 1, 28]).add({d:75}), true),  "2 meses",   "75 days = 2 months");
+    equal(start.from(moment([2007, 1, 28]).add({d:76}), true),  "3 meses",   "76 days = 3 months");
+    equal(start.from(moment([2007, 1, 28]).add({M:1}), true),   "um mês",    "1 month = a month");
+    equal(start.from(moment([2007, 1, 28]).add({M:5}), true),   "5 meses",   "5 months = 5 months");
+    equal(start.from(moment([2007, 1, 28]).add({d:344}), true), "11 meses",  "344 days = 11 months");
+    equal(start.from(moment([2007, 1, 28]).add({d:345}), true), "um ano",     "345 days = a year");
+    equal(start.from(moment([2007, 1, 28]).add({d:547}), true), "um ano",     "547 days = a year");
+    equal(start.from(moment([2007, 1, 28]).add({d:548}), true), "2 anos",    "548 days = 2 years");
+    equal(start.from(moment([2007, 1, 28]).add({y:1}), true),   "um ano",     "1 year = a year");
+    equal(start.from(moment([2007, 1, 28]).add({y:5}), true),   "5 anos",    "5 years = 5 years");
 });
 
 test("suffix", 2, function() {
-    _date.lang('pt');
-    equal(_date(30000).from(0), "em segundos", "prefix");
-    equal(_date(0).from(30000), "segundos atrás", "suffix");
+    moment.lang('pt');
+    equal(moment(30000).from(0), "em segundos", "prefix");
+    equal(moment(0).from(30000), "segundos atrás", "suffix");
 });
 
 test("fromNow", 2, function() {
-    _date.lang('pt');
-    equal(_date().add({s:30}).fromNow(), "em segundos", "in seconds");
-    equal(_date().add({d:5}).fromNow(), "em 5 dias", "in 5 days");
+    moment.lang('pt');
+    equal(moment().add({s:30}).fromNow(), "em segundos", "in seconds");
+    equal(moment().add({d:5}).fromNow(), "em 5 dias", "in 5 days");
 });
index 4889cc85eb7cf146711dc4967f799f742dbe2078..77f7451c65c36854e985a119d322cf4e3d61a22b 100644 (file)
@@ -6,7 +6,7 @@
 module("lang:en");
 
 test("format", 15, function() {
-    _date.lang('en');
+    moment.lang('en');
     var a = [
             ['dddd, MMMM Do YYYY, h:mm:ss a',      'Sunday, February 14th 2010, 3:25:50 pm'],
             ['ddd, hA',                            'Sun, 3PM'],
@@ -24,7 +24,7 @@ test("format", 15, function() {
             ['z zz',                               'PST PST'],
             ['t\\he DDDo \\d\\ay of t\\he ye\\ar', 'the 45th day of the year']
         ],
-        b = _date(new Date(2010, 1, 14, 15, 25, 50, 125)),
+        b = moment(new Date(2010, 1, 14, 15, 25, 50, 125)),
         i;
     for (i = 0; i < a.length; i++) {
         equal(b.format(a[i][0]), a[i][1], a[i][0] + ' ---> ' + a[i][1]);
@@ -32,104 +32,104 @@ test("format", 15, function() {
 });
 
 test("format ordinal", 31, function() {
-    _date.lang('en');
-    equal(_date([2011, 0, 1]).format('DDDo'), '1st', '1st');
-    equal(_date([2011, 0, 2]).format('DDDo'), '2nd', '2nd');
-    equal(_date([2011, 0, 3]).format('DDDo'), '3rd', '3rd');
-    equal(_date([2011, 0, 4]).format('DDDo'), '4th', '4th');
-    equal(_date([2011, 0, 5]).format('DDDo'), '5th', '5th');
-    equal(_date([2011, 0, 6]).format('DDDo'), '6th', '6th');
-    equal(_date([2011, 0, 7]).format('DDDo'), '7th', '7th');
-    equal(_date([2011, 0, 8]).format('DDDo'), '8th', '8th');
-    equal(_date([2011, 0, 9]).format('DDDo'), '9th', '9th');
-    equal(_date([2011, 0, 10]).format('DDDo'), '10th', '10th');
+    moment.lang('en');
+    equal(moment([2011, 0, 1]).format('DDDo'), '1st', '1st');
+    equal(moment([2011, 0, 2]).format('DDDo'), '2nd', '2nd');
+    equal(moment([2011, 0, 3]).format('DDDo'), '3rd', '3rd');
+    equal(moment([2011, 0, 4]).format('DDDo'), '4th', '4th');
+    equal(moment([2011, 0, 5]).format('DDDo'), '5th', '5th');
+    equal(moment([2011, 0, 6]).format('DDDo'), '6th', '6th');
+    equal(moment([2011, 0, 7]).format('DDDo'), '7th', '7th');
+    equal(moment([2011, 0, 8]).format('DDDo'), '8th', '8th');
+    equal(moment([2011, 0, 9]).format('DDDo'), '9th', '9th');
+    equal(moment([2011, 0, 10]).format('DDDo'), '10th', '10th');
 
-    equal(_date([2011, 0, 11]).format('DDDo'), '11th', '11th');
-    equal(_date([2011, 0, 12]).format('DDDo'), '12th', '12th');
-    equal(_date([2011, 0, 13]).format('DDDo'), '13th', '13th');
-    equal(_date([2011, 0, 14]).format('DDDo'), '14th', '14th');
-    equal(_date([2011, 0, 15]).format('DDDo'), '15th', '15th');
-    equal(_date([2011, 0, 16]).format('DDDo'), '16th', '16th');
-    equal(_date([2011, 0, 17]).format('DDDo'), '17th', '17th');
-    equal(_date([2011, 0, 18]).format('DDDo'), '18th', '18th');
-    equal(_date([2011, 0, 19]).format('DDDo'), '19th', '19th');
-    equal(_date([2011, 0, 20]).format('DDDo'), '20th', '20th');
+    equal(moment([2011, 0, 11]).format('DDDo'), '11th', '11th');
+    equal(moment([2011, 0, 12]).format('DDDo'), '12th', '12th');
+    equal(moment([2011, 0, 13]).format('DDDo'), '13th', '13th');
+    equal(moment([2011, 0, 14]).format('DDDo'), '14th', '14th');
+    equal(moment([2011, 0, 15]).format('DDDo'), '15th', '15th');
+    equal(moment([2011, 0, 16]).format('DDDo'), '16th', '16th');
+    equal(moment([2011, 0, 17]).format('DDDo'), '17th', '17th');
+    equal(moment([2011, 0, 18]).format('DDDo'), '18th', '18th');
+    equal(moment([2011, 0, 19]).format('DDDo'), '19th', '19th');
+    equal(moment([2011, 0, 20]).format('DDDo'), '20th', '20th');
 
-    equal(_date([2011, 0, 21]).format('DDDo'), '21st', '21st');
-    equal(_date([2011, 0, 22]).format('DDDo'), '22nd', '22nd');
-    equal(_date([2011, 0, 23]).format('DDDo'), '23rd', '23rd');
-    equal(_date([2011, 0, 24]).format('DDDo'), '24th', '24th');
-    equal(_date([2011, 0, 25]).format('DDDo'), '25th', '25th');
-    equal(_date([2011, 0, 26]).format('DDDo'), '26th', '26th');
-    equal(_date([2011, 0, 27]).format('DDDo'), '27th', '27th');
-    equal(_date([2011, 0, 28]).format('DDDo'), '28th', '28th');
-    equal(_date([2011, 0, 29]).format('DDDo'), '29th', '29th');
-    equal(_date([2011, 0, 30]).format('DDDo'), '30th', '30th');
+    equal(moment([2011, 0, 21]).format('DDDo'), '21st', '21st');
+    equal(moment([2011, 0, 22]).format('DDDo'), '22nd', '22nd');
+    equal(moment([2011, 0, 23]).format('DDDo'), '23rd', '23rd');
+    equal(moment([2011, 0, 24]).format('DDDo'), '24th', '24th');
+    equal(moment([2011, 0, 25]).format('DDDo'), '25th', '25th');
+    equal(moment([2011, 0, 26]).format('DDDo'), '26th', '26th');
+    equal(moment([2011, 0, 27]).format('DDDo'), '27th', '27th');
+    equal(moment([2011, 0, 28]).format('DDDo'), '28th', '28th');
+    equal(moment([2011, 0, 29]).format('DDDo'), '29th', '29th');
+    equal(moment([2011, 0, 30]).format('DDDo'), '30th', '30th');
 
-    equal(_date([2011, 0, 31]).format('DDDo'), '31st', '31st');
+    equal(moment([2011, 0, 31]).format('DDDo'), '31st', '31st');
 });
 
 test("format month", 12, function() {
-    _date.lang('en');
+    moment.lang('en');
     var expected = 'January Jan_February Feb_March Mar_April Apr_May May_June Jun_July Jul_August Aug_September Sep_October Oct_November Nov_December Dec'.split("_");
     var i;
     for (i = 0; i < expected.length; i++) {
-        equal(_date([2011, i, 0]).format('MMMM MMM'), expected[i], expected[i]);
+        equal(moment([2011, i, 0]).format('MMMM MMM'), expected[i], expected[i]);
     }
 });
 
 test("format week", 7, function() {
-    _date.lang('en');
+    moment.lang('en');
     var expected = 'Sunday Sun_Monday Mon_Tuesday Tue_Wednesday Wed_Thursday Thu_Friday Fri_Saturday Sat'.split("_");
     var i;
     for (i = 0; i < expected.length; i++) {
-        equal(_date([2011, 0, 2 + i]).format('dddd ddd'), expected[i], expected[i]);
+        equal(moment([2011, 0, 2 + i]).format('dddd ddd'), expected[i], expected[i]);
     }
 });
 
 test("from", 30, function() {
-    _date.lang('en');
-    var start = _date([2007, 1, 28]);
-    equal(start.from(_date([2007, 1, 28]).add({s:44}), true),  "seconds",    "44 seconds = seconds");
-    equal(start.from(_date([2007, 1, 28]).add({s:45}), true),  "a minute",   "45 seconds = a minute");
-    equal(start.from(_date([2007, 1, 28]).add({s:89}), true),  "a minute",   "89 seconds = a minute");
-    equal(start.from(_date([2007, 1, 28]).add({s:90}), true),  "2 minutes",  "90 seconds = 2 minutes");
-    equal(start.from(_date([2007, 1, 28]).add({m:44}), true),  "44 minutes", "44 minutes = 44 minutes");
-    equal(start.from(_date([2007, 1, 28]).add({m:45}), true),  "an hour",    "45 minutes = an hour");
-    equal(start.from(_date([2007, 1, 28]).add({m:89}), true),  "an hour",    "89 minutes = an hour");
-    equal(start.from(_date([2007, 1, 28]).add({m:90}), true),  "2 hours",    "90 minutes = 2 hours");
-    equal(start.from(_date([2007, 1, 28]).add({h:5}), true),   "5 hours",    "5 hours = 5 hours");
-    equal(start.from(_date([2007, 1, 28]).add({h:21}), true),  "21 hours",   "21 hours = 21 hours");
-    equal(start.from(_date([2007, 1, 28]).add({h:22}), true),  "a day",      "22 hours = a day");
-    equal(start.from(_date([2007, 1, 28]).add({h:35}), true),  "a day",      "35 hours = a day");
-    equal(start.from(_date([2007, 1, 28]).add({h:36}), true),  "2 days",     "36 hours = 2 days");
-    equal(start.from(_date([2007, 1, 28]).add({d:1}), true),   "a day",      "1 day = a day");
-    equal(start.from(_date([2007, 1, 28]).add({d:5}), true),   "5 days",     "5 days = 5 days");
-    equal(start.from(_date([2007, 1, 28]).add({d:25}), true),  "25 days",    "25 days = 25 days");
-    equal(start.from(_date([2007, 1, 28]).add({d:26}), true),  "a month",    "26 days = a month");
-    equal(start.from(_date([2007, 1, 28]).add({d:30}), true),  "a month",    "30 days = a month");
-    equal(start.from(_date([2007, 1, 28]).add({d:45}), true),  "a month",    "45 days = a month");
-    equal(start.from(_date([2007, 1, 28]).add({d:46}), true),  "2 months",   "46 days = 2 months");
-    equal(start.from(_date([2007, 1, 28]).add({d:75}), true),  "2 months",   "75 days = 2 months");
-    equal(start.from(_date([2007, 1, 28]).add({d:76}), true),  "3 months",   "76 days = 3 months");
-    equal(start.from(_date([2007, 1, 28]).add({M:1}), true),   "a month",    "1 month = a month");
-    equal(start.from(_date([2007, 1, 28]).add({M:5}), true),   "5 months",   "5 months = 5 months");
-    equal(start.from(_date([2007, 1, 28]).add({d:344}), true), "11 months",  "344 days = 11 months");
-    equal(start.from(_date([2007, 1, 28]).add({d:345}), true), "a year",     "345 days = a year");
-    equal(start.from(_date([2007, 1, 28]).add({d:547}), true), "a year",     "547 days = a year");
-    equal(start.from(_date([2007, 1, 28]).add({d:548}), true), "2 years",    "548 days = 2 years");
-    equal(start.from(_date([2007, 1, 28]).add({y:1}), true),   "a year",     "1 year = a year");
-    equal(start.from(_date([2007, 1, 28]).add({y:5}), true),   "5 years",    "5 years = 5 years");
+    moment.lang('en');
+    var start = moment([2007, 1, 28]);
+    equal(start.from(moment([2007, 1, 28]).add({s:44}), true),  "seconds",    "44 seconds = seconds");
+    equal(start.from(moment([2007, 1, 28]).add({s:45}), true),  "a minute",   "45 seconds = a minute");
+    equal(start.from(moment([2007, 1, 28]).add({s:89}), true),  "a minute",   "89 seconds = a minute");
+    equal(start.from(moment([2007, 1, 28]).add({s:90}), true),  "2 minutes",  "90 seconds = 2 minutes");
+    equal(start.from(moment([2007, 1, 28]).add({m:44}), true),  "44 minutes", "44 minutes = 44 minutes");
+    equal(start.from(moment([2007, 1, 28]).add({m:45}), true),  "an hour",    "45 minutes = an hour");
+    equal(start.from(moment([2007, 1, 28]).add({m:89}), true),  "an hour",    "89 minutes = an hour");
+    equal(start.from(moment([2007, 1, 28]).add({m:90}), true),  "2 hours",    "90 minutes = 2 hours");
+    equal(start.from(moment([2007, 1, 28]).add({h:5}), true),   "5 hours",    "5 hours = 5 hours");
+    equal(start.from(moment([2007, 1, 28]).add({h:21}), true),  "21 hours",   "21 hours = 21 hours");
+    equal(start.from(moment([2007, 1, 28]).add({h:22}), true),  "a day",      "22 hours = a day");
+    equal(start.from(moment([2007, 1, 28]).add({h:35}), true),  "a day",      "35 hours = a day");
+    equal(start.from(moment([2007, 1, 28]).add({h:36}), true),  "2 days",     "36 hours = 2 days");
+    equal(start.from(moment([2007, 1, 28]).add({d:1}), true),   "a day",      "1 day = a day");
+    equal(start.from(moment([2007, 1, 28]).add({d:5}), true),   "5 days",     "5 days = 5 days");
+    equal(start.from(moment([2007, 1, 28]).add({d:25}), true),  "25 days",    "25 days = 25 days");
+    equal(start.from(moment([2007, 1, 28]).add({d:26}), true),  "a month",    "26 days = a month");
+    equal(start.from(moment([2007, 1, 28]).add({d:30}), true),  "a month",    "30 days = a month");
+    equal(start.from(moment([2007, 1, 28]).add({d:45}), true),  "a month",    "45 days = a month");
+    equal(start.from(moment([2007, 1, 28]).add({d:46}), true),  "2 months",   "46 days = 2 months");
+    equal(start.from(moment([2007, 1, 28]).add({d:75}), true),  "2 months",   "75 days = 2 months");
+    equal(start.from(moment([2007, 1, 28]).add({d:76}), true),  "3 months",   "76 days = 3 months");
+    equal(start.from(moment([2007, 1, 28]).add({M:1}), true),   "a month",    "1 month = a month");
+    equal(start.from(moment([2007, 1, 28]).add({M:5}), true),   "5 months",   "5 months = 5 months");
+    equal(start.from(moment([2007, 1, 28]).add({d:344}), true), "11 months",  "344 days = 11 months");
+    equal(start.from(moment([2007, 1, 28]).add({d:345}), true), "a year",     "345 days = a year");
+    equal(start.from(moment([2007, 1, 28]).add({d:547}), true), "a year",     "547 days = a year");
+    equal(start.from(moment([2007, 1, 28]).add({d:548}), true), "2 years",    "548 days = 2 years");
+    equal(start.from(moment([2007, 1, 28]).add({y:1}), true),   "a year",     "1 year = a year");
+    equal(start.from(moment([2007, 1, 28]).add({y:5}), true),   "5 years",    "5 years = 5 years");
 });
 
 test("suffix", 2, function() {
-    _date.lang('en');
-    equal(_date(30000).from(0), "in seconds", "prefix");
-    equal(_date(0).from(30000), "seconds ago", "suffix");
+    moment.lang('en');
+    equal(moment(30000).from(0), "in seconds", "prefix");
+    equal(moment(0).from(30000), "seconds ago", "suffix");
 });
 
 test("fromNow", 2, function() {
-    _date.lang('en');
-    equal(_date().add({s:30}).fromNow(), "in seconds", "in seconds");
-    equal(_date().add({d:5}).fromNow(), "in 5 days", "in 5 days");
+    moment.lang('en');
+    equal(moment().add({s:30}).fromNow(), "in seconds", "in seconds");
+    equal(moment().add({d:5}).fromNow(), "in 5 days", "in 5 days");
 });
index 992410cc2b4b3a996da639c0fe0d029b572c4aeb..d8c54c6a095b6624d48c9e896e01c22e74b8a9f5 100644 (file)
@@ -6,7 +6,7 @@
 module("lang:fr");
 
 test("format", 15, function() {
-    _date.lang('fr');
+    moment.lang('fr');
     var a = [
             ['dddd, MMMM Do YYYY, h:mm:ss a',      'Dimanche, Février 14er 2010, 3:25:50 pm'],
             ['ddd, hA',                            'Dim, 3PM'],
@@ -24,7 +24,7 @@ test("format", 15, function() {
             ['z zz',                               'PST PST'],
             ['t\\he DDDo \\d\\ay of t\\he ye\\ar', 'the 45ème day of the year']
         ],
-        b = _date(new Date(2010, 1, 14, 15, 25, 50, 125)),
+        b = moment(new Date(2010, 1, 14, 15, 25, 50, 125)),
         i;
     for (i = 0; i < a.length; i++) {
         equal(b.format(a[i][0]), a[i][1], a[i][0] + ' ---> ' + a[i][1]);
@@ -32,104 +32,104 @@ test("format", 15, function() {
 });
 
 test("format ordinal", 31, function() {
-    _date.lang('fr');
-    equal(_date([2011, 0, 1]).format('DDDo'), '1ème', '1ème');
-    equal(_date([2011, 0, 2]).format('DDDo'), '2ème', '2ème');
-    equal(_date([2011, 0, 3]).format('DDDo'), '3ème', '3ème');
-    equal(_date([2011, 0, 4]).format('DDDo'), '4ème', '4ème');
-    equal(_date([2011, 0, 5]).format('DDDo'), '5ème', '5ème');
-    equal(_date([2011, 0, 6]).format('DDDo'), '6ème', '6ème');
-    equal(_date([2011, 0, 7]).format('DDDo'), '7ème', '7ème');
-    equal(_date([2011, 0, 8]).format('DDDo'), '8ème', '8ème');
-    equal(_date([2011, 0, 9]).format('DDDo'), '9ème', '9ème');
-    equal(_date([2011, 0, 10]).format('DDDo'), '10er', '10er');
+    moment.lang('fr');
+    equal(moment([2011, 0, 1]).format('DDDo'), '1ème', '1ème');
+    equal(moment([2011, 0, 2]).format('DDDo'), '2ème', '2ème');
+    equal(moment([2011, 0, 3]).format('DDDo'), '3ème', '3ème');
+    equal(moment([2011, 0, 4]).format('DDDo'), '4ème', '4ème');
+    equal(moment([2011, 0, 5]).format('DDDo'), '5ème', '5ème');
+    equal(moment([2011, 0, 6]).format('DDDo'), '6ème', '6ème');
+    equal(moment([2011, 0, 7]).format('DDDo'), '7ème', '7ème');
+    equal(moment([2011, 0, 8]).format('DDDo'), '8ème', '8ème');
+    equal(moment([2011, 0, 9]).format('DDDo'), '9ème', '9ème');
+    equal(moment([2011, 0, 10]).format('DDDo'), '10er', '10er');
 
-    equal(_date([2011, 0, 11]).format('DDDo'), '11er', '11er');
-    equal(_date([2011, 0, 12]).format('DDDo'), '12er', '12er');
-    equal(_date([2011, 0, 13]).format('DDDo'), '13er', '13er');
-    equal(_date([2011, 0, 14]).format('DDDo'), '14er', '14er');
-    equal(_date([2011, 0, 15]).format('DDDo'), '15er', '15er');
-    equal(_date([2011, 0, 16]).format('DDDo'), '16er', '16er');
-    equal(_date([2011, 0, 17]).format('DDDo'), '17er', '17er');
-    equal(_date([2011, 0, 18]).format('DDDo'), '18er', '18er');
-    equal(_date([2011, 0, 19]).format('DDDo'), '19er', '19er');
-    equal(_date([2011, 0, 20]).format('DDDo'), '20ème', '20ème');
+    equal(moment([2011, 0, 11]).format('DDDo'), '11er', '11er');
+    equal(moment([2011, 0, 12]).format('DDDo'), '12er', '12er');
+    equal(moment([2011, 0, 13]).format('DDDo'), '13er', '13er');
+    equal(moment([2011, 0, 14]).format('DDDo'), '14er', '14er');
+    equal(moment([2011, 0, 15]).format('DDDo'), '15er', '15er');
+    equal(moment([2011, 0, 16]).format('DDDo'), '16er', '16er');
+    equal(moment([2011, 0, 17]).format('DDDo'), '17er', '17er');
+    equal(moment([2011, 0, 18]).format('DDDo'), '18er', '18er');
+    equal(moment([2011, 0, 19]).format('DDDo'), '19er', '19er');
+    equal(moment([2011, 0, 20]).format('DDDo'), '20ème', '20ème');
 
-    equal(_date([2011, 0, 21]).format('DDDo'), '21ème', '21ème');
-    equal(_date([2011, 0, 22]).format('DDDo'), '22ème', '22ème');
-    equal(_date([2011, 0, 23]).format('DDDo'), '23ème', '23ème');
-    equal(_date([2011, 0, 24]).format('DDDo'), '24ème', '24ème');
-    equal(_date([2011, 0, 25]).format('DDDo'), '25ème', '25ème');
-    equal(_date([2011, 0, 26]).format('DDDo'), '26ème', '26ème');
-    equal(_date([2011, 0, 27]).format('DDDo'), '27ème', '27ème');
-    equal(_date([2011, 0, 28]).format('DDDo'), '28ème', '28ème');
-    equal(_date([2011, 0, 29]).format('DDDo'), '29ème', '29ème');
-    equal(_date([2011, 0, 30]).format('DDDo'), '30ème', '30ème');
+    equal(moment([2011, 0, 21]).format('DDDo'), '21ème', '21ème');
+    equal(moment([2011, 0, 22]).format('DDDo'), '22ème', '22ème');
+    equal(moment([2011, 0, 23]).format('DDDo'), '23ème', '23ème');
+    equal(moment([2011, 0, 24]).format('DDDo'), '24ème', '24ème');
+    equal(moment([2011, 0, 25]).format('DDDo'), '25ème', '25ème');
+    equal(moment([2011, 0, 26]).format('DDDo'), '26ème', '26ème');
+    equal(moment([2011, 0, 27]).format('DDDo'), '27ème', '27ème');
+    equal(moment([2011, 0, 28]).format('DDDo'), '28ème', '28ème');
+    equal(moment([2011, 0, 29]).format('DDDo'), '29ème', '29ème');
+    equal(moment([2011, 0, 30]).format('DDDo'), '30ème', '30ème');
 
-    equal(_date([2011, 0, 31]).format('DDDo'), '31ème', '31ème');
+    equal(moment([2011, 0, 31]).format('DDDo'), '31ème', '31ème');
 });
 
 test("format month", 12, function() {
-    _date.lang('fr');
+    moment.lang('fr');
     var expected = 'Janvier Jan_Février Fev_Mars Mar_Avril Avr_Mai Mai_Juin Juin_Juillet Juil_Aout Aou_Septembre Sep_Octobre Oct_Novembre Nov_Décembre Dec'.split("_");
     var i;
     for (i = 0; i < expected.length; i++) {
-        equal(_date([2011, i, 0]).format('MMMM MMM'), expected[i], expected[i]);
+        equal(moment([2011, i, 0]).format('MMMM MMM'), expected[i], expected[i]);
     }
 });
 
 test("format week", 7, function() {
-    _date.lang('fr');
+    moment.lang('fr');
     var expected = 'Dimanche Dim_Lundi Lun_Mardi Mar_Mercredi Mer_Jeudi Jeu_Vendredi Ven_Samedi Sam'.split("_");
     var i;
     for (i = 0; i < expected.length; i++) {
-        equal(_date([2011, 0, 2 + i]).format('dddd ddd'), expected[i], expected[i]);
+        equal(moment([2011, 0, 2 + i]).format('dddd ddd'), expected[i], expected[i]);
     }
 });
 
 test("from", 30, function() {
-    _date.lang('fr');
-    var start = _date([2007, 1, 28]);
-    equal(start.from(_date([2007, 1, 28]).add({s:44}), true),  "secondes",    "44 seconds = seconds");
-    equal(start.from(_date([2007, 1, 28]).add({s:45}), true),  "une minute",   "45 seconds = a minute");
-    equal(start.from(_date([2007, 1, 28]).add({s:89}), true),  "une minute",   "89 seconds = a minute");
-    equal(start.from(_date([2007, 1, 28]).add({s:90}), true),  "2 minutes",  "90 seconds = 2 minutes");
-    equal(start.from(_date([2007, 1, 28]).add({m:44}), true),  "44 minutes", "44 minutes = 44 minutes");
-    equal(start.from(_date([2007, 1, 28]).add({m:45}), true),  "une heure",    "45 minutes = an hour");
-    equal(start.from(_date([2007, 1, 28]).add({m:89}), true),  "une heure",    "89 minutes = an hour");
-    equal(start.from(_date([2007, 1, 28]).add({m:90}), true),  "2 heures",    "90 minutes = 2 hours");
-    equal(start.from(_date([2007, 1, 28]).add({h:5}), true),   "5 heures",    "5 hours = 5 hours");
-    equal(start.from(_date([2007, 1, 28]).add({h:21}), true),  "21 heures",   "21 hours = 21 hours");
-    equal(start.from(_date([2007, 1, 28]).add({h:22}), true),  "un jour",      "22 hours = a day");
-    equal(start.from(_date([2007, 1, 28]).add({h:35}), true),  "un jour",      "35 hours = a day");
-    equal(start.from(_date([2007, 1, 28]).add({h:36}), true),  "2 jours",     "36 hours = 2 days");
-    equal(start.from(_date([2007, 1, 28]).add({d:1}), true),   "un jour",      "1 day = a day");
-    equal(start.from(_date([2007, 1, 28]).add({d:5}), true),   "5 jours",     "5 days = 5 days");
-    equal(start.from(_date([2007, 1, 28]).add({d:25}), true),  "25 jours",    "25 days = 25 days");
-    equal(start.from(_date([2007, 1, 28]).add({d:26}), true),  "un mois",    "26 days = a month");
-    equal(start.from(_date([2007, 1, 28]).add({d:30}), true),  "un mois",    "30 days = a month");
-    equal(start.from(_date([2007, 1, 28]).add({d:45}), true),  "un mois",    "45 days = a month");
-    equal(start.from(_date([2007, 1, 28]).add({d:46}), true),  "2 mois",   "46 days = 2 months");
-    equal(start.from(_date([2007, 1, 28]).add({d:75}), true),  "2 mois",   "75 days = 2 months");
-    equal(start.from(_date([2007, 1, 28]).add({d:76}), true),  "3 mois",   "76 days = 3 months");
-    equal(start.from(_date([2007, 1, 28]).add({M:1}), true),   "un mois",    "1 month = a month");
-    equal(start.from(_date([2007, 1, 28]).add({M:5}), true),   "5 mois",   "5 months = 5 months");
-    equal(start.from(_date([2007, 1, 28]).add({d:344}), true), "11 mois",  "344 days = 11 months");
-    equal(start.from(_date([2007, 1, 28]).add({d:345}), true), "une année",     "345 days = a year");
-    equal(start.from(_date([2007, 1, 28]).add({d:547}), true), "une année",     "547 days = a year");
-    equal(start.from(_date([2007, 1, 28]).add({d:548}), true), "2 années",    "548 days = 2 years");
-    equal(start.from(_date([2007, 1, 28]).add({y:1}), true),   "une année",     "1 year = a year");
-    equal(start.from(_date([2007, 1, 28]).add({y:5}), true),   "5 années",    "5 years = 5 years");
+    moment.lang('fr');
+    var start = moment([2007, 1, 28]);
+    equal(start.from(moment([2007, 1, 28]).add({s:44}), true),  "secondes",    "44 seconds = seconds");
+    equal(start.from(moment([2007, 1, 28]).add({s:45}), true),  "une minute",   "45 seconds = a minute");
+    equal(start.from(moment([2007, 1, 28]).add({s:89}), true),  "une minute",   "89 seconds = a minute");
+    equal(start.from(moment([2007, 1, 28]).add({s:90}), true),  "2 minutes",  "90 seconds = 2 minutes");
+    equal(start.from(moment([2007, 1, 28]).add({m:44}), true),  "44 minutes", "44 minutes = 44 minutes");
+    equal(start.from(moment([2007, 1, 28]).add({m:45}), true),  "une heure",    "45 minutes = an hour");
+    equal(start.from(moment([2007, 1, 28]).add({m:89}), true),  "une heure",    "89 minutes = an hour");
+    equal(start.from(moment([2007, 1, 28]).add({m:90}), true),  "2 heures",    "90 minutes = 2 hours");
+    equal(start.from(moment([2007, 1, 28]).add({h:5}), true),   "5 heures",    "5 hours = 5 hours");
+    equal(start.from(moment([2007, 1, 28]).add({h:21}), true),  "21 heures",   "21 hours = 21 hours");
+    equal(start.from(moment([2007, 1, 28]).add({h:22}), true),  "un jour",      "22 hours = a day");
+    equal(start.from(moment([2007, 1, 28]).add({h:35}), true),  "un jour",      "35 hours = a day");
+    equal(start.from(moment([2007, 1, 28]).add({h:36}), true),  "2 jours",     "36 hours = 2 days");
+    equal(start.from(moment([2007, 1, 28]).add({d:1}), true),   "un jour",      "1 day = a day");
+    equal(start.from(moment([2007, 1, 28]).add({d:5}), true),   "5 jours",     "5 days = 5 days");
+    equal(start.from(moment([2007, 1, 28]).add({d:25}), true),  "25 jours",    "25 days = 25 days");
+    equal(start.from(moment([2007, 1, 28]).add({d:26}), true),  "un mois",    "26 days = a month");
+    equal(start.from(moment([2007, 1, 28]).add({d:30}), true),  "un mois",    "30 days = a month");
+    equal(start.from(moment([2007, 1, 28]).add({d:45}), true),  "un mois",    "45 days = a month");
+    equal(start.from(moment([2007, 1, 28]).add({d:46}), true),  "2 mois",   "46 days = 2 months");
+    equal(start.from(moment([2007, 1, 28]).add({d:75}), true),  "2 mois",   "75 days = 2 months");
+    equal(start.from(moment([2007, 1, 28]).add({d:76}), true),  "3 mois",   "76 days = 3 months");
+    equal(start.from(moment([2007, 1, 28]).add({M:1}), true),   "un mois",    "1 month = a month");
+    equal(start.from(moment([2007, 1, 28]).add({M:5}), true),   "5 mois",   "5 months = 5 months");
+    equal(start.from(moment([2007, 1, 28]).add({d:344}), true), "11 mois",  "344 days = 11 months");
+    equal(start.from(moment([2007, 1, 28]).add({d:345}), true), "une année",     "345 days = a year");
+    equal(start.from(moment([2007, 1, 28]).add({d:547}), true), "une année",     "547 days = a year");
+    equal(start.from(moment([2007, 1, 28]).add({d:548}), true), "2 années",    "548 days = 2 years");
+    equal(start.from(moment([2007, 1, 28]).add({y:1}), true),   "une année",     "1 year = a year");
+    equal(start.from(moment([2007, 1, 28]).add({y:5}), true),   "5 années",    "5 years = 5 years");
 });
 
 test("suffix", 2, function() {
-    _date.lang('fr');
-    equal(_date(30000).from(0), "in secondes", "prefix");
-    equal(_date(0).from(30000), "il y a secondes", "suffix");
+    moment.lang('fr');
+    equal(moment(30000).from(0), "in secondes", "prefix");
+    equal(moment(0).from(30000), "il y a secondes", "suffix");
 });
 
 test("fromNow", 2, function() {
-    _date.lang('fr');
-    equal(_date().add({s:30}).fromNow(), "in secondes", "in seconds");
-    equal(_date().add({d:5}).fromNow(), "in 5 jours", "in 5 days");
+    moment.lang('fr');
+    equal(moment().add({s:30}).fromNow(), "in secondes", "in seconds");
+    equal(moment().add({d:5}).fromNow(), "in 5 jours", "in 5 days");
 });
\ No newline at end of file
index 1f9d284e5aa80f7cfbfe8779e7c5bcff906955d2..1991eb7c4f6f715dfecb2baa02fb0601d67a085c 100644 (file)
@@ -6,7 +6,7 @@
 module("lang:it");
 
 test("format", 15, function() {
-    _date.lang('it');
+    moment.lang('it');
     var a = [
             ['dddd, MMMM Do YYYY, h:mm:ss a',      'Domenica, Febbraio 14º 2010, 3:25:50 pm'],
             ['ddd, hA',                            'Dom, 3PM'],
@@ -24,7 +24,7 @@ test("format", 15, function() {
             ['z zz',                               'PST PST'],
             ['t\\he DDDo \\d\\ay of t\\he ye\\ar', 'the 45º day of the year']
         ],
-        b = _date(new Date(2010, 1, 14, 15, 25, 50, 125)),
+        b = moment(new Date(2010, 1, 14, 15, 25, 50, 125)),
         i;
     for (i = 0; i < a.length; i++) {
         equal(b.format(a[i][0]), a[i][1], a[i][0] + ' ---> ' + a[i][1]);
@@ -32,104 +32,104 @@ test("format", 15, function() {
 });
 
 test("format ordinal", 31, function() {
-    _date.lang('it');
-    equal(_date([2011, 0, 1]).format('DDDo'), '1º', '1º');
-    equal(_date([2011, 0, 2]).format('DDDo'), '2º', '2º');
-    equal(_date([2011, 0, 3]).format('DDDo'), '3º', '3º');
-    equal(_date([2011, 0, 4]).format('DDDo'), '4º', '4º');
-    equal(_date([2011, 0, 5]).format('DDDo'), '5º', '5º');
-    equal(_date([2011, 0, 6]).format('DDDo'), '6º', '6º');
-    equal(_date([2011, 0, 7]).format('DDDo'), '7º', '7º');
-    equal(_date([2011, 0, 8]).format('DDDo'), '8º', '8º');
-    equal(_date([2011, 0, 9]).format('DDDo'), '9º', '9º');
-    equal(_date([2011, 0, 10]).format('DDDo'), '10º', '10º');
+    moment.lang('it');
+    equal(moment([2011, 0, 1]).format('DDDo'), '1º', '1º');
+    equal(moment([2011, 0, 2]).format('DDDo'), '2º', '2º');
+    equal(moment([2011, 0, 3]).format('DDDo'), '3º', '3º');
+    equal(moment([2011, 0, 4]).format('DDDo'), '4º', '4º');
+    equal(moment([2011, 0, 5]).format('DDDo'), '5º', '5º');
+    equal(moment([2011, 0, 6]).format('DDDo'), '6º', '6º');
+    equal(moment([2011, 0, 7]).format('DDDo'), '7º', '7º');
+    equal(moment([2011, 0, 8]).format('DDDo'), '8º', '8º');
+    equal(moment([2011, 0, 9]).format('DDDo'), '9º', '9º');
+    equal(moment([2011, 0, 10]).format('DDDo'), '10º', '10º');
 
-    equal(_date([2011, 0, 11]).format('DDDo'), '11º', '11º');
-    equal(_date([2011, 0, 12]).format('DDDo'), '12º', '12º');
-    equal(_date([2011, 0, 13]).format('DDDo'), '13º', '13º');
-    equal(_date([2011, 0, 14]).format('DDDo'), '14º', '14º');
-    equal(_date([2011, 0, 15]).format('DDDo'), '15º', '15º');
-    equal(_date([2011, 0, 16]).format('DDDo'), '16º', '16º');
-    equal(_date([2011, 0, 17]).format('DDDo'), '17º', '17º');
-    equal(_date([2011, 0, 18]).format('DDDo'), '18º', '18º');
-    equal(_date([2011, 0, 19]).format('DDDo'), '19º', '19º');
-    equal(_date([2011, 0, 20]).format('DDDo'), '20º', '20º');
+    equal(moment([2011, 0, 11]).format('DDDo'), '11º', '11º');
+    equal(moment([2011, 0, 12]).format('DDDo'), '12º', '12º');
+    equal(moment([2011, 0, 13]).format('DDDo'), '13º', '13º');
+    equal(moment([2011, 0, 14]).format('DDDo'), '14º', '14º');
+    equal(moment([2011, 0, 15]).format('DDDo'), '15º', '15º');
+    equal(moment([2011, 0, 16]).format('DDDo'), '16º', '16º');
+    equal(moment([2011, 0, 17]).format('DDDo'), '17º', '17º');
+    equal(moment([2011, 0, 18]).format('DDDo'), '18º', '18º');
+    equal(moment([2011, 0, 19]).format('DDDo'), '19º', '19º');
+    equal(moment([2011, 0, 20]).format('DDDo'), '20º', '20º');
 
-    equal(_date([2011, 0, 21]).format('DDDo'), '21º', '21º');
-    equal(_date([2011, 0, 22]).format('DDDo'), '22º', '22º');
-    equal(_date([2011, 0, 23]).format('DDDo'), '23º', '23º');
-    equal(_date([2011, 0, 24]).format('DDDo'), '24º', '24º');
-    equal(_date([2011, 0, 25]).format('DDDo'), '25º', '25º');
-    equal(_date([2011, 0, 26]).format('DDDo'), '26º', '26º');
-    equal(_date([2011, 0, 27]).format('DDDo'), '27º', '27º');
-    equal(_date([2011, 0, 28]).format('DDDo'), '28º', '28º');
-    equal(_date([2011, 0, 29]).format('DDDo'), '29º', '29º');
-    equal(_date([2011, 0, 30]).format('DDDo'), '30º', '30º');
+    equal(moment([2011, 0, 21]).format('DDDo'), '21º', '21º');
+    equal(moment([2011, 0, 22]).format('DDDo'), '22º', '22º');
+    equal(moment([2011, 0, 23]).format('DDDo'), '23º', '23º');
+    equal(moment([2011, 0, 24]).format('DDDo'), '24º', '24º');
+    equal(moment([2011, 0, 25]).format('DDDo'), '25º', '25º');
+    equal(moment([2011, 0, 26]).format('DDDo'), '26º', '26º');
+    equal(moment([2011, 0, 27]).format('DDDo'), '27º', '27º');
+    equal(moment([2011, 0, 28]).format('DDDo'), '28º', '28º');
+    equal(moment([2011, 0, 29]).format('DDDo'), '29º', '29º');
+    equal(moment([2011, 0, 30]).format('DDDo'), '30º', '30º');
 
-    equal(_date([2011, 0, 31]).format('DDDo'), '31º', '31º');
+    equal(moment([2011, 0, 31]).format('DDDo'), '31º', '31º');
 });
 
 test("format month", 12, function() {
-    _date.lang('it');
+    moment.lang('it');
     var expected = 'Gennaio Gen_Febbraio Feb_Marzo Mar_Aprile Apr_Maggio Mag_Giugno Giu_Luglio Lug_Agosto Ago_Settebre Set_Ottobre Ott_Novembre Nov_Dicembre Dic'.split("_");
     var i;
     for (i = 0; i < expected.length; i++) {
-        equal(_date([2011, i, 0]).format('MMMM MMM'), expected[i], expected[i]);
+        equal(moment([2011, i, 0]).format('MMMM MMM'), expected[i], expected[i]);
     }
 });
 
 test("format week", 7, function() {
-    _date.lang('it');
+    moment.lang('it');
     var expected = 'Domenica Dom_Lunedi Lun_Martedi Mar_Mercoledi Mer_Giovedi Gio_Venerdi Ven_Sabato Sab'.split("_");
     var i;
     for (i = 0; i < expected.length; i++) {
-        equal(_date([2011, 0, 2 + i]).format('dddd ddd'), expected[i], expected[i]);
+        equal(moment([2011, 0, 2 + i]).format('dddd ddd'), expected[i], expected[i]);
     }
 });
 
 test("from", 30, function() {
-    _date.lang('it');
-    var start = _date([2007, 1, 28]);
-    equal(start.from(_date([2007, 1, 28]).add({s:44}), true),  "secondi",    "44 seconds = seconds");
-    equal(start.from(_date([2007, 1, 28]).add({s:45}), true),  "un minuto",   "45 seconds = a minute");
-    equal(start.from(_date([2007, 1, 28]).add({s:89}), true),  "un minuto",   "89 seconds = a minute");
-    equal(start.from(_date([2007, 1, 28]).add({s:90}), true),  "2 minuti",  "90 seconds = 2 minutes");
-    equal(start.from(_date([2007, 1, 28]).add({m:44}), true),  "44 minuti", "44 minutes = 44 minutes");
-    equal(start.from(_date([2007, 1, 28]).add({m:45}), true),  "un ora",    "45 minutes = an hour");
-    equal(start.from(_date([2007, 1, 28]).add({m:89}), true),  "un ora",    "89 minutes = an hour");
-    equal(start.from(_date([2007, 1, 28]).add({m:90}), true),  "2 ore",    "90 minutes = 2 hours");
-    equal(start.from(_date([2007, 1, 28]).add({h:5}), true),   "5 ore",    "5 hours = 5 hours");
-    equal(start.from(_date([2007, 1, 28]).add({h:21}), true),  "21 ore",   "21 hours = 21 hours");
-    equal(start.from(_date([2007, 1, 28]).add({h:22}), true),  "un giorno",      "22 hours = a day");
-    equal(start.from(_date([2007, 1, 28]).add({h:35}), true),  "un giorno",      "35 hours = a day");
-    equal(start.from(_date([2007, 1, 28]).add({h:36}), true),  "2 giorni",     "36 hours = 2 days");
-    equal(start.from(_date([2007, 1, 28]).add({d:1}), true),   "un giorno",      "1 day = a day");
-    equal(start.from(_date([2007, 1, 28]).add({d:5}), true),   "5 giorni",     "5 days = 5 days");
-    equal(start.from(_date([2007, 1, 28]).add({d:25}), true),  "25 giorni",    "25 days = 25 days");
-    equal(start.from(_date([2007, 1, 28]).add({d:26}), true),  "un mese",    "26 days = a month");
-    equal(start.from(_date([2007, 1, 28]).add({d:30}), true),  "un mese",    "30 days = a month");
-    equal(start.from(_date([2007, 1, 28]).add({d:45}), true),  "un mese",    "45 days = a month");
-    equal(start.from(_date([2007, 1, 28]).add({d:46}), true),  "2 mesi",   "46 days = 2 months");
-    equal(start.from(_date([2007, 1, 28]).add({d:75}), true),  "2 mesi",   "75 days = 2 months");
-    equal(start.from(_date([2007, 1, 28]).add({d:76}), true),  "3 mesi",   "76 days = 3 months");
-    equal(start.from(_date([2007, 1, 28]).add({M:1}), true),   "un mese",    "1 month = a month");
-    equal(start.from(_date([2007, 1, 28]).add({M:5}), true),   "5 mesi",   "5 months = 5 months");
-    equal(start.from(_date([2007, 1, 28]).add({d:344}), true), "11 mesi",  "344 days = 11 months");
-    equal(start.from(_date([2007, 1, 28]).add({d:345}), true), "un anno",     "345 days = a year");
-    equal(start.from(_date([2007, 1, 28]).add({d:547}), true), "un anno",     "547 days = a year");
-    equal(start.from(_date([2007, 1, 28]).add({d:548}), true), "2 anni",    "548 days = 2 years");
-    equal(start.from(_date([2007, 1, 28]).add({y:1}), true),   "un anno",     "1 year = a year");
-    equal(start.from(_date([2007, 1, 28]).add({y:5}), true),   "5 anni",    "5 years = 5 years");
+    moment.lang('it');
+    var start = moment([2007, 1, 28]);
+    equal(start.from(moment([2007, 1, 28]).add({s:44}), true),  "secondi",    "44 seconds = seconds");
+    equal(start.from(moment([2007, 1, 28]).add({s:45}), true),  "un minuto",   "45 seconds = a minute");
+    equal(start.from(moment([2007, 1, 28]).add({s:89}), true),  "un minuto",   "89 seconds = a minute");
+    equal(start.from(moment([2007, 1, 28]).add({s:90}), true),  "2 minuti",  "90 seconds = 2 minutes");
+    equal(start.from(moment([2007, 1, 28]).add({m:44}), true),  "44 minuti", "44 minutes = 44 minutes");
+    equal(start.from(moment([2007, 1, 28]).add({m:45}), true),  "un ora",    "45 minutes = an hour");
+    equal(start.from(moment([2007, 1, 28]).add({m:89}), true),  "un ora",    "89 minutes = an hour");
+    equal(start.from(moment([2007, 1, 28]).add({m:90}), true),  "2 ore",    "90 minutes = 2 hours");
+    equal(start.from(moment([2007, 1, 28]).add({h:5}), true),   "5 ore",    "5 hours = 5 hours");
+    equal(start.from(moment([2007, 1, 28]).add({h:21}), true),  "21 ore",   "21 hours = 21 hours");
+    equal(start.from(moment([2007, 1, 28]).add({h:22}), true),  "un giorno",      "22 hours = a day");
+    equal(start.from(moment([2007, 1, 28]).add({h:35}), true),  "un giorno",      "35 hours = a day");
+    equal(start.from(moment([2007, 1, 28]).add({h:36}), true),  "2 giorni",     "36 hours = 2 days");
+    equal(start.from(moment([2007, 1, 28]).add({d:1}), true),   "un giorno",      "1 day = a day");
+    equal(start.from(moment([2007, 1, 28]).add({d:5}), true),   "5 giorni",     "5 days = 5 days");
+    equal(start.from(moment([2007, 1, 28]).add({d:25}), true),  "25 giorni",    "25 days = 25 days");
+    equal(start.from(moment([2007, 1, 28]).add({d:26}), true),  "un mese",    "26 days = a month");
+    equal(start.from(moment([2007, 1, 28]).add({d:30}), true),  "un mese",    "30 days = a month");
+    equal(start.from(moment([2007, 1, 28]).add({d:45}), true),  "un mese",    "45 days = a month");
+    equal(start.from(moment([2007, 1, 28]).add({d:46}), true),  "2 mesi",   "46 days = 2 months");
+    equal(start.from(moment([2007, 1, 28]).add({d:75}), true),  "2 mesi",   "75 days = 2 months");
+    equal(start.from(moment([2007, 1, 28]).add({d:76}), true),  "3 mesi",   "76 days = 3 months");
+    equal(start.from(moment([2007, 1, 28]).add({M:1}), true),   "un mese",    "1 month = a month");
+    equal(start.from(moment([2007, 1, 28]).add({M:5}), true),   "5 mesi",   "5 months = 5 months");
+    equal(start.from(moment([2007, 1, 28]).add({d:344}), true), "11 mesi",  "344 days = 11 months");
+    equal(start.from(moment([2007, 1, 28]).add({d:345}), true), "un anno",     "345 days = a year");
+    equal(start.from(moment([2007, 1, 28]).add({d:547}), true), "un anno",     "547 days = a year");
+    equal(start.from(moment([2007, 1, 28]).add({d:548}), true), "2 anni",    "548 days = 2 years");
+    equal(start.from(moment([2007, 1, 28]).add({y:1}), true),   "un anno",     "1 year = a year");
+    equal(start.from(moment([2007, 1, 28]).add({y:5}), true),   "5 anni",    "5 years = 5 years");
 });
 
 test("suffix", 2, function() {
-    _date.lang('it');
-    equal(_date(30000).from(0), "in secondi", "prefix");
-    equal(_date(0).from(30000), "secondi fa", "suffix");
+    moment.lang('it');
+    equal(moment(30000).from(0), "in secondi", "prefix");
+    equal(moment(0).from(30000), "secondi fa", "suffix");
 });
 
 test("fromNow", 2, function() {
-    _date.lang('it');
-    equal(_date().add({s:30}).fromNow(), "in secondi", "in seconds");
-    equal(_date().add({d:5}).fromNow(), "in 5 giorni", "in 5 days");
+    moment.lang('it');
+    equal(moment().add({s:30}).fromNow(), "in secondi", "in seconds");
+    equal(moment().add({d:5}).fromNow(), "in 5 giorni", "in 5 days");
 });
index 86b63f61bb85f58863e76934360885a7749ca36d..2797d0ecc33654f916f0bf11db41827b1f1983d6 100644 (file)
@@ -6,7 +6,7 @@
 module("lang:pt");
 
 test("format", 15, function() {
-    _date.lang('pt');
+    moment.lang('pt');
     var a = [
             ['dddd, MMMM Do YYYY, h:mm:ss a',      'Domingo, Fevereiro 14º 2010, 3:25:50 pm'],
             ['ddd, hA',                            'Dom, 3PM'],
@@ -24,7 +24,7 @@ test("format", 15, function() {
             ['z zz',                               'PST PST'],
             ['t\\he DDDo \\d\\ay of t\\he ye\\ar', 'the 45º day of the year']
         ],
-        b = _date(new Date(2010, 1, 14, 15, 25, 50, 125)),
+        b = moment(new Date(2010, 1, 14, 15, 25, 50, 125)),
         i;
     for (i = 0; i < a.length; i++) {
         equal(b.format(a[i][0]), a[i][1], a[i][0] + ' ---> ' + a[i][1]);
@@ -32,104 +32,104 @@ test("format", 15, function() {
 });
 
 test("format ordinal", 31, function() {
-    _date.lang('pt');
-    equal(_date([2011, 0, 1]).format('DDDo'), '1º', '1º');
-    equal(_date([2011, 0, 2]).format('DDDo'), '2º', '2º');
-    equal(_date([2011, 0, 3]).format('DDDo'), '3º', '3º');
-    equal(_date([2011, 0, 4]).format('DDDo'), '4º', '4º');
-    equal(_date([2011, 0, 5]).format('DDDo'), '5º', '5º');
-    equal(_date([2011, 0, 6]).format('DDDo'), '6º', '6º');
-    equal(_date([2011, 0, 7]).format('DDDo'), '7º', '7º');
-    equal(_date([2011, 0, 8]).format('DDDo'), '8º', '8º');
-    equal(_date([2011, 0, 9]).format('DDDo'), '9º', '9º');
-    equal(_date([2011, 0, 10]).format('DDDo'), '10º', '10º');
+    moment.lang('pt');
+    equal(moment([2011, 0, 1]).format('DDDo'), '1º', '1º');
+    equal(moment([2011, 0, 2]).format('DDDo'), '2º', '2º');
+    equal(moment([2011, 0, 3]).format('DDDo'), '3º', '3º');
+    equal(moment([2011, 0, 4]).format('DDDo'), '4º', '4º');
+    equal(moment([2011, 0, 5]).format('DDDo'), '5º', '5º');
+    equal(moment([2011, 0, 6]).format('DDDo'), '6º', '6º');
+    equal(moment([2011, 0, 7]).format('DDDo'), '7º', '7º');
+    equal(moment([2011, 0, 8]).format('DDDo'), '8º', '8º');
+    equal(moment([2011, 0, 9]).format('DDDo'), '9º', '9º');
+    equal(moment([2011, 0, 10]).format('DDDo'), '10º', '10º');
 
-    equal(_date([2011, 0, 11]).format('DDDo'), '11º', '11º');
-    equal(_date([2011, 0, 12]).format('DDDo'), '12º', '12º');
-    equal(_date([2011, 0, 13]).format('DDDo'), '13º', '13º');
-    equal(_date([2011, 0, 14]).format('DDDo'), '14º', '14º');
-    equal(_date([2011, 0, 15]).format('DDDo'), '15º', '15º');
-    equal(_date([2011, 0, 16]).format('DDDo'), '16º', '16º');
-    equal(_date([2011, 0, 17]).format('DDDo'), '17º', '17º');
-    equal(_date([2011, 0, 18]).format('DDDo'), '18º', '18º');
-    equal(_date([2011, 0, 19]).format('DDDo'), '19º', '19º');
-    equal(_date([2011, 0, 20]).format('DDDo'), '20º', '20º');
+    equal(moment([2011, 0, 11]).format('DDDo'), '11º', '11º');
+    equal(moment([2011, 0, 12]).format('DDDo'), '12º', '12º');
+    equal(moment([2011, 0, 13]).format('DDDo'), '13º', '13º');
+    equal(moment([2011, 0, 14]).format('DDDo'), '14º', '14º');
+    equal(moment([2011, 0, 15]).format('DDDo'), '15º', '15º');
+    equal(moment([2011, 0, 16]).format('DDDo'), '16º', '16º');
+    equal(moment([2011, 0, 17]).format('DDDo'), '17º', '17º');
+    equal(moment([2011, 0, 18]).format('DDDo'), '18º', '18º');
+    equal(moment([2011, 0, 19]).format('DDDo'), '19º', '19º');
+    equal(moment([2011, 0, 20]).format('DDDo'), '20º', '20º');
 
-    equal(_date([2011, 0, 21]).format('DDDo'), '21º', '21º');
-    equal(_date([2011, 0, 22]).format('DDDo'), '22º', '22º');
-    equal(_date([2011, 0, 23]).format('DDDo'), '23º', '23º');
-    equal(_date([2011, 0, 24]).format('DDDo'), '24º', '24º');
-    equal(_date([2011, 0, 25]).format('DDDo'), '25º', '25º');
-    equal(_date([2011, 0, 26]).format('DDDo'), '26º', '26º');
-    equal(_date([2011, 0, 27]).format('DDDo'), '27º', '27º');
-    equal(_date([2011, 0, 28]).format('DDDo'), '28º', '28º');
-    equal(_date([2011, 0, 29]).format('DDDo'), '29º', '29º');
-    equal(_date([2011, 0, 30]).format('DDDo'), '30º', '30º');
+    equal(moment([2011, 0, 21]).format('DDDo'), '21º', '21º');
+    equal(moment([2011, 0, 22]).format('DDDo'), '22º', '22º');
+    equal(moment([2011, 0, 23]).format('DDDo'), '23º', '23º');
+    equal(moment([2011, 0, 24]).format('DDDo'), '24º', '24º');
+    equal(moment([2011, 0, 25]).format('DDDo'), '25º', '25º');
+    equal(moment([2011, 0, 26]).format('DDDo'), '26º', '26º');
+    equal(moment([2011, 0, 27]).format('DDDo'), '27º', '27º');
+    equal(moment([2011, 0, 28]).format('DDDo'), '28º', '28º');
+    equal(moment([2011, 0, 29]).format('DDDo'), '29º', '29º');
+    equal(moment([2011, 0, 30]).format('DDDo'), '30º', '30º');
 
-    equal(_date([2011, 0, 31]).format('DDDo'), '31º', '31º');
+    equal(moment([2011, 0, 31]).format('DDDo'), '31º', '31º');
 });
 
 test("format month", 12, function() {
-    _date.lang('pt');
+    moment.lang('pt');
     var expected = 'Janeiro Jan_Fevereiro Feb_Março Mar_Abril Abr_Maio Mai_Junho Jun_Julho Jul_Agosto Ago_Setembro Set_Outubro Out_Novembro Nov_Dezembro Dez'.split("_");
     var i;
     for (i = 0; i < expected.length; i++) {
-        equal(_date([2011, i, 0]).format('MMMM MMM'), expected[i], expected[i]);
+        equal(moment([2011, i, 0]).format('MMMM MMM'), expected[i], expected[i]);
     }
 });
 
 test("format week", 7, function() {
-    _date.lang('pt');
+    moment.lang('pt');
     var expected = 'Domingo Dom_Segunda-feira Seg_Terça-feira Ter_Quarta-feira Qua_Quinta-feira Qui_Sexta-feira Sex_Sábado Sáb'.split("_");
     var i;
     for (i = 0; i < expected.length; i++) {
-        equal(_date([2011, 0, 2 + i]).format('dddd ddd'), expected[i], expected[i]);
+        equal(moment([2011, 0, 2 + i]).format('dddd ddd'), expected[i], expected[i]);
     }
 });
 
 test("from", 30, function() {
-    _date.lang('pt');
-    var start = _date([2007, 1, 28]);
-    equal(start.from(_date([2007, 1, 28]).add({s:44}), true),  "segundos",    "44 seconds = seconds");
-    equal(start.from(_date([2007, 1, 28]).add({s:45}), true),  "um minuto",   "45 seconds = a minute");
-    equal(start.from(_date([2007, 1, 28]).add({s:89}), true),  "um minuto",   "89 seconds = a minute");
-    equal(start.from(_date([2007, 1, 28]).add({s:90}), true),  "2 minutos",  "90 seconds = 2 minutes");
-    equal(start.from(_date([2007, 1, 28]).add({m:44}), true),  "44 minutos", "44 minutes = 44 minutes");
-    equal(start.from(_date([2007, 1, 28]).add({m:45}), true),  "uma hora",    "45 minutes = an hour");
-    equal(start.from(_date([2007, 1, 28]).add({m:89}), true),  "uma hora",    "89 minutes = an hour");
-    equal(start.from(_date([2007, 1, 28]).add({m:90}), true),  "2 horas",    "90 minutes = 2 hours");
-    equal(start.from(_date([2007, 1, 28]).add({h:5}), true),   "5 horas",    "5 hours = 5 hours");
-    equal(start.from(_date([2007, 1, 28]).add({h:21}), true),  "21 horas",   "21 hours = 21 hours");
-    equal(start.from(_date([2007, 1, 28]).add({h:22}), true),  "um dia",      "22 hours = a day");
-    equal(start.from(_date([2007, 1, 28]).add({h:35}), true),  "um dia",      "35 hours = a day");
-    equal(start.from(_date([2007, 1, 28]).add({h:36}), true),  "2 dias",     "36 hours = 2 days");
-    equal(start.from(_date([2007, 1, 28]).add({d:1}), true),   "um dia",      "1 day = a day");
-    equal(start.from(_date([2007, 1, 28]).add({d:5}), true),   "5 dias",     "5 days = 5 days");
-    equal(start.from(_date([2007, 1, 28]).add({d:25}), true),  "25 dias",    "25 days = 25 days");
-    equal(start.from(_date([2007, 1, 28]).add({d:26}), true),  "um mês",    "26 days = a month");
-    equal(start.from(_date([2007, 1, 28]).add({d:30}), true),  "um mês",    "30 days = a month");
-    equal(start.from(_date([2007, 1, 28]).add({d:45}), true),  "um mês",    "45 days = a month");
-    equal(start.from(_date([2007, 1, 28]).add({d:46}), true),  "2 meses",   "46 days = 2 months");
-    equal(start.from(_date([2007, 1, 28]).add({d:75}), true),  "2 meses",   "75 days = 2 months");
-    equal(start.from(_date([2007, 1, 28]).add({d:76}), true),  "3 meses",   "76 days = 3 months");
-    equal(start.from(_date([2007, 1, 28]).add({M:1}), true),   "um mês",    "1 month = a month");
-    equal(start.from(_date([2007, 1, 28]).add({M:5}), true),   "5 meses",   "5 months = 5 months");
-    equal(start.from(_date([2007, 1, 28]).add({d:344}), true), "11 meses",  "344 days = 11 months");
-    equal(start.from(_date([2007, 1, 28]).add({d:345}), true), "um ano",     "345 days = a year");
-    equal(start.from(_date([2007, 1, 28]).add({d:547}), true), "um ano",     "547 days = a year");
-    equal(start.from(_date([2007, 1, 28]).add({d:548}), true), "2 anos",    "548 days = 2 years");
-    equal(start.from(_date([2007, 1, 28]).add({y:1}), true),   "um ano",     "1 year = a year");
-    equal(start.from(_date([2007, 1, 28]).add({y:5}), true),   "5 anos",    "5 years = 5 years");
+    moment.lang('pt');
+    var start = moment([2007, 1, 28]);
+    equal(start.from(moment([2007, 1, 28]).add({s:44}), true),  "segundos",    "44 seconds = seconds");
+    equal(start.from(moment([2007, 1, 28]).add({s:45}), true),  "um minuto",   "45 seconds = a minute");
+    equal(start.from(moment([2007, 1, 28]).add({s:89}), true),  "um minuto",   "89 seconds = a minute");
+    equal(start.from(moment([2007, 1, 28]).add({s:90}), true),  "2 minutos",  "90 seconds = 2 minutes");
+    equal(start.from(moment([2007, 1, 28]).add({m:44}), true),  "44 minutos", "44 minutes = 44 minutes");
+    equal(start.from(moment([2007, 1, 28]).add({m:45}), true),  "uma hora",    "45 minutes = an hour");
+    equal(start.from(moment([2007, 1, 28]).add({m:89}), true),  "uma hora",    "89 minutes = an hour");
+    equal(start.from(moment([2007, 1, 28]).add({m:90}), true),  "2 horas",    "90 minutes = 2 hours");
+    equal(start.from(moment([2007, 1, 28]).add({h:5}), true),   "5 horas",    "5 hours = 5 hours");
+    equal(start.from(moment([2007, 1, 28]).add({h:21}), true),  "21 horas",   "21 hours = 21 hours");
+    equal(start.from(moment([2007, 1, 28]).add({h:22}), true),  "um dia",      "22 hours = a day");
+    equal(start.from(moment([2007, 1, 28]).add({h:35}), true),  "um dia",      "35 hours = a day");
+    equal(start.from(moment([2007, 1, 28]).add({h:36}), true),  "2 dias",     "36 hours = 2 days");
+    equal(start.from(moment([2007, 1, 28]).add({d:1}), true),   "um dia",      "1 day = a day");
+    equal(start.from(moment([2007, 1, 28]).add({d:5}), true),   "5 dias",     "5 days = 5 days");
+    equal(start.from(moment([2007, 1, 28]).add({d:25}), true),  "25 dias",    "25 days = 25 days");
+    equal(start.from(moment([2007, 1, 28]).add({d:26}), true),  "um mês",    "26 days = a month");
+    equal(start.from(moment([2007, 1, 28]).add({d:30}), true),  "um mês",    "30 days = a month");
+    equal(start.from(moment([2007, 1, 28]).add({d:45}), true),  "um mês",    "45 days = a month");
+    equal(start.from(moment([2007, 1, 28]).add({d:46}), true),  "2 meses",   "46 days = 2 months");
+    equal(start.from(moment([2007, 1, 28]).add({d:75}), true),  "2 meses",   "75 days = 2 months");
+    equal(start.from(moment([2007, 1, 28]).add({d:76}), true),  "3 meses",   "76 days = 3 months");
+    equal(start.from(moment([2007, 1, 28]).add({M:1}), true),   "um mês",    "1 month = a month");
+    equal(start.from(moment([2007, 1, 28]).add({M:5}), true),   "5 meses",   "5 months = 5 months");
+    equal(start.from(moment([2007, 1, 28]).add({d:344}), true), "11 meses",  "344 days = 11 months");
+    equal(start.from(moment([2007, 1, 28]).add({d:345}), true), "um ano",     "345 days = a year");
+    equal(start.from(moment([2007, 1, 28]).add({d:547}), true), "um ano",     "547 days = a year");
+    equal(start.from(moment([2007, 1, 28]).add({d:548}), true), "2 anos",    "548 days = 2 years");
+    equal(start.from(moment([2007, 1, 28]).add({y:1}), true),   "um ano",     "1 year = a year");
+    equal(start.from(moment([2007, 1, 28]).add({y:5}), true),   "5 anos",    "5 years = 5 years");
 });
 
 test("suffix", 2, function() {
-    _date.lang('pt');
-    equal(_date(30000).from(0), "em segundos", "prefix");
-    equal(_date(0).from(30000), "segundos atrás", "suffix");
+    moment.lang('pt');
+    equal(moment(30000).from(0), "em segundos", "prefix");
+    equal(moment(0).from(30000), "segundos atrás", "suffix");
 });
 
 test("fromNow", 2, function() {
-    _date.lang('pt');
-    equal(_date().add({s:30}).fromNow(), "em segundos", "in seconds");
-    equal(_date().add({d:5}).fromNow(), "em 5 dias", "in 5 days");
+    moment.lang('pt');
+    equal(moment().add({s:30}).fromNow(), "em segundos", "in seconds");
+    equal(moment().add({d:5}).fromNow(), "em 5 dias", "in 5 days");
 });