-(function(a){function g(){f.autorun=!0,f.currentModule&&e.moduleDone({name:f.currentModule,failed:f.moduleStats.bad,passed:f.moduleStats.all-f.moduleStats.bad,total:f.moduleStats.all});var a=s("qunit-banner"),b=s("qunit-tests"),c=+(new Date)-f.started,d=f.stats.all-f.stats.bad,g=["Tests completed in ",c," milliseconds.<br/>",'<span class="passed">',d,'</span> tests of <span class="total">',f.stats.all,'</span> passed, <span class="failed">',f.stats.bad,"</span> failed."].join("");a&&(a.className=f.stats.bad?"qunit-fail":"qunit-pass"),b&&(s("qunit-testresult").innerHTML=g),e.done({failed:f.stats.bad,passed:d,total:f.stats.all,runtime:c})}function h(a){var b=f.filters.length,c=!1;if(!b)return!0;while(b--){var d=f.filters[b],e=d.charAt(0)=="!";e&&(d=d.slice(1));if(a.indexOf(d)!==-1)return!e;e&&(c=!0)}return c}function i(){try{throw new Error}catch(a){if(a.stacktrace)return a.stacktrace.split("\n")[6];if(a.stack)return a.stack.split("\n")[4]}}function j(a){return a?(a+="",a.replace(/[\&"<>\\]/g,function(a){switch(a){case"&":return"&";case"\\":return"\\\\";case'"':return'"';case"<":return"<";case">":return">";default:return a}})):""}function k(a){f.queue.push(a),f.autorun&&!f.blocking&&l()}function l(){var b=(new Date).getTime();while(f.queue.length&&!f.blocking)if(f.updateRate<=0||(new Date).getTime()-b<f.updateRate)f.queue.shift()();else{a.setTimeout(l,13);break}!f.blocking&&!f.queue.length&&g()}function m(){f.pollution=[];if(f.noglobals)for(var b in a)f.pollution.push(b)}function n(a){var b=f.pollution;m();var c=o(b,f.pollution);c.length>0&&(ok(!1,"Introduced global variable(s): "+c.join(", ")),f.current.expected++);var d=o(f.pollution,b);d.length>0&&(ok(!1,"Deleted global variable(s): "+d.join(", ")),f.current.expected++)}function o(a,b){var c=a.slice();for(var d=0;d<c.length;d++)for(var e=0;e<b.length;e++)if(c[d]===b[e]){c.splice(d,1),d--;break}return c}function p(b,c,d){typeof console!="undefined"&&console.error&&console.warn?(console.error(b),console.error(c),console.warn(d.toString())):a.opera&&opera.postError&&opera.postError(b,c,d.toString)}function q(a,b){for(var c in b)a[c]=b[c];return a}function r(a,b,c){a.addEventListener?a.addEventListener(b,c,!1):a.attachEvent?a.attachEvent("on"+b,c):c()}function s(a){return typeof document!="undefined"&&!!document&&!!document.getElementById&&document.getElementById(a)}function t(a){var b="",c;for(var d=0;a[d];d++)c=a[d],c.nodeType===3||c.nodeType===4?b+=c.nodeValue:c.nodeType!==8&&(b+=t(c.childNodes));return b}var b={setTimeout:typeof a.setTimeout!="undefined",sessionStorage:function(){try{return!!sessionStorage.getItem}catch(a){return!1}}()},c=0,d=function(a,b,c,d,e,f){this.name=a,this.testName=b,this.expected=c,this.testEnvironmentArg=d,this.async=e,this.callback=f,this.assertions=[]};d.prototype={init:function(){var a=s("qunit-tests");if(a){var b=document.createElement("strong");b.innerHTML="Running "+this.name;var d=document.createElement("li");d.appendChild(b),d.className="running",d.id=this.id="test-output"+c++,a.appendChild(d)}},setup:function(){this.module!=f.previousModule&&(f.previousModule&&e.moduleDone({name:f.previousModule,failed:f.moduleStats.bad,passed:f.moduleStats.all-f.moduleStats.bad,total:f.moduleStats.all}),f.previousModule=this.module,f.moduleStats={all:0,bad:0},e.moduleStart({name:this.module})),f.current=this,this.testEnvironment=q({setup:function(){},teardown:function(){}},this.moduleTestEnvironment),this.testEnvironmentArg&&q(this.testEnvironment,this.testEnvironmentArg),e.testStart({name:this.testName}),e.current_testEnvironment=this.testEnvironment;try{f.pollution||m(),this.testEnvironment.setup.call(this.testEnvironment)}catch(a){e.ok(!1,"Setup failed on "+this.testName+": "+a.message)}},run:function(){this.async&&e.stop();if(f.notrycatch){this.callback.call(this.testEnvironment);return}try{this.callback.call(this.testEnvironment)}catch(a){p("Test "+this.testName+" died, exception and test follows",a,this.callback),e.ok(!1,"Died on test #"+(this.assertions.length+1)+": "+a.message+" - "+e.jsDump.parse(a)),m(),f.blocking&&start()}},teardown:function(){try{n(),this.testEnvironment.teardown.call(this.testEnvironment)}catch(a){e.ok(!1,"Teardown failed on "+this.testName+": "+a.message)}},finish:function(){this.expected&&this.expected!=this.assertions.length&&e.ok(!1,"Expected "+this.expected+" assertions, but "+this.assertions.length+" were run");var c=0,d=0,g=s("qunit-tests");f.stats.all+=this.assertions.length,f.moduleStats.all+=this.assertions.length;if(g){var h=document.createElement("ol");for(var i=0;i<this.assertions.length;i++){var j=this.assertions[i],k=document.createElement("li");k.className=j.result?"pass":"fail",k.innerHTML=j.message||(j.result?"okay":"failed"),h.appendChild(k),j.result?c++:(d++,f.stats.bad++,f.moduleStats.bad++)}e.config.reorder&&b.sessionStorage&&sessionStorage.setItem("qunit-"+this.testName,d),d==0&&(h.style.display="none");var l=document.createElement("strong");l.innerHTML=this.name+" <b class='counts'>(<b class='failed'>"+d+"</b>, <b class='passed'>"+c+"</b>, "+this.assertions.length+")</b>",r(l,"click",function(){var a=l.nextSibling,b=a.style.display;a.style.display=b==="none"?"block":"none"}),r(l,"dblclick",function(b){var c=b&&b.target?b.target:a.event.srcElement;if(c.nodeName.toLowerCase()=="span"||c.nodeName.toLowerCase()=="b")c=c.parentNode;a.location&&c.nodeName.toLowerCase()==="strong"&&(a.location.search="?"+encodeURIComponent(t([c]).replace(/\(.+\)$/,"").replace(/(^\s*|\s*$)/g,"")))});var k=s(this.id);k.className=d?"fail":"pass",k.removeChild(k.firstChild),k.appendChild(l),k.appendChild(h)}else for(var i=0;i<this.assertions.length;i++)this.assertions[i].result||(d++,f.stats.bad++,f.moduleStats.bad++);try{e.reset()}catch(m){p("reset() failed, following Test "+this.testName+", exception and reset fn follows",m,e.reset)}e.testDone({name:this.testName,failed:d,passed:this.assertions.length-d,total:this.assertions.length})},queue:function(){function c(){k(function(){a.setup()}),k(function(){a.run()}),k(function(){a.teardown()}),k(function(){a.finish()})}var a=this;k(function(){a.init()});var d=e.config.reorder&&b.sessionStorage&&+sessionStorage.getItem("qunit-"+this.testName);d?c():k(c)}};var e={module:function(a,b){f.currentModule=a,f.currentModuleTestEnviroment=b},asyncTest:function(a,b,c){arguments.length===2&&(c=b,b=0),e.test(a,b,c,!0)},test:function(a,b,c,e){var g='<span class="test-name">'+a+"</span>",i;arguments.length===2&&(c=b,b=null),b&&typeof b=="object"&&(i=b,b=null),f.currentModule&&(g='<span class="module-name">'+f.currentModule+"</span>: "+g);if(!h(f.currentModule+": "+a))return;var j=new d(g,a,b,i,e,c);j.module=f.currentModule,j.moduleTestEnvironment=f.currentModuleTestEnviroment,j.queue()},expect:function(a){f.current.expected=a},ok:function(a,b){a=!!a;var c={result:a,message:b};b=j(b),e.log(c),f.current.assertions.push({result:a,message:b})},equal:function(a,b,c){e.push(b==a,a,b,c)},notEqual:function(a,b,c){e.push(b!=a,a,b,c)},deepEqual:function(a,b,c){e.push(e.equiv(a,b),a,b,c)},notDeepEqual:function(a,b,c){e.push(!e.equiv(a,b),a,b,c)},strictEqual:function(a,b,c){e.push(b===a,a,b,c)},notStrictEqual:function(a,b,c){e.push(b!==a,a,b,c)},raises:function(a,b,c){var d,f=!1;typeof b=="string"&&(c=b,b=null);try{a()}catch(g){d=g}d&&(b?e.objectType(b)==="regexp"?f=b.test(d):d instanceof b?f=!0:b.call({},d)===!0&&(f=!0):f=!0),e.ok(f,c)},start:function(){f.semaphore--;if(f.semaphore>0)return;f.semaphore<0&&(f.semaphore=0),b.setTimeout?a.setTimeout(function(){f.timeout&&clearTimeout(f.timeout),f.blocking=!1,l()},13):(f.blocking=!1,l())},stop:function(c){f.semaphore++,f.blocking=!0,c&&b.setTimeout&&(clearTimeout(f.timeout),f.timeout=a.setTimeout(function(){e.ok(!1,"Test timed out"),e.start()},c))}};e.equals=e.equal,e.same=e.deepEqual;var f={queue:[],blocking:!0,reorder:!0};(function(){var b=a.location||{search:"",protocol:"file:"},c=b.search.slice(1).split("&");for(var d=0;d<c.length;d++)c[d]=decodeURIComponent(c[d]),c[d]==="noglobals"?(c.splice(d,1),d--,f.noglobals=!0):c[d]==="notrycatch"?(c.splice(d,1),d--,f.notrycatch=!0):c[d].search("=")>-1&&(c.splice(d,1),d--);f.filters=c,e.isLocal=b.protocol==="file:"})(),typeof exports=="undefined"||typeof require=="undefined"?(q(a,e),a.QUnit=e):(q(exports,e),exports.QUnit=e),q(e,{config:f,init:function(){q(f,{stats:{all:0,bad:0},moduleStats:{all:0,bad:0},started:+(new Date),updateRate:1e3,blocking:!1,autostart:!0,autorun:!1,filters:[],queue:[],semaphore:0});var a=s("qunit-tests"),b=s("qunit-banner"),c=s("qunit-testresult");a&&(a.innerHTML=""),b&&(b.className=""),c&&c.parentNode.removeChild(c),a&&(c=document.createElement("p"),c.id="qunit-testresult",c.className="result",a.parentNode.insertBefore(c,a),c.innerHTML="Running...<br/> ")},reset:function(){if(a.jQuery)jQuery("#main, #qunit-fixture").html(f.fixture);else{var b=s("main")||s("qunit-fixture");b&&(b.innerHTML=f.fixture)}},triggerEvent:function(a,b,c){document.createEvent?(c=document.createEvent("MouseEvents"),c.initMouseEvent(b,!0,!0,a.ownerDocument.defaultView,0,0,0,0,0,!1,!1,!1,!1,0,null),a.dispatchEvent(c)):a.fireEvent&&a.fireEvent("on"+b)},is:function(a,b){return e.objectType(b)==a},objectType:function(a){if(typeof a=="undefined")return"undefined";if(a===null)return"null";var b=Object.prototype.toString.call(a).match(/^\[object\s(.*)\]$/)[1]||"";switch(b){case"Number":return isNaN(a)?"nan":"number";case"String":case"Boolean":case"Array":case"Date":case"RegExp":case"Function":return b.toLowerCase()}return typeof a=="object"?"object":undefined},push:function(a,b,c,d){var g={result:a,message:d,actual:b,expected:c};d=j(d)||(a?"okay":"failed"),d='<span class="test-message">'+d+"</span>",c=j(e.jsDump.parse(c)),b=j(e.jsDump.parse(b));var h=d+'<table><tr class="test-expected"><th>Expected: </th><td><pre>'+c+"</pre></td></tr>";b!=c&&(h+='<tr class="test-actual"><th>Result: </th><td><pre>'+b+"</pre></td></tr>",h+='<tr class="test-diff"><th>Diff: </th><td><pre>'+e.diff(c,b)+"</pre></td></tr>");if(!a){var k=i();k&&(g.source=k,h+='<tr class="test-source"><th>Source: </th><td><pre>'+k+"</pre></td></tr>")}h+="</table>",e.log(g),f.current.assertions.push({result:!!a,message:h})},begin:function(){},done:function(){},log:function(){},testStart:function(){},testDone:function(){},moduleStart:function(){},moduleDone:function(){}});if(typeof document=="undefined"||document.readyState==="complete")f.autorun=!0;r(a,"load",function(){e.begin({});var a=q({},f);e.init(),q(f,a),f.blocking=!1;var c=s("qunit-userAgent");c&&(c.innerHTML=navigator.userAgent);var d=s("qunit-header");if(d){var g=location.href.lastIndexOf(location.search);if(g>-1){var h=location.href.slice(0,g);if(h==location.href)d.innerHTML='<a href=""> '+d.innerHTML+"</a> ";else{var i=decodeURIComponent(location.search.slice(1));d.innerHTML='<a href="'+h+'">'+d.innerHTML+'</a> › <a href="">'+i+"</a>"}}}var j=s("qunit-testrunner-toolbar");if(j){var k=document.createElement("input");k.type="checkbox",k.id="qunit-filter-pass",r(k,"click",function(){var a=document.getElementById("qunit-tests");if(k.checked)a.className=a.className+" hidepass";else{var c=" "+a.className.replace(/[\n\t\r]/g," ")+" ";a.className=c.replace(/ hidepass /," ")}b.sessionStorage&&sessionStorage.setItem("qunit-filter-passed-tests",k.checked?"true":"")});if(b.sessionStorage&&sessionStorage.getItem("qunit-filter-passed-tests")){k.checked=!0;var l=document.getElementById("qunit-tests");l.className=l.className+" hidepass"}j.appendChild(k);var m=document.createElement("label");m.setAttribute("for","qunit-filter-pass"),m.innerHTML="Hide passed tests",j.appendChild(m)}var n=s("main")||s("qunit-fixture");n&&(f.fixture=n.innerHTML),f.autostart&&e.start()}),e.equiv=function(){function d(a,b,c){var d=e.objectType(a);if(d)return e.objectType(b[d])==="function"?b[d].apply(b,c):b[d]}var a,b=[],c=[],f=function(){function d(a,b){return a instanceof b.constructor||b instanceof a.constructor?b==a:b===a}return{string:d,"boolean":d,number:d,"null":d,"undefined":d,nan:function(a){return isNaN(a)},date:function(a,b){return e.objectType(a)==="date"&&b.valueOf()===a.valueOf()},regexp:function(a,b){return e.objectType(a)==="regexp"&&b.source===a.source&&b.global===a.global&&b.ignoreCase===a.ignoreCase&&b.multiline===a.multiline},"function":function(){var a=b[b.length-1];return a!==Object&&typeof a!="undefined"},array:function(b,d){var f,g,h,i;if(e.objectType(b)!=="array")return!1;i=d.length;if(i!==b.length)return!1;c.push(d);for(f=0;f<i;f++){h=!1;for(g=0;g<c.length;g++)c[g]===d[f]&&(h=!0);if(!h&&!a(d[f],b[f]))return c.pop(),!1}return c.pop(),!0},object:function(d,e){var f,g,h,i=!0,j=[],k=[];if(e.constructor!==d.constructor)return!1;b.push(e.constructor),c.push(e);for(f in e){h=!1;for(g=0;g<c.length;g++)c[g]===e[f]&&(h=!0);j.push(f);if(!h&&!a(e[f],d[f])){i=!1;break}}b.pop(),c.pop();for(f in d)k.push(f);return i&&a(j.sort(),k.sort())}}}();return a=function(){var a=Array.prototype.slice.apply(arguments);return a.length<2?!0:function(a,b){return a===b?!0:a===null||b===null||typeof a=="undefined"||typeof b=="undefined"||e.objectType(a)!==e.objectType(b)?!1:d(a,f,[b,a])}(a[0],a[1])&&arguments.callee.apply(this,a.splice(1,a.length-1))},a}(),e.jsDump=function(){function a(a){return'"'+a.toString().replace(/"/g,'\\"')+'"'}function b(a){return a+""}function c(a,b,c){var d=g.separator(),e=g.indent(),f=g.indent(1);return b.join&&(b=b.join(","+d+f)),b?[a,f+b,e+c].join(d):a+c}function d(a){var b=a.length,d=Array(b);this.up();while(b--)d[b]=this.parse(a[b]);return this.down(),c("[",d,"]")}var f=/^function (\w+)/,g={parse:function(a,b){var c=this.parsers[b||this.typeOf(a)];return b=typeof c,b=="function"?c.call(this,a):b=="string"?c:this.parsers.error},typeOf:function(a){var b;return a===null?b="null":typeof a=="undefined"?b="undefined":e.is("RegExp",a)?b="regexp":e.is("Date",a)?b="date":e.is("Function",a)?b="function":typeof a.setInterval!==undefined&&typeof a.document!="undefined"&&typeof a.nodeType=="undefined"?b="window":a.nodeType===9?b="document":a.nodeType?b="node":typeof a=="object"&&typeof a.length=="number"&&a.length>=0?b="array":b=typeof a,b},separator:function(){return this.multiline?this.HTML?"<br />":"\n":this.HTML?" ":" "},indent:function(a){if(!this.multiline)return"";var b=this.indentChar;return this.HTML&&(b=b.replace(/\t/g," ").replace(/ /g," ")),Array(this._depth_+(a||0)).join(b)},up:function(a){this._depth_+=a||1},down:function(a){this._depth_-=a||1},setParser:function(a,b){this.parsers[a]=b},quote:a,literal:b,join:c,_depth_:1,parsers:{window:"[Window]",document:"[Document]",error:"[ERROR]",unknown:"[Unknown]","null":"null","undefined":"undefined","function":function(a){var b="function",d="name"in a?a.name:(f.exec(a)||[])[1];return d&&(b+=" "+d),b+="(",b=[b,e.jsDump.parse(a,"functionArgs"),"){"].join(""),c(b,e.jsDump.parse(a,"functionCode"),"}")},array:d,nodelist:d,arguments:d,object:function(a){var b=[];e.jsDump.up();for(var d in a)b.push(e.jsDump.parse(d,"key")+": "+e.jsDump.parse(a[d]));return e.jsDump.down(),c("{",b,"}")},node:function(a){var b=e.jsDump.HTML?"<":"<",c=e.jsDump.HTML?">":">",d=a.nodeName.toLowerCase(),f=b+d;for(var g in e.jsDump.DOMAttrs){var h=a[e.jsDump.DOMAttrs[g]];h&&(f+=" "+g+"="+e.jsDump.parse(h,"attribute"))}return f+c+b+"/"+d+c},functionArgs:function(a){var b=a.length;if(!b)return"";var c=Array(b);while(b--)c[b]=String.fromCharCode(97+b);return" "+c.join(", ")+" "},key:a,functionCode:"[code]",attribute:a,string:a,date:a,regexp:b,number:b,"boolean":b},DOMAttrs:{id:"id",name:"name","class":"className"},HTML:!1,indentChar:" ",multiline:!0};return g}(),e.diff=function(){function a(a,b){var c=new Object,d=new Object;for(var e=0;e<b.length;e++)c[b[e]]==null&&(c[b[e]]={rows:new Array,o:null}),c[b[e]].rows.push(e);for(var e=0;e<a.length;e++)d[a[e]]==null&&(d[a[e]]={rows:new Array,n:null}),d[a[e]].rows.push(e);for(var e in c)c[e].rows.length==1&&typeof d[e]!="undefined"&&d[e].rows.length==1&&(b[c[e].rows[0]]={text:b[c[e].rows[0]],row:d[e].rows[0]},a[d[e].rows[0]]={text:a[d[e].rows[0]],row:c[e].rows[0]});for(var e=0;e<b.length-1;e++)b[e].text!=null&&b[e+1].text==null&&b[e].row+1<a.length&&a[b[e].row+1].text==null&&b[e+1]==a[b[e].row+1]&&(b[e+1]={text:b[e+1],row:b[e].row+1},a[b[e].row+1]={text:a[b[e].row+1],row:e+1});for(var e=b.length-1;e>0;e--)b[e].text!=null&&b[e-1].text==null&&b[e].row>0&&a[b[e].row-1].text==null&&b[e-1]==a[b[e].row-1]&&(b[e-1]={text:b[e-1],row:b[e].row-1},a[b[e].row-1]={text:a[b[e].row-1],row:e-1});return{o:a,n:b}}return function(b,c){b=b.replace(/\s+$/,""),c=c.replace(/\s+$/,"");var d=a(b==""?[]:b.split(/\s+/),c==""?[]:c.split(/\s+/)),e="",f=b.match(/\s+/g);f==null?f=[" "]:f.push(" ");var g=c.match(/\s+/g);g==null?g=[" "]:g.push(" ");if(d.n.length==0)for(var h=0;h<d.o.length;h++)e+="<del>"+d.o[h]+f[h]+"</del>";else{if(d.n[0].text==null)for(c=0;c<d.o.length&&d.o[c].text==null;c++)e+="<del>"+d.o[c]+f[c]+"</del>";for(var h=0;h<d.n.length;h++)if(d.n[h].text==null)e+="<ins>"+d.n[h]+g[h]+"</ins>";else{var i="";for(c=d.n[h].row+1;c<d.o.length&&d.o[c].text==null;c++)i+="<del>"+d.o[c]+f[c]+"</del>";e+=" "+d.n[h].text+g[h]+i}}return e}}()})(this),function(){var a;typeof window=="undefined"?(a=require("../../moment"),module=QUnit.module):a=window.moment,module("create"),test("array",8,function(){ok(a([2010]).native()instanceof Date,"[2010]"),ok(a([2010,1]).native()instanceof Date,"[2010, 1]"),ok(a([2010,1,12]).native()instanceof Date,"[2010, 1, 12]"),ok(a([2010,1,12,1]).native()instanceof Date,"[2010, 1, 12, 1]"),ok(a([2010,1,12,1,1]).native()instanceof Date,"[2010, 1, 12, 1, 1]"),ok(a([2010,1,12,1,1,1]).native()instanceof Date,"[2010, 1, 12, 1, 1, 1]"),ok(a([2010,1,12,1,1,1,1]).native()instanceof Date,"[2010, 1, 12, 1, 1, 1, 1]"),deepEqual(a(new Date(2010,1,14,15,25,50,125)),a([2010,1,14,15,25,50,125]),"constructing with array === constructing with new Date()")}),test("number",2,function(){ok(a(1e3).native()instanceof Date,"1000"),ok(a(1e3).valueOf()===1e3,"testing valueOf")}),test("date",1,function(){ok(a(new Date).native()instanceof Date,"new Date()")}),test("moment",2,function(){ok(a(a()).native()instanceof Date,"moment(moment())"),ok(a(a(a())).native()instanceof Date,"moment(moment(moment()))")}),test("undefined",1,function(){ok(a().native()instanceof Date,"undefined")}),test("string without format",2,function(){ok(a("Aug 9, 1995").native()instanceof Date,"Aug 9, 1995"),ok(a("Mon, 25 Dec 1995 13:30:00 GMT").native()instanceof Date,"Mon, 25 Dec 1995 13:30:00 GMT")}),test("string with format",13,function(){var b=[["MM-DD-YYYY","12-02-1999"],["DD-MM-YYYY","12-02-1999"],["DD/MM/YYYY","12/02/1999"],["DD_MM_YYYY","12_02_1999"],["DD:MM:YYYY","12:02:1999"],["D-M-YY","2-2-99"],["YY","99"],["DDD-YYYY","300-1999"],["DD-MM-YYYY h:m:s","12-02-1999 2:45:10"],["DD-MM-YYYY h:m:s a","12-02-1999 2:45:10 am"],["DD-MM-YYYY h:m:s a","12-02-1999 2:45:10 pm"],["YYYY-MM-DDTHH:mm:ss","2011-11-11T11:11:11"],["MM-DD-YYYY \\M","12-02-1999 M"]],c;for(c=0;c<b.length;c++)equal(a(b[c][1],b[c][0]).format(b[c][0]),b[c][1],b[c][0]+" ---> "+b[c][1])}),test("string with array of formats",3,function(){equal(a("13-02-1999",["MM-DD-YYYY","DD-MM-YYYY"]).format("MM DD YYYY"),"02 13 1999","switching month and day"),equal(a("02-13-1999",["MM/DD/YYYY","YYYY-MM-DD","MM-DD-YYYY"]).format("MM DD YYYY"),"02 13 1999","year last"),equal(a("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(a("71","YY").format("YYYY"),"1971","71 > 1971"),equal(a("69","YY").format("YYYY"),"2069","69 > 2069")}),module("add and subtract"),test("add and subtract short",12,function(){var b=a();b.year(2011),b.month(9),b.date(12),b.hours(6),b.minutes(7),b.seconds(8),equal(b.add({ms:1e3}).seconds(),9,"Add milliseconds"),equal(b.add({s:1}).seconds(),10,"Add seconds"),equal(b.add({m:1}).minutes(),8,"Add minutes"),equal(b.add({h:1}).hours(),7,"Add hours"),equal(b.add({d:1}).date(),13,"Add date"),equal(b.add({w:1}).date(),20,"Add week"),equal(b.add({M:1}).month(),10,"Add month"),equal(b.add({y:1}).year(),2012,"Add year");var c=a([2010,0,31]).add({M:1}),d=a([2010,1,28]).subtract({M:1});equal(c.month(),1,"add month, jan 31st to feb 28th"),equal(c.date(),28,"add month, jan 31st to feb 28th"),equal(d.month(),0,"subtract month, feb 28th to jan 28th"),equal(d.date(),28,"subtract month, feb 28th to jan 28th")}),test("add and subtract long",8,function(){var b=a();b.year(2011),b.month(9),b.date(12),b.hours(6),b.minutes(7),b.seconds(8),equal(b.add({milliseconds:1e3}).seconds(),9,"Add milliseconds"),equal(b.add({seconds:1}).seconds(),10,"Add seconds"),equal(b.add({minutes:1}).minutes(),8,"Add minutes"),equal(b.add({hours:1}).hours(),7,"Add hours"),equal(b.add({days:1}).date(),13,"Add date"),equal(b.add({weeks:1}).date(),20,"Add week"),equal(b.add({months:1}).month(),10,"Add month"),equal(b.add({years:1}).year(),2012,"Add year")}),test("add and subtract string short",8,function(){var b=a();b.year(2011),b.month(9),b.date(12),b.hours(6),b.minutes(7),b.seconds(8),equal(b.add("milliseconds",1e3).seconds(),9,"Add milliseconds"),equal(b.add("seconds",1).seconds(),10,"Add seconds"),equal(b.add("minutes",1).minutes(),8,"Add minutes"),equal(b.add("hours",1).hours(),7,"Add hours"),equal(b.add("days",1).date(),13,"Add date"),equal(b.add("weeks",1).date(),20,"Add week"),equal(b.add("months",1).month(),10,"Add month"),equal(b.add("years",1).year(),2012,"Add year")}),test("add and subtract string short",8,function(){var b=a();b.year(2011),b.month(9),b.date(12),b.hours(6),b.minutes(7),b.seconds(8),equal(b.add("ms",1e3).seconds(),9,"Add milliseconds"),equal(b.add("s",1).seconds(),10,"Add seconds"),equal(b.add("m",1).minutes(),8,"Add minutes"),equal(b.add("h",1).hours(),7,"Add hours"),equal(b.add("d",1).date(),13,"Add date"),equal(b.add("w",1).date(),20,"Add week"),equal(b.add("M",1).month(),10,"Add month"),equal(b.add("y",1).year(),2012,"Add year")}),module("diff"),test("diff",5,function(){equal(a(1e3).diff(0),1e3,"1 second - 0 = 1000"),equal(a(1e3).diff(500),500,"1 second - .5 second = -500"),equal(a(0).diff(1e3),-1e3,"0 - 1 second = -1000"),equal(a(new Date(1e3)).diff(1e3),0,"1 second - 1 second = 0");var b=new Date,c=new Date;b.setHours(b.getHours()+1),equal(a(b).diff(c),36e5,"1 hour from now = 360000")}),test("diff key after",9,function(){equal(a([2010]).diff([2011],"years"),-1,"year diff"),equal(a([2010]).diff([2011,6],"years",!0),-1.5,"year diff, float"),equal(a([2010]).diff([2010,2],"months"),-2,"month diff"),equal(a([2010]).diff([2010,0,7],"weeks"),-1,"week diff"),equal(a([2010]).diff([2010,0,21],"weeks"),-3,"week diff"),equal(a([2010]).diff([2010,0,4],"days"),-3,"day diff"),equal(a([2010]).diff([2010,0,1,4],"hours"),-4,"hour diff"),equal(a([2010]).diff([2010,0,1,0,5],"minutes"),-5,"minute diff"),equal(a([2010]).diff([2010,0,1,0,0,6],"seconds"),-6,"second diff")}),test("diff key before",9,function(){equal(a([2011]).diff([2010],"years"),1,"year diff"),equal(a([2011,6]).diff([2010],"years",!0),1.5,"year diff, float"),equal(a([2010,2]).diff([2010],"months"),2,"month diff"),equal(a([2010,0,4]).diff([2010],"days"),3,"day diff"),equal(a([2010,0,7]).diff([2010],"weeks"),1,"week diff"),equal(a([2010,0,21]).diff([2010],"weeks"),3,"week diff"),equal(a([2010,0,1,4]).diff([2010],"hours"),4,"hour diff"),equal(a([2010,0,1,0,5]).diff([2010],"minutes"),5,"minute diff"),equal(a([2010,0,1,0,0,6]).diff([2010],"seconds"),6,"second diff")}),test("diff overflow",4,function(){equal(a([2011]).diff([2010],"months"),12,"month diff"),equal(a([2010,0,2]).diff([2010],"hours"),24,"hour diff"),equal(a([2010,0,1,2]).diff([2010],"minutes"),120,"minute diff"),equal(a([2010,0,1,0,4]).diff([2010],"seconds"),240,"second diff")}),module("leap year"),test("leap year",4,function(){equal(a([2010,0,1]).isLeapYear(),!1,"2010"),equal(a([2100,0,1]).isLeapYear(),!1,"2100"),equal(a([2008,0,1]).isLeapYear(),!0,"2008"),equal(a([2e3,0,1]).isLeapYear(),!0,"2000")}),module("getters and setters"),test("getters",7,function(){var b=a([2011,9,12,6,7,8]);equal(b.year(),2011,"year"),equal(b.month(),9,"month"),equal(b.date(),12,"date"),equal(b.day(),3,"day"),equal(b.hours(),6,"hour"),equal(b.minutes(),7,"minute"),equal(b.seconds(),8,"second")}),test("setters",7,function(){var b=a();b.year(2011),b.month(9),b.date(12),b.hours(6),b.minutes(7),b.seconds(8),equal(b.year(),2011,"year"),equal(b.month(),9,"month"),equal(b.date(),12,"date"),equal(b.day(),3,"day"),equal(b.hours(),6,"hour"),equal(b.minutes(),7,"minute"),equal(b.seconds(),8,"second")}),test("setters - falsey values",1,function(){var b=a();b.minutes(1),b.minutes(0),equal(b.minutes(),0,"falsey value")}),test("chaining setters",7,function(){var b=a();b.year(2011).month(9).date(12).hours(6).minutes(7).seconds(8),equal(b.year(),2011,"year"),equal(b.month(),9,"month"),equal(b.date(),12,"date"),equal(b.day(),3,"day"),equal(b.hours(),6,"hour"),equal(b.minutes(),7,"minute"),equal(b.seconds(),8,"second")})},function(){var a;typeof window=="undefined"?(a=require("../../moment"),module=QUnit.module):a=window.moment,module("lang:en"),test("format",18,function(){a.lang("en");var b=[["dddd, MMMM Do YYYY, h:mm:ss a","Sunday, February 14th 2010, 3:25:50 pm"],["ddd, hA","Sun, 3PM"],["M Mo MM MMMM MMM","2 2nd 02 February Feb"],["YYYY YY","2010 10"],["D Do DD","14 14th 14"],["d do dddd ddd","0 0th Sunday Sun"],["DDD DDDo DDDD","45 45th 045"],["w wo ww","8 8th 08"],["h hh","3 03"],["H HH","15 15"],["m mm","25 25"],["s ss","50 50"],["a A","pm PM"],["t\\he DDDo \\d\\ay of t\\he ye\\ar","the 45th day of the year"],["L","02/14/2010"],["LL","February 14 2010"],["LLL","February 14 2010 3:25 PM"],["LLLL","Sunday, February 14 2010 3:25 PM"]],c=a(new Date(2010,1,14,15,25,50,125)),d;for(d=0;d<b.length;d++)equal(c.format(b[d][0]),b[d][1],b[d][0]+" ---> "+b[d][1])}),test("format YY",1,function(){var b=a(new Date(2009,1,14,15,25,50,125));equal(b.format("YY"),"09","YY ---> 09")}),test("format timezone",2,function(){var b=a(new Date(2010,1,14,15,25,50,125));ok(b.format("z").match(/^[A-Z]{3,4}$/),'z ---> Something like "PST"'),ok(b.format("zz").match(/^[A-Z]{3,4}$/),'zz ---> Something like "PST"')}),test("format ordinal",31,function(){a.lang("en"),equal(a([2011,0,1]).format("DDDo"),"1st","1st"),equal(a([2011,0,2]).format("DDDo"),"2nd","2nd"),equal(a([2011,0,3]).format("DDDo"),"3rd","3rd"),equal(a([2011,0,4]).format("DDDo"),"4th","4th"),equal(a([2011,0,5]).format("DDDo"),"5th","5th"),equal(a([2011,0,6]).format("DDDo"),"6th","6th"),equal(a([2011,0,7]).format("DDDo"),"7th","7th"),equal(a([2011,0,8]).format("DDDo"),"8th","8th"),equal(a([2011,0,9]).format("DDDo"),"9th","9th"),equal(a([2011,0,10]).format("DDDo"),"10th","10th"),equal(a([2011,0,11]).format("DDDo"),"11th","11th"),equal(a([2011,0,12]).format("DDDo"),"12th","12th"),equal(a([2011,0,13]).format("DDDo"),"13th","13th"),equal(a([2011,0,14]).format("DDDo"),"14th","14th"),equal(a([2011,0,15]).format("DDDo"),"15th","15th"),equal(a([2011,0,16]).format("DDDo"),"16th","16th"),equal(a([2011,0,17]).format("DDDo"),"17th","17th"),equal(a([2011,0,18]).format("DDDo"),"18th","18th"),equal(a([2011,0,19]).format("DDDo"),"19th","19th"),equal(a([2011,0,20]).format("DDDo"),"20th","20th"),equal(a([2011,0,21]).format("DDDo"),"21st","21st"),equal(a([2011,0,22]).format("DDDo"),"22nd","22nd"),equal(a([2011,0,23]).format("DDDo"),"23rd","23rd"),equal(a([2011,0,24]).format("DDDo"),"24th","24th"),equal(a([2011,0,25]).format("DDDo"),"25th","25th"),equal(a([2011,0,26]).format("DDDo"),"26th","26th"),equal(a([2011,0,27]).format("DDDo"),"27th","27th"),equal(a([2011,0,28]).format("DDDo"),"28th","28th"),equal(a([2011,0,29]).format("DDDo"),"29th","29th"),equal(a([2011,0,30]).format("DDDo"),"30th","30th"),equal(a([2011,0,31]).format("DDDo"),"31st","31st")}),test("format month",12,function(){a.lang("en");var b="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("_"),c;for(c=0;c<b.length;c++)equal(a([2011,c,0]).format("MMMM MMM"),b[c],b[c])}),test("format week",7,function(){a.lang("en");var b="Sunday Sun_Monday Mon_Tuesday Tue_Wednesday Wed_Thursday Thu_Friday Fri_Saturday Sat".split("_"),c;for(c=0;c<b.length;c++)equal(a([2011,0,2+c]).format("dddd ddd"),b[c],b[c])}),test("from",30,function(){a.lang("en");var b=a([2007,1,28]);equal(b.from(a([2007,1,28]).add({s:44}),!0),"a few seconds","44 seconds = a few seconds"),equal(b.from(a([2007,1,28]).add({s:45}),!0),"a minute","45 seconds = a minute"),equal(b.from(a([2007,1,28]).add({s:89}),!0),"a minute","89 seconds = a minute"),equal(b.from(a([2007,1,28]).add({s:90}),!0),"2 minutes","90 seconds = 2 minutes"),equal(b.from(a([2007,1,28]).add({m:44}),!0),"44 minutes","44 minutes = 44 minutes"),equal(b.from(a([2007,1,28]).add({m:45}),!0),"an hour","45 minutes = an hour"),equal(b.from(a([2007,1,28]).add({m:89}),!0),"an hour","89 minutes = an hour"),equal(b.from(a([2007,1,28]).add({m:90}),!0),"2 hours","90 minutes = 2 hours"),equal(b.from(a([2007,1,28]).add({h:5}),!0),"5 hours","5 hours = 5 hours"),equal(b.from(a([2007,1,28]).add({h:21}),!0),"21 hours","21 hours = 21 hours"),equal(b.from(a([2007,1,28]).add({h:22}),!0),"a day","22 hours = a day"),equal(b.from(a([2007,1,28]).add({h:35}),!0),"a day","35 hours = a day"),equal(b.from(a([2007,1,28]).add({h:36}),!0),"2 days","36 hours = 2 days"),equal(b.from(a([2007,1,28]).add({d:1}),!0),"a day","1 day = a day"),equal(b.from(a([2007,1,28]).add({d:5}),!0),"5 days","5 days = 5 days"),equal(b.from(a([2007,1,28]).add({d:25}),!0),"25 days","25 days = 25 days"),equal(b.from(a([2007,1,28]).add({d:26}),!0),"a month","26 days = a month"),equal(b.from(a([2007,1,28]).add({d:30}),!0),"a month","30 days = a month"),equal(b.from(a([2007,1,28]).add({d:45}),!0),"a month","45 days = a month"),equal(b.from(a([2007,1,28]).add({d:46}),!0),"2 months","46 days = 2 months"),equal(b.from(a([2007,1,28]).add({d:74}),!0),"2 months","75 days = 2 months"),equal(b.from(a([2007,1,28]).add({d:76}),!0),"3 months","76 days = 3 months"),equal(b.from(a([2007,1,28]).add({M:1}),!0),"a month","1 month = a month"),equal(b.from(a([2007,1,28]).add({M:5}),!0),"5 months","5 months = 5 months"),equal(b.from(a([2007,1,28]).add({d:344}),!0),"11 months","344 days = 11 months"),equal(b.from(a([2007,1,28]).add({d:345}),!0),"a year","345 days = a year"),equal(b.from(a([2007,1,28]).add({d:547}),!0),"a year","547 days = a year"),equal(b.from(a([2007,1,28]).add({d:548}),!0),"2 years","548 days = 2 years"),equal(b.from(a([2007,1,28]).add({y:1}),!0),"a year","1 year = a year"),equal(b.from(a([2007,1,28]).add({y:5}),!0),"5 years","5 years = 5 years")}),test("suffix",2,function(){a.lang("en"),equal(a(3e4).from(0),"in a few seconds","prefix"),equal(a(0).from(3e4),"a few seconds ago","suffix")}),test("now from now",1,function(){a.lang("en"),equal(a().fromNow(),"a few seconds ago","now from now should display as in the past")}),test("fromNow",2,function(){a.lang("en"),equal(a().add({s:30}).fromNow(),"in a few seconds","in a few seconds"),equal(a().add({d:5}).fromNow(),"in 5 days","in 5 days")}),module("lang:fr"),test("format",18,function(){a.lang("fr");var b=[["dddd, MMMM Do YYYY, h:mm:ss a","dimanche, février 14ème 2010, 3:25:50 pm"],["ddd, hA","dim., 3PM"],["M Mo MM MMMM MMM","2 2ème 02 février févr."],["YYYY YY","2010 10"],["D Do DD","14 14ème 14"],["d do dddd ddd","0 0ème dimanche dim."],["DDD DDDo DDDD","45 45ème 045"],["w wo ww","8 8ème 08"],["h hh","3 03"],["H HH","15 15"],["m mm","25 25"],["s ss","50 50"],["a A","pm PM"],["t\\he DDDo \\d\\ay of t\\he ye\\ar","the 45ème day of the year"],["L","14/02/2010"],["LL","14 février 2010"],["LLL","14 février 2010 15:25"],["LLLL","dimanche 14 février 2010 15:25"]],c=a(new Date(2010,1,14,15,25,50,125)),d;for(d=0;d<b.length;d++)equal(c.format(b[d][0]),b[d][1],b[d][0]+" ---> "+b[d][1])}),test("format YY",1,function(){var b=a(new Date(2009,1,14,15,25,50,125));equal(b.format("YY"),"09","YY ---> 09")}),test("format timezone",2,function(){var b=a(new Date(2010,1,14,15,25,50,125));ok(b.format("z").match(/^[A-Z]{3,4}$/),'z ---> Something like "PST"'),ok(b.format("zz").match(/^[A-Z]{3,4}$/),'zz ---> Something like "PST"')}),test("format ordinal",31,function(){a.lang("fr"),equal(a([2011,0,1]).format("DDDo"),"1er","1er"),equal(a([2011,0,2]).format("DDDo"),"2ème","2ème"),equal(a([2011,0,3]).format("DDDo"),"3ème","3ème"),equal(a([2011,0,4]).format("DDDo"),"4ème","4ème"),equal(a([2011,0,5]).format("DDDo"),"5ème","5ème"),equal(a([2011,0,6]).format("DDDo"),"6ème","6ème"),equal(a([2011,0,7]).format("DDDo"),"7ème","7ème"),equal(a([2011,0,8]).format("DDDo"),"8ème","8ème"),equal(a([2011,0,9]).format("DDDo"),"9ème","9ème"),equal(a([2011,0,10]).format("DDDo"),"10ème","10ème"),equal(a([2011,0,11]).format("DDDo"),"11ème","11ème"),equal(a([2011,0,12]).format("DDDo"),"12ème","12ème"),equal(a([2011,0,13]).format("DDDo"),"13ème","13ème"),equal(a([2011,0,14]).format("DDDo"),"14ème","14ème"),equal(a([2011,0,15]).format("DDDo"),"15ème","15ème"),equal(a([2011,0,16]).format("DDDo"),"16ème","16ème"),equal(a([2011,0,17]).format("DDDo"),"17ème","17ème"),equal(a([2011,0,18]).format("DDDo"),"18ème","18ème"),equal(a([2011,0,19]).format("DDDo"),"19ème","19ème"),equal(a([2011,0,20]).format("DDDo"),"20ème","20ème"),equal(a([2011,0,21]).format("DDDo"),"21ème","21ème"),equal(a([2011,0,22]).format("DDDo"),"22ème","22ème"),equal(a([2011,0,23]).format("DDDo"),"23ème","23ème"),equal(a([2011,0,24]).format("DDDo"),"24ème","24ème"),equal(a([2011,0,25]).format("DDDo"),"25ème","25ème"),equal(a([2011,0,26]).format("DDDo"),"26ème","26ème"),equal(a([2011,0,27]).format("DDDo"),"27ème","27ème"),equal(a([2011,0,28]).format("DDDo"),"28ème","28ème"),equal(a([2011,0,29]).format("DDDo"),"29ème","29ème"),equal(a([2011,0,30]).format("DDDo"),"30ème","30ème"),equal(a([2011,0,31]).format("DDDo"),"31ème","31ème")}),test("format month",12,function(){a.lang("fr");var b="janvier janv._février févr._mars mars_avril avr._mai mai_juin juin_juillet juil._août août_septembre sept._octobre oct._novembre nov._décembre déc.".split("_"),c;for(c=0;c<b.length;c++)equal(a([2011,c,0]).format("MMMM MMM"),b[c],b[c])}),test("format week",7,function(){a.lang("fr");var b="dimanche dim._lundi lun._mardi mar._mercredi mer._jeudi jeu._vendredi ven._samedi sam.".split("_"),c;for(c=0;c<b.length;c++)equal(a([2011,0,2+c]).format("dddd ddd"),b[c],b[c])}),test("from",30,function(){a.lang("fr");var b=a([2007,1,28]);equal(b.from(a([2007,1,28]).add({s:44}),!0),"quelques secondes","44 seconds = a few seconds"),equal(b.from(a([2007,1,28]).add({s:45}),!0),"une minute","45 seconds = a minute"),equal(b.from(a([2007,1,28]).add({s:89}),!0),"une minute","89 seconds = a minute"),equal(b.from(a([2007,1,28]).add({s:90}),!0),"2 minutes","90 seconds = 2 minutes"),equal(b.from(a([2007,1,28]).add({m:44}),!0),"44 minutes","44 minutes = 44 minutes"),equal(b.from(a([2007,1,28]).add({m:45}),!0),"une heure","45 minutes = an hour"),equal(b.from(a([2007,1,28]).add({m:89}),!0),"une heure","89 minutes = an hour"),equal(b.from(a([2007,1,28]).add({m:90}),!0),"2 heures","90 minutes = 2 hours"),equal(b.from(a([2007,1,28]).add({h:5}),!0),"5 heures","5 hours = 5 hours"),equal(b.from(a([2007,1,28]).add({h:21}),!0),"21 heures","21 hours = 21 hours"),equal(b.from(a([2007,1,28]).add({h:22}),!0),"un jour","22 hours = a day"),equal(b.from(a([2007,1,28]).add({h:35}),!0),"un jour","35 hours = a day"),equal(b.from(a([2007,1,28]).add({h:36}),!0),"2 jours","36 hours = 2 days"),equal(b.from(a([2007,1,28]).add({d:1}),!0),"un jour","1 day = a day"),equal(b.from(a([2007,1,28]).add({d:5}),!0),"5 jours","5 days = 5 days"),equal(b.from(a([2007,1,28]).add({d:25}),!0),"25 jours","25 days = 25 days"),equal(b.from(a([2007,1,28]).add({d:26}),!0),"un mois","26 days = a month"),equal(b.from(a([2007,1,28]).add({d:30}),!0),"un mois","30 days = a month"),equal(b.from(a([2007,1,28]).add({d:45}),!0),"un mois","45 days = a month"),equal(b.from(a([2007,1,28]).add({d:46}),!0),"2 mois","46 days = 2 months"),equal(b.from(a([2007,1,28]).add({d:74}),!0),"2 mois","75 days = 2 months"),equal(b.from(a([2007,1,28]).add({d:76}),!0),"3 mois","76 days = 3 months"),equal(b.from(a([2007,1,28]).add({M:1}),!0),"un mois","1 month = a month"),equal(b.from(a([2007,1,28]).add({M:5}),!0),"5 mois","5 months = 5 months"),equal(b.from(a([2007,1,28]).add({d:344}),!0),"11 mois","344 days = 11 months"),equal(b.from(a([2007,1,28]).add({d:345}),!0),"une année","345 days = a year"),equal(b.from(a([2007,1,28]).add({d:547}),!0),"une année","547 days = a year"),equal(b.from(a([2007,1,28]).add({d:548}),!0),"2 années","548 days = 2 years"),equal(b.from(a([2007,1,28]).add({y:1}),!0),"une année","1 year = a year"),equal(b.from(a([2007,1,28]).add({y:5}),!0),"5 années","5 years = 5 years")}),test("suffix",2,function(){a.lang("fr"),equal(a(3e4).from(0),"dans quelques secondes","prefix"),equal(a(0).from(3e4),"il y a quelques secondes","suffix")}),test("fromNow",2,function(){a.lang("fr"),equal(a().add({s:30}).fromNow(),"dans quelques secondes","in a few seconds"),equal(a().add({d:5}).fromNow(),"dans 5 jours","in 5 days")}),module("lang:it"),test("format",18,function(){a.lang("it");var b=[["dddd, MMMM Do YYYY, h:mm:ss a","Domenica, Febbraio 14º 2010, 3:25:50 pm"],["ddd, hA","Dom, 3PM"],["M Mo MM MMMM MMM","2 2º 02 Febbraio Feb"],["YYYY YY","2010 10"],["D Do DD","14 14º 14"],["d do dddd ddd","0 0º Domenica Dom"],["DDD DDDo DDDD","45 45º 045"],["w wo ww","8 8º 08"],["h hh","3 03"],["H HH","15 15"],["m mm","25 25"],["s ss","50 50"],["a A","pm PM"],["t\\he DDDo \\d\\ay of t\\he ye\\ar","the 45º day of the year"],["L","14/02/2010"],["LL","14 Febbraio 2010"],["LLL","14 Febbraio 2010 15:25"],["LLLL","Domenica, 14 Febbraio 2010 15:25"]],c=a(new Date(2010,1,14,15,25,50,125)),d;for(d=0;d<b.length;d++)equal(c.format(b[d][0]),b[d][1],b[d][0]+" ---> "+b[d][1])}),test("format YY",1,function(){var b=a(new Date(2009,1,14,15,25,50,125));equal(b.format("YY"),"09","YY ---> 09")}),test("format timezone",2,function(){var b=a(new Date(2010,1,14,15,25,50,125));ok(b.format("z").match(/^[A-Z]{3,4}$/),'z ---> Something like "PST"'),ok(b.format("zz").match(/^[A-Z]{3,4}$/),'zz ---> Something like "PST"')}),test("format ordinal",31,function(){a.lang("it"),equal(a([2011,0,1]).format("DDDo"),"1º","1º"),equal(a([2011,0,2]).format("DDDo"),"2º","2º"),equal(a([2011,0,3]).format("DDDo"),"3º","3º"),equal(a([2011,0,4]).format("DDDo"),"4º","4º"),equal(a([2011,0,5]).format("DDDo"),"5º","5º"),equal(a([2011,0,6]).format("DDDo"),"6º","6º"),equal(a([2011,0,7]).format("DDDo"),"7º","7º"),equal(a([2011,0,8]).format("DDDo"),"8º","8º"),equal(a([2011,0,9]).format("DDDo"),"9º","9º"),equal(a([2011,0,10]).format("DDDo"),"10º","10º"),equal(a([2011,0,11]).format("DDDo"),"11º","11º"),equal(a([2011,0,12]).format("DDDo"),"12º","12º"),equal(a([2011,0,13]).format("DDDo"),"13º","13º"),equal(a([2011,0,14]).format("DDDo"),"14º","14º"),equal(a([2011,0,15]).format("DDDo"),"15º","15º"),equal(a([2011,0,16]).format("DDDo"),"16º","16º"),equal(a([2011,0,17]).format("DDDo"),"17º","17º"),equal(a([2011,0,18]).format("DDDo"),"18º","18º"),equal(a([2011,0,19]).format("DDDo"),"19º","19º"),equal(a([2011,0,20]).format("DDDo"),"20º","20º"),equal(a([2011,0,21]).format("DDDo"),"21º","21º"),equal(a([2011,0,22]).format("DDDo"),"22º","22º"),equal(a([2011,0,23]).format("DDDo"),"23º","23º"),equal(a([2011,0,24]).format("DDDo"),"24º","24º"),equal(a([2011,0,25]).format("DDDo"),"25º","25º"),equal(a([2011,0,26]).format("DDDo"),"26º","26º"),equal(a([2011,0,27]).format("DDDo"),"27º","27º"),equal(a([2011,0,28]).format("DDDo"),"28º","28º"),equal(a([2011,0,29]).format("DDDo"),"29º","29º"),equal(a([2011,0,30]).format("DDDo"),"30º","30º"),equal(a([2011,0,31]).format("DDDo"),"31º","31º")}),test("format month",12,function(){a.lang("it");var b="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("_"),c;for(c=0;c<b.length;c++)equal(a([2011,c,0]).format("MMMM MMM"),b[c],b[c])}),test("format week",7,function(){a.lang("it");var b="Domenica Dom_Lunedi Lun_Martedi Mar_Mercoledi Mer_Giovedi Gio_Venerdi Ven_Sabato Sab".split("_"),c;for(c=0;c<b.length;c++)equal(a([2011,0,2+c]).format("dddd ddd"),b[c],b[c])}),test("from",30,function(){a.lang("it");var b=a([2007,1,28]);equal(b.from(a([2007,1,28]).add({s:44}),!0),"secondi","44 seconds = seconds"),equal(b.from(a([2007,1,28]).add({s:45}),!0),"un minuto","45 seconds = a minute"),equal(b.from(a([2007,1,28]).add({s:89}),!0),"un minuto","89 seconds = a minute"),equal(b.from(a([2007,1,28]).add({s:90}),!0),"2 minuti","90 seconds = 2 minutes"),equal(b.from(a([2007,1,28]).add({m:44}),!0),"44 minuti","44 minutes = 44 minutes"),equal(b.from(a([2007,1,28]).add({m:45}),!0),"un ora","45 minutes = an hour"),equal(b.from(a([2007,1,28]).add({m:89}),!0),"un ora","89 minutes = an hour"),equal(b.from(a([2007,1,28]).add({m:90}),!0),"2 ore","90 minutes = 2 hours"),equal(b.from(a([2007,1,28]).add({h:5}),!0),"5 ore","5 hours = 5 hours"),equal(b.from(a([2007,1,28]).add({h:21}),!0),"21 ore","21 hours = 21 hours"),equal(b.from(a([2007,1,28]).add({h:22}),!0),"un giorno","22 hours = a day"),equal(b.from(a([2007,1,28]).add({h:35}),!0),"un giorno","35 hours = a day"),equal(b.from(a([2007,1,28]).add({h:36}),!0),"2 giorni","36 hours = 2 days"),equal(b.from(a([2007,1,28]).add({d:1}),!0),"un giorno","1 day = a day"),equal(b.from(a([2007,1,28]).add({d:5}),!0),"5 giorni","5 days = 5 days"),equal(b.from(a([2007,1,28]).add({d:25}),!0),"25 giorni","25 days = 25 days"),equal(b.from(a([2007,1,28]).add({d:26}),!0),"un mese","26 days = a month"),equal(b.from(a([2007,1,28]).add({d:30}),!0),"un mese","30 days = a month"),equal(b.from(a([2007,1,28]).add({d:45}),!0),"un mese","45 days = a month"),equal(b.from(a([2007,1,28]).add({d:46}),!0),"2 mesi","46 days = 2 months"),equal(b.from(a([2007,1,28]).add({d:74}),!0),"2 mesi","75 days = 2 months"),equal(b.from(a([2007,1,28]).add({d:76}),!0),"3 mesi","76 days = 3 months"),equal(b.from(a([2007,1,28]).add({M:1}),!0),"un mese","1 month = a month"),equal(b.from(a([2007,1,28]).add({M:5}),!0),"5 mesi","5 months = 5 months"),equal(b.from(a([2007,1,28]).add({d:344}),!0),"11 mesi","344 days = 11 months"),equal(b.from(a([2007,1,28]).add({d:345}),!0),"un anno","345 days = a year"),equal(b.from(a([2007,1,28]).add({d:547}),!0),"un anno","547 days = a year"),equal(b.from(a([2007,1,28]).add({d:548}),!0),"2 anni","548 days = 2 years"),equal(b.from(a([2007,1,28]).add({y:1}),!0),"un anno","1 year = a year"),equal(b.from(a([2007,1,28]).add({y:5}),!0),"5 anni","5 years = 5 years")}),test("suffix",2,function(){a.lang("it"),equal(a(3e4).from(0),"in secondi","prefix"),equal(a(0).from(3e4),"secondi fa","suffix")}),test("fromNow",2,function(){a.lang("it"),equal(a().add({s:30}).fromNow(),"in secondi","in seconds"),equal(a().add({d:5}).fromNow(),"in 5 giorni","in 5 days")}),module("lang:pt"),test("format",18,function(){a.lang("pt");var b=[["dddd, MMMM Do YYYY, h:mm:ss a","Domingo, Fevereiro 14º 2010, 3:25:50 pm"],["ddd, hA","Dom, 3PM"],["M Mo MM MMMM MMM","2 2º 02 Fevereiro Feb"],["YYYY YY","2010 10"],["D Do DD","14 14º 14"],["d do dddd ddd","0 0º Domingo Dom"],["DDD DDDo DDDD","45 45º 045"],["w wo ww","8 8º 08"],["h hh","3 03"],["H HH","15 15"],["m mm","25 25"],["s ss","50 50"],["a A","pm PM"],["t\\he DDDo \\d\\ay of t\\he ye\\ar","the 45º day of the year"],["L","14/02/2010"],["LL","14 de Fevereiro de 2010"],["LLL","14 de Fevereiro de 2010 15:25"],["LLLL","Domingo, 14 de Fevereiro de 2010 15:25"]],c=a(new Date(2010,1,14,15,25,50,125)),d;for(d=0;d<b.length;d++)equal(c.format(b[d][0]),b[d][1],b[d][0]+" ---> "+b[d][1])}),test("format YY",1,function(){var b=a(new Date(2009,1,14,15,25,50,125));equal(b.format("YY"),"09","YY ---> 09")}),test("format timezone",2,function(){var b=a(new Date(2010,1,14,15,25,50,125));ok(b.format("z").match(/^[A-Z]{3,4}$/),'z ---> Something like "PST"'),ok(b.format("zz").match(/^[A-Z]{3,4}$/),'zz ---> Something like "PST"')}),test("format ordinal",31,function(){a.lang("pt"),equal(a([2011,0,1]).format("DDDo"),"1º","1º"),equal(a([2011,0,2]).format("DDDo"),"2º","2º"),equal(a([2011,0,3]).format("DDDo"),"3º","3º"),equal(a([2011,0,4]).format("DDDo"),"4º","4º"),equal(a([2011,0,5]).format("DDDo"),"5º","5º"),equal(a([2011,0,6]).format("DDDo"),"6º","6º"),equal(a([2011,0,7]).format("DDDo"),"7º","7º"),equal(a([2011,0,8]).format("DDDo"),"8º","8º"),equal(a([2011,0,9]).format("DDDo"),"9º","9º"),equal(a([2011,0,10]).format("DDDo"),"10º","10º"),equal(a([2011,0,11]).format("DDDo"),"11º","11º"),equal(a([2011,0,12]).format("DDDo"),"12º","12º"),equal(a([2011,0,13]).format("DDDo"),"13º","13º"),equal(a([2011,0,14]).format("DDDo"),"14º","14º"),equal(a([2011,0,15]).format("DDDo"),"15º","15º"),equal(a([2011,0,16]).format("DDDo"),"16º","16º"),equal(a([2011,0,17]).format("DDDo"),"17º","17º"),equal(a([2011,0,18]).format("DDDo"),"18º","18º"),equal(a([2011,0,19]).format("DDDo"),"19º","19º"),equal(a([2011,0,20]).format("DDDo"),"20º","20º"),equal(a([2011,0,21]).format("DDDo"),"21º","21º"),equal(a([2011,0,22]).format("DDDo"),"22º","22º"),equal(a([2011,0,23]).format("DDDo"),"23º","23º"),equal(a([2011,0,24]).format("DDDo"),"24º","24º"),equal(a([2011,0,25]).format("DDDo"),"25º","25º"),equal(a([2011,0,26]).format("DDDo"),"26º","26º"),equal(a([2011,0,27]).format("DDDo"),"27º","27º"),equal(a([2011,0,28]).format("DDDo"),"28º","28º"),equal(a([2011,0,29]).format("DDDo"),"29º","29º"),equal(a([2011,0,30]).format("DDDo"),"30º","30º"),equal(a([2011,0,31]).format("DDDo"),"31º","31º")}),test("format month",12,function(){a.lang("pt");var b="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("_"),c;for(c=0;c<b.length;c++)equal(a([2011,c,0]).format("MMMM MMM"),b[c],b[c])}),test("format week",7,function(){a.lang("pt");var b="Domingo Dom_Segunda-feira Seg_Terça-feira Ter_Quarta-feira Qua_Quinta-feira Qui_Sexta-feira Sex_Sábado Sáb".split("_"),c;for(c=0;c<b.length;c++)equal(a([2011,0,2+c]).format("dddd ddd"),b[c],b[c])}),test("from",30,function(){a.lang("pt");var b=a([2007,1,28]);equal(b.from(a([2007,1,28]).add({s:44}),!0),"segundos","44 seconds = seconds"),equal(b.from(a([2007,1,28]).add({s:45}),!0),"um minuto","45 seconds = a minute"),equal(b.from(a([2007,1,28]).add({s:89}),!0),"um minuto","89 seconds = a minute"),equal(b.from(a([2007,1,28]).add({s:90}),!0),"2 minutos","90 seconds = 2 minutes"),equal(b.from(a([2007,1,28]).add({m:44}),!0),"44 minutos","44 minutes = 44 minutes"),equal(b.from(a([2007,1,28]).add({m:45}),!0),"uma hora","45 minutes = an hour"),equal(b.from(a([2007,1,28]).add({m:89}),!0),"uma hora","89 minutes = an hour"),equal(b.from(a([2007,1,28]).add({m:90}),!0),"2 horas","90 minutes = 2 hours"),equal(b.from(a([2007,1,28]).add({h:5}),!0),"5 horas","5 hours = 5 hours"),equal(b.from(a([2007,1,28]).add({h:21}),!0),"21 horas","21 hours = 21 hours"),equal(b.from(a([2007,1,28]).add({h:22}),!0),"um dia","22 hours = a day"),equal(b.from(a([2007,1,28]).add({h:35}),!0),"um dia","35 hours = a day"),equal(b.from(a([2007,1,28]).add({h:36}),!0),"2 dias","36 hours = 2 days"),equal(b.from(a([2007,1,28]).add({d:1}),!0),"um dia","1 day = a day"),equal(b.from(a([2007,1,28]).add({d:5}),!0),"5 dias","5 days = 5 days"),equal(b.from(a([2007,1,28]).add({d:25}),!0),"25 dias","25 days = 25 days"),equal(b.from(a([2007,1,28]).add({d:26}),!0),"um mês","26 days = a month"),equal(b.from(a([2007,1,28]).add({d:30}),!0),"um mês","30 days = a month"),equal(b.from(a([2007,1,28]).add({d:45}),!0),"um mês","45 days = a month"),equal(b.from(a([2007,1,28]).add({d:46}),!0),"2 meses","46 days = 2 months"),equal(b.from(a([2007,1,28]).add({d:74}),!0),"2 meses","75 days = 2 months"),equal(b.from(a([2007,1,28]).add({d:76}),!0),"3 meses","76 days = 3 months"),equal(b.from(a([2007,1,28]).add({M:1}),!0),"um mês","1 month = a month"),equal(b.from(a([2007,1,28]).add({M:5}),!0),"5 meses","5 months = 5 months"),equal(b.from(a([2007,1,28]).add({d:344}),!0),"11 meses","344 days = 11 months"),equal(b.from(a([2007,1,28]).add({d:345}),!0),"um ano","345 days = a year"),equal(b.from(a([2007,1,28]).add({d:547}),!0),"um ano","547 days = a year"),equal(b.from(a([2007,1,28]).add({d:548}),!0),"2 anos","548 days = 2 years"),equal(b.from(a([2007,1,28]).add({y:1}),!0),"um ano","1 year = a year"),equal(b.from(a([2007,1,28]).add({y:5}),!0),"5 anos","5 years = 5 years")}),test("suffix",2,function(){a.lang("pt"),equal(a(3e4).from(0),"em segundos","prefix"),equal(a(0).from(3e4),"segundos atrás","suffix")}),test("fromNow",2,function(){a.lang("pt"),equal(a().add({s:30}).fromNow(),"em segundos","in seconds"),equal(a().add({d:5}).fromNow(),"em 5 dias","in 5 days")}),module("lang:es"),test("format",18,function(){a.lang("es");var b=[["dddd, MMMM Do YYYY, h:mm:ss a","Domingo, Febrero 14º 2010, 3:25:50 pm"],["ddd, hA","Dom., 3PM"],["M Mo MM MMMM MMM","2 2º 02 Febrero Feb."],["YYYY YY","2010 10"],["D Do DD","14 14º 14"],["d do dddd ddd","0 0º Domingo Dom."],["DDD DDDo DDDD","45 45º 045"],["w wo ww","8 8º 08"],["h hh","3 03"],["H HH","15 15"],["m mm","25 25"],["s ss","50 50"],["a A","pm PM"],["t\\he DDDo \\d\\ay of t\\he ye\\ar","the 45º day of the year"],["L","14/02/2010"],["LL","14 Febrero 2010"],["LLL","14 Febrero 2010 15:25"],["LLLL","Domingo 14 Febrero 2010 15:25"]],c=a(new Date(2010,1,14,15,25,50,125)),d;for(d=0;d<b.length;d++)equal(c.format(b[d][0]),b[d][1],b[d][0]+" ---> "+b[d][1])}),test("format YY",1,function(){var b=a(new Date(2009,1,14,15,25,50,125));equal(b.format("YY"),"09","YY ---> 09")}),test("format timezone",2,function(){var b=a(new Date(2010,1,14,15,25,50,125));ok(b.format("z").match(/^[A-Z]{3,4}$/),'z ---> Something like "PST"'),ok(b.format("zz").match(/^[A-Z]{3,4}$/),'zz ---> Something like "PST"')}),test("format ordinal",31,function(){a.lang("es"),equal(a([2011,0,1]).format("DDDo"),"1º","1º"),equal(a([2011,0,2]).format("DDDo"),"2º","2º"),equal(a([2011,0,3]).format("DDDo"),"3º","3º"),equal(a([2011,0,4]).format("DDDo"),"4º","4º"),equal(a([2011,0,5]).format("DDDo"),"5º","5º"),equal(a([2011,0,6]).format("DDDo"),"6º","6º"),equal(a([2011,0,7]).format("DDDo"),"7º","7º"),equal(a([2011,0,8]).format("DDDo"),"8º","8º"),equal(a([2011,0,9]).format("DDDo"),"9º","9º"),equal(a([2011,0,10]).format("DDDo"),"10º","10º"),equal(a([2011,0,11]).format("DDDo"),"11º","11º"),equal(a([2011,0,12]).format("DDDo"),"12º","12º"),equal(a([2011,0,13]).format("DDDo"),"13º","13º"),equal(a([2011,0,14]).format("DDDo"),"14º","14º"),equal(a([2011,0,15]).format("DDDo"),"15º","15º"),equal(a([2011,0,16]).format("DDDo"),"16º","16º"),equal(a([2011,0,17]).format("DDDo"),"17º","17º"),equal(a([2011,0,18]).format("DDDo"),"18º","18º"),equal(a([2011,0,19]).format("DDDo"),"19º","19º"),equal(a([2011,0,20]).format("DDDo"),"20º","20º"),equal(a([2011,0,21]).format("DDDo"),"21º","21º"),equal(a([2011,0,22]).format("DDDo"),"22º","22º"),equal(a([2011,0,23]).format("DDDo"),"23º","23º"),equal(a([2011,0,24]).format("DDDo"),"24º","24º"),equal(a([2011,0,25]).format("DDDo"),"25º","25º"),equal(a([2011,0,26]).format("DDDo"),"26º","26º"),equal(a([2011,0,27]).format("DDDo"),"27º","27º"),equal(a([2011,0,28]).format("DDDo"),"28º","28º"),equal(a([2011,0,29]).format("DDDo"),"29º","29º"),equal(a([2011,0,30]).format("DDDo"),"30º","30º"),equal(a([2011,0,31]).format("DDDo"),"31º","31º")}),test("format month",12,function(){a.lang("es");var b="Enero Ene._Febrero Feb._Marzo Mar._Abril Abr._Mayo May._Junio Jun._Julio Jul._Agosto Ago._Septiembre Sep._Octubre Oct._Noviembre Nov._Diciembre Dic.".split("_"),c;for(c=0;c<b.length;c++)equal(a([2011,c,0]).format("MMMM MMM"),b[c],b[c])}),test("format week",7,function(){a.lang("es");var b="Domingo Dom._Lunes Lun._Martes Mar._Miércoles Mié._Jueves Jue._Viernes Vie._Sábado Sáb.".split("_"),c;for(c=0;c<b.length;c++)equal(a([2011,0,2+c]).format("dddd ddd"),b[c],b[c])}),test("from",30,function(){a.lang("es");var b=a([2007,1,28]);equal(b.from(a([2007,1,28]).add({s:44}),!0),"unos segundos","44 seconds = a few seconds"),equal(b.from(a([2007,1,28]).add({s:45}),!0),"un minuto","45 seconds = a minute"),equal(b.from(a([2007,1,28]).add({s:89}),!0),"un minuto","89 seconds = a minute"),equal(b.from(a([2007,1,28]).add({s:90}),!0),"2 minutos","90 seconds = 2 minutes"),equal(b.from(a([2007,1,28]).add({m:44}),!0),"44 minutos","44 minutes = 44 minutes"),equal(b.from(a([2007,1,28]).add({m:45}),!0),"una hora","45 minutes = an hour"),equal(b.from(a([2007,1,28]).add({m:89}),!0),"una hora","89 minutes = an hour"),equal(b.from(a([2007,1,28]).add({m:90}),!0),"2 horas","90 minutes = 2 hours"),equal(b.from(a([2007,1,28]).add({h:5}),!0),"5 horas","5 hours = 5 hours"),equal(b.from(a([2007,1,28]).add({h:21}),!0),"21 horas","21 hours = 21 hours"),equal(b.from(a([2007,1,28]).add({h:22}),!0),"un día","22 hours = a day"),equal(b.from(a([2007,1,28]).add({h:35}),!0),"un día","35 hours = a day"),equal(b.from(a([2007,1,28]).add({h:36}),!0),"2 días","36 hours = 2 days"),equal(b.from(a([2007,1,28]).add({d:1}),!0),"un día","1 day = a day"),equal(b.from(a([2007,1,28]).add({d:5}),!0),"5 días","5 days = 5 days"),equal(b.from(a([2007,1,28]).add({d:25}),!0),"25 días","25 days = 25 days"),equal(b.from(a([2007,1,28]).add({d:26}),!0),"un mes","26 days = a month"),equal(b.from(a([2007,1,28]).add({d:30}),!0),"un mes","30 days = a month"),equal(b.from(a([2007,1,28]).add({d:45}),!0),"un mes","45 days = a month"),equal(b.from(a([2007,1,28]).add({d:46}),!0),"2 meses","46 days = 2 months"),equal(b.from(a([2007,1,28]).add({d:74}),!0),"2 meses","75 days = 2 months"),equal(b.from(a([2007,1,28]).add({d:76}),!0),"3 meses","76 days = 3 months"),equal(b.from(a([2007,1,28]).add({M:1}),!0),"un mes","1 month = a month"),equal(b.from(a([2007,1,28]).add({M:5}),!0),"5 meses","5 months = 5 months"),equal(b.from(a([2007,1,28]).add({d:344}),!0),"11 meses","344 days = 11 months"),equal(b.from(a([2007,1,28]).add({d:345}),!0),"un año","345 days = a year"),equal(b.from(a([2007,1,28]).add({d:547}),!0),"un año","547 days = a year"),equal(b.from(a([2007,1,28]).add({d:548}),!0),"2 años","548 days = 2 years"),equal(b.from(a([2007,1,28]).add({y:1}),!0),"un año","1 year = a year"),equal(b.from(a([2007,1,28]).add({y:5}),!0),"5 años","5 years = 5 years")}),test("suffix",2,function(){a.lang("es"),equal(a(3e4).from(0),"en unos segundos","prefix"),equal(a(0).from(3e4),"hace unos segundos","suffix")}),test("now from now",1,function(){a.lang("es"),equal(a().fromNow(),"hace unos segundos","now from now should display as in the past")}),test("fromNow",2,function(){a.lang("es"),equal(a().add({s:30}).fromNow(),"en unos segundos","en unos segundos"),equal(a().add({d:5}).fromNow(),"en 5 días","en 5 días")}),module("lang:nl"),test("format",18,function(){a.lang("nl");var b=[["dddd, MMMM Do YYYY, HH:mm:ss","zondag, februari 14de 2010, 15:25:50"],["ddd, HH","zo., 15"],["M Mo MM MMMM MMM","2 2de 02 februari feb."],["YYYY YY","2010 10"],["D Do DD","14 14de 14"],["d do dddd ddd","0 0de zondag zo."],["DDD DDDo DDDD","45 45ste 045"],["w wo ww","8 8ste 08"],["h hh","3 03"],["H HH","15 15"],["m mm","25 25"],["s ss","50 50"],["a A","pm PM"],["t\\he DDDo \\d\\ay of t\\he ye\\ar","the 45ste day of the year"],["L","14-02-2010"],["LL","februari 14 2010"],["LLL","februari 14 2010 15:25"],["LLLL","zondag, 14 februari 2010 15:25"]],c=a(new Date(2010,1,14,15,25,50,125)),d;for(d=0;d<b.length;d++)equal(c.format(b[d][0]),b[d][1],b[d][0]+" ---> "+b[d][1])}),test("format YY",1,function(){var b=a(new Date(2009,1,14,15,25,50,125));equal(b.format("YY"),"09","YY ---> 09")}),test("format timezone",2,function(){var b=a(new Date(2010,1,14,15,25,50,125));ok(b.format("z").match(/^[A-Z]{3,4}$/),'z ---> Something like "PST"'),ok(b.format("zz").match(/^[A-Z]{3,4}$/),'zz ---> Something like "PST"')}),test("format ordinal",31,function(){a.lang("nl"),equal(a([2011,0,1]).format("DDDo"),"1ste","1ste"),equal(a([2011,0,2]).format("DDDo"),"2de","2de"),equal(a([2011,0,3]).format("DDDo"),"3de","3de"),equal(a([2011,0,4]).format("DDDo"),"4de","4de"),equal(a([2011,0,5]).format("DDDo"),"5de","5de"),equal(a([2011,0,6]).format("DDDo"),"6de","6de"),equal(a([2011,0,7]).format("DDDo"),"7de","7de"),equal(a([2011,0,8]).format("DDDo"),"8ste","8ste"),equal(a([2011,0,9]).format("DDDo"),"9de","9de"),equal(a([2011,0,10]).format("DDDo"),"10de","10de"),equal(a([2011,0,11]).format("DDDo"),"11de","11de"),equal(a([2011,0,12]).format("DDDo"),"12de","12de"),equal(a([2011,0,13]).format("DDDo"),"13de","13de"),equal(a([2011,0,14]).format("DDDo"),"14de","14de"),equal(a([2011,0,15]).format("DDDo"),"15de","15de"),equal(a([2011,0,16]).format("DDDo"),"16de","16de"),equal(a([2011,0,17]).format("DDDo"),"17de","17de"),equal(a([2011,0,18]).format("DDDo"),"18de","18de"),equal(a([2011,0,19]).format("DDDo"),"19de","19de"),equal(a([2011,0,20]).format("DDDo"),"20ste","20ste"),equal(a([2011,0,21]).format("DDDo"),"21ste","21ste"),equal(a([2011,0,22]).format("DDDo"),"22ste","22ste"),equal(a([2011,0,23]).format("DDDo"),"23ste","23ste"),equal(a([2011,0,24]).format("DDDo"),"24ste","24ste"),equal(a([2011,0,25]).format("DDDo"),"25ste","25ste"),equal(a([2011,0,26]).format("DDDo"),"26ste","26ste"),equal(a([2011,0,27]).format("DDDo"),"27ste","27ste"),equal(a([2011,0,28]).format("DDDo"),"28ste","28ste"),equal(a([2011,0,29]).format("DDDo"),"29ste","29ste"),equal(a([2011,0,30]).format("DDDo"),"30ste","30ste"),equal(a([2011,0,31]).format("DDDo"),"31ste","31ste")}),test("format month",12,function(){a.lang("nl");var b="januari jan._februari feb._maart mar._april apr._mei mei._juni jun._juli jul._augustus aug._september sep._oktober okt._november nov._december dec.".split("_"),c;for(c=0;c<b.length;c++)equal(a([2011,c,0]).format("MMMM MMM"),b[c],b[c])}),test("format week",7,function(){a.lang("nl");var b="zondag zo._maandag ma._dinsdag di._woensdag wo._donderdag do._vrijdag vr._zaterdag za.".split("_"),c;for(c=0;c<b.length;c++)equal(a([2011,0,2+c]).format("dddd ddd"),b[c],b[c])}),test("from",30,function(){a.lang("nl");var b=a([2007,1,28]);equal(b.from(a([2007,1,28]).add({s:44}),!0),"een paar seconden","44 seconds = a few seconds"),equal(b.from(a([2007,1,28]).add({s:45}),!0),"één minuutje","45 seconds = a minute"),equal(b.from(a([2007,1,28]).add({s:89}),!0),"één minuutje","89 seconds = a minute"),equal(b.from(a([2007,1,28]).add({s:90}),!0),"2 minuten","90 seconds = 2 minutes"),equal(b.from(a([2007,1,28]).add({m:44}),!0),"44 minuten","44 minutes = 44 minutes"),equal(b.from(a([2007,1,28]).add({m:45}),!0),"één uur","45 minutes = an hour"),equal(b.from(a([2007,1,28]).add({m:89}),!0),"één uur","89 minutes = an hour"),equal(b.from(a([2007,1,28]).add({m:90}),!0),"2 uren","90 minutes = 2 hours"),equal(b.from(a([2007,1,28]).add({h:5}),!0),"5 uren","5 hours = 5 hours"),equal(b.from(a([2007,1,28]).add({h:21}),!0),"21 uren","21 hours = 21 hours"),equal(b.from(a([2007,1,28]).add({h:22}),!0),"één dag","22 hours = a day"),equal(b.from(a([2007,1,28]).add({h:35}),!0),"één dag","35 hours = a day"),equal(b.from(a([2007,1,28]).add({h:36}),!0),"2 dagen","36 hours = 2 days"),equal(b.from(a([2007,1,28]).add({d:1}),!0),"één dag","1 day = a day"),equal(b.from(a([2007,1,28]).add({d:5}),!0),"5 dagen","5 days = 5 days"),equal(b.from(a([2007,1,28]).add({d:25}),!0),"25 dagen","25 days = 25 days"),equal(b.from(a([2007,1,28]).add({d:26}),!0),"één maand","26 days = a month"),equal(b.from(a([2007,1,28]).add({d:30}),!0),"één maand","30 days = a month"),equal(b.from(a([2007,1,28]).add({d:45}),!0),"één maand","45 days = a month"),equal(b.from(a([2007,1,28]).add({d:46}),!0),"2 maanden","46 days = 2 months"),equal(b.from(a([2007,1,28]).add({d:74}),!0),"2 maanden","75 days = 2 months"),equal(b.from(a([2007,1,28]).add({d:76}),!0),"3 maanden","76 days = 3 months"),equal(b.from(a([2007,1,28]).add({M:1}),!0),"één maand","1 month = a month"),equal(b.from(a([2007,1,28]).add({M:5}),!0),"5 maanden","5 months = 5 months"),equal(b.from(a([2007,1,28]).add({d:344}),!0),"11 maanden","344 days = 11 months"),equal(b.from(a([2007,1,28]).add({d:345}),!0),"één jaar","345 days = a year"),equal(b.from(a([2007,1,28]).add({d:547}),!0),"één jaar","547 days = a year"),equal(b.from(a([2007,1,28]).add({d:548}),!0),"2 jaren","548 days = 2 years"),equal(b.from(a([2007,1,28]).add({y:1}),!0),"één jaar","1 year = a year"),equal(b.from(a([2007,1,28]).add({y:5}),!0),"5 jaren","5 years = 5 years")}),test("suffix",2,function(){a.lang("nl"),equal(a(3e4).from(0),"over een paar seconden","prefix"),equal(a(0).from(3e4),"een paar seconden geleden","suffix")}),test("now from now",1,function(){a.lang("nl"),equal(a().fromNow(),"een paar seconden geleden","now from now should display as in the past")}),test("fromNow",2,function(){a.lang("nl"),equal(a().add({s:30}).fromNow(),"over een paar seconden","in a few seconds"),equal(a().add({d:5}).fromNow(),"over 5 dagen","in 5 days")})}()
\ No newline at end of file
+/*
+ * QUnit - A JavaScript Unit Testing Framework
+ *
+ * http://docs.jquery.com/QUnit
+ *
+ * Copyright (c) 2011 John Resig, Jörn Zaefferer
+ * Dual licensed under the MIT (MIT-LICENSE.txt)
+ * or GPL (GPL-LICENSE.txt) licenses.
+ */
+
+(function(window) {
+
+var defined = {
+ setTimeout: typeof window.setTimeout !== "undefined",
+ sessionStorage: (function() {
+ try {
+ return !!sessionStorage.getItem;
+ } catch(e){
+ return false;
+ }
+ })()
+};
+
+var testId = 0;
+
+var Test = function(name, testName, expected, testEnvironmentArg, async, callback) {
+ this.name = name;
+ this.testName = testName;
+ this.expected = expected;
+ this.testEnvironmentArg = testEnvironmentArg;
+ this.async = async;
+ this.callback = callback;
+ this.assertions = [];
+};
+Test.prototype = {
+ init: function() {
+ var tests = id("qunit-tests");
+ if (tests) {
+ var b = document.createElement("strong");
+ b.innerHTML = "Running " + this.name;
+ var li = document.createElement("li");
+ li.appendChild( b );
+ li.className = "running";
+ li.id = this.id = "test-output" + testId++;
+ tests.appendChild( li );
+ }
+ },
+ setup: function() {
+ if (this.module != config.previousModule) {
+ if ( config.previousModule ) {
+ QUnit.moduleDone( {
+ name: config.previousModule,
+ failed: config.moduleStats.bad,
+ passed: config.moduleStats.all - config.moduleStats.bad,
+ total: config.moduleStats.all
+ } );
+ }
+ config.previousModule = this.module;
+ config.moduleStats = { all: 0, bad: 0 };
+ QUnit.moduleStart( {
+ name: this.module
+ } );
+ }
+
+ config.current = this;
+ this.testEnvironment = extend({
+ setup: function() {},
+ teardown: function() {}
+ }, this.moduleTestEnvironment);
+ if (this.testEnvironmentArg) {
+ extend(this.testEnvironment, this.testEnvironmentArg);
+ }
+
+ QUnit.testStart( {
+ name: this.testName
+ } );
+
+ // allow utility functions to access the current test environment
+ // TODO why??
+ QUnit.current_testEnvironment = this.testEnvironment;
+
+ try {
+ if ( !config.pollution ) {
+ saveGlobal();
+ }
+
+ this.testEnvironment.setup.call(this.testEnvironment);
+ } catch(e) {
+ QUnit.ok( false, "Setup failed on " + this.testName + ": " + e.message );
+ }
+ },
+ run: function() {
+ if ( this.async ) {
+ QUnit.stop();
+ }
+
+ if ( config.notrycatch ) {
+ this.callback.call(this.testEnvironment);
+ return;
+ }
+ try {
+ this.callback.call(this.testEnvironment);
+ } catch(e) {
+ fail("Test " + this.testName + " died, exception and test follows", e, this.callback);
+ QUnit.ok( false, "Died on test #" + (this.assertions.length + 1) + ": " + e.message + " - " + QUnit.jsDump.parse(e) );
+ // else next test will carry the responsibility
+ saveGlobal();
+
+ // Restart the tests if they're blocking
+ if ( config.blocking ) {
+ start();
+ }
+ }
+ },
+ teardown: function() {
+ try {
+ checkPollution();
+ this.testEnvironment.teardown.call(this.testEnvironment);
+ } catch(e) {
+ QUnit.ok( false, "Teardown failed on " + this.testName + ": " + e.message );
+ }
+ },
+ finish: function() {
+ if ( this.expected && this.expected != this.assertions.length ) {
+ QUnit.ok( false, "Expected " + this.expected + " assertions, but " + this.assertions.length + " were run" );
+ }
+
+ var good = 0, bad = 0,
+ tests = id("qunit-tests");
+
+ config.stats.all += this.assertions.length;
+ config.moduleStats.all += this.assertions.length;
+
+ if ( tests ) {
+ var ol = document.createElement("ol");
+
+ for ( var i = 0; i < this.assertions.length; i++ ) {
+ var assertion = this.assertions[i];
+
+ var li = document.createElement("li");
+ li.className = assertion.result ? "pass" : "fail";
+ li.innerHTML = assertion.message || (assertion.result ? "okay" : "failed");
+ ol.appendChild( li );
+
+ if ( assertion.result ) {
+ good++;
+ } else {
+ bad++;
+ config.stats.bad++;
+ config.moduleStats.bad++;
+ }
+ }
+
+ // store result when possible
+ QUnit.config.reorder && defined.sessionStorage && sessionStorage.setItem("qunit-" + this.testName, bad);
+
+ if (bad == 0) {
+ ol.style.display = "none";
+ }
+
+ var b = document.createElement("strong");
+ b.innerHTML = this.name + " <b class='counts'>(<b class='failed'>" + bad + "</b>, <b class='passed'>" + good + "</b>, " + this.assertions.length + ")</b>";
+
+ addEvent(b, "click", function() {
+ var next = b.nextSibling, display = next.style.display;
+ next.style.display = display === "none" ? "block" : "none";
+ });
+
+ addEvent(b, "dblclick", function(e) {
+ var target = e && e.target ? e.target : window.event.srcElement;
+ if ( target.nodeName.toLowerCase() == "span" || target.nodeName.toLowerCase() == "b" ) {
+ target = target.parentNode;
+ }
+ if ( window.location && target.nodeName.toLowerCase() === "strong" ) {
+ window.location.search = "?" + encodeURIComponent(getText([target]).replace(/\(.+\)$/, "").replace(/(^\s*|\s*$)/g, ""));
+ }
+ });
+
+ var li = id(this.id);
+ li.className = bad ? "fail" : "pass";
+ li.removeChild( li.firstChild );
+ li.appendChild( b );
+ li.appendChild( ol );
+
+ } else {
+ for ( var i = 0; i < this.assertions.length; i++ ) {
+ if ( !this.assertions[i].result ) {
+ bad++;
+ config.stats.bad++;
+ config.moduleStats.bad++;
+ }
+ }
+ }
+
+ try {
+ QUnit.reset();
+ } catch(e) {
+ fail("reset() failed, following Test " + this.testName + ", exception and reset fn follows", e, QUnit.reset);
+ }
+
+ QUnit.testDone( {
+ name: this.testName,
+ failed: bad,
+ passed: this.assertions.length - bad,
+ total: this.assertions.length
+ } );
+ },
+
+ queue: function() {
+ var test = this;
+ synchronize(function() {
+ test.init();
+ });
+ function run() {
+ // each of these can by async
+ synchronize(function() {
+ test.setup();
+ });
+ synchronize(function() {
+ test.run();
+ });
+ synchronize(function() {
+ test.teardown();
+ });
+ synchronize(function() {
+ test.finish();
+ });
+ }
+ // defer when previous test run passed, if storage is available
+ var bad = QUnit.config.reorder && defined.sessionStorage && +sessionStorage.getItem("qunit-" + this.testName);
+ if (bad) {
+ run();
+ } else {
+ synchronize(run);
+ };
+ }
+
+};
+
+var QUnit = {
+
+ // call on start of module test to prepend name to all tests
+ module: function(name, testEnvironment) {
+ config.currentModule = name;
+ config.currentModuleTestEnviroment = testEnvironment;
+ },
+
+ asyncTest: function(testName, expected, callback) {
+ if ( arguments.length === 2 ) {
+ callback = expected;
+ expected = 0;
+ }
+
+ QUnit.test(testName, expected, callback, true);
+ },
+
+ test: function(testName, expected, callback, async) {
+ var name = '<span class="test-name">' + testName + '</span>', testEnvironmentArg;
+
+ if ( arguments.length === 2 ) {
+ callback = expected;
+ expected = null;
+ }
+ // is 2nd argument a testEnvironment?
+ if ( expected && typeof expected === 'object') {
+ testEnvironmentArg = expected;
+ expected = null;
+ }
+
+ if ( config.currentModule ) {
+ name = '<span class="module-name">' + config.currentModule + "</span>: " + name;
+ }
+
+ if ( !validTest(config.currentModule + ": " + testName) ) {
+ return;
+ }
+
+ var test = new Test(name, testName, expected, testEnvironmentArg, async, callback);
+ test.module = config.currentModule;
+ test.moduleTestEnvironment = config.currentModuleTestEnviroment;
+ test.queue();
+ },
+
+ /**
+ * Specify the number of expected assertions to gurantee that failed test (no assertions are run at all) don't slip through.
+ */
+ expect: function(asserts) {
+ config.current.expected = asserts;
+ },
+
+ /**
+ * Asserts true.
+ * @example ok( "asdfasdf".length > 5, "There must be at least 5 chars" );
+ */
+ ok: function(a, msg) {
+ a = !!a;
+ var details = {
+ result: a,
+ message: msg
+ };
+ msg = escapeHtml(msg);
+ QUnit.log(details);
+ config.current.assertions.push({
+ result: a,
+ message: msg
+ });
+ },
+
+ /**
+ * Checks that the first two arguments are equal, with an optional message.
+ * Prints out both actual and expected values.
+ *
+ * Prefered to ok( actual == expected, message )
+ *
+ * @example equal( format("Received {0} bytes.", 2), "Received 2 bytes." );
+ *
+ * @param Object actual
+ * @param Object expected
+ * @param String message (optional)
+ */
+ equal: function(actual, expected, message) {
+ QUnit.push(expected == actual, actual, expected, message);
+ },
+
+ notEqual: function(actual, expected, message) {
+ QUnit.push(expected != actual, actual, expected, message);
+ },
+
+ deepEqual: function(actual, expected, message) {
+ QUnit.push(QUnit.equiv(actual, expected), actual, expected, message);
+ },
+
+ notDeepEqual: function(actual, expected, message) {
+ QUnit.push(!QUnit.equiv(actual, expected), actual, expected, message);
+ },
+
+ strictEqual: function(actual, expected, message) {
+ QUnit.push(expected === actual, actual, expected, message);
+ },
+
+ notStrictEqual: function(actual, expected, message) {
+ QUnit.push(expected !== actual, actual, expected, message);
+ },
+
+ raises: function(block, expected, message) {
+ var actual, ok = false;
+
+ if (typeof expected === 'string') {
+ message = expected;
+ expected = null;
+ }
+
+ try {
+ block();
+ } catch (e) {
+ actual = e;
+ }
+
+ if (actual) {
+ // we don't want to validate thrown error
+ if (!expected) {
+ ok = true;
+ // expected is a regexp
+ } else if (QUnit.objectType(expected) === "regexp") {
+ ok = expected.test(actual);
+ // expected is a constructor
+ } else if (actual instanceof expected) {
+ ok = true;
+ // expected is a validation function which returns true is validation passed
+ } else if (expected.call({}, actual) === true) {
+ ok = true;
+ }
+ }
+
+ QUnit.ok(ok, message);
+ },
+
+ start: function() {
+ config.semaphore--;
+ if (config.semaphore > 0) {
+ // don't start until equal number of stop-calls
+ return;
+ }
+ if (config.semaphore < 0) {
+ // ignore if start is called more often then stop
+ config.semaphore = 0;
+ }
+ // A slight delay, to avoid any current callbacks
+ if ( defined.setTimeout ) {
+ window.setTimeout(function() {
+ if ( config.timeout ) {
+ clearTimeout(config.timeout);
+ }
+
+ config.blocking = false;
+ process();
+ }, 13);
+ } else {
+ config.blocking = false;
+ process();
+ }
+ },
+
+ stop: function(timeout) {
+ config.semaphore++;
+ config.blocking = true;
+
+ if ( timeout && defined.setTimeout ) {
+ clearTimeout(config.timeout);
+ config.timeout = window.setTimeout(function() {
+ QUnit.ok( false, "Test timed out" );
+ QUnit.start();
+ }, timeout);
+ }
+ }
+
+};
+
+// Backwards compatibility, deprecated
+QUnit.equals = QUnit.equal;
+QUnit.same = QUnit.deepEqual;
+
+// Maintain internal state
+var config = {
+ // The queue of tests to run
+ queue: [],
+
+ // block until document ready
+ blocking: true,
+
+ // by default, run previously failed tests first
+ // very useful in combination with "Hide passed tests" checked
+ reorder: true
+};
+
+// Load paramaters
+(function() {
+ var location = window.location || { search: "", protocol: "file:" },
+ GETParams = location.search.slice(1).split('&');
+
+ for ( var i = 0; i < GETParams.length; i++ ) {
+ GETParams[i] = decodeURIComponent( GETParams[i] );
+ if ( GETParams[i] === "noglobals" ) {
+ GETParams.splice( i, 1 );
+ i--;
+ config.noglobals = true;
+ } else if ( GETParams[i] === "notrycatch" ) {
+ GETParams.splice( i, 1 );
+ i--;
+ config.notrycatch = true;
+ } else if ( GETParams[i].search('=') > -1 ) {
+ GETParams.splice( i, 1 );
+ i--;
+ }
+ }
+
+ // restrict modules/tests by get parameters
+ config.filters = GETParams;
+
+ // Figure out if we're running the tests from a server or not
+ QUnit.isLocal = !!(location.protocol === 'file:');
+})();
+
+// Expose the API as global variables, unless an 'exports'
+// object exists, in that case we assume we're in CommonJS
+if ( typeof exports === "undefined" || typeof require === "undefined" ) {
+ extend(window, QUnit);
+ window.QUnit = QUnit;
+} else {
+ extend(exports, QUnit);
+ exports.QUnit = QUnit;
+}
+
+// define these after exposing globals to keep them in these QUnit namespace only
+extend(QUnit, {
+ config: config,
+
+ // Initialize the configuration options
+ init: function() {
+ extend(config, {
+ stats: { all: 0, bad: 0 },
+ moduleStats: { all: 0, bad: 0 },
+ started: +new Date,
+ updateRate: 1000,
+ blocking: false,
+ autostart: true,
+ autorun: false,
+ filters: [],
+ queue: [],
+ semaphore: 0
+ });
+
+ var tests = id( "qunit-tests" ),
+ banner = id( "qunit-banner" ),
+ result = id( "qunit-testresult" );
+
+ if ( tests ) {
+ tests.innerHTML = "";
+ }
+
+ if ( banner ) {
+ banner.className = "";
+ }
+
+ if ( result ) {
+ result.parentNode.removeChild( result );
+ }
+
+ if ( tests ) {
+ result = document.createElement( "p" );
+ result.id = "qunit-testresult";
+ result.className = "result";
+ tests.parentNode.insertBefore( result, tests );
+ result.innerHTML = 'Running...<br/> ';
+ }
+ },
+
+ /**
+ * Resets the test setup. Useful for tests that modify the DOM.
+ *
+ * If jQuery is available, uses jQuery's html(), otherwise just innerHTML.
+ */
+ reset: function() {
+ if ( window.jQuery ) {
+ jQuery( "#main, #qunit-fixture" ).html( config.fixture );
+ } else {
+ var main = id( 'main' ) || id( 'qunit-fixture' );
+ if ( main ) {
+ main.innerHTML = config.fixture;
+ }
+ }
+ },
+
+ /**
+ * Trigger an event on an element.
+ *
+ * @example triggerEvent( document.body, "click" );
+ *
+ * @param DOMElement elem
+ * @param String type
+ */
+ triggerEvent: function( elem, type, event ) {
+ if ( document.createEvent ) {
+ event = document.createEvent("MouseEvents");
+ event.initMouseEvent(type, true, true, elem.ownerDocument.defaultView,
+ 0, 0, 0, 0, 0, false, false, false, false, 0, null);
+ elem.dispatchEvent( event );
+
+ } else if ( elem.fireEvent ) {
+ elem.fireEvent("on"+type);
+ }
+ },
+
+ // Safe object type checking
+ is: function( type, obj ) {
+ return QUnit.objectType( obj ) == type;
+ },
+
+ objectType: function( obj ) {
+ if (typeof obj === "undefined") {
+ return "undefined";
+
+ // consider: typeof null === object
+ }
+ if (obj === null) {
+ return "null";
+ }
+
+ var type = Object.prototype.toString.call( obj )
+ .match(/^\[object\s(.*)\]$/)[1] || '';
+
+ switch (type) {
+ case 'Number':
+ if (isNaN(obj)) {
+ return "nan";
+ } else {
+ return "number";
+ }
+ case 'String':
+ case 'Boolean':
+ case 'Array':
+ case 'Date':
+ case 'RegExp':
+ case 'Function':
+ return type.toLowerCase();
+ }
+ if (typeof obj === "object") {
+ return "object";
+ }
+ return undefined;
+ },
+
+ push: function(result, actual, expected, message) {
+ var details = {
+ result: result,
+ message: message,
+ actual: actual,
+ expected: expected
+ };
+
+ message = escapeHtml(message) || (result ? "okay" : "failed");
+ message = '<span class="test-message">' + message + "</span>";
+ expected = escapeHtml(QUnit.jsDump.parse(expected));
+ actual = escapeHtml(QUnit.jsDump.parse(actual));
+ var output = message + '<table><tr class="test-expected"><th>Expected: </th><td><pre>' + expected + '</pre></td></tr>';
+ if (actual != expected) {
+ output += '<tr class="test-actual"><th>Result: </th><td><pre>' + actual + '</pre></td></tr>';
+ output += '<tr class="test-diff"><th>Diff: </th><td><pre>' + QUnit.diff(expected, actual) +'</pre></td></tr>';
+ }
+ if (!result) {
+ var source = sourceFromStacktrace();
+ if (source) {
+ details.source = source;
+ output += '<tr class="test-source"><th>Source: </th><td><pre>' + source +'</pre></td></tr>';
+ }
+ }
+ output += "</table>";
+
+ QUnit.log(details);
+
+ config.current.assertions.push({
+ result: !!result,
+ message: output
+ });
+ },
+
+ // Logging callbacks; all receive a single argument with the listed properties
+ // run test/logs.html for any related changes
+ begin: function() {},
+ // done: { failed, passed, total, runtime }
+ done: function() {},
+ // log: { result, actual, expected, message }
+ log: function() {},
+ // testStart: { name }
+ testStart: function() {},
+ // testDone: { name, failed, passed, total }
+ testDone: function() {},
+ // moduleStart: { name }
+ moduleStart: function() {},
+ // moduleDone: { name, failed, passed, total }
+ moduleDone: function() {}
+});
+
+if ( typeof document === "undefined" || document.readyState === "complete" ) {
+ config.autorun = true;
+}
+
+addEvent(window, "load", function() {
+ QUnit.begin({});
+
+ // Initialize the config, saving the execution queue
+ var oldconfig = extend({}, config);
+ QUnit.init();
+ extend(config, oldconfig);
+
+ config.blocking = false;
+
+ var userAgent = id("qunit-userAgent");
+ if ( userAgent ) {
+ userAgent.innerHTML = navigator.userAgent;
+ }
+ var banner = id("qunit-header");
+ if ( banner ) {
+ var paramsIndex = location.href.lastIndexOf(location.search);
+ if ( paramsIndex > -1 ) {
+ var mainPageLocation = location.href.slice(0, paramsIndex);
+ if ( mainPageLocation == location.href ) {
+ banner.innerHTML = '<a href=""> ' + banner.innerHTML + '</a> ';
+ } else {
+ var testName = decodeURIComponent(location.search.slice(1));
+ banner.innerHTML = '<a href="' + mainPageLocation + '">' + banner.innerHTML + '</a> › <a href="">' + testName + '</a>';
+ }
+ }
+ }
+
+ var toolbar = id("qunit-testrunner-toolbar");
+ if ( toolbar ) {
+ var filter = document.createElement("input");
+ filter.type = "checkbox";
+ filter.id = "qunit-filter-pass";
+ addEvent( filter, "click", function() {
+ var ol = document.getElementById("qunit-tests");
+ if ( filter.checked ) {
+ ol.className = ol.className + " hidepass";
+ } else {
+ var tmp = " " + ol.className.replace( /[\n\t\r]/g, " " ) + " ";
+ ol.className = tmp.replace(/ hidepass /, " ");
+ }
+ if ( defined.sessionStorage ) {
+ sessionStorage.setItem("qunit-filter-passed-tests", filter.checked ? "true" : "");
+ }
+ });
+ if ( defined.sessionStorage && sessionStorage.getItem("qunit-filter-passed-tests") ) {
+ filter.checked = true;
+ var ol = document.getElementById("qunit-tests");
+ ol.className = ol.className + " hidepass";
+ }
+ toolbar.appendChild( filter );
+
+ var label = document.createElement("label");
+ label.setAttribute("for", "qunit-filter-pass");
+ label.innerHTML = "Hide passed tests";
+ toolbar.appendChild( label );
+ }
+
+ var main = id('main') || id('qunit-fixture');
+ if ( main ) {
+ config.fixture = main.innerHTML;
+ }
+
+ if (config.autostart) {
+ QUnit.start();
+ }
+});
+
+function done() {
+ config.autorun = true;
+
+ // Log the last module results
+ if ( config.currentModule ) {
+ QUnit.moduleDone( {
+ name: config.currentModule,
+ failed: config.moduleStats.bad,
+ passed: config.moduleStats.all - config.moduleStats.bad,
+ total: config.moduleStats.all
+ } );
+ }
+
+ var banner = id("qunit-banner"),
+ tests = id("qunit-tests"),
+ runtime = +new Date - config.started,
+ passed = config.stats.all - config.stats.bad,
+ html = [
+ 'Tests completed in ',
+ runtime,
+ ' milliseconds.<br/>',
+ '<span class="passed">',
+ passed,
+ '</span> tests of <span class="total">',
+ config.stats.all,
+ '</span> passed, <span class="failed">',
+ config.stats.bad,
+ '</span> failed.'
+ ].join('');
+
+ if ( banner ) {
+ banner.className = (config.stats.bad ? "qunit-fail" : "qunit-pass");
+ }
+
+ if ( tests ) {
+ id( "qunit-testresult" ).innerHTML = html;
+ }
+
+ QUnit.done( {
+ failed: config.stats.bad,
+ passed: passed,
+ total: config.stats.all,
+ runtime: runtime
+ } );
+}
+
+function validTest( name ) {
+ var i = config.filters.length,
+ run = false;
+
+ if ( !i ) {
+ return true;
+ }
+
+ while ( i-- ) {
+ var filter = config.filters[i],
+ not = filter.charAt(0) == '!';
+
+ if ( not ) {
+ filter = filter.slice(1);
+ }
+
+ if ( name.indexOf(filter) !== -1 ) {
+ return !not;
+ }
+
+ if ( not ) {
+ run = true;
+ }
+ }
+
+ return run;
+}
+
+// so far supports only Firefox, Chrome and Opera (buggy)
+// could be extended in the future to use something like https://github.com/csnover/TraceKit
+function sourceFromStacktrace() {
+ try {
+ throw new Error();
+ } catch ( e ) {
+ if (e.stacktrace) {
+ // Opera
+ return e.stacktrace.split("\n")[6];
+ } else if (e.stack) {
+ // Firefox, Chrome
+ return e.stack.split("\n")[4];
+ }
+ }
+}
+
+function escapeHtml(s) {
+ if (!s) {
+ return "";
+ }
+ s = s + "";
+ return s.replace(/[\&"<>\\]/g, function(s) {
+ switch(s) {
+ case "&": return "&";
+ case "\\": return "\\\\";
+ case '"': return '\"';
+ case "<": return "<";
+ case ">": return ">";
+ default: return s;
+ }
+ });
+}
+
+function synchronize( callback ) {
+ config.queue.push( callback );
+
+ if ( config.autorun && !config.blocking ) {
+ process();
+ }
+}
+
+function process() {
+ var start = (new Date()).getTime();
+
+ while ( config.queue.length && !config.blocking ) {
+ if ( config.updateRate <= 0 || (((new Date()).getTime() - start) < config.updateRate) ) {
+ config.queue.shift()();
+ } else {
+ window.setTimeout( process, 13 );
+ break;
+ }
+ }
+ if (!config.blocking && !config.queue.length) {
+ done();
+ }
+}
+
+function saveGlobal() {
+ config.pollution = [];
+
+ if ( config.noglobals ) {
+ for ( var key in window ) {
+ config.pollution.push( key );
+ }
+ }
+}
+
+function checkPollution( name ) {
+ var old = config.pollution;
+ saveGlobal();
+
+ var newGlobals = diff( old, config.pollution );
+ if ( newGlobals.length > 0 ) {
+ ok( false, "Introduced global variable(s): " + newGlobals.join(", ") );
+ config.current.expected++;
+ }
+
+ var deletedGlobals = diff( config.pollution, old );
+ if ( deletedGlobals.length > 0 ) {
+ ok( false, "Deleted global variable(s): " + deletedGlobals.join(", ") );
+ config.current.expected++;
+ }
+}
+
+// returns a new Array with the elements that are in a but not in b
+function diff( a, b ) {
+ var result = a.slice();
+ for ( var i = 0; i < result.length; i++ ) {
+ for ( var j = 0; j < b.length; j++ ) {
+ if ( result[i] === b[j] ) {
+ result.splice(i, 1);
+ i--;
+ break;
+ }
+ }
+ }
+ return result;
+}
+
+function fail(message, exception, callback) {
+ if ( typeof console !== "undefined" && console.error && console.warn ) {
+ console.error(message);
+ console.error(exception);
+ console.warn(callback.toString());
+
+ } else if ( window.opera && opera.postError ) {
+ opera.postError(message, exception, callback.toString);
+ }
+}
+
+function extend(a, b) {
+ for ( var prop in b ) {
+ a[prop] = b[prop];
+ }
+
+ return a;
+}
+
+function addEvent(elem, type, fn) {
+ if ( elem.addEventListener ) {
+ elem.addEventListener( type, fn, false );
+ } else if ( elem.attachEvent ) {
+ elem.attachEvent( "on" + type, fn );
+ } else {
+ fn();
+ }
+}
+
+function id(name) {
+ return !!(typeof document !== "undefined" && document && document.getElementById) &&
+ document.getElementById( name );
+}
+
+// Test for equality any JavaScript type.
+// Discussions and reference: http://philrathe.com/articles/equiv
+// Test suites: http://philrathe.com/tests/equiv
+// Author: Philippe Rathé <prathe@gmail.com>
+QUnit.equiv = function () {
+
+ var innerEquiv; // the real equiv function
+ var callers = []; // stack to decide between skip/abort functions
+ var parents = []; // stack to avoiding loops from circular referencing
+
+ // Call the o related callback with the given arguments.
+ function bindCallbacks(o, callbacks, args) {
+ var prop = QUnit.objectType(o);
+ if (prop) {
+ if (QUnit.objectType(callbacks[prop]) === "function") {
+ return callbacks[prop].apply(callbacks, args);
+ } else {
+ return callbacks[prop]; // or undefined
+ }
+ }
+ }
+
+ var callbacks = function () {
+
+ // for string, boolean, number and null
+ function useStrictEquality(b, a) {
+ if (b instanceof a.constructor || a instanceof b.constructor) {
+ // to catch short annotaion VS 'new' annotation of a declaration
+ // e.g. var i = 1;
+ // var j = new Number(1);
+ return a == b;
+ } else {
+ return a === b;
+ }
+ }
+
+ return {
+ "string": useStrictEquality,
+ "boolean": useStrictEquality,
+ "number": useStrictEquality,
+ "null": useStrictEquality,
+ "undefined": useStrictEquality,
+
+ "nan": function (b) {
+ return isNaN(b);
+ },
+
+ "date": function (b, a) {
+ return QUnit.objectType(b) === "date" && a.valueOf() === b.valueOf();
+ },
+
+ "regexp": function (b, a) {
+ return QUnit.objectType(b) === "regexp" &&
+ a.source === b.source && // the regex itself
+ a.global === b.global && // and its modifers (gmi) ...
+ a.ignoreCase === b.ignoreCase &&
+ a.multiline === b.multiline;
+ },
+
+ // - skip when the property is a method of an instance (OOP)
+ // - abort otherwise,
+ // initial === would have catch identical references anyway
+ "function": function () {
+ var caller = callers[callers.length - 1];
+ return caller !== Object &&
+ typeof caller !== "undefined";
+ },
+
+ "array": function (b, a) {
+ var i, j, loop;
+ var len;
+
+ // b could be an object literal here
+ if ( ! (QUnit.objectType(b) === "array")) {
+ return false;
+ }
+
+ len = a.length;
+ if (len !== b.length) { // safe and faster
+ return false;
+ }
+
+ //track reference to avoid circular references
+ parents.push(a);
+ for (i = 0; i < len; i++) {
+ loop = false;
+ for(j=0;j<parents.length;j++){
+ if(parents[j] === a[i]){
+ loop = true;//dont rewalk array
+ }
+ }
+ if (!loop && ! innerEquiv(a[i], b[i])) {
+ parents.pop();
+ return false;
+ }
+ }
+ parents.pop();
+ return true;
+ },
+
+ "object": function (b, a) {
+ var i, j, loop;
+ var eq = true; // unless we can proove it
+ var aProperties = [], bProperties = []; // collection of strings
+
+ // comparing constructors is more strict than using instanceof
+ if ( a.constructor !== b.constructor) {
+ return false;
+ }
+
+ // stack constructor before traversing properties
+ callers.push(a.constructor);
+ //track reference to avoid circular references
+ parents.push(a);
+
+ for (i in a) { // be strict: don't ensures hasOwnProperty and go deep
+ loop = false;
+ for(j=0;j<parents.length;j++){
+ if(parents[j] === a[i])
+ loop = true; //don't go down the same path twice
+ }
+ aProperties.push(i); // collect a's properties
+
+ if (!loop && ! innerEquiv(a[i], b[i])) {
+ eq = false;
+ break;
+ }
+ }
+
+ callers.pop(); // unstack, we are done
+ parents.pop();
+
+ for (i in b) {
+ bProperties.push(i); // collect b's properties
+ }
+
+ // Ensures identical properties name
+ return eq && innerEquiv(aProperties.sort(), bProperties.sort());
+ }
+ };
+ }();
+
+ innerEquiv = function () { // can take multiple arguments
+ var args = Array.prototype.slice.apply(arguments);
+ if (args.length < 2) {
+ return true; // end transition
+ }
+
+ return (function (a, b) {
+ if (a === b) {
+ return true; // catch the most you can
+ } else if (a === null || b === null || typeof a === "undefined" || typeof b === "undefined" || QUnit.objectType(a) !== QUnit.objectType(b)) {
+ return false; // don't lose time with error prone cases
+ } else {
+ return bindCallbacks(a, callbacks, [b, a]);
+ }
+
+ // apply transition with (1..n) arguments
+ })(args[0], args[1]) && arguments.callee.apply(this, args.splice(1, args.length -1));
+ };
+
+ return innerEquiv;
+
+}();
+
+/**
+ * jsDump
+ * Copyright (c) 2008 Ariel Flesler - aflesler(at)gmail(dot)com | http://flesler.blogspot.com
+ * Licensed under BSD (http://www.opensource.org/licenses/bsd-license.php)
+ * Date: 5/15/2008
+ * @projectDescription Advanced and extensible data dumping for Javascript.
+ * @version 1.0.0
+ * @author Ariel Flesler
+ * @link {http://flesler.blogspot.com/2008/05/jsdump-pretty-dump-of-any-javascript.html}
+ */
+QUnit.jsDump = (function() {
+ function quote( str ) {
+ return '"' + str.toString().replace(/"/g, '\\"') + '"';
+ };
+ function literal( o ) {
+ return o + '';
+ };
+ function join( pre, arr, post ) {
+ var s = jsDump.separator(),
+ base = jsDump.indent(),
+ inner = jsDump.indent(1);
+ if ( arr.join )
+ arr = arr.join( ',' + s + inner );
+ if ( !arr )
+ return pre + post;
+ return [ pre, inner + arr, base + post ].join(s);
+ };
+ function array( arr ) {
+ var i = arr.length, ret = Array(i);
+ this.up();
+ while ( i-- )
+ ret[i] = this.parse( arr[i] );
+ this.down();
+ return join( '[', ret, ']' );
+ };
+
+ var reName = /^function (\w+)/;
+
+ var jsDump = {
+ parse:function( obj, type ) { //type is used mostly internally, you can fix a (custom)type in advance
+ var parser = this.parsers[ type || this.typeOf(obj) ];
+ type = typeof parser;
+
+ return type == 'function' ? parser.call( this, obj ) :
+ type == 'string' ? parser :
+ this.parsers.error;
+ },
+ typeOf:function( obj ) {
+ var type;
+ if ( obj === null ) {
+ type = "null";
+ } else if (typeof obj === "undefined") {
+ type = "undefined";
+ } else if (QUnit.is("RegExp", obj)) {
+ type = "regexp";
+ } else if (QUnit.is("Date", obj)) {
+ type = "date";
+ } else if (QUnit.is("Function", obj)) {
+ type = "function";
+ } else if (typeof obj.setInterval !== undefined && typeof obj.document !== "undefined" && typeof obj.nodeType === "undefined") {
+ type = "window";
+ } else if (obj.nodeType === 9) {
+ type = "document";
+ } else if (obj.nodeType) {
+ type = "node";
+ } else if (typeof obj === "object" && typeof obj.length === "number" && obj.length >= 0) {
+ type = "array";
+ } else {
+ type = typeof obj;
+ }
+ return type;
+ },
+ separator:function() {
+ return this.multiline ? this.HTML ? '<br />' : '\n' : this.HTML ? ' ' : ' ';
+ },
+ indent:function( extra ) {// extra can be a number, shortcut for increasing-calling-decreasing
+ if ( !this.multiline )
+ return '';
+ var chr = this.indentChar;
+ if ( this.HTML )
+ chr = chr.replace(/\t/g,' ').replace(/ /g,' ');
+ return Array( this._depth_ + (extra||0) ).join(chr);
+ },
+ up:function( a ) {
+ this._depth_ += a || 1;
+ },
+ down:function( a ) {
+ this._depth_ -= a || 1;
+ },
+ setParser:function( name, parser ) {
+ this.parsers[name] = parser;
+ },
+ // The next 3 are exposed so you can use them
+ quote:quote,
+ literal:literal,
+ join:join,
+ //
+ _depth_: 1,
+ // This is the list of parsers, to modify them, use jsDump.setParser
+ parsers:{
+ window: '[Window]',
+ document: '[Document]',
+ error:'[ERROR]', //when no parser is found, shouldn't happen
+ unknown: '[Unknown]',
+ 'null':'null',
+ 'undefined':'undefined',
+ 'function':function( fn ) {
+ var ret = 'function',
+ name = 'name' in fn ? fn.name : (reName.exec(fn)||[])[1];//functions never have name in IE
+ if ( name )
+ ret += ' ' + name;
+ ret += '(';
+
+ ret = [ ret, QUnit.jsDump.parse( fn, 'functionArgs' ), '){'].join('');
+ return join( ret, QUnit.jsDump.parse(fn,'functionCode'), '}' );
+ },
+ array: array,
+ nodelist: array,
+ arguments: array,
+ object:function( map ) {
+ var ret = [ ];
+ QUnit.jsDump.up();
+ for ( var key in map )
+ ret.push( QUnit.jsDump.parse(key,'key') + ': ' + QUnit.jsDump.parse(map[key]) );
+ QUnit.jsDump.down();
+ return join( '{', ret, '}' );
+ },
+ node:function( node ) {
+ var open = QUnit.jsDump.HTML ? '<' : '<',
+ close = QUnit.jsDump.HTML ? '>' : '>';
+
+ var tag = node.nodeName.toLowerCase(),
+ ret = open + tag;
+
+ for ( var a in QUnit.jsDump.DOMAttrs ) {
+ var val = node[QUnit.jsDump.DOMAttrs[a]];
+ if ( val )
+ ret += ' ' + a + '=' + QUnit.jsDump.parse( val, 'attribute' );
+ }
+ return ret + close + open + '/' + tag + close;
+ },
+ functionArgs:function( fn ) {//function calls it internally, it's the arguments part of the function
+ var l = fn.length;
+ if ( !l ) return '';
+
+ var args = Array(l);
+ while ( l-- )
+ args[l] = String.fromCharCode(97+l);//97 is 'a'
+ return ' ' + args.join(', ') + ' ';
+ },
+ key:quote, //object calls it internally, the key part of an item in a map
+ functionCode:'[code]', //function calls it internally, it's the content of the function
+ attribute:quote, //node calls it internally, it's an html attribute value
+ string:quote,
+ date:quote,
+ regexp:literal, //regex
+ number:literal,
+ 'boolean':literal
+ },
+ DOMAttrs:{//attributes to dump from nodes, name=>realName
+ id:'id',
+ name:'name',
+ 'class':'className'
+ },
+ HTML:false,//if true, entities are escaped ( <, >, \t, space and \n )
+ indentChar:' ',//indentation unit
+ multiline:true //if true, items in a collection, are separated by a \n, else just a space.
+ };
+
+ return jsDump;
+})();
+
+// from Sizzle.js
+function getText( elems ) {
+ var ret = "", elem;
+
+ for ( var i = 0; elems[i]; i++ ) {
+ elem = elems[i];
+
+ // Get the text from text nodes and CDATA nodes
+ if ( elem.nodeType === 3 || elem.nodeType === 4 ) {
+ ret += elem.nodeValue;
+
+ // Traverse everything else, except comment nodes
+ } else if ( elem.nodeType !== 8 ) {
+ ret += getText( elem.childNodes );
+ }
+ }
+
+ return ret;
+};
+
+/*
+ * Javascript Diff Algorithm
+ * By John Resig (http://ejohn.org/)
+ * Modified by Chu Alan "sprite"
+ *
+ * Released under the MIT license.
+ *
+ * More Info:
+ * http://ejohn.org/projects/javascript-diff-algorithm/
+ *
+ * Usage: QUnit.diff(expected, actual)
+ *
+ * QUnit.diff("the quick brown fox jumped over", "the quick fox jumps over") == "the quick <del>brown </del> fox <del>jumped </del><ins>jumps </ins> over"
+ */
+QUnit.diff = (function() {
+ function diff(o, n){
+ var ns = new Object();
+ var os = new Object();
+
+ for (var i = 0; i < n.length; i++) {
+ if (ns[n[i]] == null)
+ ns[n[i]] = {
+ rows: new Array(),
+ o: null
+ };
+ ns[n[i]].rows.push(i);
+ }
+
+ for (var i = 0; i < o.length; i++) {
+ if (os[o[i]] == null)
+ os[o[i]] = {
+ rows: new Array(),
+ n: null
+ };
+ os[o[i]].rows.push(i);
+ }
+
+ for (var i in ns) {
+ if (ns[i].rows.length == 1 && typeof(os[i]) != "undefined" && os[i].rows.length == 1) {
+ n[ns[i].rows[0]] = {
+ text: n[ns[i].rows[0]],
+ row: os[i].rows[0]
+ };
+ o[os[i].rows[0]] = {
+ text: o[os[i].rows[0]],
+ row: ns[i].rows[0]
+ };
+ }
+ }
+
+ for (var i = 0; i < n.length - 1; i++) {
+ if (n[i].text != null && n[i + 1].text == null && n[i].row + 1 < o.length && o[n[i].row + 1].text == null &&
+ n[i + 1] == o[n[i].row + 1]) {
+ n[i + 1] = {
+ text: n[i + 1],
+ row: n[i].row + 1
+ };
+ o[n[i].row + 1] = {
+ text: o[n[i].row + 1],
+ row: i + 1
+ };
+ }
+ }
+
+ for (var i = n.length - 1; i > 0; i--) {
+ if (n[i].text != null && n[i - 1].text == null && n[i].row > 0 && o[n[i].row - 1].text == null &&
+ n[i - 1] == o[n[i].row - 1]) {
+ n[i - 1] = {
+ text: n[i - 1],
+ row: n[i].row - 1
+ };
+ o[n[i].row - 1] = {
+ text: o[n[i].row - 1],
+ row: i - 1
+ };
+ }
+ }
+
+ return {
+ o: o,
+ n: n
+ };
+ }
+
+ return function(o, n){
+ o = o.replace(/\s+$/, '');
+ n = n.replace(/\s+$/, '');
+ var out = diff(o == "" ? [] : o.split(/\s+/), n == "" ? [] : n.split(/\s+/));
+
+ var str = "";
+
+ var oSpace = o.match(/\s+/g);
+ if (oSpace == null) {
+ oSpace = [" "];
+ }
+ else {
+ oSpace.push(" ");
+ }
+ var nSpace = n.match(/\s+/g);
+ if (nSpace == null) {
+ nSpace = [" "];
+ }
+ else {
+ nSpace.push(" ");
+ }
+
+ if (out.n.length == 0) {
+ for (var i = 0; i < out.o.length; i++) {
+ str += '<del>' + out.o[i] + oSpace[i] + "</del>";
+ }
+ }
+ else {
+ if (out.n[0].text == null) {
+ for (n = 0; n < out.o.length && out.o[n].text == null; n++) {
+ str += '<del>' + out.o[n] + oSpace[n] + "</del>";
+ }
+ }
+
+ for (var i = 0; i < out.n.length; i++) {
+ if (out.n[i].text == null) {
+ str += '<ins>' + out.n[i] + nSpace[i] + "</ins>";
+ }
+ else {
+ var pre = "";
+
+ for (n = out.n[i].row + 1; n < out.o.length && out.o[n].text == null; n++) {
+ pre += '<del>' + out.o[n] + oSpace[n] + "</del>";
+ }
+ str += " " + out.n[i].text + nSpace[i] + pre;
+ }
+ }
+ }
+
+ return str;
+ };
+})();
+
+})(this);(function() {
+
+/**************************************************
+ Node
+ *************************************************/
+
+var moment;
+if (typeof window === 'undefined') {
+ moment = require('../../moment');
+ module = QUnit.module;
+} else {
+ moment = window.moment;
+}
+
+/**************************************************
+ Tests
+ *************************************************/
+
+
+module("create");
+
+
+test("array", 8, function() {
+ ok(moment([2010]).native() instanceof Date, "[2010]");
+ ok(moment([2010, 1]).native() instanceof Date, "[2010, 1]");
+ ok(moment([2010, 1, 12]).native() instanceof Date, "[2010, 1, 12]");
+ ok(moment([2010, 1, 12, 1]).native() instanceof Date, "[2010, 1, 12, 1]");
+ ok(moment([2010, 1, 12, 1, 1]).native() instanceof Date, "[2010, 1, 12, 1, 1]");
+ ok(moment([2010, 1, 12, 1, 1, 1]).native() instanceof Date, "[2010, 1, 12, 1, 1, 1]");
+ ok(moment([2010, 1, 12, 1, 1, 1, 1]).native() instanceof Date, "[2010, 1, 12, 1, 1, 1, 1]");
+ deepEqual(moment(new Date(2010, 1, 14, 15, 25, 50, 125)), moment([2010, 1, 14, 15, 25, 50, 125]), "constructing with array === constructing with new Date()");
+});
+
+
+test("number", 2, function() {
+ ok(moment(1000).native() instanceof Date, "1000");
+ ok((moment(1000).valueOf() === 1000), "testing valueOf");
+});
+
+
+test("date", 1, function() {
+ ok(moment(new Date()).native() instanceof Date, "new Date()");
+});
+
+test("moment", 2, function() {
+ ok(moment(moment()).native() instanceof Date, "moment(moment())");
+ ok(moment(moment(moment())).native() instanceof Date, "moment(moment(moment()))");
+});
+
+test("undefined", 1, function() {
+ ok(moment().native() instanceof Date, "undefined");
+});
+
+
+test("string without format", 2, function() {
+ ok(moment("Aug 9, 1995").native() instanceof Date, "Aug 9, 1995");
+ ok(moment("Mon, 25 Dec 1995 13:30:00 GMT").native() instanceof Date, "Mon, 25 Dec 1995 13:30:00 GMT");
+});
+
+
+test("string with format", 13, function() {
+ var a = [
+ ['MM-DD-YYYY', '12-02-1999'],
+ ['DD-MM-YYYY', '12-02-1999'],
+ ['DD/MM/YYYY', '12/02/1999'],
+ ['DD_MM_YYYY', '12_02_1999'],
+ ['DD:MM:YYYY', '12:02:1999'],
+ ['D-M-YY', '2-2-99'],
+ ['YY', '99'],
+ ['DDD-YYYY', '300-1999'],
+ ['DD-MM-YYYY h:m:s', '12-02-1999 2:45:10'],
+ ['DD-MM-YYYY h:m:s a', '12-02-1999 2:45:10 am'],
+ ['DD-MM-YYYY h:m:s a', '12-02-1999 2:45:10 pm'],
+ ['YYYY-MM-DDTHH:mm:ss', '2011-11-11T11:11:11'],
+ ['MM-DD-YYYY \\M', '12-02-1999 M']
+ ],
+ i;
+ for (i = 0; i < a.length; i++) {
+ 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(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(moment('71', 'YY').format('YYYY'), '1971', '71 > 1971');
+ equal(moment('69', 'YY').format('YYYY'), '2069', '69 > 2069');
+});
+
+
+module("add and subtract");
+
+
+test("add and subtract short", 12, function() {
+ var a = moment();
+ a.year(2011);
+ a.month(9);
+ a.date(12);
+ a.hours(6);
+ a.minutes(7);
+ a.seconds(8);
+
+ equal(a.add({ms:1000}).seconds(), 9, 'Add milliseconds');
+ equal(a.add({s:1}).seconds(), 10, 'Add seconds');
+ equal(a.add({m:1}).minutes(), 8, 'Add minutes');
+ equal(a.add({h:1}).hours(), 7, 'Add hours');
+ equal(a.add({d:1}).date(), 13, 'Add date');
+ equal(a.add({w:1}).date(), 20, 'Add week');
+ equal(a.add({M:1}).month(), 10, 'Add month');
+ equal(a.add({y:1}).year(), 2012, 'Add year');
+
+ 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');
+ equal(c.month(), 0, 'subtract month, feb 28th to jan 28th');
+ equal(c.date(), 28, 'subtract month, feb 28th to jan 28th');
+});
+
+test("add and subtract long", 8, function() {
+ var a = moment();
+ a.year(2011);
+ a.month(9);
+ a.date(12);
+ a.hours(6);
+ a.minutes(7);
+ a.seconds(8);
+
+ equal(a.add({milliseconds:1000}).seconds(), 9, 'Add milliseconds');
+ equal(a.add({seconds:1}).seconds(), 10, 'Add seconds');
+ equal(a.add({minutes:1}).minutes(), 8, 'Add minutes');
+ equal(a.add({hours:1}).hours(), 7, 'Add hours');
+ equal(a.add({days:1}).date(), 13, 'Add date');
+ equal(a.add({weeks:1}).date(), 20, 'Add week');
+ equal(a.add({months:1}).month(), 10, 'Add month');
+ equal(a.add({years:1}).year(), 2012, 'Add year');
+});
+
+test("add and subtract string short", 8, function() {
+ var a = moment();
+ a.year(2011);
+ a.month(9);
+ a.date(12);
+ a.hours(6);
+ a.minutes(7);
+ a.seconds(8);
+
+ equal(a.add('milliseconds', 1000).seconds(), 9, 'Add milliseconds');
+ equal(a.add('seconds', 1).seconds(), 10, 'Add seconds');
+ equal(a.add('minutes', 1).minutes(), 8, 'Add minutes');
+ equal(a.add('hours', 1).hours(), 7, 'Add hours');
+ equal(a.add('days', 1).date(), 13, 'Add date');
+ equal(a.add('weeks', 1).date(), 20, 'Add week');
+ equal(a.add('months', 1).month(), 10, 'Add month');
+ equal(a.add('years', 1).year(), 2012, 'Add year');
+});
+
+test("add and subtract string short", 8, function() {
+ var a = moment();
+ a.year(2011);
+ a.month(9);
+ a.date(12);
+ a.hours(6);
+ a.minutes(7);
+ a.seconds(8);
+
+ equal(a.add('ms', 1000).seconds(), 9, 'Add milliseconds');
+ equal(a.add('s', 1).seconds(), 10, 'Add seconds');
+ equal(a.add('m', 1).minutes(), 8, 'Add minutes');
+ equal(a.add('h', 1).hours(), 7, 'Add hours');
+ equal(a.add('d', 1).date(), 13, 'Add date');
+ equal(a.add('w', 1).date(), 20, 'Add week');
+ equal(a.add('M', 1).month(), 10, 'Add month');
+ equal(a.add('y', 1).year(), 2012, 'Add year');
+});
+
+module("diff");
+
+
+test("diff", 5, function() {
+ 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(moment(oneHourDate).diff(nowDate), 60 * 60 * 1000, "1 hour from now = 360000");
+});
+
+test("diff key after", 9, function() {
+ equal(moment([2010]).diff([2011], 'years'), -1, "year diff");
+ equal(moment([2010]).diff([2011, 6], 'years', true), -1.5, "year diff, float");
+ equal(moment([2010]).diff([2010, 2], 'months'), -2, "month diff");
+ equal(moment([2010]).diff([2010, 0, 7], 'weeks'), -1, "week diff");
+ equal(moment([2010]).diff([2010, 0, 21], 'weeks'), -3, "week diff");
+ equal(moment([2010]).diff([2010, 0, 4], 'days'), -3, "day diff");
+ equal(moment([2010]).diff([2010, 0, 1, 4], 'hours'), -4, "hour diff");
+ equal(moment([2010]).diff([2010, 0, 1, 0, 5], 'minutes'), -5, "minute diff");
+ equal(moment([2010]).diff([2010, 0, 1, 0, 0, 6], 'seconds'), -6, "second diff");
+});
+
+test("diff key before", 9, function() {
+ equal(moment([2011]).diff([2010], 'years'), 1, "year diff");
+ equal(moment([2011, 6]).diff([2010], 'years', true), 1.5, "year diff, float");
+ equal(moment([2010, 2]).diff([2010], 'months'), 2, "month diff");
+ equal(moment([2010, 0, 4]).diff([2010], 'days'), 3, "day diff");
+ equal(moment([2010, 0, 7]).diff([2010], 'weeks'), 1, "week diff");
+ equal(moment([2010, 0, 21]).diff([2010], 'weeks'), 3, "week diff");
+ equal(moment([2010, 0, 1, 4]).diff([2010], 'hours'), 4, "hour diff");
+ equal(moment([2010, 0, 1, 0, 5]).diff([2010], 'minutes'), 5, "minute diff");
+ equal(moment([2010, 0, 1, 0, 0, 6]).diff([2010], 'seconds'), 6, "second diff");
+});
+
+test("diff overflow", 4, function() {
+ equal(moment([2011]).diff([2010], 'months'), 12, "month diff");
+ equal(moment([2010, 0, 2]).diff([2010], 'hours'), 24, "hour diff");
+ equal(moment([2010, 0, 1, 2]).diff([2010], 'minutes'), 120, "minute diff");
+ equal(moment([2010, 0, 1, 0, 4]).diff([2010], 'seconds'), 240, "second diff");
+});
+
+
+module("leap year");
+
+
+test("leap year", 4, function() {
+ 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');
+});
+
+
+module("getters and setters");
+
+
+test("getters", 7, function() {
+ var a = moment([2011, 9, 12, 6, 7, 8]);
+ equal(a.year(), 2011, 'year');
+ equal(a.month(), 9, 'month');
+ equal(a.date(), 12, 'date');
+ equal(a.day(), 3, 'day');
+ equal(a.hours(), 6, 'hour');
+ equal(a.minutes(), 7, 'minute');
+ equal(a.seconds(), 8, 'second');
+});
+
+test("setters", 7, function() {
+ var a = moment();
+ a.year(2011);
+ a.month(9);
+ a.date(12);
+ a.hours(6);
+ a.minutes(7);
+ a.seconds(8);
+ equal(a.year(), 2011, 'year');
+ equal(a.month(), 9, 'month');
+ equal(a.date(), 12, 'date');
+ equal(a.day(), 3, 'day');
+ equal(a.hours(), 6, 'hour');
+ equal(a.minutes(), 7, 'minute');
+ equal(a.seconds(), 8, 'second');
+});
+
+test("setters - falsey values", 1, function() {
+ var a = moment();
+ // ensure minutes wasn't coincidentally 0 already
+ a.minutes(1);
+ a.minutes(0);
+ equal(a.minutes(), 0, 'falsey value');
+});
+
+test("chaining setters", 7, function() {
+ var a = moment();
+ a.year(2011)
+ .month(9)
+ .date(12)
+ .hours(6)
+ .minutes(7)
+ .seconds(8);
+ equal(a.year(), 2011, 'year');
+ equal(a.month(), 9, 'month');
+ equal(a.date(), 12, 'date');
+ equal(a.day(), 3, 'day');
+ equal(a.hours(), 6, 'hour');
+ equal(a.minutes(), 7, 'minute');
+ equal(a.seconds(), 8, 'second');
+});
+
+})();
+
+(function() { var moment; if (typeof window === 'undefined') { moment = require('../../moment'); module = QUnit.module; } else { moment = window.moment; }
+/**************************************************
+ English
+ *************************************************/
+
+module("lang:en");
+
+test("format", 18, function() {
+ 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'],
+ ['M Mo MM MMMM MMM', '2 2nd 02 February Feb'],
+ ['YYYY YY', '2010 10'],
+ ['D Do DD', '14 14th 14'],
+ ['d do dddd ddd', '0 0th Sunday Sun'],
+ ['DDD DDDo DDDD', '45 45th 045'],
+ ['w wo ww', '8 8th 08'],
+ ['h hh', '3 03'],
+ ['H HH', '15 15'],
+ ['m mm', '25 25'],
+ ['s ss', '50 50'],
+ ['a A', 'pm PM'],
+ ['t\\he DDDo \\d\\ay of t\\he ye\\ar', 'the 45th day of the year'],
+ ['L', '02/14/2010'],
+ ['LL', 'February 14 2010'],
+ ['LLL', 'February 14 2010 3:25 PM'],
+ ['LLLL', 'Sunday, February 14 2010 3:25 PM']
+ ],
+ 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]);
+ }
+});
+
+test("format YY", 1, function() {
+ var b = moment(new Date(2009, 1, 14, 15, 25, 50, 125));
+ equal(b.format('YY'), '09', 'YY ---> 09');
+});
+
+test("format timezone", 2, function() {
+ var b = moment(new Date(2010, 1, 14, 15, 25, 50, 125));
+ ok(b.format('z').match(/^[A-Z]{3,4}$/), 'z ---> Something like "PST"');
+ ok(b.format('zz').match(/^[A-Z]{3,4}$/), 'zz ---> Something like "PST"');
+});
+
+test("format ordinal", 31, function() {
+ 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() {
+ 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(moment([2011, i, 0]).format('MMMM MMM'), expected[i], expected[i]);
+ }
+});
+
+test("format week", 7, function() {
+ 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(moment([2011, 0, 2 + i]).format('dddd ddd'), expected[i], expected[i]);
+ }
+});
+
+test("from", 30, function() {
+ moment.lang('en');
+ var start = moment([2007, 1, 28]);
+ equal(start.from(moment([2007, 1, 28]).add({s:44}), true), "a few seconds", "44 seconds = a few 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:74}), 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() {
+ moment.lang('en');
+ equal(moment(30000).from(0), "in a few seconds", "prefix");
+ equal(moment(0).from(30000), "a few seconds ago", "suffix");
+});
+
+
+test("now from now", 1, function() {
+ moment.lang('en');
+ equal(moment().fromNow(), "a few seconds ago", "now from now should display as in the past");
+});
+
+
+test("fromNow", 2, function() {
+ moment.lang('en');
+ equal(moment().add({s:30}).fromNow(), "in a few seconds", "in a few seconds");
+ equal(moment().add({d:5}).fromNow(), "in 5 days", "in 5 days");
+});
+
+
+/**************************************************
+ French
+ *************************************************/
+
+module("lang:fr");
+
+test("format", 18, function() {
+ moment.lang('fr');
+ var a = [
+ ['dddd, MMMM Do YYYY, h:mm:ss a', 'dimanche, février 14ème 2010, 3:25:50 pm'],
+ ['ddd, hA', 'dim., 3PM'],
+ ['M Mo MM MMMM MMM', '2 2ème 02 février févr.'],
+ ['YYYY YY', '2010 10'],
+ ['D Do DD', '14 14ème 14'],
+ ['d do dddd ddd', '0 0ème dimanche dim.'],
+ ['DDD DDDo DDDD', '45 45ème 045'],
+ ['w wo ww', '8 8ème 08'],
+ ['h hh', '3 03'],
+ ['H HH', '15 15'],
+ ['m mm', '25 25'],
+ ['s ss', '50 50'],
+ ['a A', 'pm PM'],
+ ['t\\he DDDo \\d\\ay of t\\he ye\\ar', 'the 45ème day of the year'],
+ ['L', '14/02/2010'],
+ ['LL', '14 février 2010'],
+ ['LLL', '14 février 2010 15:25'],
+ ['LLLL', 'dimanche 14 février 2010 15:25']
+ ],
+ 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]);
+ }
+});
+
+test("format YY", 1, function() {
+ var b = moment(new Date(2009, 1, 14, 15, 25, 50, 125));
+ equal(b.format('YY'), '09', 'YY ---> 09');
+});
+
+test("format timezone", 2, function() {
+ var b = moment(new Date(2010, 1, 14, 15, 25, 50, 125));
+ ok(b.format('z').match(/^[A-Z]{3,4}$/), 'z ---> Something like "PST"');
+ ok(b.format('zz').match(/^[A-Z]{3,4}$/), 'zz ---> Something like "PST"');
+});
+
+test("format ordinal", 31, function() {
+ moment.lang('fr');
+ equal(moment([2011, 0, 1]).format('DDDo'), '1er', '1er');
+ 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'), '10ème', '10ème');
+
+ equal(moment([2011, 0, 11]).format('DDDo'), '11ème', '11ème');
+ equal(moment([2011, 0, 12]).format('DDDo'), '12ème', '12ème');
+ equal(moment([2011, 0, 13]).format('DDDo'), '13ème', '13ème');
+ equal(moment([2011, 0, 14]).format('DDDo'), '14ème', '14ème');
+ equal(moment([2011, 0, 15]).format('DDDo'), '15ème', '15ème');
+ equal(moment([2011, 0, 16]).format('DDDo'), '16ème', '16ème');
+ equal(moment([2011, 0, 17]).format('DDDo'), '17ème', '17ème');
+ equal(moment([2011, 0, 18]).format('DDDo'), '18ème', '18ème');
+ equal(moment([2011, 0, 19]).format('DDDo'), '19ème', '19ème');
+ 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() {
+ moment.lang('fr');
+ var expected = 'janvier janv._février févr._mars mars_avril avr._mai mai_juin juin_juillet juil._août août_septembre sept._octobre oct._novembre nov._décembre déc.'.split("_");
+ var i;
+ for (i = 0; i < expected.length; i++) {
+ equal(moment([2011, i, 0]).format('MMMM MMM'), expected[i], expected[i]);
+ }
+});
+
+test("format week", 7, function() {
+ 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(moment([2011, 0, 2 + i]).format('dddd ddd'), expected[i], expected[i]);
+ }
+});
+
+test("from", 30, function() {
+ moment.lang('fr');
+ var start = moment([2007, 1, 28]);
+ equal(start.from(moment([2007, 1, 28]).add({s:44}), true), "quelques secondes", "44 seconds = a few 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:74}), 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() {
+ moment.lang('fr');
+ equal(moment(30000).from(0), "dans quelques secondes", "prefix");
+ equal(moment(0).from(30000), "il y a quelques secondes", "suffix");
+});
+
+test("fromNow", 2, function() {
+ moment.lang('fr');
+ equal(moment().add({s:30}).fromNow(), "dans quelques secondes", "in a few seconds");
+ equal(moment().add({d:5}).fromNow(), "dans 5 jours", "in 5 days");
+});
+
+/**************************************************
+ Italian
+ *************************************************/
+
+module("lang:it");
+
+test("format", 18, function() {
+ 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'],
+ ['M Mo MM MMMM MMM', '2 2º 02 Febbraio Feb'],
+ ['YYYY YY', '2010 10'],
+ ['D Do DD', '14 14º 14'],
+ ['d do dddd ddd', '0 0º Domenica Dom'],
+ ['DDD DDDo DDDD', '45 45º 045'],
+ ['w wo ww', '8 8º 08'],
+ ['h hh', '3 03'],
+ ['H HH', '15 15'],
+ ['m mm', '25 25'],
+ ['s ss', '50 50'],
+ ['a A', 'pm PM'],
+ ['t\\he DDDo \\d\\ay of t\\he ye\\ar', 'the 45º day of the year'],
+ ['L', '14/02/2010'],
+ ['LL', '14 Febbraio 2010'],
+ ['LLL', '14 Febbraio 2010 15:25'],
+ ['LLLL', 'Domenica, 14 Febbraio 2010 15:25']
+ ],
+ 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]);
+ }
+});
+
+test("format YY", 1, function() {
+ var b = moment(new Date(2009, 1, 14, 15, 25, 50, 125));
+ equal(b.format('YY'), '09', 'YY ---> 09');
+});
+
+test("format timezone", 2, function() {
+ var b = moment(new Date(2010, 1, 14, 15, 25, 50, 125));
+ ok(b.format('z').match(/^[A-Z]{3,4}$/), 'z ---> Something like "PST"');
+ ok(b.format('zz').match(/^[A-Z]{3,4}$/), 'zz ---> Something like "PST"');
+});
+
+test("format ordinal", 31, function() {
+ 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() {
+ 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(moment([2011, i, 0]).format('MMMM MMM'), expected[i], expected[i]);
+ }
+});
+
+test("format week", 7, function() {
+ 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(moment([2011, 0, 2 + i]).format('dddd ddd'), expected[i], expected[i]);
+ }
+});
+
+test("from", 30, function() {
+ 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:74}), 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() {
+ moment.lang('it');
+ equal(moment(30000).from(0), "in secondi", "prefix");
+ equal(moment(0).from(30000), "secondi fa", "suffix");
+});
+
+test("fromNow", 2, function() {
+ 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");
+});
+
+/**************************************************
+ Portuguese
+ *************************************************/
+
+module("lang:pt");
+
+test("format", 18, function() {
+ 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'],
+ ['M Mo MM MMMM MMM', '2 2º 02 Fevereiro Feb'],
+ ['YYYY YY', '2010 10'],
+ ['D Do DD', '14 14º 14'],
+ ['d do dddd ddd', '0 0º Domingo Dom'],
+ ['DDD DDDo DDDD', '45 45º 045'],
+ ['w wo ww', '8 8º 08'],
+ ['h hh', '3 03'],
+ ['H HH', '15 15'],
+ ['m mm', '25 25'],
+ ['s ss', '50 50'],
+ ['a A', 'pm PM'],
+ ['t\\he DDDo \\d\\ay of t\\he ye\\ar', 'the 45º day of the year'],
+ ['L', '14/02/2010'],
+ ['LL', '14 de Fevereiro de 2010'],
+ ['LLL', '14 de Fevereiro de 2010 15:25'],
+ ['LLLL', 'Domingo, 14 de Fevereiro de 2010 15:25']
+ ],
+ 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]);
+ }
+});
+
+test("format YY", 1, function() {
+ var b = moment(new Date(2009, 1, 14, 15, 25, 50, 125));
+ equal(b.format('YY'), '09', 'YY ---> 09');
+});
+
+test("format timezone", 2, function() {
+ var b = moment(new Date(2010, 1, 14, 15, 25, 50, 125));
+ ok(b.format('z').match(/^[A-Z]{3,4}$/), 'z ---> Something like "PST"');
+ ok(b.format('zz').match(/^[A-Z]{3,4}$/), 'zz ---> Something like "PST"');
+});
+
+test("format ordinal", 31, function() {
+ 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() {
+ 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(moment([2011, i, 0]).format('MMMM MMM'), expected[i], expected[i]);
+ }
+});
+
+test("format week", 7, function() {
+ 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(moment([2011, 0, 2 + i]).format('dddd ddd'), expected[i], expected[i]);
+ }
+});
+
+test("from", 30, function() {
+ 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:74}), 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() {
+ moment.lang('pt');
+ equal(moment(30000).from(0), "em segundos", "prefix");
+ equal(moment(0).from(30000), "segundos atrás", "suffix");
+});
+
+test("fromNow", 2, function() {
+ 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");
+});
+
+/**************************************************
+ Spanish
+ *************************************************/
+
+module("lang:es");
+
+test("format", 18, function() {
+ moment.lang('es');
+ var a = [
+ ['dddd, MMMM Do YYYY, h:mm:ss a', 'Domingo, Febrero 14º 2010, 3:25:50 pm'],
+ ['ddd, hA', 'Dom., 3PM'],
+ ['M Mo MM MMMM MMM', '2 2º 02 Febrero Feb.'],
+ ['YYYY YY', '2010 10'],
+ ['D Do DD', '14 14º 14'],
+ ['d do dddd ddd', '0 0º Domingo Dom.'],
+ ['DDD DDDo DDDD', '45 45º 045'],
+ ['w wo ww', '8 8º 08'],
+ ['h hh', '3 03'],
+ ['H HH', '15 15'],
+ ['m mm', '25 25'],
+ ['s ss', '50 50'],
+ ['a A', 'pm PM'],
+ ['t\\he DDDo \\d\\ay of t\\he ye\\ar', 'the 45º day of the year'],
+ ['L', '14/02/2010'],
+ ['LL', '14 Febrero 2010'],
+ ['LLL', '14 Febrero 2010 15:25'],
+ ['LLLL', 'Domingo 14 Febrero 2010 15:25']
+ ],
+ 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]);
+ }
+});
+
+test("format YY", 1, function() {
+ var b = moment(new Date(2009, 1, 14, 15, 25, 50, 125));
+ equal(b.format('YY'), '09', 'YY ---> 09');
+});
+
+test("format timezone", 2, function() {
+ var b = moment(new Date(2010, 1, 14, 15, 25, 50, 125));
+ ok(b.format('z').match(/^[A-Z]{3,4}$/), 'z ---> Something like "PST"');
+ ok(b.format('zz').match(/^[A-Z]{3,4}$/), 'zz ---> Something like "PST"');
+});
+
+test("format ordinal", 31, function() {
+ moment.lang('es');
+ 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() {
+ moment.lang('es');
+ var expected = 'Enero Ene._Febrero Feb._Marzo Mar._Abril Abr._Mayo May._Junio Jun._Julio Jul._Agosto Ago._Septiembre Sep._Octubre Oct._Noviembre Nov._Diciembre Dic.'.split("_");
+ var i;
+ for (i = 0; i < expected.length; i++) {
+ equal(moment([2011, i, 0]).format('MMMM MMM'), expected[i], expected[i]);
+ }
+});
+
+test("format week", 7, function() {
+ moment.lang('es');
+ var expected = 'Domingo Dom._Lunes Lun._Martes Mar._Miércoles Mié._Jueves Jue._Viernes Vie._Sábado Sáb.'.split("_");
+ var i;
+ for (i = 0; i < expected.length; i++) {
+ equal(moment([2011, 0, 2 + i]).format('dddd ddd'), expected[i], expected[i]);
+ }
+});
+
+test("from", 30, function() {
+ moment.lang('es');
+ var start = moment([2007, 1, 28]);
+ equal(start.from(moment([2007, 1, 28]).add({s:44}), true), "unos segundos", "44 seconds = a few 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 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), "una hora", "45 minutes = an hour");
+ equal(start.from(moment([2007, 1, 28]).add({m:89}), true), "una 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), "un día", "22 hours = a day");
+ equal(start.from(moment([2007, 1, 28]).add({h:35}), true), "un día", "35 hours = a day");
+ equal(start.from(moment([2007, 1, 28]).add({h:36}), true), "2 días", "36 hours = 2 days");
+ equal(start.from(moment([2007, 1, 28]).add({d:1}), true), "un día", "1 day = a day");
+ equal(start.from(moment([2007, 1, 28]).add({d:5}), true), "5 días", "5 days = 5 days");
+ equal(start.from(moment([2007, 1, 28]).add({d:25}), true), "25 días", "25 days = 25 days");
+ equal(start.from(moment([2007, 1, 28]).add({d:26}), true), "un mes", "26 days = a month");
+ equal(start.from(moment([2007, 1, 28]).add({d:30}), true), "un mes", "30 days = a month");
+ equal(start.from(moment([2007, 1, 28]).add({d:45}), true), "un mes", "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:74}), 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), "un mes", "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), "un año", "345 days = a year");
+ equal(start.from(moment([2007, 1, 28]).add({d:547}), true), "un año", "547 days = a year");
+ equal(start.from(moment([2007, 1, 28]).add({d:548}), true), "2 años", "548 days = 2 years");
+ equal(start.from(moment([2007, 1, 28]).add({y:1}), true), "un año", "1 year = a year");
+ equal(start.from(moment([2007, 1, 28]).add({y:5}), true), "5 años", "5 years = 5 years");
+});
+
+test("suffix", 2, function() {
+ moment.lang('es');
+ equal(moment(30000).from(0), "en unos segundos", "prefix");
+ equal(moment(0).from(30000), "hace unos segundos", "suffix");
+});
+
+
+test("now from now", 1, function() {
+ moment.lang('es');
+ equal(moment().fromNow(), "hace unos segundos", "now from now should display as in the past");
+});
+
+
+test("fromNow", 2, function() {
+ moment.lang('es');
+ equal(moment().add({s:30}).fromNow(), "en unos segundos", "en unos segundos");
+ equal(moment().add({d:5}).fromNow(), "en 5 días", "en 5 días");
+});
+
+
+/**************************************************
+ Dutch
+ *************************************************/
+
+module("lang:nl");
+
+test("format", 18, function() {
+ moment.lang('nl');
+ var a = [
+ ['dddd, MMMM Do YYYY, HH:mm:ss', 'zondag, februari 14de 2010, 15:25:50'],
+ ['ddd, HH', 'zo., 15'],
+ ['M Mo MM MMMM MMM', '2 2de 02 februari feb.'],
+ ['YYYY YY', '2010 10'],
+ ['D Do DD', '14 14de 14'],
+ ['d do dddd ddd', '0 0de zondag zo.'],
+ ['DDD DDDo DDDD', '45 45ste 045'],
+ ['w wo ww', '8 8ste 08'],
+ ['h hh', '3 03'],
+ ['H HH', '15 15'],
+ ['m mm', '25 25'],
+ ['s ss', '50 50'],
+ ['a A', 'pm PM'],
+ ['t\\he DDDo \\d\\ay of t\\he ye\\ar', 'the 45ste day of the year'],
+ ['L', '14-02-2010'],
+ ['LL', 'februari 14 2010'],
+ ['LLL', 'februari 14 2010 15:25'],
+ ['LLLL', 'zondag, 14 februari 2010 15:25']
+ ],
+ 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]);
+ }
+});
+
+test("format YY", 1, function() {
+ var b = moment(new Date(2009, 1, 14, 15, 25, 50, 125));
+ equal(b.format('YY'), '09', 'YY ---> 09');
+});
+
+test("format timezone", 2, function() {
+ var b = moment(new Date(2010, 1, 14, 15, 25, 50, 125));
+ ok(b.format('z').match(/^[A-Z]{3,4}$/), 'z ---> Something like "PST"');
+ ok(b.format('zz').match(/^[A-Z]{3,4}$/), 'zz ---> Something like "PST"');
+});
+
+test("format ordinal", 31, function() {
+ moment.lang('nl');
+ equal(moment([2011, 0, 1]).format('DDDo'), '1ste', '1ste');
+ equal(moment([2011, 0, 2]).format('DDDo'), '2de', '2de');
+ equal(moment([2011, 0, 3]).format('DDDo'), '3de', '3de');
+ equal(moment([2011, 0, 4]).format('DDDo'), '4de', '4de');
+ equal(moment([2011, 0, 5]).format('DDDo'), '5de', '5de');
+ equal(moment([2011, 0, 6]).format('DDDo'), '6de', '6de');
+ equal(moment([2011, 0, 7]).format('DDDo'), '7de', '7de');
+ equal(moment([2011, 0, 8]).format('DDDo'), '8ste', '8ste');
+ equal(moment([2011, 0, 9]).format('DDDo'), '9de', '9de');
+ equal(moment([2011, 0, 10]).format('DDDo'), '10de', '10de');
+
+ equal(moment([2011, 0, 11]).format('DDDo'), '11de', '11de');
+ equal(moment([2011, 0, 12]).format('DDDo'), '12de', '12de');
+ equal(moment([2011, 0, 13]).format('DDDo'), '13de', '13de');
+ equal(moment([2011, 0, 14]).format('DDDo'), '14de', '14de');
+ equal(moment([2011, 0, 15]).format('DDDo'), '15de', '15de');
+ equal(moment([2011, 0, 16]).format('DDDo'), '16de', '16de');
+ equal(moment([2011, 0, 17]).format('DDDo'), '17de', '17de');
+ equal(moment([2011, 0, 18]).format('DDDo'), '18de', '18de');
+ equal(moment([2011, 0, 19]).format('DDDo'), '19de', '19de');
+ equal(moment([2011, 0, 20]).format('DDDo'), '20ste', '20ste');
+
+ equal(moment([2011, 0, 21]).format('DDDo'), '21ste', '21ste');
+ equal(moment([2011, 0, 22]).format('DDDo'), '22ste', '22ste');
+ equal(moment([2011, 0, 23]).format('DDDo'), '23ste', '23ste');
+ equal(moment([2011, 0, 24]).format('DDDo'), '24ste', '24ste');
+ equal(moment([2011, 0, 25]).format('DDDo'), '25ste', '25ste');
+ equal(moment([2011, 0, 26]).format('DDDo'), '26ste', '26ste');
+ equal(moment([2011, 0, 27]).format('DDDo'), '27ste', '27ste');
+ equal(moment([2011, 0, 28]).format('DDDo'), '28ste', '28ste');
+ equal(moment([2011, 0, 29]).format('DDDo'), '29ste', '29ste');
+ equal(moment([2011, 0, 30]).format('DDDo'), '30ste', '30ste');
+
+ equal(moment([2011, 0, 31]).format('DDDo'), '31ste', '31ste');
+});
+
+test("format month", 12, function() {
+ moment.lang('nl');
+ var expected = 'januari jan._februari feb._maart mar._april apr._mei mei._juni jun._juli jul._augustus aug._september sep._oktober okt._november nov._december dec.'.split("_");
+ var i;
+ for (i = 0; i < expected.length; i++) {
+ equal(moment([2011, i, 0]).format('MMMM MMM'), expected[i], expected[i]);
+ }
+});
+
+test("format week", 7, function() {
+ moment.lang('nl');
+ var expected = 'zondag zo._maandag ma._dinsdag di._woensdag wo._donderdag do._vrijdag vr._zaterdag za.'.split("_");
+ var i;
+ for (i = 0; i < expected.length; i++) {
+ equal(moment([2011, 0, 2 + i]).format('dddd ddd'), expected[i], expected[i]);
+ }
+});
+
+test("from", 30, function() {
+ moment.lang('nl');
+ var start = moment([2007, 1, 28]);
+ equal(start.from(moment([2007, 1, 28]).add({s:44}), true), "een paar seconden", "44 seconds = a few seconds");
+ equal(start.from(moment([2007, 1, 28]).add({s:45}), true), "één minuutje", "45 seconds = a minute");
+ equal(start.from(moment([2007, 1, 28]).add({s:89}), true), "één minuutje", "89 seconds = a minute");
+ equal(start.from(moment([2007, 1, 28]).add({s:90}), true), "2 minuten", "90 seconds = 2 minutes");
+ equal(start.from(moment([2007, 1, 28]).add({m:44}), true), "44 minuten", "44 minutes = 44 minutes");
+ equal(start.from(moment([2007, 1, 28]).add({m:45}), true), "één uur", "45 minutes = an hour");
+ equal(start.from(moment([2007, 1, 28]).add({m:89}), true), "één uur", "89 minutes = an hour");
+ equal(start.from(moment([2007, 1, 28]).add({m:90}), true), "2 uren", "90 minutes = 2 hours");
+ equal(start.from(moment([2007, 1, 28]).add({h:5}), true), "5 uren", "5 hours = 5 hours");
+ equal(start.from(moment([2007, 1, 28]).add({h:21}), true), "21 uren", "21 hours = 21 hours");
+ equal(start.from(moment([2007, 1, 28]).add({h:22}), true), "één dag", "22 hours = a day");
+ equal(start.from(moment([2007, 1, 28]).add({h:35}), true), "één dag", "35 hours = a day");
+ equal(start.from(moment([2007, 1, 28]).add({h:36}), true), "2 dagen", "36 hours = 2 days");
+ equal(start.from(moment([2007, 1, 28]).add({d:1}), true), "één dag", "1 day = a day");
+ equal(start.from(moment([2007, 1, 28]).add({d:5}), true), "5 dagen", "5 days = 5 days");
+ equal(start.from(moment([2007, 1, 28]).add({d:25}), true), "25 dagen", "25 days = 25 days");
+ equal(start.from(moment([2007, 1, 28]).add({d:26}), true), "één maand", "26 days = a month");
+ equal(start.from(moment([2007, 1, 28]).add({d:30}), true), "één maand", "30 days = a month");
+ equal(start.from(moment([2007, 1, 28]).add({d:45}), true), "één maand", "45 days = a month");
+ equal(start.from(moment([2007, 1, 28]).add({d:46}), true), "2 maanden", "46 days = 2 months");
+ equal(start.from(moment([2007, 1, 28]).add({d:74}), true), "2 maanden", "75 days = 2 months");
+ equal(start.from(moment([2007, 1, 28]).add({d:76}), true), "3 maanden", "76 days = 3 months");
+ equal(start.from(moment([2007, 1, 28]).add({M:1}), true), "één maand", "1 month = a month");
+ equal(start.from(moment([2007, 1, 28]).add({M:5}), true), "5 maanden", "5 months = 5 months");
+ equal(start.from(moment([2007, 1, 28]).add({d:344}), true), "11 maanden", "344 days = 11 months");
+ equal(start.from(moment([2007, 1, 28]).add({d:345}), true), "één jaar", "345 days = a year");
+ equal(start.from(moment([2007, 1, 28]).add({d:547}), true), "één jaar", "547 days = a year");
+ equal(start.from(moment([2007, 1, 28]).add({d:548}), true), "2 jaren", "548 days = 2 years");
+ equal(start.from(moment([2007, 1, 28]).add({y:1}), true), "één jaar", "1 year = a year");
+ equal(start.from(moment([2007, 1, 28]).add({y:5}), true), "5 jaren", "5 years = 5 years");
+});
+
+test("suffix", 2, function() {
+ moment.lang('nl');
+ equal(moment(30000).from(0), "over een paar seconden", "prefix");
+ equal(moment(0).from(30000), "een paar seconden geleden", "suffix");
+});
+
+
+test("now from now", 1, function() {
+ moment.lang('nl');
+ equal(moment().fromNow(), "een paar seconden geleden", "now from now should display as in the past");
+});
+
+
+test("fromNow", 2, function() {
+ moment.lang('nl');
+ equal(moment().add({s:30}).fromNow(), "over een paar seconden", "in a few seconds");
+ equal(moment().add({d:5}).fromNow(), "over 5 dagen", "in 5 days");
+});
+
+
+/**************************************************
+ German
+ *************************************************/
+
+module("lang:de");
+
+test("format", 18, function() {
+ moment.lang('de');
+ var a = [
+ ['dddd, Do MMMM YYYY, h:mm:ss a', 'Sonntag, 14. Februar 2010, 3:25:50 pm'],
+ ['ddd, hA', 'So., 3PM'],
+ ['M Mo MM MMMM MMM', '2 2. 02 Februar Febr.'],
+ ['YYYY YY', '2010 10'],
+ ['D Do DD', '14 14. 14'],
+ ['d do dddd ddd', '0 0. Sonntag So.'],
+ ['DDD DDDo DDDD', '45 45. 045'],
+ ['w wo ww', '8 8. 08'],
+ ['h hh', '3 03'],
+ ['H HH', '15 15'],
+ ['m mm', '25 25'],
+ ['s ss', '50 50'],
+ ['a A', 'pm PM'],
+ ['t\\he DDDo \\d\\ay of t\\he ye\\ar', 'the 45. day of the year'],
+ ['L', '14.02.2010'],
+ ['LL', '14. Februar 2010'],
+ ['LLL', '14. Februar 2010 15:25 Uhr'],
+ ['LLLL', 'Sonntag, 14. Februar 2010 15:25 Uhr']
+ ],
+ 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]);
+ }
+});
+
+test("format YY", 1, function() {
+ var b = moment(new Date(2009, 1, 14, 15, 25, 50, 125));
+ equal(b.format('YY'), '09', 'YY ---> 09');
+});
+
+test("format timezone", 2, function() {
+ var b = moment(new Date(2010, 1, 14, 15, 25, 50, 125));
+ ok(b.format('z').match(/^[A-Z]{3,4}$/), 'z ---> Something like "PST"');
+ ok(b.format('zz').match(/^[A-Z]{3,4}$/), 'zz ---> Something like "PST"');
+});
+
+test("format ordinal", 31, function() {
+ moment.lang('de');
+ 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() {
+ moment.lang('de');
+ var expected = 'Januar Jan._Februar Febr._März Mrz._April Apr._Mai Mai_Juni Jun._Juli Jul._August Aug._September Sept._Oktober Okt._November Nov._Dezember Dez.'.split("_");
+ var i;
+ for (i = 0; i < expected.length; i++) {
+ equal(moment([2011, i, 0]).format('MMMM MMM'), expected[i], expected[i]);
+ }
+});
+
+test("format week", 7, function() {
+ moment.lang('de');
+ var expected = 'Sonntag So._Montag Mo._Dienstag Di._Mittwoch Mi._Donnerstag Do._Freitag Fr._Samstag Sa.'.split("_");
+ var i;
+ for (i = 0; i < expected.length; i++) {
+ equal(moment([2011, 0, 2 + i]).format('dddd ddd'), expected[i], expected[i]);
+ }
+});
+
+test("from", 30, function() {
+ moment.lang('de');
+ var start = moment([2007, 1, 28]);
+ equal(start.from(moment([2007, 1, 28]).add({s:44}), true), "ein paar Sekunden", "44 seconds = a few seconds");
+ equal(start.from(moment([2007, 1, 28]).add({s:45}), true), "einer Minute", "45 seconds = a minute");
+ equal(start.from(moment([2007, 1, 28]).add({s:89}), true), "einer Minute", "89 seconds = a minute");
+ equal(start.from(moment([2007, 1, 28]).add({s:90}), true), "2 Minuten", "90 seconds = 2 minutes");
+ equal(start.from(moment([2007, 1, 28]).add({m:44}), true), "44 Minuten", "44 minutes = 44 minutes");
+ equal(start.from(moment([2007, 1, 28]).add({m:45}), true), "einer Stunde", "45 minutes = an hour");
+ equal(start.from(moment([2007, 1, 28]).add({m:89}), true), "einer Stunde", "89 minutes = an hour");
+ equal(start.from(moment([2007, 1, 28]).add({m:90}), true), "2 Stunden", "90 minutes = 2 hours");
+ equal(start.from(moment([2007, 1, 28]).add({h:5}), true), "5 Stunden", "5 hours = 5 hours");
+ equal(start.from(moment([2007, 1, 28]).add({h:21}), true), "21 Stunden", "21 hours = 21 hours");
+ equal(start.from(moment([2007, 1, 28]).add({h:22}), true), "einem Tag", "22 hours = a day");
+ equal(start.from(moment([2007, 1, 28]).add({h:35}), true), "einem Tag", "35 hours = a day");
+ equal(start.from(moment([2007, 1, 28]).add({h:36}), true), "2 Tagen", "36 hours = 2 days");
+ equal(start.from(moment([2007, 1, 28]).add({d:1}), true), "einem Tag", "1 day = a day");
+ equal(start.from(moment([2007, 1, 28]).add({d:5}), true), "5 Tagen", "5 days = 5 days");
+ equal(start.from(moment([2007, 1, 28]).add({d:25}), true), "25 Tagen", "25 days = 25 days");
+ equal(start.from(moment([2007, 1, 28]).add({d:26}), true), "einem Monat", "26 days = a month");
+ equal(start.from(moment([2007, 1, 28]).add({d:30}), true), "einem Monat", "30 days = a month");
+ equal(start.from(moment([2007, 1, 28]).add({d:45}), true), "einem Monat", "45 days = a month");
+ equal(start.from(moment([2007, 1, 28]).add({d:46}), true), "2 Monaten", "46 days = 2 months");
+ equal(start.from(moment([2007, 1, 28]).add({d:74}), true), "2 Monaten", "75 days = 2 months");
+ equal(start.from(moment([2007, 1, 28]).add({d:76}), true), "3 Monaten", "76 days = 3 months");
+ equal(start.from(moment([2007, 1, 28]).add({M:1}), true), "einem Monat", "1 month = a month");
+ equal(start.from(moment([2007, 1, 28]).add({M:5}), true), "5 Monaten", "5 months = 5 months");
+ equal(start.from(moment([2007, 1, 28]).add({d:344}), true), "11 Monaten", "344 days = 11 months");
+ equal(start.from(moment([2007, 1, 28]).add({d:345}), true), "einem Jahr", "345 days = a year");
+ equal(start.from(moment([2007, 1, 28]).add({d:547}), true), "einem Jahr", "547 days = a year");
+ equal(start.from(moment([2007, 1, 28]).add({d:548}), true), "2 Jahren", "548 days = 2 years");
+ equal(start.from(moment([2007, 1, 28]).add({y:1}), true), "einem Jahr", "1 year = a year");
+ equal(start.from(moment([2007, 1, 28]).add({y:5}), true), "5 Jahren", "5 years = 5 years");
+});
+
+test("suffix", 2, function() {
+ moment.lang('de');
+ equal(moment(30000).from(0), "in ein paar Sekunden", "prefix");
+ equal(moment(0).from(30000), "vor ein paar Sekunden", "suffix");
+});
+
+test("fromNow", 2, function() {
+ moment.lang('de');
+ equal(moment().add({s:30}).fromNow(), "in ein paar Sekunden", "in a few seconds");
+ equal(moment().add({d:5}).fromNow(), "in 5 Tagen", "in 5 days");
+});
+
+/**************************************************
+ English
+ *************************************************/
+
+module("lang:sv");
+
+test("format", 18, function() {
+ moment.lang('sv');
+ var a = [
+ ['dddd, MMMM Do YYYY, h:mm:ss a', 'söndag, februari 14e 2010, 3:25:50 pm'],
+ ['ddd, hA', 'sön, 3PM'],
+ ['M Mo MM MMMM MMM', '2 2a 02 februari feb'],
+ ['YYYY YY', '2010 10'],
+ ['D Do DD', '14 14e 14'],
+ ['d do dddd ddd', '0 0e söndag sön'],
+ ['DDD DDDo DDDD', '45 45e 045'],
+ ['w wo ww', '8 8e 08'],
+ ['h hh', '3 03'],
+ ['H HH', '15 15'],
+ ['m mm', '25 25'],
+ ['s ss', '50 50'],
+ ['a A', 'pm PM'],
+ ['t\\he DDDo \\d\\ay of t\\he ye\\ar', 'the 45e day of the year'],
+ ['L', '2010-02-14'],
+ ['LL', '14 februari 2010'],
+ ['LLL', '14 februari 2010 15:25'],
+ ['LLLL', 'söndag 14 februari 2010 15:25']
+ ],
+ 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]);
+ }
+});
+
+test("format YY", 1, function() {
+ var b = moment(new Date(2009, 1, 14, 15, 25, 50, 125));
+ equal(b.format('YY'), '09', 'YY ---> 09');
+});
+
+test("format timezone", 2, function() {
+ var b = moment(new Date(2010, 1, 14, 15, 25, 50, 125));
+ ok(b.format('z').match(/^[A-Z]{3,4}$/), 'z ---> Something like "PST"');
+ ok(b.format('zz').match(/^[A-Z]{3,4}$/), 'zz ---> Something like "PST"');
+});
+
+test("format ordinal", 31, function() {
+ moment.lang('sv');
+ equal(moment([2011, 0, 1]).format('DDDo'), '1a', '1a');
+ equal(moment([2011, 0, 2]).format('DDDo'), '2a', '2a');
+ equal(moment([2011, 0, 3]).format('DDDo'), '3e', '3e');
+ equal(moment([2011, 0, 4]).format('DDDo'), '4e', '4e');
+ equal(moment([2011, 0, 5]).format('DDDo'), '5e', '5e');
+ equal(moment([2011, 0, 6]).format('DDDo'), '6e', '6e');
+ equal(moment([2011, 0, 7]).format('DDDo'), '7e', '7e');
+ equal(moment([2011, 0, 8]).format('DDDo'), '8e', '8e');
+ equal(moment([2011, 0, 9]).format('DDDo'), '9e', '9e');
+ equal(moment([2011, 0, 10]).format('DDDo'), '10e', '10e');
+
+ equal(moment([2011, 0, 11]).format('DDDo'), '11e', '11e');
+ equal(moment([2011, 0, 12]).format('DDDo'), '12e', '12e');
+ equal(moment([2011, 0, 13]).format('DDDo'), '13e', '13e');
+ equal(moment([2011, 0, 14]).format('DDDo'), '14e', '14e');
+ equal(moment([2011, 0, 15]).format('DDDo'), '15e', '15e');
+ equal(moment([2011, 0, 16]).format('DDDo'), '16e', '16e');
+ equal(moment([2011, 0, 17]).format('DDDo'), '17e', '17e');
+ equal(moment([2011, 0, 18]).format('DDDo'), '18e', '18e');
+ equal(moment([2011, 0, 19]).format('DDDo'), '19e', '19e');
+ equal(moment([2011, 0, 20]).format('DDDo'), '20e', '20e');
+
+ equal(moment([2011, 0, 21]).format('DDDo'), '21a', '21a');
+ equal(moment([2011, 0, 22]).format('DDDo'), '22a', '22a');
+ equal(moment([2011, 0, 23]).format('DDDo'), '23e', '23e');
+ equal(moment([2011, 0, 24]).format('DDDo'), '24e', '24e');
+ equal(moment([2011, 0, 25]).format('DDDo'), '25e', '25e');
+ equal(moment([2011, 0, 26]).format('DDDo'), '26e', '26e');
+ equal(moment([2011, 0, 27]).format('DDDo'), '27e', '27e');
+ equal(moment([2011, 0, 28]).format('DDDo'), '28e', '28e');
+ equal(moment([2011, 0, 29]).format('DDDo'), '29e', '29e');
+ equal(moment([2011, 0, 30]).format('DDDo'), '30e', '30e');
+
+ equal(moment([2011, 0, 31]).format('DDDo'), '31a', '31a');
+});
+
+test("format month", 12, function() {
+ moment.lang('sv');
+ var expected = 'januari jan_februari feb_mars mar_april apr_maj maj_juni jun_juli jul_augusti aug_september sep_oktober okt_november nov_december dec'.split("_");
+ var i;
+ for (i = 0; i < expected.length; i++) {
+ equal(moment([2011, i, 0]).format('MMMM MMM'), expected[i], expected[i]);
+ }
+});
+
+test("format week", 7, function() {
+ moment.lang('sv');
+ var expected = 'söndag sön_måndag mån_tisdag tis_onsdag ons_torsdag tor_fredag fre_lördag lör'.split("_");
+ var i;
+ for (i = 0; i < expected.length; i++) {
+ equal(moment([2011, 0, 2 + i]).format('dddd ddd'), expected[i], expected[i]);
+ }
+});
+
+test("from", 30, function() {
+ moment.lang('sv');
+ var start = moment([2007, 1, 28]);
+ equal(start.from(moment([2007, 1, 28]).add({s:44}), true), "några sekunder", "44 sekunder = a few seconds");
+ equal(start.from(moment([2007, 1, 28]).add({s:45}), true), "en minut", "45 seconds = a minute");
+ equal(start.from(moment([2007, 1, 28]).add({s:89}), true), "en minut", "89 seconds = a minute");
+ equal(start.from(moment([2007, 1, 28]).add({s:90}), true), "2 minuter", "90 seconds = 2 minutes");
+ equal(start.from(moment([2007, 1, 28]).add({m:44}), true), "44 minuter", "44 minutes = 44 minutes");
+ equal(start.from(moment([2007, 1, 28]).add({m:45}), true), "en timme", "45 minutes = an hour");
+ equal(start.from(moment([2007, 1, 28]).add({m:89}), true), "en timme", "89 minutes = an hour");
+ equal(start.from(moment([2007, 1, 28]).add({m:90}), true), "2 timmar", "90 minutes = 2 hours");
+ equal(start.from(moment([2007, 1, 28]).add({h:5}), true), "5 timmar", "5 hours = 5 hours");
+ equal(start.from(moment([2007, 1, 28]).add({h:21}), true), "21 timmar", "21 hours = 21 hours");
+ equal(start.from(moment([2007, 1, 28]).add({h:22}), true), "en dag", "22 hours = a day");
+ equal(start.from(moment([2007, 1, 28]).add({h:35}), true), "en dag", "35 hours = a day");
+ equal(start.from(moment([2007, 1, 28]).add({h:36}), true), "2 dagar", "36 hours = 2 days");
+ equal(start.from(moment([2007, 1, 28]).add({d:1}), true), "en dag", "1 day = a day");
+ equal(start.from(moment([2007, 1, 28]).add({d:5}), true), "5 dagar", "5 days = 5 days");
+ equal(start.from(moment([2007, 1, 28]).add({d:25}), true), "25 dagar", "25 days = 25 days");
+ equal(start.from(moment([2007, 1, 28]).add({d:26}), true), "en månad", "26 days = a month");
+ equal(start.from(moment([2007, 1, 28]).add({d:30}), true), "en månad", "30 days = a month");
+ equal(start.from(moment([2007, 1, 28]).add({d:45}), true), "en månad", "45 days = a month");
+ equal(start.from(moment([2007, 1, 28]).add({d:46}), true), "2 månader", "46 days = 2 months");
+ equal(start.from(moment([2007, 1, 28]).add({d:74}), true), "2 månader", "75 days = 2 months");
+ equal(start.from(moment([2007, 1, 28]).add({d:76}), true), "3 månader", "76 days = 3 months");
+ equal(start.from(moment([2007, 1, 28]).add({M:1}), true), "en månad", "1 month = a month");
+ equal(start.from(moment([2007, 1, 28]).add({M:5}), true), "5 månader", "5 months = 5 months");
+ equal(start.from(moment([2007, 1, 28]).add({d:344}), true), "11 månader", "344 days = 11 months");
+ equal(start.from(moment([2007, 1, 28]).add({d:345}), true), "ett år", "345 days = a year");
+ equal(start.from(moment([2007, 1, 28]).add({d:547}), true), "ett år", "547 days = a year");
+ equal(start.from(moment([2007, 1, 28]).add({d:548}), true), "2 år", "548 days = 2 years");
+ equal(start.from(moment([2007, 1, 28]).add({y:1}), true), "ett år", "1 year = a year");
+ equal(start.from(moment([2007, 1, 28]).add({y:5}), true), "5 år", "5 years = 5 years");
+});
+
+test("suffix", 2, function() {
+ moment.lang('sv');
+ equal(moment(30000).from(0), "om några sekunder", "prefix");
+ equal(moment(0).from(30000), "för några sekunder sen", "suffix");
+});
+
+
+test("now from now", 1, function() {
+ moment.lang('sv');
+ equal(moment().fromNow(), "för några sekunder sen", "now from now should display as in the past");
+});
+
+
+test("fromNow", 2, function() {
+ moment.lang('sv');
+ equal(moment().add({s:30}).fromNow(), "om några sekunder", "in a few seconds");
+ equal(moment().add({d:5}).fromNow(), "om 5 dagar", "in 5 days");
+});
+
+
+/**************************************************
+ Polish
+ *************************************************/
+
+module("lang:pl");
+
+test("format", 18, function() {
+ moment.lang('pl');
+ var a = [
+ ['dddd, MMMM Do YYYY, h:mm:ss a', 'niedziela, luty 14. 2010, 3:25:50 pm'],
+ ['ddd, hA', 'nie, 3PM'],
+ ['M Mo MM MMMM MMM', '2 2. 02 luty lut'],
+ ['YYYY YY', '2010 10'],
+ ['D Do DD', '14 14. 14'],
+ ['d do dddd ddd', '0 0. niedziela nie'],
+ ['DDD DDDo DDDD', '45 45. 045'],
+ ['w wo ww', '8 8. 08'],
+ ['h hh', '3 03'],
+ ['H HH', '15 15'],
+ ['m mm', '25 25'],
+ ['s ss', '50 50'],
+ ['a A', 'pm PM'],
+ ['t\\he DDDo \\d\\ay of t\\he ye\\ar', 'the 45. day of the year'],
+ ['L', '14-02-2010'],
+ ['LL', '14 luty 2010'],
+ ['LLL', '14 luty 2010 15:25'],
+ ['LLLL', 'niedziela, 14 luty 2010 15:25']
+ ],
+ 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]);
+ }
+});
+
+test("format YY", 1, function() {
+ var b = moment(new Date(2009, 1, 14, 15, 25, 50, 125));
+ equal(b.format('YY'), '09', 'YY ---> 09');
+});
+
+test("format timezone", 2, function() {
+ var b = moment(new Date(2010, 1, 14, 15, 25, 50, 125));
+ ok(b.format('z').match(/^[A-Z]{3,4}$/), 'z ---> Something like "PST"');
+ ok(b.format('zz').match(/^[A-Z]{3,4}$/), 'zz ---> Something like "PST"');
+});
+
+test("format ordinal", 31, function() {
+ moment.lang('pl');
+ 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() {
+ moment.lang('pl');
+ var expected = 'styczeń sty_luty lut_marzec mar_kwiecień kwi_maj maj_czerwiec cze_lipiec lip_sierpień sie_wrzesień wrz_październik paź_listopad lis_grudzień gru'.split("_");
+ var i;
+ for (i = 0; i < expected.length; i++) {
+ equal(moment([2011, i, 0]).format('MMMM MMM'), expected[i], expected[i]);
+ }
+});
+
+test("format week", 7, function() {
+ moment.lang('pl');
+ var expected = 'niedziela nie_poniedziałek pon_wtorek wt_środa śr_czwartek czw_piątek pt_sobota sb'.split("_");
+ var i;
+ for (i = 0; i < expected.length; i++) {
+ equal(moment([2011, 0, 2 + i]).format('dddd ddd'), expected[i], expected[i]);
+ }
+});
+
+test("from", 30, function() {
+ moment.lang('pl');
+ var start = moment([2007, 1, 28]);
+ equal(start.from(moment([2007, 1, 28]).add({s:44}), true), "kilka sekund", "44 seconds = a few seconds");
+ equal(start.from(moment([2007, 1, 28]).add({s:45}), true), "minutę", "45 seconds = a minute");
+ equal(start.from(moment([2007, 1, 28]).add({s:89}), true), "minutę", "89 seconds = a minute");
+ equal(start.from(moment([2007, 1, 28]).add({s:90}), true), "2 minut", "90 seconds = 2 minutes");
+ equal(start.from(moment([2007, 1, 28]).add({m:44}), true), "44 minut", "44 minutes = 44 minutes");
+ equal(start.from(moment([2007, 1, 28]).add({m:45}), true), "godzinę", "45 minutes = an hour");
+ equal(start.from(moment([2007, 1, 28]).add({m:89}), true), "godzinę", "89 minutes = an hour");
+ equal(start.from(moment([2007, 1, 28]).add({m:90}), true), "2 godzin", "90 minutes = 2 hours");
+ equal(start.from(moment([2007, 1, 28]).add({h:5}), true), "5 godzin", "5 hours = 5 hours");
+ equal(start.from(moment([2007, 1, 28]).add({h:21}), true), "21 godzin", "21 hours = 21 hours");
+ equal(start.from(moment([2007, 1, 28]).add({h:22}), true), "1 dzień", "22 hours = a day");
+ equal(start.from(moment([2007, 1, 28]).add({h:35}), true), "1 dzień", "35 hours = a day");
+ equal(start.from(moment([2007, 1, 28]).add({h:36}), true), "2 dni", "36 hours = 2 days");
+ equal(start.from(moment([2007, 1, 28]).add({d:1}), true), "1 dzień", "1 day = a day");
+ equal(start.from(moment([2007, 1, 28]).add({d:5}), true), "5 dni", "5 days = 5 days");
+ equal(start.from(moment([2007, 1, 28]).add({d:25}), true), "25 dni", "25 days = 25 days");
+ equal(start.from(moment([2007, 1, 28]).add({d:26}), true), "miesiąc", "26 days = a month");
+ equal(start.from(moment([2007, 1, 28]).add({d:30}), true), "miesiąc", "30 days = a month");
+ equal(start.from(moment([2007, 1, 28]).add({d:45}), true), "miesiąc", "45 days = a month");
+ equal(start.from(moment([2007, 1, 28]).add({d:46}), true), "2 miesięcy", "46 days = 2 months");
+ equal(start.from(moment([2007, 1, 28]).add({d:74}), true), "2 miesięcy", "75 days = 2 months");
+ equal(start.from(moment([2007, 1, 28]).add({d:76}), true), "3 miesięcy", "76 days = 3 months");
+ equal(start.from(moment([2007, 1, 28]).add({M:1}), true), "miesiąc", "1 month = a month");
+ equal(start.from(moment([2007, 1, 28]).add({M:5}), true), "5 miesięcy", "5 months = 5 months");
+ equal(start.from(moment([2007, 1, 28]).add({d:344}), true), "11 miesięcy", "344 days = 11 months");
+ equal(start.from(moment([2007, 1, 28]).add({d:345}), true), "rok", "345 days = a year");
+ equal(start.from(moment([2007, 1, 28]).add({d:547}), true), "rok", "547 days = a year");
+ equal(start.from(moment([2007, 1, 28]).add({d:548}), true), "2 lat", "548 days = 2 years");
+ equal(start.from(moment([2007, 1, 28]).add({y:1}), true), "rok", "1 year = a year");
+ equal(start.from(moment([2007, 1, 28]).add({y:5}), true), "5 lat", "5 years = 5 years");
+});
+
+test("suffix", 2, function() {
+ moment.lang('pl');
+ equal(moment(30000).from(0), "za kilka sekund", "prefix");
+ equal(moment(0).from(30000), "kilka sekund temu", "suffix");
+});
+
+
+test("now from now", 1, function() {
+ moment.lang('pl');
+ equal(moment().fromNow(), "kilka sekund temu", "now from now should display as in the past");
+});
+
+
+test("fromNow", 2, function() {
+ moment.lang('pl');
+ equal(moment().add({s:30}).fromNow(), "za kilka sekund", "in a few seconds");
+ equal(moment().add({d:5}).fromNow(), "za 5 dni", "in 5 days");
+});
+
+})();
\ No newline at end of file