From: Tim Wood Date: Mon, 14 Nov 2011 17:57:11 +0000 (-0800) Subject: Moving format YY and format z/zz to global unit tests #55 X-Git-Tag: 1.1.2~15 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=e30f7d3bb2ba70db068145cc334abbbbfee3c2c6;p=thirdparty%2Fmoment.git Moving format YY and format z/zz to global unit tests #55 Also expanding timezone format unit test to accept 3-5 uppercase characters. --- diff --git a/lang/test/de.js b/lang/test/de.js index 9b8aeffc5..f8e7a8006 100644 --- a/lang/test/de.js +++ b/lang/test/de.js @@ -34,17 +34,6 @@ test("format", 18, function() { } }); -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.'); diff --git a/lang/test/en.js b/lang/test/en.js index ff5350183..7e8fca27c 100644 --- a/lang/test/en.js +++ b/lang/test/en.js @@ -34,17 +34,6 @@ test("format", 18, function() { } }); -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'); diff --git a/lang/test/es.js b/lang/test/es.js index 2cea3ad3e..9c354a671 100644 --- a/lang/test/es.js +++ b/lang/test/es.js @@ -34,17 +34,6 @@ test("format", 18, function() { } }); -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º'); diff --git a/lang/test/fr.js b/lang/test/fr.js index 1db073d11..d352ebdc4 100644 --- a/lang/test/fr.js +++ b/lang/test/fr.js @@ -34,17 +34,6 @@ test("format", 18, function() { } }); -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'); diff --git a/lang/test/it.js b/lang/test/it.js index f325fcc24..0e2b843de 100644 --- a/lang/test/it.js +++ b/lang/test/it.js @@ -34,17 +34,6 @@ test("format", 18, function() { } }); -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º'); diff --git a/lang/test/nl.js b/lang/test/nl.js index db2970cf8..b737580df 100644 --- a/lang/test/nl.js +++ b/lang/test/nl.js @@ -34,17 +34,6 @@ test("format", 18, function() { } }); -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'); diff --git a/lang/test/pl.js b/lang/test/pl.js index 35beec354..c257da657 100644 --- a/lang/test/pl.js +++ b/lang/test/pl.js @@ -34,17 +34,6 @@ test("format", 18, function() { } }); -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.'); diff --git a/lang/test/pt.js b/lang/test/pt.js index eaf68eb58..685c60079 100644 --- a/lang/test/pt.js +++ b/lang/test/pt.js @@ -34,17 +34,6 @@ test("format", 18, function() { } }); -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º'); diff --git a/lang/test/sv.js b/lang/test/sv.js index c2771ac48..b7cd620dd 100644 --- a/lang/test/sv.js +++ b/lang/test/sv.js @@ -34,17 +34,6 @@ test("format", 18, function() { } }); -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'); diff --git a/site/docs/index.html b/site/docs/index.html index dde811701..b98a140d6 100644 --- a/site/docs/index.html +++ b/site/docs/index.html @@ -1,4 +1,4 @@ -Moment.js Documentation

Moment.js Documentation

A lightweight javascript date library for parsing, manipulating, and formatting dates.

Where to get it

Github

Production Version 1.1.12.5kb minified & gzippedDevelopment Version 1.1.117.9kb full source + comments

You can also clone the project with Git by running:

git clone git://github.com/timrwood/moment

npm

npm install moment

Where to use it

Moment was designed to work in both the browser and in NodeJS. All code will work in both environments. All unit tests are run in both environments.

In NodeJS

var moment = require('moment');
+Moment.js Documentation

Moment.js Documentation

A lightweight javascript date library for parsing, manipulating, and formatting dates.

Where to get it

Github

Production Version 1.1.12.5kb minified & gzippedDevelopment Version 1.1.117.9kb full source + comments

You can also clone the project with Git by running:

git clone git://github.com/timrwood/moment

npm

npm install moment

Where to use it

Moment was designed to work in both the browser and in NodeJS. All code will work in both environments. All unit tests are run in both environments.

In NodeJS

var moment = require('moment');
 moment().add('hours', 1).fromNow(); // "1 hour ago"
 

In the browser

<script src="moment.min.js"></script>
 moment().add('hours', 1).fromNow(); // "1 hour ago"
@@ -190,7 +190,7 @@ moment(1316116057189).fromNow(); // il y a une heure
         (b === 2) ? 'nd' : 
         (b === 3) ? 'rd' : 'th';
 };
-

For more information on ordinal numbers, see wikipedia