From: Tim Wood Date: Sat, 15 Oct 2011 00:17:53 +0000 (-0700) Subject: Renaming the library to 'moment' X-Git-Tag: 1.0.1~15 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=32d58a64e28f105289dc7d3f3ff74e0fc5644d8d;p=thirdparty%2Fmoment.git Renaming the library to 'moment' --- diff --git a/build.js b/build.js index 119cbf253..f7fc8917a 100755 --- 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 diff --git a/lang/all.min.js b/lang/all.min.js index e97fec765..514701834 100644 --- a/lang/all.min.js +++ b/lang/all.min.js @@ -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 diff --git a/lang/fr.js b/lang/fr.js index 60d3f7818..62b468f9c 100644 --- a/lang/fr.js +++ b/lang/fr.js @@ -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 diff --git a/lang/fr.min.js b/lang/fr.min.js index c9ee738a8..fe92c1454 100644 --- a/lang/fr.min.js +++ b/lang/fr.min.js @@ -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 diff --git a/lang/it.js b/lang/it.js index 8d040bbda..e94423bc7 100644 --- a/lang/it.js +++ b/lang/it.js @@ -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 diff --git a/lang/it.min.js b/lang/it.min.js index ae9bc0d8c..6c9fb3490 100644 --- a/lang/it.min.js +++ b/lang/it.min.js @@ -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 diff --git a/lang/pt.js b/lang/pt.js index 006180bd5..227e2efc3 100644 --- a/lang/pt.js +++ b/lang/pt.js @@ -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 diff --git a/lang/pt.min.js b/lang/pt.min.js index 0909f9b3e..8f9dea67b 100644 --- a/lang/pt.min.js +++ b/lang/pt.min.js @@ -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 diff --git a/underscore.date.js b/moment.js similarity index 89% rename from underscore.date.js rename to moment.js index 589a11365..b214fdd6f 100644 --- a/underscore.date.js +++ 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'), @@ -92,18 +92,18 @@ 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 @@ -113,18 +113,18 @@ 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); @@ -132,7 +132,7 @@ 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 @@ -289,33 +289,35 @@ 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; @@ -323,18 +325,20 @@ 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("_"), @@ -365,7 +369,7 @@ // 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) { @@ -388,7 +392,7 @@ } // shortcut for prototype - _date.fn = UnderscoreDate.prototype = { + moment.fn = Moment.prototype = { valueOf : function () { return +this._d; @@ -413,18 +417,18 @@ }, 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 () { @@ -435,7 +439,7 @@ // 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; @@ -454,19 +458,15 @@ 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 diff --git a/underscore.date.min.js b/moment.min.js similarity index 52% rename from underscore.date.min.js rename to moment.min.js index 33cf9a902..fa7dfcede 100755 --- a/underscore.date.min.js +++ b/moment.min.js @@ -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.length11?"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;g11?"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 ' + 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()"); -}); - diff --git a/test/index.html b/test/index.html index f574f2d62..7474512d0 100755 --- a/test/index.html +++ b/test/index.html @@ -1,20 +1,21 @@ - underscore.date unit test suite + + moment unit test suite - +
-

underscore.date unit test suite

+

moment unit test suite

    diff --git a/test/lang.js b/test/lang.js index 3c94578f6..c92e2e1e0 100644 --- a/test/lang.js +++ b/test/lang.js @@ -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"); }); diff --git a/test/lang/en.js b/test/lang/en.js index 4889cc85e..77f7451c6 100644 --- a/test/lang/en.js +++ b/test/lang/en.js @@ -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"); }); diff --git a/test/lang/fr.js b/test/lang/fr.js index 992410cc2..d8c54c6a0 100644 --- a/test/lang/fr.js +++ b/test/lang/fr.js @@ -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 diff --git a/test/lang/it.js b/test/lang/it.js index 1f9d284e5..1991eb7c4 100644 --- a/test/lang/it.js +++ b/test/lang/it.js @@ -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"); }); diff --git a/test/lang/pt.js b/test/lang/pt.js index 86b63f61b..2797d0ecc 100644 --- a/test/lang/pt.js +++ b/test/lang/pt.js @@ -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"); });