diff --git a/.gitattributes b/.gitattributes
new file mode 100644
index 0000000..7b7ab85
--- /dev/null
+++ b/.gitattributes
@@ -0,0 +1,4 @@
+# we don't have non-text files, don't take chances with git's text=auto
+* text
+# this file is read by nuget (Windows) tooling, lets keep it happy
+Moment.js.nuspec eol=crlf
diff --git a/.jscs.json b/.jscs.json
index 72747b5..442e0a7 100644
--- a/.jscs.json
+++ b/.jscs.json
@@ -53,7 +53,6 @@
"requireCamelCaseOrUpperCaseIdentifiers": "ignoreProperties",
"disallowKeywords": ["with"],
"disallowMultipleLineStrings": true,
- "validateLineBreaks": "LF",
"validateIndentation": 4,
"disallowTrailingWhitespace": true,
"disallowTrailingComma": true,
diff --git a/CHANGELOG.md b/CHANGELOG.md
index 837daaa..433fa85 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -1,5 +1,59 @@
Changelog
=========
+
+### 2.13.0 [See full changelog](https://gist.github.com/ichernev/0132fcf5b61f7fc140b0bb0090480d49)
+
+## Enhancements:
+* [#2982](https://github.com/moment/moment/pull/2982) Add 'date' as alias to 'day' for startOf() and endOf().
+* [#2955](https://github.com/moment/moment/pull/2955) Add parsing negative components in durations when ISO 8601
+* [#2991](https://github.com/moment/moment/pull/2991) isBetween support for both open and closed intervals
+* [#3105](https://github.com/moment/moment/pull/3105) Add localeSorted argument to weekday listers
+* [#3102](https://github.com/moment/moment/pull/3102) Add k and kk formatting tokens
+
+## Bugfixes
+* [#3109](https://github.com/moment/moment/pull/3109) Fix [#1756](https://github.com/moment/moment/issues/1756) Resolved thread-safe issue on server side.
+* [#3078](https://github.com/moment/moment/pull/3078) Fix parsing for months/weekdays with weird characters
+* [#3098](https://github.com/moment/moment/pull/3098) Use Z suffix when in UTC mode ([#3020](https://github.com/moment/moment/issues/3020))
+* [#2995](https://github.com/moment/moment/pull/2995) Fix floating point rounding errors in durations
+* [#3059](https://github.com/moment/moment/pull/3059) fix bug where diff returns -0 in month-related diffs
+* [#3045](https://github.com/moment/moment/pull/3045) Fix mistaking any input for 'a' token
+* [#2877](https://github.com/moment/moment/pull/2877) Use explicit .valueOf() calls instead of coercion
+* [#3036](https://github.com/moment/moment/pull/3036) Year setter should keep time when DST changes
+
+Plus 3 new locales and locale fixes.
+
+### 2.12.0 [See full changelog](https://gist.github.com/ichernev/6e5bfdf8d6522fc4ac73)
+
+## Enhancements:
+* [#2932](https://github.com/moment/moment/pull/2932) List loaded locales
+* [#2818](https://github.com/moment/moment/pull/2818) Parse ISO-8061 duration containing both day and week values
+* [#2774](https://github.com/moment/moment/pull/2774) Implement locale inheritance and locale updating
+
+## Bugfixes:
+* [#2970](https://github.com/moment/moment/pull/2970) change add subtract to handle decimal values by rounding
+* [#2887](https://github.com/moment/moment/pull/2887) Fix toJSON casting of invalid moment
+* [#2897](https://github.com/moment/moment/pull/2897) parse string arguments for month() correctly, closes #2884
+* [#2946](https://github.com/moment/moment/pull/2946) Fix usage suggestions for min and max
+
+## New locales:
+* [#2917](https://github.com/moment/moment/pull/2917) Locale Punjabi(Gurmukhi) India format conversion
+
+And more
+
+### 2.11.2 (Fix ReDoS attack vector)
+
+* [#2939](https://github.com/moment/moment/pull/2939) use full-string match to speed up aspnet regex match
+
+### 2.11.1 [See full changelog](https://gist.github.com/ichernev/8ec3ee25b749b4cff3c2)
+
+## Bugfixes:
+* [#2881](https://github.com/moment/moment/pull/2881) Revert "Merge pull request #2746 from mbad0la:develop" Sep->Sept
+* [#2868](https://github.com/moment/moment/pull/2868) Add format and parse token Y, so it actually works
+* [#2865](https://github.com/moment/moment/pull/2865) Use typeof checks for undefined for global variables
+* [#2858](https://github.com/moment/moment/pull/2858) Fix Date mocking regression introduced in 2.11.0
+* [#2864](https://github.com/moment/moment/pull/2864) Include changelog in npm release
+* [#2830](https://github.com/moment/moment/pull/2830) dep: add grunt-cli
+* [#2869](https://github.com/moment/moment/pull/2869) Fix months parsing for some locales
### 2.11.0 [See full changelog](https://gist.github.com/ichernev/6594bc29719dde6b2f66)
diff --git a/LICENSE b/LICENSE
index 34f5b37..9ee5374 100644
--- a/LICENSE
+++ b/LICENSE
@@ -1,4 +1,4 @@
-Copyright (c) 2011-2015 Tim Wood, Iskren Chernev, Moment.js contributors
+Copyright (c) 2011-2016 Tim Wood, Iskren Chernev, Moment.js contributors
Permission is hereby granted, free of charge, to any person
obtaining a copy of this software and associated documentation
diff --git a/Moment.js.nuspec b/Moment.js.nuspec
index 972fb41..0ab4b48 100644
--- a/Moment.js.nuspec
+++ b/Moment.js.nuspec
@@ -1,28 +1,28 @@
-
-
-
- Moment.js
- 2.11.0
- Tim Wood
- Cory Deppen, Iskren Chernev
- A lightweight javascript date library for parsing, manipulating, and formatting dates.
-
- - Add LTS localised format that includes seconds
- - Added formatToken 'x' for unix offset in milliseconds #1938
- - Support 24:00:00.000 to mean next day, at midnight.
- - Accept 'date' key when creating moment with object
- - Use native toISOString when we can
- - Some bugfixes and language improvements
-
- http://momentjs.com/
- http://pbs.twimg.com/profile_images/482670411402858496/Xrtdc94q_normal.png
- https://raw.github.com/timrwood/moment/master/LICENSE
- JavaScript date time browser node.js
-
-
-
-
-
-
-
-
+
+
+
+ Moment.js
+ 2.13.0
+ Tim Wood
+ Cory Deppen, Iskren Chernev
+ A lightweight javascript date library for parsing, manipulating, and formatting dates.
+
+ - Add LTS localised format that includes seconds
+ - Added formatToken 'x' for unix offset in milliseconds #1938
+ - Support 24:00:00.000 to mean next day, at midnight.
+ - Accept 'date' key when creating moment with object
+ - Use native toISOString when we can
+ - Some bugfixes and language improvements
+
+ http://momentjs.com/
+ http://pbs.twimg.com/profile_images/482670411402858496/Xrtdc94q_normal.png
+ https://raw.github.com/timrwood/moment/master/LICENSE
+ JavaScript date time browser node.js
+
+
+
+
+
+
+
+
diff --git a/README.md b/README.md
index 21cb48a..c45e9d6 100644
--- a/README.md
+++ b/README.md
@@ -1,11 +1,11 @@
[![Join the chat at https://gitter.im/moment/moment](https://badges.gitter.im/Join%20Chat.svg)](https://gitter.im/moment/moment?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge&utm_content=badge)
[![NPM version][npm-version-image]][npm-url] [![NPM downloads][npm-downloads-image]][npm-url] [![MIT License][license-image]][license-url] [![Build Status][travis-image]][travis-url]
-[![Coverage Status](https://coveralls.io/repos/moment/moment/badge.svg?branch=master)](https://coveralls.io/r/moment/moment?branch=master)
+[![Coverage Status](https://coveralls.io/repos/moment/moment/badge.svg?branch=develop)](https://coveralls.io/r/moment/moment?branch=develop)
A lightweight JavaScript date library for parsing, validating, manipulating, and formatting dates.
-## [Documentation](http://momentjs.com/docs/)
+**[Documentation](http://momentjs.com/docs/)**
## Port to ECMAScript 6 (version 2.10.0)
diff --git a/component.json b/component.json
index 433de87..c181d7b 100644
--- a/component.json
+++ b/component.json
@@ -1,6 +1,6 @@
{
"name": "moment",
- "version": "2.11.0",
+ "version": "2.13.0",
"main": "moment.js",
"description": "Parse, validate, manipulate, and display dates in JavaScript.",
"files": [
@@ -58,6 +58,7 @@
"locale/kk.js",
"locale/km.js",
"locale/ko.js",
+ "locale/ky.js",
"locale/lb.js",
"locale/lo.js",
"locale/lt.js",
@@ -73,6 +74,7 @@
"locale/ne.js",
"locale/nl.js",
"locale/nn.js",
+ "locale/pa-in.js",
"locale/pl.js",
"locale/pt-br.js",
"locale/pt.js",
@@ -85,6 +87,7 @@
"locale/sq.js",
"locale/sr-cyrl.js",
"locale/sr.js",
+ "locale/ss.js",
"locale/sv.js",
"locale/sw.js",
"locale/ta.js",
@@ -99,6 +102,7 @@
"locale/uk.js",
"locale/uz.js",
"locale/vi.js",
+ "locale/x-pseudo.js",
"locale/zh-cn.js",
"locale/zh-tw.js"
],
diff --git a/locale/ar-ma.js b/locale/ar-ma.js
index 9bddd5a..923a493 100644
--- a/locale/ar-ma.js
+++ b/locale/ar-ma.js
@@ -17,6 +17,7 @@
weekdays : 'الأحد_الإتنين_الثلاثاء_الأربعاء_الخميس_الجمعة_السبت'.split('_'),
weekdaysShort : 'احد_اتنين_ثلاثاء_اربعاء_خميس_جمعة_سبت'.split('_'),
weekdaysMin : 'ح_ن_ث_ر_خ_ج_س'.split('_'),
+ weekdaysParseExact : true,
longDateFormat : {
LT : 'HH:mm',
LTS : 'HH:mm:ss',
diff --git a/locale/ar-sa.js b/locale/ar-sa.js
index 7541c52..aecb80a 100644
--- a/locale/ar-sa.js
+++ b/locale/ar-sa.js
@@ -40,6 +40,7 @@
weekdays : 'الأحد_الإثنين_الثلاثاء_الأربعاء_الخميس_الجمعة_السبت'.split('_'),
weekdaysShort : 'أحد_إثنين_ثلاثاء_أربعاء_خميس_جمعة_سبت'.split('_'),
weekdaysMin : 'ح_ن_ث_ر_خ_ج_س'.split('_'),
+ weekdaysParseExact : true,
longDateFormat : {
LT : 'HH:mm',
LTS : 'HH:mm:ss',
diff --git a/locale/ar-tn.js b/locale/ar-tn.js
index b4ee8fc..b8e07a0 100644
--- a/locale/ar-tn.js
+++ b/locale/ar-tn.js
@@ -15,6 +15,7 @@
weekdays: 'الأحد_الإثنين_الثلاثاء_الأربعاء_الخميس_الجمعة_السبت'.split('_'),
weekdaysShort: 'أحد_إثنين_ثلاثاء_أربعاء_خميس_جمعة_سبت'.split('_'),
weekdaysMin: 'ح_ن_ث_ر_خ_ج_س'.split('_'),
+ weekdaysParseExact : true,
longDateFormat: {
LT: 'HH:mm',
LTS: 'HH:mm:ss',
diff --git a/locale/ar.js b/locale/ar.js
index 3613c59..b478c0f 100644
--- a/locale/ar.js
+++ b/locale/ar.js
@@ -73,6 +73,7 @@
weekdays : 'الأحد_الإثنين_الثلاثاء_الأربعاء_الخميس_الجمعة_السبت'.split('_'),
weekdaysShort : 'أحد_إثنين_ثلاثاء_أربعاء_خميس_جمعة_سبت'.split('_'),
weekdaysMin : 'ح_ن_ث_ر_خ_ج_س'.split('_'),
+ weekdaysParseExact : true,
longDateFormat : {
LT : 'HH:mm',
LTS : 'HH:mm:ss',
diff --git a/locale/az.js b/locale/az.js
index 5ff9b08..1beeca5 100644
--- a/locale/az.js
+++ b/locale/az.js
@@ -37,6 +37,7 @@
weekdays : 'Bazar_Bazar ertəsi_Çərşənbə axşamı_Çərşənbə_Cümə axşamı_Cümə_Şənbə'.split('_'),
weekdaysShort : 'Baz_BzE_ÇAx_Çər_CAx_Cüm_Şən'.split('_'),
weekdaysMin : 'Bz_BE_ÇA_Çə_CA_Cü_Şə'.split('_'),
+ weekdaysParseExact : true,
longDateFormat : {
LT : 'HH:mm',
LTS : 'HH:mm:ss',
diff --git a/locale/bn.js b/locale/bn.js
index 4eca5ee..f6ae260 100644
--- a/locale/bn.js
+++ b/locale/bn.js
@@ -83,12 +83,18 @@
});
},
meridiemParse: /রাত|সকাল|দুপুর|বিকাল|রাত/,
- isPM: function (input) {
- return /^(দুপুর|বিকাল|রাত)$/.test(input);
+ meridiemHour : function (hour, meridiem) {
+ if (hour === 12) {
+ hour = 0;
+ }
+ if ((meridiem === 'রাত' && hour >= 4) ||
+ (meridiem === 'দুপুর' && hour < 5) ||
+ meridiem === 'বিকাল') {
+ return hour + 12;
+ } else {
+ return hour;
+ }
},
- //Bengali is a vast language its spoken
- //in different forms in various parts of the world.
- //I have just generalized with most common one used
meridiem : function (hour, minute, isLower) {
if (hour < 4) {
return 'রাত';
diff --git a/locale/bo.js b/locale/bo.js
index 3ab3389..77ea1bd 100644
--- a/locale/bo.js
+++ b/locale/bo.js
@@ -83,8 +83,17 @@
});
},
meridiemParse: /མཚན་མོ|ཞོགས་ཀས|ཉིན་གུང|དགོང་དག|མཚན་མོ/,
- isPM: function (input) {
- return /^(ཉིན་གུང|དགོང་དག|མཚན་མོ)$/.test(input);
+ meridiemHour : function (hour, meridiem) {
+ if (hour === 12) {
+ hour = 0;
+ }
+ if ((meridiem === 'མཚན་མོ' && hour >= 4) ||
+ (meridiem === 'ཉིན་གུང' && hour < 5) ||
+ meridiem === 'དགོང་དག') {
+ return hour + 12;
+ } else {
+ return hour;
+ }
},
meridiem : function (hour, minute, isLower) {
if (hour < 4) {
diff --git a/locale/br.js b/locale/br.js
index 2896cfb..7b42d42 100644
--- a/locale/br.js
+++ b/locale/br.js
@@ -60,6 +60,7 @@
weekdays : 'Sul_Lun_Meurzh_Merc\'her_Yaou_Gwener_Sadorn'.split('_'),
weekdaysShort : 'Sul_Lun_Meu_Mer_Yao_Gwe_Sad'.split('_'),
weekdaysMin : 'Su_Lu_Me_Mer_Ya_Gw_Sa'.split('_'),
+ weekdaysParseExact : true,
longDateFormat : {
LT : 'h[e]mm A',
LTS : 'h[e]mm:ss A',
diff --git a/locale/bs.js b/locale/bs.js
index e0b3dae..bbe54dc 100644
--- a/locale/bs.js
+++ b/locale/bs.js
@@ -67,9 +67,11 @@
var bs = moment.defineLocale('bs', {
months : 'januar_februar_mart_april_maj_juni_juli_august_septembar_oktobar_novembar_decembar'.split('_'),
monthsShort : 'jan._feb._mar._apr._maj._jun._jul._aug._sep._okt._nov._dec.'.split('_'),
+ monthsParseExact: true,
weekdays : 'nedjelja_ponedjeljak_utorak_srijeda_četvrtak_petak_subota'.split('_'),
weekdaysShort : 'ned._pon._uto._sri._čet._pet._sub.'.split('_'),
weekdaysMin : 'ne_po_ut_sr_če_pe_su'.split('_'),
+ weekdaysParseExact : true,
longDateFormat : {
LT : 'H:mm',
LTS : 'H:mm:ss',
diff --git a/locale/ca.js b/locale/ca.js
index 15f75fe..d796dc3 100644
--- a/locale/ca.js
+++ b/locale/ca.js
@@ -13,9 +13,11 @@
var ca = moment.defineLocale('ca', {
months : 'gener_febrer_març_abril_maig_juny_juliol_agost_setembre_octubre_novembre_desembre'.split('_'),
monthsShort : 'gen._febr._mar._abr._mai._jun._jul._ag._set._oct._nov._des.'.split('_'),
+ monthsParseExact : true,
weekdays : 'diumenge_dilluns_dimarts_dimecres_dijous_divendres_dissabte'.split('_'),
weekdaysShort : 'dg._dl._dt._dc._dj._dv._ds.'.split('_'),
weekdaysMin : 'Dg_Dl_Dt_Dc_Dj_Dv_Ds'.split('_'),
+ weekdaysParseExact : true,
longDateFormat : {
LT : 'H:mm',
LTS : 'H:mm:ss',
diff --git a/locale/cy.js b/locale/cy.js
index 64dfe43..958871e 100644
--- a/locale/cy.js
+++ b/locale/cy.js
@@ -16,6 +16,7 @@
weekdays: 'Dydd Sul_Dydd Llun_Dydd Mawrth_Dydd Mercher_Dydd Iau_Dydd Gwener_Dydd Sadwrn'.split('_'),
weekdaysShort: 'Sul_Llun_Maw_Mer_Iau_Gwe_Sad'.split('_'),
weekdaysMin: 'Su_Ll_Ma_Me_Ia_Gw_Sa'.split('_'),
+ weekdaysParseExact : true,
// time formats are the same as en-gb
longDateFormat: {
LT: 'HH:mm',
diff --git a/locale/de-at.js b/locale/de-at.js
index 20da9cf..0ea81bc 100644
--- a/locale/de-at.js
+++ b/locale/de-at.js
@@ -30,9 +30,11 @@
var de_at = moment.defineLocale('de-at', {
months : 'Jänner_Februar_März_April_Mai_Juni_Juli_August_September_Oktober_November_Dezember'.split('_'),
monthsShort : 'Jän._Febr._Mrz._Apr._Mai_Jun._Jul._Aug._Sept._Okt._Nov._Dez.'.split('_'),
+ monthsParseExact : true,
weekdays : 'Sonntag_Montag_Dienstag_Mittwoch_Donnerstag_Freitag_Samstag'.split('_'),
weekdaysShort : 'So._Mo._Di._Mi._Do._Fr._Sa.'.split('_'),
weekdaysMin : 'So_Mo_Di_Mi_Do_Fr_Sa'.split('_'),
+ weekdaysParseExact : true,
longDateFormat : {
LT: 'HH:mm',
LTS: 'HH:mm:ss',
diff --git a/locale/de.js b/locale/de.js
index 41c81a1..f1dfa9e 100644
--- a/locale/de.js
+++ b/locale/de.js
@@ -29,9 +29,11 @@
var de = moment.defineLocale('de', {
months : 'Januar_Februar_März_April_Mai_Juni_Juli_August_September_Oktober_November_Dezember'.split('_'),
monthsShort : 'Jan._Febr._Mrz._Apr._Mai_Jun._Jul._Aug._Sept._Okt._Nov._Dez.'.split('_'),
+ monthsParseExact : true,
weekdays : 'Sonntag_Montag_Dienstag_Mittwoch_Donnerstag_Freitag_Samstag'.split('_'),
weekdaysShort : 'So._Mo._Di._Mi._Do._Fr._Sa.'.split('_'),
weekdaysMin : 'So_Mo_Di_Mi_Do_Fr_Sa'.split('_'),
+ weekdaysParseExact : true,
longDateFormat : {
LT: 'HH:mm',
LTS: 'HH:mm:ss',
diff --git a/locale/dv.js b/locale/dv.js
index 5fc59b6..d29d662 100644
--- a/locale/dv.js
+++ b/locale/dv.js
@@ -50,7 +50,7 @@
},
meridiemParse: /މކ|މފ/,
isPM : function (input) {
- return '' === input;
+ return 'މފ' === input;
},
meridiem : function (hour, minute, isLower) {
if (hour < 12) {
diff --git a/locale/en-au.js b/locale/en-au.js
index a064564..58608c1 100644
--- a/locale/en-au.js
+++ b/locale/en-au.js
@@ -11,10 +11,7 @@
var en_au = moment.defineLocale('en-au', {
months : 'January_February_March_April_May_June_July_August_September_October_November_December'.split('_'),
- monthsShort : 'Jan_Feb_Mar_Apr_May_Jun_Jul_Aug_Sept_Oct_Nov_Dec'.split('_'),
- monthsParse : [/^jan/i, /^feb/i, /^mar/i, /^apr/i, /^may/i, /^jun/i, /^jul/i, /^aug/i, /^sep/i, /^oct/i, /^nov/i, /^dec/i],
- longMonthsParse : [/^january$/i, /^february$/i, /^march$/i, /^april$/i, /^may$/i, /^june$/i, /^july$/i, /^august$/i, /^september$/i, /^october$/i, /^november$/i, /^december$/i],
- shortMonthsParse : [/^jan$/i, /^feb$/i, /^mar$/i, /^apr$/i, /^may$/i, /^jun$/i, /^jul$/i, /^aug/i, /^sept?$/i, /^oct$/i, /^nov$/i, /^dec$/i],
+ monthsShort : 'Jan_Feb_Mar_Apr_May_Jun_Jul_Aug_Sep_Oct_Nov_Dec'.split('_'),
weekdays : 'Sunday_Monday_Tuesday_Wednesday_Thursday_Friday_Saturday'.split('_'),
weekdaysShort : 'Sun_Mon_Tue_Wed_Thu_Fri_Sat'.split('_'),
weekdaysMin : 'Su_Mo_Tu_We_Th_Fr_Sa'.split('_'),
diff --git a/locale/en-ca.js b/locale/en-ca.js
index afa34ed..3e3bc4f 100644
--- a/locale/en-ca.js
+++ b/locale/en-ca.js
@@ -12,10 +12,7 @@
var en_ca = moment.defineLocale('en-ca', {
months : 'January_February_March_April_May_June_July_August_September_October_November_December'.split('_'),
- monthsShort : 'Jan_Feb_Mar_Apr_May_Jun_Jul_Aug_Sept_Oct_Nov_Dec'.split('_'),
- monthsParse : [/^jan/i, /^feb/i, /^mar/i, /^apr/i, /^may/i, /^jun/i, /^jul/i, /^aug/i, /^sep/i, /^oct/i, /^nov/i, /^dec/i],
- longMonthsParse : [/^january$/i, /^february$/i, /^march$/i, /^april$/i, /^may$/i, /^june$/i, /^july$/i, /^august$/i, /^september$/i, /^october$/i, /^november$/i, /^december$/i],
- shortMonthsParse : [/^jan$/i, /^feb$/i, /^mar$/i, /^apr$/i, /^may$/i, /^jun$/i, /^jul$/i, /^aug/i, /^sept?$/i, /^oct$/i, /^nov$/i, /^dec$/i],
+ monthsShort : 'Jan_Feb_Mar_Apr_May_Jun_Jul_Aug_Sep_Oct_Nov_Dec'.split('_'),
weekdays : 'Sunday_Monday_Tuesday_Wednesday_Thursday_Friday_Saturday'.split('_'),
weekdaysShort : 'Sun_Mon_Tue_Wed_Thu_Fri_Sat'.split('_'),
weekdaysMin : 'Su_Mo_Tu_We_Th_Fr_Sa'.split('_'),
@@ -23,9 +20,9 @@
LT : 'h:mm A',
LTS : 'h:mm:ss A',
L : 'YYYY-MM-DD',
- LL : 'D MMMM, YYYY',
- LLL : 'D MMMM, YYYY h:mm A',
- LLLL : 'dddd, D MMMM, YYYY h:mm A'
+ LL : 'MMMM D, YYYY',
+ LLL : 'MMMM D, YYYY h:mm A',
+ LLLL : 'dddd, MMMM D, YYYY h:mm A'
},
calendar : {
sameDay : '[Today at] LT',
diff --git a/locale/en-gb.js b/locale/en-gb.js
index b7a8614..47b2c20 100644
--- a/locale/en-gb.js
+++ b/locale/en-gb.js
@@ -12,10 +12,7 @@
var en_gb = moment.defineLocale('en-gb', {
months : 'January_February_March_April_May_June_July_August_September_October_November_December'.split('_'),
- monthsShort : 'Jan_Feb_Mar_Apr_May_Jun_Jul_Aug_Sept_Oct_Nov_Dec'.split('_'),
- monthsParse : [/^jan/i, /^feb/i, /^mar/i, /^apr/i, /^may/i, /^jun/i, /^jul/i, /^aug/i, /^sep/i, /^oct/i, /^nov/i, /^dec/i],
- longMonthsParse : [/^january$/i, /^february$/i, /^march$/i, /^april$/i, /^may$/i, /^june$/i, /^july$/i, /^august$/i, /^september$/i, /^october$/i, /^november$/i, /^december$/i],
- shortMonthsParse : [/^jan$/i, /^feb$/i, /^mar$/i, /^apr$/i, /^may$/i, /^jun$/i, /^jul$/i, /^aug/i, /^sept?$/i, /^oct$/i, /^nov$/i, /^dec$/i],
+ monthsShort : 'Jan_Feb_Mar_Apr_May_Jun_Jul_Aug_Sep_Oct_Nov_Dec'.split('_'),
weekdays : 'Sunday_Monday_Tuesday_Wednesday_Thursday_Friday_Saturday'.split('_'),
weekdaysShort : 'Sun_Mon_Tue_Wed_Thu_Fri_Sat'.split('_'),
weekdaysMin : 'Su_Mo_Tu_We_Th_Fr_Sa'.split('_'),
diff --git a/locale/en-ie.js b/locale/en-ie.js
index 307dbe0..c0ff10c 100644
--- a/locale/en-ie.js
+++ b/locale/en-ie.js
@@ -13,9 +13,6 @@
var en_ie = moment.defineLocale('en-ie', {
months : 'January_February_March_April_May_June_July_August_September_October_November_December'.split('_'),
monthsShort : 'Jan_Feb_Mar_Apr_May_Jun_Jul_Aug_Sep_Oct_Nov_Dec'.split('_'),
- monthsParse : [/^jan/i, /^feb/i, /^mar/i, /^apr/i, /^may/i, /^jun/i, /^jul/i, /^aug/i, /^sep/i, /^oct/i, /^nov/i, /^dec/i],
- longMonthsParse : [/^january$/i, /^february$/i, /^march$/i, /^april$/i, /^may$/i, /^june$/i, /^july$/i, /^august$/i, /^september$/i, /^october$/i, /^november$/i, /^december$/i],
- shortMonthsParse : [/^jan$/i, /^feb$/i, /^mar$/i, /^apr$/i, /^may$/i, /^jun$/i, /^jul$/i, /^aug/i, /^sept?$/i, /^oct$/i, /^nov$/i, /^dec$/i],
weekdays : 'Sunday_Monday_Tuesday_Wednesday_Thursday_Friday_Saturday'.split('_'),
weekdaysShort : 'Sun_Mon_Tue_Wed_Thu_Fri_Sat'.split('_'),
weekdaysMin : 'Su_Mo_Tu_We_Th_Fr_Sa'.split('_'),
diff --git a/locale/en-nz.js b/locale/en-nz.js
index 29665f5..14a50ea 100644
--- a/locale/en-nz.js
+++ b/locale/en-nz.js
@@ -11,10 +11,7 @@
var en_nz = moment.defineLocale('en-nz', {
months : 'January_February_March_April_May_June_July_August_September_October_November_December'.split('_'),
- monthsShort : 'Jan_Feb_Mar_Apr_May_Jun_Jul_Aug_Sept_Oct_Nov_Dec'.split('_'),
- monthsParse : [/^jan/i, /^feb/i, /^mar/i, /^apr/i, /^may/i, /^jun/i, /^jul/i, /^aug/i, /^sep/i, /^oct/i, /^nov/i, /^dec/i],
- longMonthsParse : [/^january$/i, /^february$/i, /^march$/i, /^april$/i, /^may$/i, /^june$/i, /^july$/i, /^august$/i, /^september$/i, /^october$/i, /^november$/i, /^december$/i],
- shortMonthsParse : [/^jan$/i, /^feb$/i, /^mar$/i, /^apr$/i, /^may$/i, /^jun$/i, /^jul$/i, /^aug/i, /^sept?$/i, /^oct$/i, /^nov$/i, /^dec$/i],
+ monthsShort : 'Jan_Feb_Mar_Apr_May_Jun_Jul_Aug_Sep_Oct_Nov_Dec'.split('_'),
weekdays : 'Sunday_Monday_Tuesday_Wednesday_Thursday_Friday_Saturday'.split('_'),
weekdaysShort : 'Sun_Mon_Tue_Wed_Thu_Fri_Sat'.split('_'),
weekdaysMin : 'Su_Mo_Tu_We_Th_Fr_Sa'.split('_'),
diff --git a/locale/es.js b/locale/es.js
index efb51a3..555e94b 100644
--- a/locale/es.js
+++ b/locale/es.js
@@ -22,9 +22,11 @@
return monthsShortDot[m.month()];
}
},
+ monthsParseExact : true,
weekdays : 'domingo_lunes_martes_miércoles_jueves_viernes_sábado'.split('_'),
weekdaysShort : 'dom._lun._mar._mié._jue._vie._sáb.'.split('_'),
weekdaysMin : 'do_lu_ma_mi_ju_vi_sá'.split('_'),
+ weekdaysParseExact : true,
longDateFormat : {
LT : 'H:mm',
LTS : 'H:mm:ss',
diff --git a/locale/eu.js b/locale/eu.js
index 52db117..7383f89 100644
--- a/locale/eu.js
+++ b/locale/eu.js
@@ -13,9 +13,11 @@
var eu = moment.defineLocale('eu', {
months : 'urtarrila_otsaila_martxoa_apirila_maiatza_ekaina_uztaila_abuztua_iraila_urria_azaroa_abendua'.split('_'),
monthsShort : 'urt._ots._mar._api._mai._eka._uzt._abu._ira._urr._aza._abe.'.split('_'),
+ monthsParseExact : true,
weekdays : 'igandea_astelehena_asteartea_asteazkena_osteguna_ostirala_larunbata'.split('_'),
weekdaysShort : 'ig._al._ar._az._og._ol._lr.'.split('_'),
weekdaysMin : 'ig_al_ar_az_og_ol_lr'.split('_'),
+ weekdaysParseExact : true,
longDateFormat : {
LT : 'HH:mm',
LTS : 'HH:mm:ss',
diff --git a/locale/fa.js b/locale/fa.js
index de40e6f..e2bd7b0 100644
--- a/locale/fa.js
+++ b/locale/fa.js
@@ -40,6 +40,7 @@
weekdays : 'یک\u200cشنبه_دوشنبه_سه\u200cشنبه_چهارشنبه_پنج\u200cشنبه_جمعه_شنبه'.split('_'),
weekdaysShort : 'یک\u200cشنبه_دوشنبه_سه\u200cشنبه_چهارشنبه_پنج\u200cشنبه_جمعه_شنبه'.split('_'),
weekdaysMin : 'ی_د_س_چ_پ_ج_ش'.split('_'),
+ weekdaysParseExact : true,
longDateFormat : {
LT : 'HH:mm',
LTS : 'HH:mm:ss',
diff --git a/locale/fr-ca.js b/locale/fr-ca.js
index f15ec8d..52108b8 100644
--- a/locale/fr-ca.js
+++ b/locale/fr-ca.js
@@ -13,9 +13,11 @@
var fr_ca = moment.defineLocale('fr-ca', {
months : 'janvier_février_mars_avril_mai_juin_juillet_août_septembre_octobre_novembre_décembre'.split('_'),
monthsShort : 'janv._févr._mars_avr._mai_juin_juil._août_sept._oct._nov._déc.'.split('_'),
+ monthsParseExact : true,
weekdays : 'dimanche_lundi_mardi_mercredi_jeudi_vendredi_samedi'.split('_'),
weekdaysShort : 'dim._lun._mar._mer._jeu._ven._sam.'.split('_'),
weekdaysMin : 'Di_Lu_Ma_Me_Je_Ve_Sa'.split('_'),
+ weekdaysParseExact : true,
longDateFormat : {
LT : 'HH:mm',
LTS : 'HH:mm:ss',
diff --git a/locale/fr-ch.js b/locale/fr-ch.js
index 9503d80..876de40 100644
--- a/locale/fr-ch.js
+++ b/locale/fr-ch.js
@@ -13,9 +13,11 @@
var fr_ch = moment.defineLocale('fr-ch', {
months : 'janvier_février_mars_avril_mai_juin_juillet_août_septembre_octobre_novembre_décembre'.split('_'),
monthsShort : 'janv._févr._mars_avr._mai_juin_juil._août_sept._oct._nov._déc.'.split('_'),
+ monthsParseExact : true,
weekdays : 'dimanche_lundi_mardi_mercredi_jeudi_vendredi_samedi'.split('_'),
weekdaysShort : 'dim._lun._mar._mer._jeu._ven._sam.'.split('_'),
weekdaysMin : 'Di_Lu_Ma_Me_Je_Ve_Sa'.split('_'),
+ weekdaysParseExact : true,
longDateFormat : {
LT : 'HH:mm',
LTS : 'HH:mm:ss',
diff --git a/locale/fr.js b/locale/fr.js
index 8ef95c9..d08ebf1 100644
--- a/locale/fr.js
+++ b/locale/fr.js
@@ -13,9 +13,11 @@
var fr = moment.defineLocale('fr', {
months : 'janvier_février_mars_avril_mai_juin_juillet_août_septembre_octobre_novembre_décembre'.split('_'),
monthsShort : 'janv._févr._mars_avr._mai_juin_juil._août_sept._oct._nov._déc.'.split('_'),
+ monthsParseExact : true,
weekdays : 'dimanche_lundi_mardi_mercredi_jeudi_vendredi_samedi'.split('_'),
weekdaysShort : 'dim._lun._mar._mer._jeu._ven._sam.'.split('_'),
weekdaysMin : 'Di_Lu_Ma_Me_Je_Ve_Sa'.split('_'),
+ weekdaysParseExact : true,
longDateFormat : {
LT : 'HH:mm',
LTS : 'HH:mm:ss',
diff --git a/locale/fy.js b/locale/fy.js
index d1b709c..9d008ca 100644
--- a/locale/fy.js
+++ b/locale/fy.js
@@ -22,9 +22,11 @@
return monthsShortWithDots[m.month()];
}
},
+ monthsParseExact : true,
weekdays : 'snein_moandei_tiisdei_woansdei_tongersdei_freed_sneon'.split('_'),
weekdaysShort : 'si._mo._ti._wo._to._fr._so.'.split('_'),
weekdaysMin : 'Si_Mo_Ti_Wo_To_Fr_So'.split('_'),
+ weekdaysParseExact : true,
longDateFormat : {
LT : 'HH:mm',
LTS : 'HH:mm:ss',
diff --git a/locale/gd.js b/locale/gd.js
index 6da5e13..578e567 100644
--- a/locale/gd.js
+++ b/locale/gd.js
@@ -11,18 +11,7 @@
var months = [
- 'Am Faoilleach',
- 'An Gearran',
- 'Am Màrt',
- 'An Giblean',
- 'An Cèitean',
- 'An t-Ògmhios',
- 'An t-Iuchar',
- 'An Lùnastal',
- 'An t-Sultain',
- 'An Dàmhair',
- 'An t-Samhain',
- 'An Dùbhlachd'
+ 'Am Faoilleach', 'An Gearran', 'Am Màrt', 'An Giblean', 'An Cèitean', 'An t-Ògmhios', 'An t-Iuchar', 'An Lùnastal', 'An t-Sultain', 'An Dàmhair', 'An t-Samhain', 'An Dùbhlachd'
];
var monthsShort = ['Faoi', 'Gear', 'Màrt', 'Gibl', 'Cèit', 'Ògmh', 'Iuch', 'Lùn', 'Sult', 'Dàmh', 'Samh', 'Dùbh'];
@@ -36,6 +25,7 @@
var gd = moment.defineLocale('gd', {
months : months,
monthsShort : monthsShort,
+ monthsParseExact : true,
weekdays : weekdays,
weekdaysShort : weekdaysShort,
weekdaysMin : weekdaysMin,
diff --git a/locale/gl.js b/locale/gl.js
index ef8e704..0621d03 100644
--- a/locale/gl.js
+++ b/locale/gl.js
@@ -13,9 +13,11 @@
var gl = moment.defineLocale('gl', {
months : 'Xaneiro_Febreiro_Marzo_Abril_Maio_Xuño_Xullo_Agosto_Setembro_Outubro_Novembro_Decembro'.split('_'),
monthsShort : 'Xan._Feb._Mar._Abr._Mai._Xuñ._Xul._Ago._Set._Out._Nov._Dec.'.split('_'),
+ monthsParseExact: true,
weekdays : 'Domingo_Luns_Martes_Mércores_Xoves_Venres_Sábado'.split('_'),
weekdaysShort : 'Dom._Lun._Mar._Mér._Xov._Ven._Sáb.'.split('_'),
weekdaysMin : 'Do_Lu_Ma_Mé_Xo_Ve_Sá'.split('_'),
+ weekdaysParseExact : true,
longDateFormat : {
LT : 'H:mm',
LTS : 'H:mm:ss',
diff --git a/locale/he.js b/locale/he.js
index 6a259be..ffc3e1f 100644
--- a/locale/he.js
+++ b/locale/he.js
@@ -74,6 +74,23 @@
}
return number + ' שנים';
}
+ },
+ meridiemParse: /אחה"צ|לפנה"צ|אחרי הצהריים|לפני הצהריים|לפנות בוקר|בבוקר|בערב/i,
+ isPM : function (input) {
+ return /^(אחה"צ|אחרי הצהריים|בערב)$/.test(input);
+ },
+ meridiem : function (hour, minute, isLower) {
+ if (hour < 5) {
+ return 'לפנות בוקר';
+ } else if (hour < 10) {
+ return 'בבוקר';
+ } else if (hour < 12) {
+ return isLower ? 'לפנה"צ' : 'לפני הצהריים';
+ } else if (hour < 18) {
+ return isLower ? 'אחה"צ' : 'אחרי הצהריים';
+ } else {
+ return 'בערב';
+ }
}
});
diff --git a/locale/hi.js b/locale/hi.js
index 0542ef7..ebd272d 100644
--- a/locale/hi.js
+++ b/locale/hi.js
@@ -38,6 +38,7 @@
var hi = moment.defineLocale('hi', {
months : 'जनवरी_फ़रवरी_मार्च_अप्रैल_मई_जून_जुलाई_अगस्त_सितम्बर_अक्टूबर_नवम्बर_दिसम्बर'.split('_'),
monthsShort : 'जन._फ़र._मार्च_अप्रै._मई_जून_जुल._अग._सित._अक्टू._नव._दिस.'.split('_'),
+ monthsParseExact: true,
weekdays : 'रविवार_सोमवार_मंगलवार_बुधवार_गुरूवार_शुक्रवार_शनिवार'.split('_'),
weekdaysShort : 'रवि_सोम_मंगल_बुध_गुरू_शुक्र_शनि'.split('_'),
weekdaysMin : 'र_सो_मं_बु_गु_शु_श'.split('_'),
diff --git a/locale/hr.js b/locale/hr.js
index 2692383..a96f3a5 100644
--- a/locale/hr.js
+++ b/locale/hr.js
@@ -69,9 +69,11 @@
standalone: 'siječanj_veljača_ožujak_travanj_svibanj_lipanj_srpanj_kolovoz_rujan_listopad_studeni_prosinac'.split('_')
},
monthsShort : 'sij._velj._ožu._tra._svi._lip._srp._kol._ruj._lis._stu._pro.'.split('_'),
+ monthsParseExact: true,
weekdays : 'nedjelja_ponedjeljak_utorak_srijeda_četvrtak_petak_subota'.split('_'),
weekdaysShort : 'ned._pon._uto._sri._čet._pet._sub.'.split('_'),
weekdaysMin : 'ne_po_ut_sr_če_pe_su'.split('_'),
+ weekdaysParseExact : true,
longDateFormat : {
LT : 'H:mm',
LTS : 'H:mm:ss',
diff --git a/locale/is.js b/locale/is.js
index f1ed257..b6f63ca 100644
--- a/locale/is.js
+++ b/locale/is.js
@@ -86,7 +86,7 @@
longDateFormat : {
LT : 'H:mm',
LTS : 'H:mm:ss',
- L : 'DD/MM/YYYY',
+ L : 'DD.MM.YYYY',
LL : 'D. MMMM YYYY',
LLL : 'D. MMMM YYYY [kl.] H:mm',
LLLL : 'dddd, D. MMMM YYYY [kl.] H:mm'
diff --git a/locale/ja.js b/locale/ja.js
index 6c6e859..1475439 100644
--- a/locale/ja.js
+++ b/locale/ja.js
@@ -43,6 +43,17 @@
lastWeek : '[前週]dddd LT',
sameElse : 'L'
},
+ ordinalParse : /\d{1,2}日/,
+ ordinal : function (number, period) {
+ switch (period) {
+ case 'd':
+ case 'D':
+ case 'DDD':
+ return number + '日';
+ default:
+ return number;
+ }
+ },
relativeTime : {
future : '%s後',
past : '%s前',
diff --git a/locale/kk.js b/locale/kk.js
index 81acd0b..9c00588 100644
--- a/locale/kk.js
+++ b/locale/kk.js
@@ -34,11 +34,11 @@
};
var kk = moment.defineLocale('kk', {
- months : 'Қаңтар_Ақпан_Наурыз_Сәуір_Мамыр_Маусым_Шілде_Тамыз_Қыркүйек_Қазан_Қараша_Желтоқсан'.split('_'),
- monthsShort : 'Қаң_Ақп_Нау_Сәу_Мам_Мау_Шіл_Там_Қыр_Қаз_Қар_Жел'.split('_'),
- weekdays : 'Жексенбі_Дүйсенбі_Сейсенбі_Сәрсенбі_Бейсенбі_Жұма_Сенбі'.split('_'),
- weekdaysShort : 'Жек_Дүй_Сей_Сәр_Бей_Жұм_Сен'.split('_'),
- weekdaysMin : 'Жк_Дй_Сй_Ср_Бй_Жм_Сн'.split('_'),
+ months : 'қаңтар_ақпан_наурыз_сәуір_мамыр_маусым_шілде_тамыз_қыркүйек_қазан_қараша_желтоқсан'.split('_'),
+ monthsShort : 'қаң_ақп_нау_сәу_мам_мау_шіл_там_қыр_қаз_қар_жел'.split('_'),
+ weekdays : 'жексенбі_дүйсенбі_сейсенбі_сәрсенбі_бейсенбі_жұма_сенбі'.split('_'),
+ weekdaysShort : 'жек_дүй_сей_сәр_бей_жұм_сен'.split('_'),
+ weekdaysMin : 'жк_дй_сй_ср_бй_жм_сн'.split('_'),
longDateFormat : {
LT : 'HH:mm',
LTS : 'HH:mm:ss',
diff --git a/locale/km.js b/locale/km.js
index 56466c9..dcfd911 100644
--- a/locale/km.js
+++ b/locale/km.js
@@ -11,8 +11,8 @@
var km = moment.defineLocale('km', {
- months: 'មករា_កុម្ភៈ_មិនា_មេសា_ឧសភា_មិថុនា_កក្កដា_សីហា_កញ្ញា_តុលា_វិច្ឆិកា_ធ្នូ'.split('_'),
- monthsShort: 'មករា_កុម្ភៈ_មិនា_មេសា_ឧសភា_មិថុនា_កក្កដា_សីហា_កញ្ញា_តុលា_វិច្ឆិកា_ធ្នូ'.split('_'),
+ months: 'មករា_កុម្ភៈ_មីនា_មេសា_ឧសភា_មិថុនា_កក្កដា_សីហា_កញ្ញា_តុលា_វិច្ឆិកា_ធ្នូ'.split('_'),
+ monthsShort: 'មករា_កុម្ភៈ_មីនា_មេសា_ឧសភា_មិថុនា_កក្កដា_សីហា_កញ្ញា_តុលា_វិច្ឆិកា_ធ្នូ'.split('_'),
weekdays: 'អាទិត្យ_ច័ន្ទ_អង្គារ_ពុធ_ព្រហស្បតិ៍_សុក្រ_សៅរ៍'.split('_'),
weekdaysShort: 'អាទិត្យ_ច័ន្ទ_អង្គារ_ពុធ_ព្រហស្បតិ៍_សុក្រ_សៅរ៍'.split('_'),
weekdaysMin: 'អាទិត្យ_ច័ន្ទ_អង្គារ_ពុធ_ព្រហស្បតិ៍_សុក្រ_សៅរ៍'.split('_'),
diff --git a/locale/ko.js b/locale/ko.js
index 151554a..0481987 100644
--- a/locale/ko.js
+++ b/locale/ko.js
@@ -39,17 +39,17 @@
relativeTime : {
future : '%s 후',
past : '%s 전',
- s : '몇초',
+ s : '몇 초',
ss : '%d초',
m : '일분',
mm : '%d분',
- h : '한시간',
+ h : '한 시간',
hh : '%d시간',
d : '하루',
dd : '%d일',
- M : '한달',
+ M : '한 달',
MM : '%d달',
- y : '일년',
+ y : '일 년',
yy : '%d년'
},
ordinalParse : /\d{1,2}일/,
diff --git a/locale/ky.js b/locale/ky.js
new file mode 100644
index 0000000..346adb7
--- /dev/null
+++ b/locale/ky.js
@@ -0,0 +1,88 @@
+//! moment.js locale configuration
+//! locale : kyrgyz (ky)
+//! author : Chyngyz Arystan uulu : https://github.com/chyngyz
+
+;(function (global, factory) {
+ typeof exports === 'object' && typeof module !== 'undefined'
+ && typeof require === 'function' ? factory(require('../moment')) :
+ typeof define === 'function' && define.amd ? define(['moment'], factory) :
+ factory(global.moment)
+}(this, function (moment) { 'use strict';
+
+
+
+ var suffixes = {
+ 0: '-чү',
+ 1: '-чи',
+ 2: '-чи',
+ 3: '-чү',
+ 4: '-чү',
+ 5: '-чи',
+ 6: '-чы',
+ 7: '-чи',
+ 8: '-чи',
+ 9: '-чу',
+ 10: '-чу',
+ 20: '-чы',
+ 30: '-чу',
+ 40: '-чы',
+ 50: '-чү',
+ 60: '-чы',
+ 70: '-чи',
+ 80: '-чи',
+ 90: '-чу',
+ 100: '-чү'
+ };
+
+ var ky = moment.defineLocale('ky', {
+ months : 'январь_февраль_март_апрель_май_июнь_июль_август_сентябрь_октябрь_ноябрь_декабрь'.split('_'),
+ monthsShort : 'янв_фев_март_апр_май_июнь_июль_авг_сен_окт_ноя_дек'.split('_'),
+ weekdays : 'Жекшемби_Дүйшөмбү_Шейшемби_Шаршемби_Бейшемби_Жума_Ишемби'.split('_'),
+ weekdaysShort : 'Жек_Дүй_Шей_Шар_Бей_Жум_Ише'.split('_'),
+ weekdaysMin : 'Жк_Дй_Шй_Шр_Бй_Жм_Иш'.split('_'),
+ longDateFormat : {
+ LT : 'HH:mm',
+ LTS : 'HH:mm:ss',
+ L : 'DD.MM.YYYY',
+ LL : 'D MMMM YYYY',
+ LLL : 'D MMMM YYYY HH:mm',
+ LLLL : 'dddd, D MMMM YYYY HH:mm'
+ },
+ calendar : {
+ sameDay : '[Бүгүн саат] LT',
+ nextDay : '[Эртең саат] LT',
+ nextWeek : 'dddd [саат] LT',
+ lastDay : '[Кече саат] LT',
+ lastWeek : '[Өткен аптанын] dddd [күнү] [саат] LT',
+ sameElse : 'L'
+ },
+ relativeTime : {
+ future : '%s ичинде',
+ past : '%s мурун',
+ s : 'бирнече секунд',
+ m : 'бир мүнөт',
+ mm : '%d мүнөт',
+ h : 'бир саат',
+ hh : '%d саат',
+ d : 'бир күн',
+ dd : '%d күн',
+ M : 'бир ай',
+ MM : '%d ай',
+ y : 'бир жыл',
+ yy : '%d жыл'
+ },
+ ordinalParse: /\d{1,2}-(чи|чы|чү|чу)/,
+ ordinal : function (number) {
+ var a = number % 10,
+ b = number >= 100 ? 100 : null;
+ return number + (suffixes[number] || suffixes[a] || suffixes[b]);
+ },
+ week : {
+ dow : 1, // Monday is the first day of the week.
+ doy : 7 // The week that contains Jan 1st is the first week of the year.
+ }
+ });
+
+ return ky;
+
+}));
\ No newline at end of file
diff --git a/locale/lb.js b/locale/lb.js
index 6713c08..bd51b39 100644
--- a/locale/lb.js
+++ b/locale/lb.js
@@ -78,9 +78,11 @@
var lb = moment.defineLocale('lb', {
months: 'Januar_Februar_Mäerz_Abrëll_Mee_Juni_Juli_August_September_Oktober_November_Dezember'.split('_'),
monthsShort: 'Jan._Febr._Mrz._Abr._Mee_Jun._Jul._Aug._Sept._Okt._Nov._Dez.'.split('_'),
+ monthsParseExact : true,
weekdays: 'Sonndeg_Méindeg_Dënschdeg_Mëttwoch_Donneschdeg_Freideg_Samschdeg'.split('_'),
weekdaysShort: 'So._Mé._Dë._Më._Do._Fr._Sa.'.split('_'),
weekdaysMin: 'So_Mé_Dë_Më_Do_Fr_Sa'.split('_'),
+ weekdaysParseExact : true,
longDateFormat: {
LT: 'H:mm [Auer]',
LTS: 'H:mm:ss [Auer]',
diff --git a/locale/lo.js b/locale/lo.js
index 7475f27..9171fd7 100644
--- a/locale/lo.js
+++ b/locale/lo.js
@@ -16,6 +16,7 @@
weekdays : 'ອາທິດ_ຈັນ_ອັງຄານ_ພຸດ_ພະຫັດ_ສຸກ_ເສົາ'.split('_'),
weekdaysShort : 'ທິດ_ຈັນ_ອັງຄານ_ພຸດ_ພະຫັດ_ສຸກ_ເສົາ'.split('_'),
weekdaysMin : 'ທ_ຈ_ອຄ_ພ_ພຫ_ສກ_ສ'.split('_'),
+ weekdaysParseExact : true,
longDateFormat : {
LT : 'HH:mm',
LTS : 'HH:mm:ss',
diff --git a/locale/lt.js b/locale/lt.js
index 72566bf..a3f05d4 100644
--- a/locale/lt.js
+++ b/locale/lt.js
@@ -65,6 +65,7 @@
},
weekdaysShort : 'Sek_Pir_Ant_Tre_Ket_Pen_Šeš'.split('_'),
weekdaysMin : 'S_P_A_T_K_Pn_Š'.split('_'),
+ weekdaysParseExact : true,
longDateFormat : {
LT : 'HH:mm',
LTS : 'HH:mm:ss',
diff --git a/locale/lv.js b/locale/lv.js
index d1864a1..21e00b0 100644
--- a/locale/lv.js
+++ b/locale/lv.js
@@ -52,6 +52,7 @@
weekdays : 'svētdiena_pirmdiena_otrdiena_trešdiena_ceturtdiena_piektdiena_sestdiena'.split('_'),
weekdaysShort : 'Sv_P_O_T_C_Pk_S'.split('_'),
weekdaysMin : 'Sv_P_O_T_C_Pk_S'.split('_'),
+ weekdaysParseExact : true,
longDateFormat : {
LT : 'HH:mm',
LTS : 'HH:mm:ss',
diff --git a/locale/me.js b/locale/me.js
index e2c1f75..a78cf5a 100644
--- a/locale/me.js
+++ b/locale/me.js
@@ -34,11 +34,13 @@
};
var me = moment.defineLocale('me', {
- months: ['januar', 'februar', 'mart', 'april', 'maj', 'jun', 'jul', 'avgust', 'septembar', 'oktobar', 'novembar', 'decembar'],
- monthsShort: ['jan.', 'feb.', 'mar.', 'apr.', 'maj', 'jun', 'jul', 'avg.', 'sep.', 'okt.', 'nov.', 'dec.'],
- weekdays: ['nedjelja', 'ponedjeljak', 'utorak', 'srijeda', 'četvrtak', 'petak', 'subota'],
- weekdaysShort: ['ned.', 'pon.', 'uto.', 'sri.', 'čet.', 'pet.', 'sub.'],
- weekdaysMin: ['ne', 'po', 'ut', 'sr', 'če', 'pe', 'su'],
+ months: 'januar_februar_mart_april_maj_jun_jul_avgust_septembar_oktobar_novembar_decembar'.split('_'),
+ monthsShort: 'jan._feb._mar._apr._maj_jun_jul_avg._sep._okt._nov._dec.'.split('_'),
+ monthsParseExact : true,
+ weekdays: 'nedjelja_ponedjeljak_utorak_srijeda_četvrtak_petak_subota'.split('_'),
+ weekdaysShort: 'ned._pon._uto._sri._čet._pet._sub.'.split('_'),
+ weekdaysMin: 'ne_po_ut_sr_če_pe_su'.split('_'),
+ weekdaysParseExact : true,
longDateFormat: {
LT: 'H:mm',
LTS : 'H:mm:ss',
diff --git a/locale/ml.js b/locale/ml.js
index 9e241f2..4ffe931 100644
--- a/locale/ml.js
+++ b/locale/ml.js
@@ -13,6 +13,7 @@
var ml = moment.defineLocale('ml', {
months : 'ജനുവരി_ഫെബ്രുവരി_മാർച്ച്_ഏപ്രിൽ_മേയ്_ജൂൺ_ജൂലൈ_ഓഗസ്റ്റ്_സെപ്റ്റംബർ_ഒക്ടോബർ_നവംബർ_ഡിസംബർ'.split('_'),
monthsShort : 'ജനു._ഫെബ്രു._മാർ._ഏപ്രി._മേയ്_ജൂൺ_ജൂലൈ._ഓഗ._സെപ്റ്റ._ഒക്ടോ._നവം._ഡിസം.'.split('_'),
+ monthsParseExact : true,
weekdays : 'ഞായറാഴ്ച_തിങ്കളാഴ്ച_ചൊവ്വാഴ്ച_ബുധനാഴ്ച_വ്യാഴാഴ്ച_വെള്ളിയാഴ്ച_ശനിയാഴ്ച'.split('_'),
weekdaysShort : 'ഞായർ_തിങ്കൾ_ചൊവ്വ_ബുധൻ_വ്യാഴം_വെള്ളി_ശനി'.split('_'),
weekdaysMin : 'ഞാ_തി_ചൊ_ബു_വ്യാ_വെ_ശ'.split('_'),
@@ -48,8 +49,17 @@
yy : '%d വർഷം'
},
meridiemParse: /രാത്രി|രാവിലെ|ഉച്ച കഴിഞ്ഞ്|വൈകുന്നേരം|രാത്രി/i,
- isPM : function (input) {
- return /^(ഉച്ച കഴിഞ്ഞ്|വൈകുന്നേരം|രാത്രി)$/.test(input);
+ meridiemHour : function (hour, meridiem) {
+ if (hour === 12) {
+ hour = 0;
+ }
+ if ((meridiem === 'രാത്രി' && hour >= 4) ||
+ meridiem === 'ഉച്ച കഴിഞ്ഞ്' ||
+ meridiem === 'വൈകുന്നേരം') {
+ return hour + 12;
+ } else {
+ return hour;
+ }
},
meridiem : function (hour, minute, isLower) {
if (hour < 4) {
diff --git a/locale/mr.js b/locale/mr.js
index 77a3fa2..2bdf262 100644
--- a/locale/mr.js
+++ b/locale/mr.js
@@ -75,6 +75,7 @@
var mr = moment.defineLocale('mr', {
months : 'जानेवारी_फेब्रुवारी_मार्च_एप्रिल_मे_जून_जुलै_ऑगस्ट_सप्टेंबर_ऑक्टोबर_नोव्हेंबर_डिसेंबर'.split('_'),
monthsShort: 'जाने._फेब्रु._मार्च._एप्रि._मे._जून._जुलै._ऑग._सप्टें._ऑक्टो._नोव्हें._डिसें.'.split('_'),
+ monthsParseExact : true,
weekdays : 'रविवार_सोमवार_मंगळवार_बुधवार_गुरूवार_शुक्रवार_शनिवार'.split('_'),
weekdaysShort : 'रवि_सोम_मंगळ_बुध_गुरू_शुक्र_शनि'.split('_'),
weekdaysMin : 'र_सो_मं_बु_गु_शु_श'.split('_'),
diff --git a/locale/nb.js b/locale/nb.js
index b8d76c6..45b57a1 100644
--- a/locale/nb.js
+++ b/locale/nb.js
@@ -14,9 +14,11 @@
var nb = moment.defineLocale('nb', {
months : 'januar_februar_mars_april_mai_juni_juli_august_september_oktober_november_desember'.split('_'),
monthsShort : 'jan._feb._mars_april_mai_juni_juli_aug._sep._okt._nov._des.'.split('_'),
+ monthsParseExact : true,
weekdays : 'søndag_mandag_tirsdag_onsdag_torsdag_fredag_lørdag'.split('_'),
weekdaysShort : 'sø._ma._ti._on._to._fr._lø.'.split('_'),
weekdaysMin : 'sø_ma_ti_on_to_fr_lø'.split('_'),
+ weekdaysParseExact : true,
longDateFormat : {
LT : 'HH:mm',
LTS : 'HH:mm:ss',
@@ -35,7 +37,7 @@
},
relativeTime : {
future : 'om %s',
- past : 'for %s siden',
+ past : '%s siden',
s : 'noen sekunder',
m : 'ett minutt',
mm : '%d minutter',
diff --git a/locale/ne.js b/locale/ne.js
index 3476401..f40eb8d 100644
--- a/locale/ne.js
+++ b/locale/ne.js
@@ -38,9 +38,11 @@
var ne = moment.defineLocale('ne', {
months : 'जनवरी_फेब्रुवरी_मार्च_अप्रिल_मई_जुन_जुलाई_अगष्ट_सेप्टेम्बर_अक्टोबर_नोभेम्बर_डिसेम्बर'.split('_'),
monthsShort : 'जन._फेब्रु._मार्च_अप्रि._मई_जुन_जुलाई._अग._सेप्ट._अक्टो._नोभे._डिसे.'.split('_'),
+ monthsParseExact : true,
weekdays : 'आइतबार_सोमबार_मङ्गलबार_बुधबार_बिहिबार_शुक्रबार_शनिबार'.split('_'),
weekdaysShort : 'आइत._सोम._मङ्गल._बुध._बिहि._शुक्र._शनि.'.split('_'),
weekdaysMin : 'आ._सो._मं._बु._बि._शु._श.'.split('_'),
+ weekdaysParseExact : true,
longDateFormat : {
LT : 'Aको h:mm बजे',
LTS : 'Aको h:mm:ss बजे',
diff --git a/locale/nl.js b/locale/nl.js
index 1ae4700..df36a45 100644
--- a/locale/nl.js
+++ b/locale/nl.js
@@ -22,9 +22,11 @@
return monthsShortWithDots[m.month()];
}
},
+ monthsParseExact : true,
weekdays : 'zondag_maandag_dinsdag_woensdag_donderdag_vrijdag_zaterdag'.split('_'),
weekdaysShort : 'zo._ma._di._wo._do._vr._za.'.split('_'),
weekdaysMin : 'Zo_Ma_Di_Wo_Do_Vr_Za'.split('_'),
+ weekdaysParseExact : true,
longDateFormat : {
LT : 'HH:mm',
LTS : 'HH:mm:ss',
diff --git a/locale/nn.js b/locale/nn.js
index 3910bb9..980b530 100644
--- a/locale/nn.js
+++ b/locale/nn.js
@@ -34,7 +34,7 @@
},
relativeTime : {
future : 'om %s',
- past : 'for %s sidan',
+ past : '%s sidan',
s : 'nokre sekund',
m : 'eit minutt',
mm : '%d minutt',
diff --git a/locale/pa-in.js b/locale/pa-in.js
new file mode 100644
index 0000000..1d4e366
--- /dev/null
+++ b/locale/pa-in.js
@@ -0,0 +1,124 @@
+//! moment.js locale configuration
+//! locale : punjabi india (pa-in)
+//! author : Harpreet Singh : https://github.com/harpreetkhalsagtbit
+
+;(function (global, factory) {
+ typeof exports === 'object' && typeof module !== 'undefined'
+ && typeof require === 'function' ? factory(require('../moment')) :
+ typeof define === 'function' && define.amd ? define(['moment'], factory) :
+ factory(global.moment)
+}(this, function (moment) { 'use strict';
+
+
+ var symbolMap = {
+ '1': '੧',
+ '2': '੨',
+ '3': '੩',
+ '4': '੪',
+ '5': '੫',
+ '6': '੬',
+ '7': '੭',
+ '8': '੮',
+ '9': '੯',
+ '0': '੦'
+ },
+ numberMap = {
+ '੧': '1',
+ '੨': '2',
+ '੩': '3',
+ '੪': '4',
+ '੫': '5',
+ '੬': '6',
+ '੭': '7',
+ '੮': '8',
+ '੯': '9',
+ '੦': '0'
+ };
+
+ var pa_in = moment.defineLocale('pa-in', {
+ // There are months name as per Nanakshahi Calender but they are not used as rigidly in modern Punjabi.
+ months : 'ਜਨਵਰੀ_ਫ਼ਰਵਰੀ_ਮਾਰਚ_ਅਪ੍ਰੈਲ_ਮਈ_ਜੂਨ_ਜੁਲਾਈ_ਅਗਸਤ_ਸਤੰਬਰ_ਅਕਤੂਬਰ_ਨਵੰਬਰ_ਦਸੰਬਰ'.split('_'),
+ monthsShort : 'ਜਨਵਰੀ_ਫ਼ਰਵਰੀ_ਮਾਰਚ_ਅਪ੍ਰੈਲ_ਮਈ_ਜੂਨ_ਜੁਲਾਈ_ਅਗਸਤ_ਸਤੰਬਰ_ਅਕਤੂਬਰ_ਨਵੰਬਰ_ਦਸੰਬਰ'.split('_'),
+ weekdays : 'ਐਤਵਾਰ_ਸੋਮਵਾਰ_ਮੰਗਲਵਾਰ_ਬੁਧਵਾਰ_ਵੀਰਵਾਰ_ਸ਼ੁੱਕਰਵਾਰ_ਸ਼ਨੀਚਰਵਾਰ'.split('_'),
+ weekdaysShort : 'ਐਤ_ਸੋਮ_ਮੰਗਲ_ਬੁਧ_ਵੀਰ_ਸ਼ੁਕਰ_ਸ਼ਨੀ'.split('_'),
+ weekdaysMin : 'ਐਤ_ਸੋਮ_ਮੰਗਲ_ਬੁਧ_ਵੀਰ_ਸ਼ੁਕਰ_ਸ਼ਨੀ'.split('_'),
+ longDateFormat : {
+ LT : 'A h:mm ਵਜੇ',
+ LTS : 'A h:mm:ss ਵਜੇ',
+ L : 'DD/MM/YYYY',
+ LL : 'D MMMM YYYY',
+ LLL : 'D MMMM YYYY, A h:mm ਵਜੇ',
+ LLLL : 'dddd, D MMMM YYYY, A h:mm ਵਜੇ'
+ },
+ calendar : {
+ sameDay : '[ਅਜ] LT',
+ nextDay : '[ਕਲ] LT',
+ nextWeek : 'dddd, LT',
+ lastDay : '[ਕਲ] LT',
+ lastWeek : '[ਪਿਛਲੇ] dddd, LT',
+ sameElse : 'L'
+ },
+ relativeTime : {
+ future : '%s ਵਿੱਚ',
+ past : '%s ਪਿਛਲੇ',
+ s : 'ਕੁਝ ਸਕਿੰਟ',
+ m : 'ਇਕ ਮਿੰਟ',
+ mm : '%d ਮਿੰਟ',
+ h : 'ਇੱਕ ਘੰਟਾ',
+ hh : '%d ਘੰਟੇ',
+ d : 'ਇੱਕ ਦਿਨ',
+ dd : '%d ਦਿਨ',
+ M : 'ਇੱਕ ਮਹੀਨਾ',
+ MM : '%d ਮਹੀਨੇ',
+ y : 'ਇੱਕ ਸਾਲ',
+ yy : '%d ਸਾਲ'
+ },
+ preparse: function (string) {
+ return string.replace(/[੧੨੩੪੫੬੭੮੯੦]/g, function (match) {
+ return numberMap[match];
+ });
+ },
+ postformat: function (string) {
+ return string.replace(/\d/g, function (match) {
+ return symbolMap[match];
+ });
+ },
+ // Punjabi notation for meridiems are quite fuzzy in practice. While there exists
+ // a rigid notion of a 'Pahar' it is not used as rigidly in modern Punjabi.
+ meridiemParse: /ਰਾਤ|ਸਵੇਰ|ਦੁਪਹਿਰ|ਸ਼ਾਮ/,
+ meridiemHour : function (hour, meridiem) {
+ if (hour === 12) {
+ hour = 0;
+ }
+ if (meridiem === 'ਰਾਤ') {
+ return hour < 4 ? hour : hour + 12;
+ } else if (meridiem === 'ਸਵੇਰ') {
+ return hour;
+ } else if (meridiem === 'ਦੁਪਹਿਰ') {
+ return hour >= 10 ? hour : hour + 12;
+ } else if (meridiem === 'ਸ਼ਾਮ') {
+ return hour + 12;
+ }
+ },
+ meridiem : function (hour, minute, isLower) {
+ if (hour < 4) {
+ return 'ਰਾਤ';
+ } else if (hour < 10) {
+ return 'ਸਵੇਰ';
+ } else if (hour < 17) {
+ return 'ਦੁਪਹਿਰ';
+ } else if (hour < 20) {
+ return 'ਸ਼ਾਮ';
+ } else {
+ return 'ਰਾਤ';
+ }
+ },
+ week : {
+ dow : 0, // Sunday is the first day of the week.
+ doy : 6 // The week that contains Jan 1st is the first week of the year.
+ }
+ });
+
+ return pa_in;
+
+}));
\ No newline at end of file
diff --git a/locale/pt-br.js b/locale/pt-br.js
index 06747f6..84e6cdd 100644
--- a/locale/pt-br.js
+++ b/locale/pt-br.js
@@ -13,9 +13,10 @@
var pt_br = moment.defineLocale('pt-br', {
months : 'Janeiro_Fevereiro_Março_Abril_Maio_Junho_Julho_Agosto_Setembro_Outubro_Novembro_Dezembro'.split('_'),
monthsShort : 'Jan_Fev_Mar_Abr_Mai_Jun_Jul_Ago_Set_Out_Nov_Dez'.split('_'),
- weekdays : 'Domingo_Segunda-Feira_Terça-Feira_Quarta-Feira_Quinta-Feira_Sexta-Feira_Sábado'.split('_'),
+ weekdays : 'Domingo_Segunda-feira_Terça-feira_Quarta-feira_Quinta-feira_Sexta-feira_Sábado'.split('_'),
weekdaysShort : 'Dom_Seg_Ter_Qua_Qui_Sex_Sáb'.split('_'),
weekdaysMin : 'Dom_2ª_3ª_4ª_5ª_6ª_Sáb'.split('_'),
+ weekdaysParseExact : true,
longDateFormat : {
LT : 'HH:mm',
LTS : 'HH:mm:ss',
diff --git a/locale/pt.js b/locale/pt.js
index bdb913f..b7fcd5a 100644
--- a/locale/pt.js
+++ b/locale/pt.js
@@ -16,6 +16,7 @@
weekdays : 'Domingo_Segunda-Feira_Terça-Feira_Quarta-Feira_Quinta-Feira_Sexta-Feira_Sábado'.split('_'),
weekdaysShort : 'Dom_Seg_Ter_Qua_Qui_Sex_Sáb'.split('_'),
weekdaysMin : 'Dom_2ª_3ª_4ª_5ª_6ª_Sáb'.split('_'),
+ weekdaysParseExact : true,
longDateFormat : {
LT : 'HH:mm',
LTS : 'HH:mm:ss',
diff --git a/locale/ro.js b/locale/ro.js
index fb92267..09ffc19 100644
--- a/locale/ro.js
+++ b/locale/ro.js
@@ -29,6 +29,7 @@
var ro = moment.defineLocale('ro', {
months : 'ianuarie_februarie_martie_aprilie_mai_iunie_iulie_august_septembrie_octombrie_noiembrie_decembrie'.split('_'),
monthsShort : 'ian._febr._mart._apr._mai_iun._iul._aug._sept._oct._nov._dec.'.split('_'),
+ monthsParseExact: true,
weekdays : 'duminică_luni_marți_miercuri_joi_vineri_sâmbătă'.split('_'),
weekdaysShort : 'Dum_Lun_Mar_Mie_Joi_Vin_Sâm'.split('_'),
weekdaysMin : 'Du_Lu_Ma_Mi_Jo_Vi_Sâ'.split('_'),
diff --git a/locale/ru.js b/locale/ru.js
index 442ddf8..ec3df2e 100644
--- a/locale/ru.js
+++ b/locale/ru.js
@@ -2,6 +2,7 @@
//! locale : russian (ru)
//! author : Viktorminator : https://github.com/Viktorminator
//! Author : Menelion Elensúle : https://github.com/Oire
+//! author : Коренберг Марк : https://github.com/socketpair
;(function (global, factory) {
typeof exports === 'object' && typeof module !== 'undefined'
@@ -30,27 +31,35 @@
return number + ' ' + plural(format[key], +number);
}
}
- var monthsParse = [/^янв/i, /^фев/i, /^мар/i, /^апр/i, /^ма[й|я]/i, /^июн/i, /^июл/i, /^авг/i, /^сен/i, /^окт/i, /^ноя/i, /^дек/i];
+ var monthsParse = [/^янв/i, /^фев/i, /^мар/i, /^апр/i, /^ма[йя]/i, /^июн/i, /^июл/i, /^авг/i, /^сен/i, /^окт/i, /^ноя/i, /^дек/i];
+ // http://new.gramota.ru/spravka/rules/139-prop : § 103
+ // Сокращения месяцев: http://new.gramota.ru/spravka/buro/search-answer?s=242637
+ // CLDR data: http://www.unicode.org/cldr/charts/28/summary/ru.html#1753
var ru = moment.defineLocale('ru', {
months : {
- format: 'Января_Февраля_Марта_Апреля_Мая_Июня_Июля_Августа_Сентября_Октября_Ноября_Декабря'.split('_'),
- standalone: 'Январь_Февраль_Март_Апрель_Май_Июнь_Июль_Август_Сентябрь_Октябрь_Ноябрь_Декабрь'.split('_')
+ format: 'января_февраля_марта_апреля_мая_июня_июля_августа_сентября_октября_ноября_декабря'.split('_'),
+ standalone: 'январь_февраль_март_апрель_май_июнь_июль_август_сентябрь_октябрь_ноябрь_декабрь'.split('_')
},
monthsShort : {
- format: 'янв_фев_мар_апр_мая_июня_июля_авг_сен_окт_ноя_дек'.split('_'),
- standalone: 'янв_фев_март_апр_май_июнь_июль_авг_сен_окт_ноя_дек'.split('_')
+ // по CLDR именно "июл." и "июн.", но какой смысл менять букву на точку ?
+ format: 'янв._февр._мар._апр._мая_июня_июля_авг._сент._окт._нояб._дек.'.split('_'),
+ standalone: 'янв._февр._март_апр._май_июнь_июль_авг._сент._окт._нояб._дек.'.split('_')
},
weekdays : {
- standalone: 'Воскресенье_Понедельник_Вторник_Среда_Четверг_Пятница_Суббота'.split('_'),
- format: 'Воскресенье_Понедельник_Вторник_Среду_Четверг_Пятницу_Субботу'.split('_'),
+ standalone: 'воскресенье_понедельник_вторник_среда_четверг_пятница_суббота'.split('_'),
+ format: 'воскресенье_понедельник_вторник_среду_четверг_пятницу_субботу'.split('_'),
isFormat: /\[ ?[Вв] ?(?:прошлую|следующую|эту)? ?\] ?dddd/
},
- weekdaysShort : 'Вс_Пн_Вт_Ср_Чт_Пт_Сб'.split('_'),
- weekdaysMin : 'Вс_Пн_Вт_Ср_Чт_Пт_Сб'.split('_'),
+ weekdaysShort : 'вс_пн_вт_ср_чт_пт_сб'.split('_'),
+ weekdaysMin : 'вс_пн_вт_ср_чт_пт_сб'.split('_'),
monthsParse : monthsParse,
longMonthsParse : monthsParse,
shortMonthsParse : monthsParse,
+ monthsRegex: /^(сентябр[яь]|октябр[яь]|декабр[яь]|феврал[яь]|январ[яь]|апрел[яь]|августа?|ноябр[яь]|сент\.|февр\.|нояб\.|июнь|янв.|июль|дек.|авг.|апр.|марта|мар[.т]|окт.|июн[яь]|июл[яь]|ма[яй])/i,
+ monthsShortRegex: /^(сентябр[яь]|октябр[яь]|декабр[яь]|феврал[яь]|январ[яь]|апрел[яь]|августа?|ноябр[яь]|сент\.|февр\.|нояб\.|июнь|янв.|июль|дек.|авг.|апр.|марта|мар[.т]|окт.|июн[яь]|июл[яь]|ма[яй])/i,
+ monthsStrictRegex: /^(сентябр[яь]|октябр[яь]|декабр[яь]|феврал[яь]|январ[яь]|апрел[яь]|августа?|ноябр[яь]|марта?|июн[яь]|июл[яь]|ма[яй])/i,
+ monthsShortStrictRegex: /^(нояб\.|февр\.|сент\.|июль|янв\.|июн[яь]|мар[.т]|авг\.|апр\.|окт\.|дек\.|ма[яй])/i,
longDateFormat : {
LT : 'HH:mm',
LTS : 'HH:mm:ss',
diff --git a/locale/si.js b/locale/si.js
index d86c9e3..8a77164 100644
--- a/locale/si.js
+++ b/locale/si.js
@@ -17,6 +17,7 @@
weekdays : 'ඉරිදා_සඳුදා_අඟහරුවාදා_බදාදා_බ්රහස්පතින්දා_සිකුරාදා_සෙනසුරාදා'.split('_'),
weekdaysShort : 'ඉරි_සඳු_අඟ_බදා_බ්රහ_සිකු_සෙන'.split('_'),
weekdaysMin : 'ඉ_ස_අ_බ_බ්ර_සි_සෙ'.split('_'),
+ weekdaysParseExact : true,
longDateFormat : {
LT : 'a h:mm',
LTS : 'a h:mm:ss',
@@ -52,6 +53,10 @@
ordinal : function (number) {
return number + ' වැනි';
},
+ meridiemParse : /පෙර වරු|පස් වරු|පෙ.ව|ප.ව./,
+ isPM : function (input) {
+ return input === 'ප.ව.' || input === 'පස් වරු';
+ },
meridiem : function (hours, minutes, isLower) {
if (hours > 11) {
return isLower ? 'ප.ව.' : 'පස් වරු';
diff --git a/locale/sl.js b/locale/sl.js
index 68d261e..a6bb706 100644
--- a/locale/sl.js
+++ b/locale/sl.js
@@ -84,9 +84,11 @@
var sl = moment.defineLocale('sl', {
months : 'januar_februar_marec_april_maj_junij_julij_avgust_september_oktober_november_december'.split('_'),
monthsShort : 'jan._feb._mar._apr._maj._jun._jul._avg._sep._okt._nov._dec.'.split('_'),
+ monthsParseExact: true,
weekdays : 'nedelja_ponedeljek_torek_sreda_četrtek_petek_sobota'.split('_'),
weekdaysShort : 'ned._pon._tor._sre._čet._pet._sob.'.split('_'),
weekdaysMin : 'ne_po_to_sr_če_pe_so'.split('_'),
+ weekdaysParseExact : true,
longDateFormat : {
LT : 'H:mm',
LTS : 'H:mm:ss',
diff --git a/locale/sq.js b/locale/sq.js
index 69dca20..68dbc14 100644
--- a/locale/sq.js
+++ b/locale/sq.js
@@ -18,6 +18,7 @@
weekdays : 'E Diel_E Hënë_E Martë_E Mërkurë_E Enjte_E Premte_E Shtunë'.split('_'),
weekdaysShort : 'Die_Hën_Mar_Mër_Enj_Pre_Sht'.split('_'),
weekdaysMin : 'D_H_Ma_Më_E_P_Sh'.split('_'),
+ weekdaysParseExact : true,
meridiemParse: /PD|MD/,
isPM: function (input) {
return input.charAt(0) === 'M';
diff --git a/locale/sr-cyrl.js b/locale/sr-cyrl.js
index c72cca7..42f9ed4 100644
--- a/locale/sr-cyrl.js
+++ b/locale/sr-cyrl.js
@@ -34,11 +34,13 @@
};
var sr_cyrl = moment.defineLocale('sr-cyrl', {
- months: ['јануар', 'фебруар', 'март', 'април', 'мај', 'јун', 'јул', 'август', 'септембар', 'октобар', 'новембар', 'децембар'],
- monthsShort: ['јан.', 'феб.', 'мар.', 'апр.', 'мај', 'јун', 'јул', 'авг.', 'сеп.', 'окт.', 'нов.', 'дец.'],
- weekdays: ['недеља', 'понедељак', 'уторак', 'среда', 'четвртак', 'петак', 'субота'],
- weekdaysShort: ['нед.', 'пон.', 'уто.', 'сре.', 'чет.', 'пет.', 'суб.'],
- weekdaysMin: ['не', 'по', 'ут', 'ср', 'че', 'пе', 'су'],
+ months: 'јануар_фебруар_март_април_мај_јун_јул_август_септембар_октобар_новембар_децембар'.split('_'),
+ monthsShort: 'јан._феб._мар._апр._мај_јун_јул_авг._сеп._окт._нов._дец.'.split('_'),
+ monthsParseExact: true,
+ weekdays: 'недеља_понедељак_уторак_среда_четвртак_петак_субота'.split('_'),
+ weekdaysShort: 'нед._пон._уто._сре._чет._пет._суб.'.split('_'),
+ weekdaysMin: 'не_по_ут_ср_че_пе_су'.split('_'),
+ weekdaysParseExact : true,
longDateFormat: {
LT: 'H:mm',
LTS : 'H:mm:ss',
diff --git a/locale/sr.js b/locale/sr.js
index 4dab6f4..d334e78 100644
--- a/locale/sr.js
+++ b/locale/sr.js
@@ -34,11 +34,13 @@
};
var sr = moment.defineLocale('sr', {
- months: ['januar', 'februar', 'mart', 'april', 'maj', 'jun', 'jul', 'avgust', 'septembar', 'oktobar', 'novembar', 'decembar'],
- monthsShort: ['jan.', 'feb.', 'mar.', 'apr.', 'maj', 'jun', 'jul', 'avg.', 'sep.', 'okt.', 'nov.', 'dec.'],
- weekdays: ['nedelja', 'ponedeljak', 'utorak', 'sreda', 'četvrtak', 'petak', 'subota'],
- weekdaysShort: ['ned.', 'pon.', 'uto.', 'sre.', 'čet.', 'pet.', 'sub.'],
- weekdaysMin: ['ne', 'po', 'ut', 'sr', 'če', 'pe', 'su'],
+ months: 'januar_februar_mart_april_maj_jun_jul_avgust_septembar_oktobar_novembar_decembar'.split('_'),
+ monthsShort: 'jan._feb._mar._apr._maj_jun_jul_avg._sep._okt._nov._dec.'.split('_'),
+ monthsParseExact: true,
+ weekdays: 'nedelja_ponedeljak_utorak_sreda_četvrtak_petak_subota'.split('_'),
+ weekdaysShort: 'ned._pon._uto._sre._čet._pet._sub.'.split('_'),
+ weekdaysMin: 'ne_po_ut_sr_če_pe_su'.split('_'),
+ weekdaysParseExact : true,
longDateFormat: {
LT: 'H:mm',
LTS : 'H:mm:ss',
diff --git a/locale/ss.js b/locale/ss.js
new file mode 100644
index 0000000..0839239
--- /dev/null
+++ b/locale/ss.js
@@ -0,0 +1,89 @@
+//! moment.js locale configuration
+//! locale : siSwati (ss)
+//! author : Nicolai Davies : https://github.com/nicolaidavies
+
+;(function (global, factory) {
+ typeof exports === 'object' && typeof module !== 'undefined'
+ && typeof require === 'function' ? factory(require('../moment')) :
+ typeof define === 'function' && define.amd ? define(['moment'], factory) :
+ factory(global.moment)
+}(this, function (moment) { 'use strict';
+
+
+
+ var ss = moment.defineLocale('ss', {
+ months : "Bhimbidvwane_Indlovana_Indlov'lenkhulu_Mabasa_Inkhwekhweti_Inhlaba_Kholwane_Ingci_Inyoni_Imphala_Lweti_Ingongoni".split('_'),
+ monthsShort : 'Bhi_Ina_Inu_Mab_Ink_Inh_Kho_Igc_Iny_Imp_Lwe_Igo'.split('_'),
+ weekdays : 'Lisontfo_Umsombuluko_Lesibili_Lesitsatfu_Lesine_Lesihlanu_Umgcibelo'.split('_'),
+ weekdaysShort : 'Lis_Umb_Lsb_Les_Lsi_Lsh_Umg'.split('_'),
+ weekdaysMin : 'Li_Us_Lb_Lt_Ls_Lh_Ug'.split('_'),
+ weekdaysParseExact : true,
+ longDateFormat : {
+ LT : 'h:mm A',
+ LTS : 'h:mm:ss A',
+ L : 'DD/MM/YYYY',
+ LL : 'D MMMM YYYY',
+ LLL : 'D MMMM YYYY h:mm A',
+ LLLL : 'dddd, D MMMM YYYY h:mm A'
+ },
+ calendar : {
+ sameDay : '[Namuhla nga] LT',
+ nextDay : '[Kusasa nga] LT',
+ nextWeek : 'dddd [nga] LT',
+ lastDay : '[Itolo nga] LT',
+ lastWeek : 'dddd [leliphelile] [nga] LT',
+ sameElse : 'L'
+ },
+ relativeTime : {
+ future : 'nga %s',
+ past : 'wenteka nga %s',
+ s : 'emizuzwana lomcane',
+ m : 'umzuzu',
+ mm : '%d emizuzu',
+ h : 'lihora',
+ hh : '%d emahora',
+ d : 'lilanga',
+ dd : '%d emalanga',
+ M : 'inyanga',
+ MM : '%d tinyanga',
+ y : 'umnyaka',
+ yy : '%d iminyaka'
+ },
+ meridiemParse: /ekuseni|emini|entsambama|ebusuku/,
+ meridiem : function (hours, minutes, isLower) {
+ if (hours < 11) {
+ return 'ekuseni';
+ } else if (hours < 15) {
+ return 'emini';
+ } else if (hours < 19) {
+ return 'entsambama';
+ } else {
+ return 'ebusuku';
+ }
+ },
+ meridiemHour : function (hour, meridiem) {
+ if (hour === 12) {
+ hour = 0;
+ }
+ if (meridiem === 'ekuseni') {
+ return hour;
+ } else if (meridiem === 'emini') {
+ return hour >= 11 ? hour : hour + 12;
+ } else if (meridiem === 'entsambama' || meridiem === 'ebusuku') {
+ if (hour === 0) {
+ return 0;
+ }
+ return hour + 12;
+ }
+ },
+ ordinalParse: /\d{1,2}/,
+ ordinal : '%d',
+ week : {
+ dow : 1, // Monday is the first day of the week.
+ doy : 4 // The week that contains Jan 4th is the first week of the year.
+ }
+ });
+
+ return ss;
+
+}));
\ No newline at end of file
diff --git a/locale/sv.js b/locale/sv.js
index 5af3bb7..a21237d 100644
--- a/locale/sv.js
+++ b/locale/sv.js
@@ -21,8 +21,10 @@
LTS : 'HH:mm:ss',
L : 'YYYY-MM-DD',
LL : 'D MMMM YYYY',
- LLL : 'D MMMM YYYY HH:mm',
- LLLL : 'dddd D MMMM YYYY HH:mm'
+ LLL : 'D MMMM YYYY [kl.] HH:mm',
+ LLLL : 'dddd D MMMM YYYY [kl.] HH:mm',
+ lll : 'D MMM YYYY HH:mm',
+ llll : 'ddd D MMM YYYY HH:mm'
},
calendar : {
sameDay: '[Idag] LT',
diff --git a/locale/sw.js b/locale/sw.js
index 8017f7d..1460edd 100644
--- a/locale/sw.js
+++ b/locale/sw.js
@@ -16,6 +16,7 @@
weekdays : 'Jumapili_Jumatatu_Jumanne_Jumatano_Alhamisi_Ijumaa_Jumamosi'.split('_'),
weekdaysShort : 'Jpl_Jtat_Jnne_Jtan_Alh_Ijm_Jmos'.split('_'),
weekdaysMin : 'J2_J3_J4_J5_Al_Ij_J1'.split('_'),
+ weekdaysParseExact : true,
longDateFormat : {
LT : 'HH:mm',
LTS : 'HH:mm:ss',
diff --git a/locale/te.js b/locale/te.js
index 775651d..f5d1620 100644
--- a/locale/te.js
+++ b/locale/te.js
@@ -13,6 +13,7 @@
var te = moment.defineLocale('te', {
months : 'జనవరి_ఫిబ్రవరి_మార్చి_ఏప్రిల్_మే_జూన్_జూలై_ఆగస్టు_సెప్టెంబర్_అక్టోబర్_నవంబర్_డిసెంబర్'.split('_'),
monthsShort : 'జన._ఫిబ్ర._మార్చి_ఏప్రి._మే_జూన్_జూలై_ఆగ._సెప్._అక్టో._నవ._డిసె.'.split('_'),
+ monthsParseExact : true,
weekdays : 'ఆదివారం_సోమవారం_మంగళవారం_బుధవారం_గురువారం_శుక్రవారం_శనివారం'.split('_'),
weekdaysShort : 'ఆది_సోమ_మంగళ_బుధ_గురు_శుక్ర_శని'.split('_'),
weekdaysMin : 'ఆ_సో_మం_బు_గు_శు_శ'.split('_'),
diff --git a/locale/th.js b/locale/th.js
index ac32542..fc4e8f8 100644
--- a/locale/th.js
+++ b/locale/th.js
@@ -13,9 +13,11 @@
var th = moment.defineLocale('th', {
months : 'มกราคม_กุมภาพันธ์_มีนาคม_เมษายน_พฤษภาคม_มิถุนายน_กรกฎาคม_สิงหาคม_กันยายน_ตุลาคม_พฤศจิกายน_ธันวาคม'.split('_'),
monthsShort : 'มกรา_กุมภา_มีนา_เมษา_พฤษภา_มิถุนา_กรกฎา_สิงหา_กันยา_ตุลา_พฤศจิกา_ธันวา'.split('_'),
+ monthsParseExact: true,
weekdays : 'อาทิตย์_จันทร์_อังคาร_พุธ_พฤหัสบดี_ศุกร์_เสาร์'.split('_'),
weekdaysShort : 'อาทิตย์_จันทร์_อังคาร_พุธ_พฤหัส_ศุกร์_เสาร์'.split('_'), // yes, three characters difference
weekdaysMin : 'อา._จ._อ._พ._พฤ._ศ._ส.'.split('_'),
+ weekdaysParseExact : true,
longDateFormat : {
LT : 'H นาฬิกา m นาที',
LTS : 'H นาฬิกา m นาที s วินาที',
diff --git a/locale/tlh.js b/locale/tlh.js
index 4ae53ef..660d70d 100644
--- a/locale/tlh.js
+++ b/locale/tlh.js
@@ -72,6 +72,7 @@
var tlh = moment.defineLocale('tlh', {
months : 'tera’ jar wa’_tera’ jar cha’_tera’ jar wej_tera’ jar loS_tera’ jar vagh_tera’ jar jav_tera’ jar Soch_tera’ jar chorgh_tera’ jar Hut_tera’ jar wa’maH_tera’ jar wa’maH wa’_tera’ jar wa’maH cha’'.split('_'),
monthsShort : 'jar wa’_jar cha’_jar wej_jar loS_jar vagh_jar jav_jar Soch_jar chorgh_jar Hut_jar wa’maH_jar wa’maH wa’_jar wa’maH cha’'.split('_'),
+ monthsParseExact : true,
weekdays : 'lojmItjaj_DaSjaj_povjaj_ghItlhjaj_loghjaj_buqjaj_ghInjaj'.split('_'),
weekdaysShort : 'lojmItjaj_DaSjaj_povjaj_ghItlhjaj_loghjaj_buqjaj_ghInjaj'.split('_'),
weekdaysMin : 'lojmItjaj_DaSjaj_povjaj_ghItlhjaj_loghjaj_buqjaj_ghInjaj'.split('_'),
diff --git a/locale/tzl.js b/locale/tzl.js
index 498f7c0..ddbbf01 100644
--- a/locale/tzl.js
+++ b/locale/tzl.js
@@ -26,6 +26,10 @@
LL : 'D. MMMM [dallas] YYYY',
LLL : 'D. MMMM [dallas] YYYY HH.mm',
LLLL : 'dddd, [li] D. MMMM [dallas] YYYY HH.mm'
+ },
+ meridiemParse: /d\'o|d\'a/i,
+ isPM : function (input) {
+ return 'd\'o' === input.toLowerCase();
},
meridiem : function (hours, minutes, isLower) {
if (hours > 11) {
diff --git a/locale/vi.js b/locale/vi.js
index 0e7ba8c..d3ee6ea 100644
--- a/locale/vi.js
+++ b/locale/vi.js
@@ -13,9 +13,22 @@
var vi = moment.defineLocale('vi', {
months : 'tháng 1_tháng 2_tháng 3_tháng 4_tháng 5_tháng 6_tháng 7_tháng 8_tháng 9_tháng 10_tháng 11_tháng 12'.split('_'),
monthsShort : 'Th01_Th02_Th03_Th04_Th05_Th06_Th07_Th08_Th09_Th10_Th11_Th12'.split('_'),
+ monthsParseExact : true,
weekdays : 'chủ nhật_thứ hai_thứ ba_thứ tư_thứ năm_thứ sáu_thứ bảy'.split('_'),
weekdaysShort : 'CN_T2_T3_T4_T5_T6_T7'.split('_'),
weekdaysMin : 'CN_T2_T3_T4_T5_T6_T7'.split('_'),
+ weekdaysParseExact : true,
+ meridiemParse: /sa|ch/i,
+ isPM : function (input) {
+ return /^ch$/i.test(input);
+ },
+ meridiem : function (hours, minutes, isLower) {
+ if (hours < 12) {
+ return isLower ? 'sa' : 'SA';
+ } else {
+ return isLower ? 'ch' : 'CH';
+ }
+ },
longDateFormat : {
LT : 'HH:mm',
LTS : 'HH:mm:ss',
diff --git a/locale/x-pseudo.js b/locale/x-pseudo.js
new file mode 100644
index 0000000..ce45b8a
--- /dev/null
+++ b/locale/x-pseudo.js
@@ -0,0 +1,68 @@
+//! moment.js locale configuration
+//! locale : pseudo (x-pseudo)
+//! author : Andrew Hood : https://github.com/andrewhood125
+
+;(function (global, factory) {
+ typeof exports === 'object' && typeof module !== 'undefined'
+ && typeof require === 'function' ? factory(require('../moment')) :
+ typeof define === 'function' && define.amd ? define(['moment'], factory) :
+ factory(global.moment)
+}(this, function (moment) { 'use strict';
+
+
+ var x_pseudo = moment.defineLocale('x-pseudo', {
+ months : 'J~áñúá~rý_F~ébrú~árý_~Márc~h_Áp~ríl_~Máý_~Júñé~_Júl~ý_Áú~gúst~_Sép~témb~ér_Ó~ctób~ér_Ñ~óvém~bér_~Décé~mbér'.split('_'),
+ monthsShort : 'J~áñ_~Féb_~Már_~Ápr_~Máý_~Júñ_~Júl_~Áúg_~Sép_~Óct_~Ñóv_~Déc'.split('_'),
+ monthsParseExact : true,
+ weekdays : 'S~úñdá~ý_Mó~ñdáý~_Túé~sdáý~_Wéd~ñésd~áý_T~húrs~dáý_~Fríd~áý_S~átúr~dáý'.split('_'),
+ weekdaysShort : 'S~úñ_~Móñ_~Túé_~Wéd_~Thú_~Frí_~Sát'.split('_'),
+ weekdaysMin : 'S~ú_Mó~_Tú_~Wé_T~h_Fr~_Sá'.split('_'),
+ weekdaysParseExact : true,
+ longDateFormat : {
+ LT : 'HH:mm',
+ L : 'DD/MM/YYYY',
+ LL : 'D MMMM YYYY',
+ LLL : 'D MMMM YYYY HH:mm',
+ LLLL : 'dddd, D MMMM YYYY HH:mm'
+ },
+ calendar : {
+ sameDay : '[T~ódá~ý át] LT',
+ nextDay : '[T~ómó~rró~w át] LT',
+ nextWeek : 'dddd [át] LT',
+ lastDay : '[Ý~ést~érdá~ý át] LT',
+ lastWeek : '[L~ást] dddd [át] LT',
+ sameElse : 'L'
+ },
+ relativeTime : {
+ future : 'í~ñ %s',
+ past : '%s á~gó',
+ s : 'á ~féw ~sécó~ñds',
+ m : 'á ~míñ~úté',
+ mm : '%d m~íñú~tés',
+ h : 'á~ñ hó~úr',
+ hh : '%d h~óúrs',
+ d : 'á ~dáý',
+ dd : '%d d~áýs',
+ M : 'á ~móñ~th',
+ MM : '%d m~óñt~hs',
+ y : 'á ~ýéár',
+ yy : '%d ý~éárs'
+ },
+ ordinalParse: /\d{1,2}(th|st|nd|rd)/,
+ ordinal : function (number) {
+ var b = number % 10,
+ output = (~~(number % 100 / 10) === 1) ? 'th' :
+ (b === 1) ? 'st' :
+ (b === 2) ? 'nd' :
+ (b === 3) ? 'rd' : 'th';
+ return number + output;
+ },
+ week : {
+ dow : 1, // Monday is the first day of the week.
+ doy : 4 // The week that contains Jan 4th is the first week of the year.
+ }
+ });
+
+ return x_pseudo;
+
+}));
\ No newline at end of file
diff --git a/locale/zh-cn.js b/locale/zh-cn.js
index aec5ede..cbc3f87 100644
--- a/locale/zh-cn.js
+++ b/locale/zh-cn.js
@@ -73,7 +73,7 @@
nextWeek : function () {
var startOfWeek, prefix;
startOfWeek = moment().startOf('week');
- prefix = this.unix() - startOfWeek.unix() >= 7 * 24 * 3600 ? '[下]' : '[本]';
+ prefix = this.diff(startOfWeek, 'days') >= 7 ? '[下]' : '[本]';
return this.minutes() === 0 ? prefix + 'dddAh点整' : prefix + 'dddAh点mm';
},
lastWeek : function () {
diff --git a/locale/zh-tw.js b/locale/zh-tw.js
index bf3a333..664f5ec 100644
--- a/locale/zh-tw.js
+++ b/locale/zh-tw.js
@@ -83,15 +83,15 @@
future : '%s內',
past : '%s前',
s : '幾秒',
- m : '一分鐘',
+ m : '1分鐘',
mm : '%d分鐘',
- h : '一小時',
+ h : '1小時',
hh : '%d小時',
- d : '一天',
+ d : '1天',
dd : '%d天',
- M : '一個月',
+ M : '1個月',
MM : '%d個月',
- y : '一年',
+ y : '1年',
yy : '%d年'
}
});
diff --git a/min/locales.js b/min/locales.js
index 3eb75af..a347422 100644
--- a/min/locales.js
+++ b/min/locales.js
@@ -78,6 +78,7 @@
weekdays : 'الأحد_الإتنين_الثلاثاء_الأربعاء_الخميس_الجمعة_السبت'.split('_'),
weekdaysShort : 'احد_اتنين_ثلاثاء_اربعاء_خميس_جمعة_سبت'.split('_'),
weekdaysMin : 'ح_ن_ث_ر_خ_ج_س'.split('_'),
+ weekdaysParseExact : true,
longDateFormat : {
LT : 'HH:mm',
LTS : 'HH:mm:ss',
@@ -149,6 +150,7 @@
weekdays : 'الأحد_الإثنين_الثلاثاء_الأربعاء_الخميس_الجمعة_السبت'.split('_'),
weekdaysShort : 'أحد_إثنين_ثلاثاء_أربعاء_خميس_جمعة_سبت'.split('_'),
weekdaysMin : 'ح_ن_ث_ر_خ_ج_س'.split('_'),
+ weekdaysParseExact : true,
longDateFormat : {
LT : 'HH:mm',
LTS : 'HH:mm:ss',
@@ -216,6 +218,7 @@
weekdays: 'الأحد_الإثنين_الثلاثاء_الأربعاء_الخميس_الجمعة_السبت'.split('_'),
weekdaysShort: 'أحد_إثنين_ثلاثاء_أربعاء_خميس_جمعة_سبت'.split('_'),
weekdaysMin: 'ح_ن_ث_ر_خ_ج_س'.split('_'),
+ weekdaysParseExact : true,
longDateFormat: {
LT: 'HH:mm',
LTS: 'HH:mm:ss',
@@ -320,6 +323,7 @@
weekdays : 'الأحد_الإثنين_الثلاثاء_الأربعاء_الخميس_الجمعة_السبت'.split('_'),
weekdaysShort : 'أحد_إثنين_ثلاثاء_أربعاء_خميس_جمعة_سبت'.split('_'),
weekdaysMin : 'ح_ن_ث_ر_خ_ج_س'.split('_'),
+ weekdaysParseExact : true,
longDateFormat : {
LT : 'HH:mm',
LTS : 'HH:mm:ss',
@@ -409,6 +413,7 @@
weekdays : 'Bazar_Bazar ertəsi_Çərşənbə axşamı_Çərşənbə_Cümə axşamı_Cümə_Şənbə'.split('_'),
weekdaysShort : 'Baz_BzE_ÇAx_Çər_CAx_Cüm_Şən'.split('_'),
weekdaysMin : 'Bz_BE_ÇA_Çə_CA_Cü_Şə'.split('_'),
+ weekdaysParseExact : true,
longDateFormat : {
LT : 'HH:mm',
LTS : 'HH:mm:ss',
@@ -750,12 +755,18 @@
});
},
meridiemParse: /রাত|সকাল|দুপুর|বিকাল|রাত/,
- isPM: function (input) {
- return /^(দুপুর|বিকাল|রাত)$/.test(input);
- },
- //Bengali is a vast language its spoken
- //in different forms in various parts of the world.
- //I have just generalized with most common one used
+ meridiemHour : function (hour, meridiem) {
+ if (hour === 12) {
+ hour = 0;
+ }
+ if ((meridiem === 'রাত' && hour >= 4) ||
+ (meridiem === 'দুপুর' && hour < 5) ||
+ meridiem === 'বিকাল') {
+ return hour + 12;
+ } else {
+ return hour;
+ }
+ },
meridiem : function (hour, minute, isLower) {
if (hour < 4) {
return 'রাত';
@@ -852,8 +863,17 @@
});
},
meridiemParse: /མཚན་མོ|ཞོགས་ཀས|ཉིན་གུང|དགོང་དག|མཚན་མོ/,
- isPM: function (input) {
- return /^(ཉིན་གུང|དགོང་དག|མཚན་མོ)$/.test(input);
+ meridiemHour : function (hour, meridiem) {
+ if (hour === 12) {
+ hour = 0;
+ }
+ if ((meridiem === 'མཚན་མོ' && hour >= 4) ||
+ (meridiem === 'ཉིན་གུང' && hour < 5) ||
+ meridiem === 'དགོང་དག') {
+ return hour + 12;
+ } else {
+ return hour;
+ }
},
meridiem : function (hour, minute, isLower) {
if (hour < 4) {
@@ -928,6 +948,7 @@
weekdays : 'Sul_Lun_Meurzh_Merc\'her_Yaou_Gwener_Sadorn'.split('_'),
weekdaysShort : 'Sul_Lun_Meu_Mer_Yao_Gwe_Sad'.split('_'),
weekdaysMin : 'Su_Lu_Me_Mer_Ya_Gw_Sa'.split('_'),
+ weekdaysParseExact : true,
longDateFormat : {
LT : 'h[e]mm A',
LTS : 'h[e]mm:ss A',
@@ -1031,9 +1052,11 @@
var bs = moment.defineLocale('bs', {
months : 'januar_februar_mart_april_maj_juni_juli_august_septembar_oktobar_novembar_decembar'.split('_'),
monthsShort : 'jan._feb._mar._apr._maj._jun._jul._aug._sep._okt._nov._dec.'.split('_'),
+ monthsParseExact: true,
weekdays : 'nedjelja_ponedjeljak_utorak_srijeda_četvrtak_petak_subota'.split('_'),
weekdaysShort : 'ned._pon._uto._sri._čet._pet._sub.'.split('_'),
weekdaysMin : 'ne_po_ut_sr_če_pe_su'.split('_'),
+ weekdaysParseExact : true,
longDateFormat : {
LT : 'H:mm',
LTS : 'H:mm:ss',
@@ -1107,9 +1130,11 @@
var ca = moment.defineLocale('ca', {
months : 'gener_febrer_març_abril_maig_juny_juliol_agost_setembre_octubre_novembre_desembre'.split('_'),
monthsShort : 'gen._febr._mar._abr._mai._jun._jul._ag._set._oct._nov._des.'.split('_'),
+ monthsParseExact : true,
weekdays : 'diumenge_dilluns_dimarts_dimecres_dijous_divendres_dissabte'.split('_'),
weekdaysShort : 'dg._dl._dt._dc._dj._dv._ds.'.split('_'),
weekdaysMin : 'Dg_Dl_Dt_Dc_Dj_Dv_Ds'.split('_'),
+ weekdaysParseExact : true,
longDateFormat : {
LT : 'H:mm',
LTS : 'H:mm:ss',
@@ -1390,6 +1415,7 @@
weekdays: 'Dydd Sul_Dydd Llun_Dydd Mawrth_Dydd Mercher_Dydd Iau_Dydd Gwener_Dydd Sadwrn'.split('_'),
weekdaysShort: 'Sul_Llun_Maw_Mer_Iau_Gwe_Sad'.split('_'),
weekdaysMin: 'Su_Ll_Ma_Me_Ia_Gw_Sa'.split('_'),
+ weekdaysParseExact : true,
// time formats are the same as en-gb
longDateFormat: {
LT: 'HH:mm',
@@ -1521,9 +1547,11 @@
var de_at = moment.defineLocale('de-at', {
months : 'Jänner_Februar_März_April_Mai_Juni_Juli_August_September_Oktober_November_Dezember'.split('_'),
monthsShort : 'Jän._Febr._Mrz._Apr._Mai_Jun._Jul._Aug._Sept._Okt._Nov._Dez.'.split('_'),
+ monthsParseExact : true,
weekdays : 'Sonntag_Montag_Dienstag_Mittwoch_Donnerstag_Freitag_Samstag'.split('_'),
weekdaysShort : 'So._Mo._Di._Mi._Do._Fr._Sa.'.split('_'),
weekdaysMin : 'So_Mo_Di_Mi_Do_Fr_Sa'.split('_'),
+ weekdaysParseExact : true,
longDateFormat : {
LT: 'HH:mm',
LTS: 'HH:mm:ss',
@@ -1586,9 +1614,11 @@
var de = moment.defineLocale('de', {
months : 'Januar_Februar_März_April_Mai_Juni_Juli_August_September_Oktober_November_Dezember'.split('_'),
monthsShort : 'Jan._Febr._Mrz._Apr._Mai_Jun._Jul._Aug._Sept._Okt._Nov._Dez.'.split('_'),
+ monthsParseExact : true,
weekdays : 'Sonntag_Montag_Dienstag_Mittwoch_Donnerstag_Freitag_Samstag'.split('_'),
weekdaysShort : 'So._Mo._Di._Mi._Do._Fr._Sa.'.split('_'),
weekdaysMin : 'So_Mo_Di_Mi_Do_Fr_Sa'.split('_'),
+ weekdaysParseExact : true,
longDateFormat : {
LT: 'HH:mm',
LTS: 'HH:mm:ss',
@@ -1672,7 +1702,7 @@
},
meridiemParse: /މކ|މފ/,
isPM : function (input) {
- return '' === input;
+ return 'މފ' === input;
},
meridiem : function (hour, minute, isLower) {
if (hour < 12) {
@@ -1808,10 +1838,7 @@
var en_au = moment.defineLocale('en-au', {
months : 'January_February_March_April_May_June_July_August_September_October_November_December'.split('_'),
- monthsShort : 'Jan_Feb_Mar_Apr_May_Jun_Jul_Aug_Sept_Oct_Nov_Dec'.split('_'),
- monthsParse : [/^jan/i, /^feb/i, /^mar/i, /^apr/i, /^may/i, /^jun/i, /^jul/i, /^aug/i, /^sep/i, /^oct/i, /^nov/i, /^dec/i],
- longMonthsParse : [/^january$/i, /^february$/i, /^march$/i, /^april$/i, /^may$/i, /^june$/i, /^july$/i, /^august$/i, /^september$/i, /^october$/i, /^november$/i, /^december$/i],
- shortMonthsParse : [/^jan$/i, /^feb$/i, /^mar$/i, /^apr$/i, /^may$/i, /^jun$/i, /^jul$/i, /^aug/i, /^sept?$/i, /^oct$/i, /^nov$/i, /^dec$/i],
+ monthsShort : 'Jan_Feb_Mar_Apr_May_Jun_Jul_Aug_Sep_Oct_Nov_Dec'.split('_'),
weekdays : 'Sunday_Monday_Tuesday_Wednesday_Thursday_Friday_Saturday'.split('_'),
weekdaysShort : 'Sun_Mon_Tue_Wed_Thu_Fri_Sat'.split('_'),
weekdaysMin : 'Su_Mo_Tu_We_Th_Fr_Sa'.split('_'),
@@ -1867,10 +1894,7 @@
var en_ca = moment.defineLocale('en-ca', {
months : 'January_February_March_April_May_June_July_August_September_October_November_December'.split('_'),
- monthsShort : 'Jan_Feb_Mar_Apr_May_Jun_Jul_Aug_Sept_Oct_Nov_Dec'.split('_'),
- monthsParse : [/^jan/i, /^feb/i, /^mar/i, /^apr/i, /^may/i, /^jun/i, /^jul/i, /^aug/i, /^sep/i, /^oct/i, /^nov/i, /^dec/i],
- longMonthsParse : [/^january$/i, /^february$/i, /^march$/i, /^april$/i, /^may$/i, /^june$/i, /^july$/i, /^august$/i, /^september$/i, /^october$/i, /^november$/i, /^december$/i],
- shortMonthsParse : [/^jan$/i, /^feb$/i, /^mar$/i, /^apr$/i, /^may$/i, /^jun$/i, /^jul$/i, /^aug/i, /^sept?$/i, /^oct$/i, /^nov$/i, /^dec$/i],
+ monthsShort : 'Jan_Feb_Mar_Apr_May_Jun_Jul_Aug_Sep_Oct_Nov_Dec'.split('_'),
weekdays : 'Sunday_Monday_Tuesday_Wednesday_Thursday_Friday_Saturday'.split('_'),
weekdaysShort : 'Sun_Mon_Tue_Wed_Thu_Fri_Sat'.split('_'),
weekdaysMin : 'Su_Mo_Tu_We_Th_Fr_Sa'.split('_'),
@@ -1878,9 +1902,9 @@
LT : 'h:mm A',
LTS : 'h:mm:ss A',
L : 'YYYY-MM-DD',
- LL : 'D MMMM, YYYY',
- LLL : 'D MMMM, YYYY h:mm A',
- LLLL : 'dddd, D MMMM, YYYY h:mm A'
+ LL : 'MMMM D, YYYY',
+ LLL : 'MMMM D, YYYY h:mm A',
+ LLLL : 'dddd, MMMM D, YYYY h:mm A'
},
calendar : {
sameDay : '[Today at] LT',
@@ -1922,10 +1946,7 @@
var en_gb = moment.defineLocale('en-gb', {
months : 'January_February_March_April_May_June_July_August_September_October_November_December'.split('_'),
- monthsShort : 'Jan_Feb_Mar_Apr_May_Jun_Jul_Aug_Sept_Oct_Nov_Dec'.split('_'),
- monthsParse : [/^jan/i, /^feb/i, /^mar/i, /^apr/i, /^may/i, /^jun/i, /^jul/i, /^aug/i, /^sep/i, /^oct/i, /^nov/i, /^dec/i],
- longMonthsParse : [/^january$/i, /^february$/i, /^march$/i, /^april$/i, /^may$/i, /^june$/i, /^july$/i, /^august$/i, /^september$/i, /^october$/i, /^november$/i, /^december$/i],
- shortMonthsParse : [/^jan$/i, /^feb$/i, /^mar$/i, /^apr$/i, /^may$/i, /^jun$/i, /^jul$/i, /^aug/i, /^sept?$/i, /^oct$/i, /^nov$/i, /^dec$/i],
+ monthsShort : 'Jan_Feb_Mar_Apr_May_Jun_Jul_Aug_Sep_Oct_Nov_Dec'.split('_'),
weekdays : 'Sunday_Monday_Tuesday_Wednesday_Thursday_Friday_Saturday'.split('_'),
weekdaysShort : 'Sun_Mon_Tue_Wed_Thu_Fri_Sat'.split('_'),
weekdaysMin : 'Su_Mo_Tu_We_Th_Fr_Sa'.split('_'),
@@ -1982,9 +2003,6 @@
var en_ie = moment.defineLocale('en-ie', {
months : 'January_February_March_April_May_June_July_August_September_October_November_December'.split('_'),
monthsShort : 'Jan_Feb_Mar_Apr_May_Jun_Jul_Aug_Sep_Oct_Nov_Dec'.split('_'),
- monthsParse : [/^jan/i, /^feb/i, /^mar/i, /^apr/i, /^may/i, /^jun/i, /^jul/i, /^aug/i, /^sep/i, /^oct/i, /^nov/i, /^dec/i],
- longMonthsParse : [/^january$/i, /^february$/i, /^march$/i, /^april$/i, /^may$/i, /^june$/i, /^july$/i, /^august$/i, /^september$/i, /^october$/i, /^november$/i, /^december$/i],
- shortMonthsParse : [/^jan$/i, /^feb$/i, /^mar$/i, /^apr$/i, /^may$/i, /^jun$/i, /^jul$/i, /^aug/i, /^sept?$/i, /^oct$/i, /^nov$/i, /^dec$/i],
weekdays : 'Sunday_Monday_Tuesday_Wednesday_Thursday_Friday_Saturday'.split('_'),
weekdaysShort : 'Sun_Mon_Tue_Wed_Thu_Fri_Sat'.split('_'),
weekdaysMin : 'Su_Mo_Tu_We_Th_Fr_Sa'.split('_'),
@@ -2039,10 +2057,7 @@
var en_nz = moment.defineLocale('en-nz', {
months : 'January_February_March_April_May_June_July_August_September_October_November_December'.split('_'),
- monthsShort : 'Jan_Feb_Mar_Apr_May_Jun_Jul_Aug_Sept_Oct_Nov_Dec'.split('_'),
- monthsParse : [/^jan/i, /^feb/i, /^mar/i, /^apr/i, /^may/i, /^jun/i, /^jul/i, /^aug/i, /^sep/i, /^oct/i, /^nov/i, /^dec/i],
- longMonthsParse : [/^january$/i, /^february$/i, /^march$/i, /^april$/i, /^may$/i, /^june$/i, /^july$/i, /^august$/i, /^september$/i, /^october$/i, /^november$/i, /^december$/i],
- shortMonthsParse : [/^jan$/i, /^feb$/i, /^mar$/i, /^apr$/i, /^may$/i, /^jun$/i, /^jul$/i, /^aug/i, /^sept?$/i, /^oct$/i, /^nov$/i, /^dec$/i],
+ monthsShort : 'Jan_Feb_Mar_Apr_May_Jun_Jul_Aug_Sep_Oct_Nov_Dec'.split('_'),
weekdays : 'Sunday_Monday_Tuesday_Wednesday_Thursday_Friday_Saturday'.split('_'),
weekdaysShort : 'Sun_Mon_Tue_Wed_Thu_Fri_Sat'.split('_'),
weekdaysMin : 'Su_Mo_Tu_We_Th_Fr_Sa'.split('_'),
@@ -2170,9 +2185,11 @@
return monthsShortDot[m.month()];
}
},
+ monthsParseExact : true,
weekdays : 'domingo_lunes_martes_miércoles_jueves_viernes_sábado'.split('_'),
weekdaysShort : 'dom._lun._mar._mié._jue._vie._sáb.'.split('_'),
weekdaysMin : 'do_lu_ma_mi_ju_vi_sá'.split('_'),
+ weekdaysParseExact : true,
longDateFormat : {
LT : 'H:mm',
LTS : 'H:mm:ss',
@@ -2298,9 +2315,11 @@
var eu = moment.defineLocale('eu', {
months : 'urtarrila_otsaila_martxoa_apirila_maiatza_ekaina_uztaila_abuztua_iraila_urria_azaroa_abendua'.split('_'),
monthsShort : 'urt._ots._mar._api._mai._eka._uzt._abu._ira._urr._aza._abe.'.split('_'),
+ monthsParseExact : true,
weekdays : 'igandea_astelehena_asteartea_asteazkena_osteguna_ostirala_larunbata'.split('_'),
weekdaysShort : 'ig._al._ar._az._og._ol._lr.'.split('_'),
weekdaysMin : 'ig_al_ar_az_og_ol_lr'.split('_'),
+ weekdaysParseExact : true,
longDateFormat : {
LT : 'HH:mm',
LTS : 'HH:mm:ss',
@@ -2378,6 +2397,7 @@
weekdays : 'یک\u200cشنبه_دوشنبه_سه\u200cشنبه_چهارشنبه_پنج\u200cشنبه_جمعه_شنبه'.split('_'),
weekdaysShort : 'یک\u200cشنبه_دوشنبه_سه\u200cشنبه_چهارشنبه_پنج\u200cشنبه_جمعه_شنبه'.split('_'),
weekdaysMin : 'ی_د_س_چ_پ_ج_ش'.split('_'),
+ weekdaysParseExact : true,
longDateFormat : {
LT : 'HH:mm',
LTS : 'HH:mm:ss',
@@ -2590,9 +2610,11 @@
var fr_ca = moment.defineLocale('fr-ca', {
months : 'janvier_février_mars_avril_mai_juin_juillet_août_septembre_octobre_novembre_décembre'.split('_'),
monthsShort : 'janv._févr._mars_avr._mai_juin_juil._août_sept._oct._nov._déc.'.split('_'),
+ monthsParseExact : true,
weekdays : 'dimanche_lundi_mardi_mercredi_jeudi_vendredi_samedi'.split('_'),
weekdaysShort : 'dim._lun._mar._mer._jeu._ven._sam.'.split('_'),
weekdaysMin : 'Di_Lu_Ma_Me_Je_Ve_Sa'.split('_'),
+ weekdaysParseExact : true,
longDateFormat : {
LT : 'HH:mm',
LTS : 'HH:mm:ss',
@@ -2637,9 +2659,11 @@
var fr_ch = moment.defineLocale('fr-ch', {
months : 'janvier_février_mars_avril_mai_juin_juillet_août_septembre_octobre_novembre_décembre'.split('_'),
monthsShort : 'janv._févr._mars_avr._mai_juin_juil._août_sept._oct._nov._déc.'.split('_'),
+ monthsParseExact : true,
weekdays : 'dimanche_lundi_mardi_mercredi_jeudi_vendredi_samedi'.split('_'),
weekdaysShort : 'dim._lun._mar._mer._jeu._ven._sam.'.split('_'),
weekdaysMin : 'Di_Lu_Ma_Me_Je_Ve_Sa'.split('_'),
+ weekdaysParseExact : true,
longDateFormat : {
LT : 'HH:mm',
LTS : 'HH:mm:ss',
@@ -2688,9 +2712,11 @@
var fr = moment.defineLocale('fr', {
months : 'janvier_février_mars_avril_mai_juin_juillet_août_septembre_octobre_novembre_décembre'.split('_'),
monthsShort : 'janv._févr._mars_avr._mai_juin_juil._août_sept._oct._nov._déc.'.split('_'),
+ monthsParseExact : true,
weekdays : 'dimanche_lundi_mardi_mercredi_jeudi_vendredi_samedi'.split('_'),
weekdaysShort : 'dim._lun._mar._mer._jeu._ven._sam.'.split('_'),
weekdaysMin : 'Di_Lu_Ma_Me_Je_Ve_Sa'.split('_'),
+ weekdaysParseExact : true,
longDateFormat : {
LT : 'HH:mm',
LTS : 'HH:mm:ss',
@@ -2748,9 +2774,11 @@
return fy__monthsShortWithDots[m.month()];
}
},
+ monthsParseExact : true,
weekdays : 'snein_moandei_tiisdei_woansdei_tongersdei_freed_sneon'.split('_'),
weekdaysShort : 'si._mo._ti._wo._to._fr._so.'.split('_'),
weekdaysMin : 'Si_Mo_Ti_Wo_To_Fr_So'.split('_'),
+ weekdaysParseExact : true,
longDateFormat : {
LT : 'HH:mm',
LTS : 'HH:mm:ss',
@@ -2797,18 +2825,7 @@
//! author : Jon Ashdown : https://github.com/jonashdown
var gd__months = [
- 'Am Faoilleach',
- 'An Gearran',
- 'Am Màrt',
- 'An Giblean',
- 'An Cèitean',
- 'An t-Ògmhios',
- 'An t-Iuchar',
- 'An Lùnastal',
- 'An t-Sultain',
- 'An Dàmhair',
- 'An t-Samhain',
- 'An Dùbhlachd'
+ 'Am Faoilleach', 'An Gearran', 'Am Màrt', 'An Giblean', 'An Cèitean', 'An t-Ògmhios', 'An t-Iuchar', 'An Lùnastal', 'An t-Sultain', 'An Dàmhair', 'An t-Samhain', 'An Dùbhlachd'
];
var gd__monthsShort = ['Faoi', 'Gear', 'Màrt', 'Gibl', 'Cèit', 'Ògmh', 'Iuch', 'Lùn', 'Sult', 'Dàmh', 'Samh', 'Dùbh'];
@@ -2822,6 +2839,7 @@
var gd = moment.defineLocale('gd', {
months : gd__months,
monthsShort : gd__monthsShort,
+ monthsParseExact : true,
weekdays : gd__weekdays,
weekdaysShort : weekdaysShort,
weekdaysMin : weekdaysMin,
@@ -2874,9 +2892,11 @@
var gl = moment.defineLocale('gl', {
months : 'Xaneiro_Febreiro_Marzo_Abril_Maio_Xuño_Xullo_Agosto_Setembro_Outubro_Novembro_Decembro'.split('_'),
monthsShort : 'Xan._Feb._Mar._Abr._Mai._Xuñ._Xul._Ago._Set._Out._Nov._Dec.'.split('_'),
+ monthsParseExact: true,
weekdays : 'Domingo_Luns_Martes_Mércores_Xoves_Venres_Sábado'.split('_'),
weekdaysShort : 'Dom._Lun._Mar._Mér._Xov._Ven._Sáb.'.split('_'),
weekdaysMin : 'Do_Lu_Ma_Mé_Xo_Ve_Sá'.split('_'),
+ weekdaysParseExact : true,
longDateFormat : {
LT : 'H:mm',
LTS : 'H:mm:ss',
@@ -2999,6 +3019,23 @@
}
return number + ' שנים';
}
+ },
+ meridiemParse: /אחה"צ|לפנה"צ|אחרי הצהריים|לפני הצהריים|לפנות בוקר|בבוקר|בערב/i,
+ isPM : function (input) {
+ return /^(אחה"צ|אחרי הצהריים|בערב)$/.test(input);
+ },
+ meridiem : function (hour, minute, isLower) {
+ if (hour < 5) {
+ return 'לפנות בוקר';
+ } else if (hour < 10) {
+ return 'בבוקר';
+ } else if (hour < 12) {
+ return isLower ? 'לפנה"צ' : 'לפני הצהריים';
+ } else if (hour < 18) {
+ return isLower ? 'אחה"צ' : 'אחרי הצהריים';
+ } else {
+ return 'בערב';
+ }
}
});
@@ -3034,6 +3071,7 @@
var hi = moment.defineLocale('hi', {
months : 'जनवरी_फ़रवरी_मार्च_अप्रैल_मई_जून_जुलाई_अगस्त_सितम्बर_अक्टूबर_नवम्बर_दिसम्बर'.split('_'),
monthsShort : 'जन._फ़र._मार्च_अप्रै._मई_जून_जुल._अग._सित._अक्टू._नव._दिस.'.split('_'),
+ monthsParseExact: true,
weekdays : 'रविवार_सोमवार_मंगलवार_बुधवार_गुरूवार_शुक्रवार_शनिवार'.split('_'),
weekdaysShort : 'रवि_सोम_मंगल_बुध_गुरू_शुक्र_शनि'.split('_'),
weekdaysMin : 'र_सो_मं_बु_गु_शु_श'.split('_'),
@@ -3177,9 +3215,11 @@
standalone: 'siječanj_veljača_ožujak_travanj_svibanj_lipanj_srpanj_kolovoz_rujan_listopad_studeni_prosinac'.split('_')
},
monthsShort : 'sij._velj._ožu._tra._svi._lip._srp._kol._ruj._lis._stu._pro.'.split('_'),
+ monthsParseExact: true,
weekdays : 'nedjelja_ponedjeljak_utorak_srijeda_četvrtak_petak_subota'.split('_'),
weekdaysShort : 'ned._pon._uto._sri._čet._pet._sub.'.split('_'),
weekdaysMin : 'ne_po_ut_sr_če_pe_su'.split('_'),
+ weekdaysParseExact : true,
longDateFormat : {
LT : 'H:mm',
LTS : 'H:mm:ss',
@@ -3580,7 +3620,7 @@
longDateFormat : {
LT : 'H:mm',
LTS : 'H:mm:ss',
- L : 'DD/MM/YYYY',
+ L : 'DD.MM.YYYY',
LL : 'D. MMMM YYYY',
LLL : 'D. MMMM YYYY [kl.] H:mm',
LLLL : 'dddd, D. MMMM YYYY [kl.] H:mm'
@@ -3711,6 +3751,17 @@
lastDay : '[昨日] LT',
lastWeek : '[前週]dddd LT',
sameElse : 'L'
+ },
+ ordinalParse : /\d{1,2}日/,
+ ordinal : function (number, period) {
+ switch (period) {
+ case 'd':
+ case 'D':
+ case 'DDD':
+ return number + '日';
+ default:
+ return number;
+ }
},
relativeTime : {
future : '%s後',
@@ -3907,11 +3958,11 @@
};
var kk = moment.defineLocale('kk', {
- months : 'Қаңтар_Ақпан_Наурыз_Сәуір_Мамыр_Маусым_Шілде_Тамыз_Қыркүйек_Қазан_Қараша_Желтоқсан'.split('_'),
- monthsShort : 'Қаң_Ақп_Нау_Сәу_Мам_Мау_Шіл_Там_Қыр_Қаз_Қар_Жел'.split('_'),
- weekdays : 'Жексенбі_Дүйсенбі_Сейсенбі_Сәрсенбі_Бейсенбі_Жұма_Сенбі'.split('_'),
- weekdaysShort : 'Жек_Дүй_Сей_Сәр_Бей_Жұм_Сен'.split('_'),
- weekdaysMin : 'Жк_Дй_Сй_Ср_Бй_Жм_Сн'.split('_'),
+ months : 'қаңтар_ақпан_наурыз_сәуір_мамыр_маусым_шілде_тамыз_қыркүйек_қазан_қараша_желтоқсан'.split('_'),
+ monthsShort : 'қаң_ақп_нау_сәу_мам_мау_шіл_там_қыр_қаз_қар_жел'.split('_'),
+ weekdays : 'жексенбі_дүйсенбі_сейсенбі_сәрсенбі_бейсенбі_жұма_сенбі'.split('_'),
+ weekdaysShort : 'жек_дүй_сей_сәр_бей_жұм_сен'.split('_'),
+ weekdaysMin : 'жк_дй_сй_ср_бй_жм_сн'.split('_'),
longDateFormat : {
LT : 'HH:mm',
LTS : 'HH:mm:ss',
@@ -3960,8 +4011,8 @@
//! author : Kruy Vanna : https://github.com/kruyvanna
var km = moment.defineLocale('km', {
- months: 'មករា_កុម្ភៈ_មិនា_មេសា_ឧសភា_មិថុនា_កក្កដា_សីហា_កញ្ញា_តុលា_វិច្ឆិកា_ធ្នូ'.split('_'),
- monthsShort: 'មករា_កុម្ភៈ_មិនា_មេសា_ឧសភា_មិថុនា_កក្កដា_សីហា_កញ្ញា_តុលា_វិច្ឆិកា_ធ្នូ'.split('_'),
+ months: 'មករា_កុម្ភៈ_មីនា_មេសា_ឧសភា_មិថុនា_កក្កដា_សីហា_កញ្ញា_តុលា_វិច្ឆិកា_ធ្នូ'.split('_'),
+ monthsShort: 'មករា_កុម្ភៈ_មីនា_មេសា_ឧសភា_មិថុនា_កក្កដា_សីហា_កញ្ញា_តុលា_វិច្ឆិកា_ធ្នូ'.split('_'),
weekdays: 'អាទិត្យ_ច័ន្ទ_អង្គារ_ពុធ_ព្រហស្បតិ៍_សុក្រ_សៅរ៍'.split('_'),
weekdaysShort: 'អាទិត្យ_ច័ន្ទ_អង្គារ_ពុធ_ព្រហស្បតិ៍_សុក្រ_សៅរ៍'.split('_'),
weekdaysMin: 'អាទិត្យ_ច័ន្ទ_អង្គារ_ពុធ_ព្រហស្បតិ៍_សុក្រ_សៅរ៍'.split('_'),
@@ -4035,17 +4086,17 @@
relativeTime : {
future : '%s 후',
past : '%s 전',
- s : '몇초',
+ s : '몇 초',
ss : '%d초',
m : '일분',
mm : '%d분',
- h : '한시간',
+ h : '한 시간',
hh : '%d시간',
d : '하루',
dd : '%d일',
- M : '한달',
+ M : '한 달',
MM : '%d달',
- y : '일년',
+ y : '일 년',
yy : '%d년'
},
ordinalParse : /\d{1,2}일/,
@@ -4056,6 +4107,83 @@
},
meridiem : function (hour, minute, isUpper) {
return hour < 12 ? '오전' : '오후';
+ }
+ });
+
+ //! moment.js locale configuration
+ //! locale : kyrgyz (ky)
+ //! author : Chyngyz Arystan uulu : https://github.com/chyngyz
+
+
+ var ky__suffixes = {
+ 0: '-чү',
+ 1: '-чи',
+ 2: '-чи',
+ 3: '-чү',
+ 4: '-чү',
+ 5: '-чи',
+ 6: '-чы',
+ 7: '-чи',
+ 8: '-чи',
+ 9: '-чу',
+ 10: '-чу',
+ 20: '-чы',
+ 30: '-чу',
+ 40: '-чы',
+ 50: '-чү',
+ 60: '-чы',
+ 70: '-чи',
+ 80: '-чи',
+ 90: '-чу',
+ 100: '-чү'
+ };
+
+ var ky = moment.defineLocale('ky', {
+ months : 'январь_февраль_март_апрель_май_июнь_июль_август_сентябрь_октябрь_ноябрь_декабрь'.split('_'),
+ monthsShort : 'янв_фев_март_апр_май_июнь_июль_авг_сен_окт_ноя_дек'.split('_'),
+ weekdays : 'Жекшемби_Дүйшөмбү_Шейшемби_Шаршемби_Бейшемби_Жума_Ишемби'.split('_'),
+ weekdaysShort : 'Жек_Дүй_Шей_Шар_Бей_Жум_Ише'.split('_'),
+ weekdaysMin : 'Жк_Дй_Шй_Шр_Бй_Жм_Иш'.split('_'),
+ longDateFormat : {
+ LT : 'HH:mm',
+ LTS : 'HH:mm:ss',
+ L : 'DD.MM.YYYY',
+ LL : 'D MMMM YYYY',
+ LLL : 'D MMMM YYYY HH:mm',
+ LLLL : 'dddd, D MMMM YYYY HH:mm'
+ },
+ calendar : {
+ sameDay : '[Бүгүн саат] LT',
+ nextDay : '[Эртең саат] LT',
+ nextWeek : 'dddd [саат] LT',
+ lastDay : '[Кече саат] LT',
+ lastWeek : '[Өткен аптанын] dddd [күнү] [саат] LT',
+ sameElse : 'L'
+ },
+ relativeTime : {
+ future : '%s ичинде',
+ past : '%s мурун',
+ s : 'бирнече секунд',
+ m : 'бир мүнөт',
+ mm : '%d мүнөт',
+ h : 'бир саат',
+ hh : '%d саат',
+ d : 'бир күн',
+ dd : '%d күн',
+ M : 'бир ай',
+ MM : '%d ай',
+ y : 'бир жыл',
+ yy : '%d жыл'
+ },
+ ordinalParse: /\d{1,2}-(чи|чы|чү|чу)/,
+ ordinal : function (number) {
+ var a = number % 10,
+ b = number >= 100 ? 100 : null;
+ return number + (ky__suffixes[number] || ky__suffixes[a] || ky__suffixes[b]);
+ },
+ week : {
+ dow : 1, // Monday is the first day of the week.
+ doy : 7 // The week that contains Jan 1st is the first week of the year.
}
});
@@ -4131,9 +4259,11 @@
var lb = moment.defineLocale('lb', {
months: 'Januar_Februar_Mäerz_Abrëll_Mee_Juni_Juli_August_September_Oktober_November_Dezember'.split('_'),
monthsShort: 'Jan._Febr._Mrz._Abr._Mee_Jun._Jul._Aug._Sept._Okt._Nov._Dez.'.split('_'),
+ monthsParseExact : true,
weekdays: 'Sonndeg_Méindeg_Dënschdeg_Mëttwoch_Donneschdeg_Freideg_Samschdeg'.split('_'),
weekdaysShort: 'So._Mé._Dë._Më._Do._Fr._Sa.'.split('_'),
weekdaysMin: 'So_Mé_Dë_Më_Do_Fr_Sa'.split('_'),
+ weekdaysParseExact : true,
longDateFormat: {
LT: 'H:mm [Auer]',
LTS: 'H:mm:ss [Auer]',
@@ -4192,6 +4322,7 @@
weekdays : 'ອາທິດ_ຈັນ_ອັງຄານ_ພຸດ_ພະຫັດ_ສຸກ_ເສົາ'.split('_'),
weekdaysShort : 'ທິດ_ຈັນ_ອັງຄານ_ພຸດ_ພະຫັດ_ສຸກ_ເສົາ'.split('_'),
weekdaysMin : 'ທ_ຈ_ອຄ_ພ_ພຫ_ສກ_ສ'.split('_'),
+ weekdaysParseExact : true,
longDateFormat : {
LT : 'HH:mm',
LTS : 'HH:mm:ss',
@@ -4299,6 +4430,7 @@
},
weekdaysShort : 'Sek_Pir_Ant_Tre_Ket_Pen_Šeš'.split('_'),
weekdaysMin : 'S_P_A_T_K_Pn_Š'.split('_'),
+ weekdaysParseExact : true,
longDateFormat : {
LT : 'HH:mm',
LTS : 'HH:mm:ss',
@@ -4390,6 +4522,7 @@
weekdays : 'svētdiena_pirmdiena_otrdiena_trešdiena_ceturtdiena_piektdiena_sestdiena'.split('_'),
weekdaysShort : 'Sv_P_O_T_C_Pk_S'.split('_'),
weekdaysMin : 'Sv_P_O_T_C_Pk_S'.split('_'),
+ weekdaysParseExact : true,
longDateFormat : {
LT : 'HH:mm',
LTS : 'HH:mm:ss',
@@ -4457,11 +4590,13 @@
};
var me = moment.defineLocale('me', {
- months: ['januar', 'februar', 'mart', 'april', 'maj', 'jun', 'jul', 'avgust', 'septembar', 'oktobar', 'novembar', 'decembar'],
- monthsShort: ['jan.', 'feb.', 'mar.', 'apr.', 'maj', 'jun', 'jul', 'avg.', 'sep.', 'okt.', 'nov.', 'dec.'],
- weekdays: ['nedjelja', 'ponedjeljak', 'utorak', 'srijeda', 'četvrtak', 'petak', 'subota'],
- weekdaysShort: ['ned.', 'pon.', 'uto.', 'sri.', 'čet.', 'pet.', 'sub.'],
- weekdaysMin: ['ne', 'po', 'ut', 'sr', 'če', 'pe', 'su'],
+ months: 'januar_februar_mart_april_maj_jun_jul_avgust_septembar_oktobar_novembar_decembar'.split('_'),
+ monthsShort: 'jan._feb._mar._apr._maj_jun_jul_avg._sep._okt._nov._dec.'.split('_'),
+ monthsParseExact : true,
+ weekdays: 'nedjelja_ponedjeljak_utorak_srijeda_četvrtak_petak_subota'.split('_'),
+ weekdaysShort: 'ned._pon._uto._sri._čet._pet._sub.'.split('_'),
+ weekdaysMin: 'ne_po_ut_sr_če_pe_su'.split('_'),
+ weekdaysParseExact : true,
longDateFormat: {
LT: 'H:mm',
LTS : 'H:mm:ss',
@@ -4613,6 +4748,7 @@
var ml = moment.defineLocale('ml', {
months : 'ജനുവരി_ഫെബ്രുവരി_മാർച്ച്_ഏപ്രിൽ_മേയ്_ജൂൺ_ജൂലൈ_ഓഗസ്റ്റ്_സെപ്റ്റംബർ_ഒക്ടോബർ_നവംബർ_ഡിസംബർ'.split('_'),
monthsShort : 'ജനു._ഫെബ്രു._മാർ._ഏപ്രി._മേയ്_ജൂൺ_ജൂലൈ._ഓഗ._സെപ്റ്റ._ഒക്ടോ._നവം._ഡിസം.'.split('_'),
+ monthsParseExact : true,
weekdays : 'ഞായറാഴ്ച_തിങ്കളാഴ്ച_ചൊവ്വാഴ്ച_ബുധനാഴ്ച_വ്യാഴാഴ്ച_വെള്ളിയാഴ്ച_ശനിയാഴ്ച'.split('_'),
weekdaysShort : 'ഞായർ_തിങ്കൾ_ചൊവ്വ_ബുധൻ_വ്യാഴം_വെള്ളി_ശനി'.split('_'),
weekdaysMin : 'ഞാ_തി_ചൊ_ബു_വ്യാ_വെ_ശ'.split('_'),
@@ -4648,8 +4784,17 @@
yy : '%d വർഷം'
},
meridiemParse: /രാത്രി|രാവിലെ|ഉച്ച കഴിഞ്ഞ്|വൈകുന്നേരം|രാത്രി/i,
- isPM : function (input) {
- return /^(ഉച്ച കഴിഞ്ഞ്|വൈകുന്നേരം|രാത്രി)$/.test(input);
+ meridiemHour : function (hour, meridiem) {
+ if (hour === 12) {
+ hour = 0;
+ }
+ if ((meridiem === 'രാത്രി' && hour >= 4) ||
+ meridiem === 'ഉച്ച കഴിഞ്ഞ്' ||
+ meridiem === 'വൈകുന്നേരം') {
+ return hour + 12;
+ } else {
+ return hour;
+ }
},
meridiem : function (hour, minute, isLower) {
if (hour < 4) {
@@ -4735,6 +4880,7 @@
var mr = moment.defineLocale('mr', {
months : 'जानेवारी_फेब्रुवारी_मार्च_एप्रिल_मे_जून_जुलै_ऑगस्ट_सप्टेंबर_ऑक्टोबर_नोव्हेंबर_डिसेंबर'.split('_'),
monthsShort: 'जाने._फेब्रु._मार्च._एप्रि._मे._जून._जुलै._ऑग._सप्टें._ऑक्टो._नोव्हें._डिसें.'.split('_'),
+ monthsParseExact : true,
weekdays : 'रविवार_सोमवार_मंगळवार_बुधवार_गुरूवार_शुक्रवार_शनिवार'.split('_'),
weekdaysShort : 'रवि_सोम_मंगळ_बुध_गुरू_शुक्र_शनि'.split('_'),
weekdaysMin : 'र_सो_मं_बु_गु_शु_श'.split('_'),
@@ -5045,9 +5191,11 @@
var nb = moment.defineLocale('nb', {
months : 'januar_februar_mars_april_mai_juni_juli_august_september_oktober_november_desember'.split('_'),
monthsShort : 'jan._feb._mars_april_mai_juni_juli_aug._sep._okt._nov._des.'.split('_'),
+ monthsParseExact : true,
weekdays : 'søndag_mandag_tirsdag_onsdag_torsdag_fredag_lørdag'.split('_'),
weekdaysShort : 'sø._ma._ti._on._to._fr._lø.'.split('_'),
weekdaysMin : 'sø_ma_ti_on_to_fr_lø'.split('_'),
+ weekdaysParseExact : true,
longDateFormat : {
LT : 'HH:mm',
LTS : 'HH:mm:ss',
@@ -5066,7 +5214,7 @@
},
relativeTime : {
future : 'om %s',
- past : 'for %s siden',
+ past : '%s siden',
s : 'noen sekunder',
m : 'ett minutt',
mm : '%d minutter',
@@ -5119,9 +5267,11 @@
var ne = moment.defineLocale('ne', {
months : 'जनवरी_फेब्रुवरी_मार्च_अप्रिल_मई_जुन_जुलाई_अगष्ट_सेप्टेम्बर_अक्टोबर_नोभेम्बर_डिसेम्बर'.split('_'),
monthsShort : 'जन._फेब्रु._मार्च_अप्रि._मई_जुन_जुलाई._अग._सेप्ट._अक्टो._नोभे._डिसे.'.split('_'),
+ monthsParseExact : true,
weekdays : 'आइतबार_सोमबार_मङ्गलबार_बुधबार_बिहिबार_शुक्रबार_शनिबार'.split('_'),
weekdaysShort : 'आइत._सोम._मङ्गल._बुध._बिहि._शुक्र._शनि.'.split('_'),
weekdaysMin : 'आ._सो._मं._बु._बि._शु._श.'.split('_'),
+ weekdaysParseExact : true,
longDateFormat : {
LT : 'Aको h:mm बजे',
LTS : 'Aको h:mm:ss बजे',
@@ -5213,9 +5363,11 @@
return nl__monthsShortWithDots[m.month()];
}
},
+ monthsParseExact : true,
weekdays : 'zondag_maandag_dinsdag_woensdag_donderdag_vrijdag_zaterdag'.split('_'),
weekdaysShort : 'zo._ma._di._wo._do._vr._za.'.split('_'),
weekdaysMin : 'Zo_Ma_Di_Wo_Do_Vr_Za'.split('_'),
+ weekdaysParseExact : true,
longDateFormat : {
LT : 'HH:mm',
LTS : 'HH:mm:ss',
@@ -5285,7 +5437,7 @@
},
relativeTime : {
future : 'om %s',
- past : 'for %s sidan',
+ past : '%s sidan',
s : 'nokre sekund',
m : 'eit minutt',
mm : '%d minutt',
@@ -5303,6 +5455,119 @@
week : {
dow : 1, // Monday is the first day of the week.
doy : 4 // The week that contains Jan 4th is the first week of the year.
+ }
+ });
+
+ //! moment.js locale configuration
+ //! locale : punjabi india (pa-in)
+ //! author : Harpreet Singh : https://github.com/harpreetkhalsagtbit
+
+ var pa_in__symbolMap = {
+ '1': '੧',
+ '2': '੨',
+ '3': '੩',
+ '4': '੪',
+ '5': '੫',
+ '6': '੬',
+ '7': '੭',
+ '8': '੮',
+ '9': '੯',
+ '0': '੦'
+ },
+ pa_in__numberMap = {
+ '੧': '1',
+ '੨': '2',
+ '੩': '3',
+ '੪': '4',
+ '੫': '5',
+ '੬': '6',
+ '੭': '7',
+ '੮': '8',
+ '੯': '9',
+ '੦': '0'
+ };
+
+ var pa_in = moment.defineLocale('pa-in', {
+ // There are months name as per Nanakshahi Calender but they are not used as rigidly in modern Punjabi.
+ months : 'ਜਨਵਰੀ_ਫ਼ਰਵਰੀ_ਮਾਰਚ_ਅਪ੍ਰੈਲ_ਮਈ_ਜੂਨ_ਜੁਲਾਈ_ਅਗਸਤ_ਸਤੰਬਰ_ਅਕਤੂਬਰ_ਨਵੰਬਰ_ਦਸੰਬਰ'.split('_'),
+ monthsShort : 'ਜਨਵਰੀ_ਫ਼ਰਵਰੀ_ਮਾਰਚ_ਅਪ੍ਰੈਲ_ਮਈ_ਜੂਨ_ਜੁਲਾਈ_ਅਗਸਤ_ਸਤੰਬਰ_ਅਕਤੂਬਰ_ਨਵੰਬਰ_ਦਸੰਬਰ'.split('_'),
+ weekdays : 'ਐਤਵਾਰ_ਸੋਮਵਾਰ_ਮੰਗਲਵਾਰ_ਬੁਧਵਾਰ_ਵੀਰਵਾਰ_ਸ਼ੁੱਕਰਵਾਰ_ਸ਼ਨੀਚਰਵਾਰ'.split('_'),
+ weekdaysShort : 'ਐਤ_ਸੋਮ_ਮੰਗਲ_ਬੁਧ_ਵੀਰ_ਸ਼ੁਕਰ_ਸ਼ਨੀ'.split('_'),
+ weekdaysMin : 'ਐਤ_ਸੋਮ_ਮੰਗਲ_ਬੁਧ_ਵੀਰ_ਸ਼ੁਕਰ_ਸ਼ਨੀ'.split('_'),
+ longDateFormat : {
+ LT : 'A h:mm ਵਜੇ',
+ LTS : 'A h:mm:ss ਵਜੇ',
+ L : 'DD/MM/YYYY',
+ LL : 'D MMMM YYYY',
+ LLL : 'D MMMM YYYY, A h:mm ਵਜੇ',
+ LLLL : 'dddd, D MMMM YYYY, A h:mm ਵਜੇ'
+ },
+ calendar : {
+ sameDay : '[ਅਜ] LT',
+ nextDay : '[ਕਲ] LT',
+ nextWeek : 'dddd, LT',
+ lastDay : '[ਕਲ] LT',
+ lastWeek : '[ਪਿਛਲੇ] dddd, LT',
+ sameElse : 'L'
+ },
+ relativeTime : {
+ future : '%s ਵਿੱਚ',
+ past : '%s ਪਿਛਲੇ',
+ s : 'ਕੁਝ ਸਕਿੰਟ',
+ m : 'ਇਕ ਮਿੰਟ',
+ mm : '%d ਮਿੰਟ',
+ h : 'ਇੱਕ ਘੰਟਾ',
+ hh : '%d ਘੰਟੇ',
+ d : 'ਇੱਕ ਦਿਨ',
+ dd : '%d ਦਿਨ',
+ M : 'ਇੱਕ ਮਹੀਨਾ',
+ MM : '%d ਮਹੀਨੇ',
+ y : 'ਇੱਕ ਸਾਲ',
+ yy : '%d ਸਾਲ'
+ },
+ preparse: function (string) {
+ return string.replace(/[੧੨੩੪੫੬੭੮੯੦]/g, function (match) {
+ return pa_in__numberMap[match];
+ });
+ },
+ postformat: function (string) {
+ return string.replace(/\d/g, function (match) {
+ return pa_in__symbolMap[match];
+ });
+ },
+ // Punjabi notation for meridiems are quite fuzzy in practice. While there exists
+ // a rigid notion of a 'Pahar' it is not used as rigidly in modern Punjabi.
+ meridiemParse: /ਰਾਤ|ਸਵੇਰ|ਦੁਪਹਿਰ|ਸ਼ਾਮ/,
+ meridiemHour : function (hour, meridiem) {
+ if (hour === 12) {
+ hour = 0;
+ }
+ if (meridiem === 'ਰਾਤ') {
+ return hour < 4 ? hour : hour + 12;
+ } else if (meridiem === 'ਸਵੇਰ') {
+ return hour;
+ } else if (meridiem === 'ਦੁਪਹਿਰ') {
+ return hour >= 10 ? hour : hour + 12;
+ } else if (meridiem === 'ਸ਼ਾਮ') {
+ return hour + 12;
+ }
+ },
+ meridiem : function (hour, minute, isLower) {
+ if (hour < 4) {
+ return 'ਰਾਤ';
+ } else if (hour < 10) {
+ return 'ਸਵੇਰ';
+ } else if (hour < 17) {
+ return 'ਦੁਪਹਿਰ';
+ } else if (hour < 20) {
+ return 'ਸ਼ਾਮ';
+ } else {
+ return 'ਰਾਤ';
+ }
+ },
+ week : {
+ dow : 0, // Sunday is the first day of the week.
+ doy : 6 // The week that contains Jan 1st is the first week of the year.
}
});
@@ -5407,9 +5672,10 @@
var pt_br = moment.defineLocale('pt-br', {
months : 'Janeiro_Fevereiro_Março_Abril_Maio_Junho_Julho_Agosto_Setembro_Outubro_Novembro_Dezembro'.split('_'),
monthsShort : 'Jan_Fev_Mar_Abr_Mai_Jun_Jul_Ago_Set_Out_Nov_Dez'.split('_'),
- weekdays : 'Domingo_Segunda-Feira_Terça-Feira_Quarta-Feira_Quinta-Feira_Sexta-Feira_Sábado'.split('_'),
+ weekdays : 'Domingo_Segunda-feira_Terça-feira_Quarta-feira_Quinta-feira_Sexta-feira_Sábado'.split('_'),
weekdaysShort : 'Dom_Seg_Ter_Qua_Qui_Sex_Sáb'.split('_'),
weekdaysMin : 'Dom_2ª_3ª_4ª_5ª_6ª_Sáb'.split('_'),
+ weekdaysParseExact : true,
longDateFormat : {
LT : 'HH:mm',
LTS : 'HH:mm:ss',
@@ -5459,6 +5725,7 @@
weekdays : 'Domingo_Segunda-Feira_Terça-Feira_Quarta-Feira_Quinta-Feira_Sexta-Feira_Sábado'.split('_'),
weekdaysShort : 'Dom_Seg_Ter_Qua_Qui_Sex_Sáb'.split('_'),
weekdaysMin : 'Dom_2ª_3ª_4ª_5ª_6ª_Sáb'.split('_'),
+ weekdaysParseExact : true,
longDateFormat : {
LT : 'HH:mm',
LTS : 'HH:mm:ss',
@@ -5525,6 +5792,7 @@
var ro = moment.defineLocale('ro', {
months : 'ianuarie_februarie_martie_aprilie_mai_iunie_iulie_august_septembrie_octombrie_noiembrie_decembrie'.split('_'),
monthsShort : 'ian._febr._mart._apr._mai_iun._iul._aug._sept._oct._nov._dec.'.split('_'),
+ monthsParseExact: true,
weekdays : 'duminică_luni_marți_miercuri_joi_vineri_sâmbătă'.split('_'),
weekdaysShort : 'Dum_Lun_Mar_Mie_Joi_Vin_Sâm'.split('_'),
weekdaysMin : 'Du_Lu_Ma_Mi_Jo_Vi_Sâ'.split('_'),
@@ -5569,6 +5837,7 @@
//! locale : russian (ru)
//! author : Viktorminator : https://github.com/Viktorminator
//! Author : Menelion Elensúle : https://github.com/Oire
+ //! author : Коренберг Марк : https://github.com/socketpair
function ru__plural(word, num) {
var forms = word.split('_');
@@ -5589,27 +5858,35 @@
return number + ' ' + ru__plural(format[key], +number);
}
}
- var monthsParse = [/^янв/i, /^фев/i, /^мар/i, /^апр/i, /^ма[й|я]/i, /^июн/i, /^июл/i, /^авг/i, /^сен/i, /^окт/i, /^ноя/i, /^дек/i];
-
+ var monthsParse = [/^янв/i, /^фев/i, /^мар/i, /^апр/i, /^ма[йя]/i, /^июн/i, /^июл/i, /^авг/i, /^сен/i, /^окт/i, /^ноя/i, /^дек/i];
+
+ // http://new.gramota.ru/spravka/rules/139-prop : § 103
+ // Сокращения месяцев: http://new.gramota.ru/spravka/buro/search-answer?s=242637
+ // CLDR data: http://www.unicode.org/cldr/charts/28/summary/ru.html#1753
var ru = moment.defineLocale('ru', {
months : {
- format: 'Января_Февраля_Марта_Апреля_Мая_Июня_Июля_Августа_Сентября_Октября_Ноября_Декабря'.split('_'),
- standalone: 'Январь_Февраль_Март_Апрель_Май_Июнь_Июль_Август_Сентябрь_Октябрь_Ноябрь_Декабрь'.split('_')
+ format: 'января_февраля_марта_апреля_мая_июня_июля_августа_сентября_октября_ноября_декабря'.split('_'),
+ standalone: 'январь_февраль_март_апрель_май_июнь_июль_август_сентябрь_октябрь_ноябрь_декабрь'.split('_')
},
monthsShort : {
- format: 'янв_фев_мар_апр_мая_июня_июля_авг_сен_окт_ноя_дек'.split('_'),
- standalone: 'янв_фев_март_апр_май_июнь_июль_авг_сен_окт_ноя_дек'.split('_')
+ // по CLDR именно "июл." и "июн.", но какой смысл менять букву на точку ?
+ format: 'янв._февр._мар._апр._мая_июня_июля_авг._сент._окт._нояб._дек.'.split('_'),
+ standalone: 'янв._февр._март_апр._май_июнь_июль_авг._сент._окт._нояб._дек.'.split('_')
},
weekdays : {
- standalone: 'Воскресенье_Понедельник_Вторник_Среда_Четверг_Пятница_Суббота'.split('_'),
- format: 'Воскресенье_Понедельник_Вторник_Среду_Четверг_Пятницу_Субботу'.split('_'),
+ standalone: 'воскресенье_понедельник_вторник_среда_четверг_пятница_суббота'.split('_'),
+ format: 'воскресенье_понедельник_вторник_среду_четверг_пятницу_субботу'.split('_'),
isFormat: /\[ ?[Вв] ?(?:прошлую|следующую|эту)? ?\] ?dddd/
},
- weekdaysShort : 'Вс_Пн_Вт_Ср_Чт_Пт_Сб'.split('_'),
- weekdaysMin : 'Вс_Пн_Вт_Ср_Чт_Пт_Сб'.split('_'),
+ weekdaysShort : 'вс_пн_вт_ср_чт_пт_сб'.split('_'),
+ weekdaysMin : 'вс_пн_вт_ср_чт_пт_сб'.split('_'),
monthsParse : monthsParse,
longMonthsParse : monthsParse,
shortMonthsParse : monthsParse,
+ monthsRegex: /^(сентябр[яь]|октябр[яь]|декабр[яь]|феврал[яь]|январ[яь]|апрел[яь]|августа?|ноябр[яь]|сент\.|февр\.|нояб\.|июнь|янв.|июль|дек.|авг.|апр.|марта|мар[.т]|окт.|июн[яь]|июл[яь]|ма[яй])/i,
+ monthsShortRegex: /^(сентябр[яь]|октябр[яь]|декабр[яь]|феврал[яь]|январ[яь]|апрел[яь]|августа?|ноябр[яь]|сент\.|февр\.|нояб\.|июнь|янв.|июль|дек.|авг.|апр.|марта|мар[.т]|окт.|июн[яь]|июл[яь]|ма[яй])/i,
+ monthsStrictRegex: /^(сентябр[яь]|октябр[яь]|декабр[яь]|феврал[яь]|январ[яь]|апрел[яь]|августа?|ноябр[яь]|марта?|июн[яь]|июл[яь]|ма[яй])/i,
+ monthsShortStrictRegex: /^(нояб\.|февр\.|сент\.|июль|янв\.|июн[яь]|мар[.т]|авг\.|апр\.|окт\.|дек\.|ма[яй])/i,
longDateFormat : {
LT : 'HH:mm',
LTS : 'HH:mm:ss',
@@ -5781,6 +6058,7 @@
weekdays : 'ඉරිදා_සඳුදා_අඟහරුවාදා_බදාදා_බ්රහස්පතින්දා_සිකුරාදා_සෙනසුරාදා'.split('_'),
weekdaysShort : 'ඉරි_සඳු_අඟ_බදා_බ්රහ_සිකු_සෙන'.split('_'),
weekdaysMin : 'ඉ_ස_අ_බ_බ්ර_සි_සෙ'.split('_'),
+ weekdaysParseExact : true,
longDateFormat : {
LT : 'a h:mm',
LTS : 'a h:mm:ss',
@@ -5815,6 +6093,10 @@
ordinalParse: /\d{1,2} වැනි/,
ordinal : function (number) {
return number + ' වැනි';
+ },
+ meridiemParse : /පෙර වරු|පස් වරු|පෙ.ව|ප.ව./,
+ isPM : function (input) {
+ return input === 'ප.ව.' || input === 'පස් වරු';
},
meridiem : function (hours, minutes, isLower) {
if (hours > 11) {
@@ -6042,9 +6324,11 @@
var sl = moment.defineLocale('sl', {
months : 'januar_februar_marec_april_maj_junij_julij_avgust_september_oktober_november_december'.split('_'),
monthsShort : 'jan._feb._mar._apr._maj._jun._jul._avg._sep._okt._nov._dec.'.split('_'),
+ monthsParseExact: true,
weekdays : 'nedelja_ponedeljek_torek_sreda_četrtek_petek_sobota'.split('_'),
weekdaysShort : 'ned._pon._tor._sre._čet._pet._sob.'.split('_'),
weekdaysMin : 'ne_po_to_sr_če_pe_so'.split('_'),
+ weekdaysParseExact : true,
longDateFormat : {
LT : 'H:mm',
LTS : 'H:mm:ss',
@@ -6125,6 +6409,7 @@
weekdays : 'E Diel_E Hënë_E Martë_E Mërkurë_E Enjte_E Premte_E Shtunë'.split('_'),
weekdaysShort : 'Die_Hën_Mar_Mër_Enj_Pre_Sht'.split('_'),
weekdaysMin : 'D_H_Ma_Më_E_P_Sh'.split('_'),
+ weekdaysParseExact : true,
meridiemParse: /PD|MD/,
isPM: function (input) {
return input.charAt(0) === 'M';
@@ -6199,11 +6484,13 @@
};
var sr_cyrl = moment.defineLocale('sr-cyrl', {
- months: ['јануар', 'фебруар', 'март', 'април', 'мај', 'јун', 'јул', 'август', 'септембар', 'октобар', 'новембар', 'децембар'],
- monthsShort: ['јан.', 'феб.', 'мар.', 'апр.', 'мај', 'јун', 'јул', 'авг.', 'сеп.', 'окт.', 'нов.', 'дец.'],
- weekdays: ['недеља', 'понедељак', 'уторак', 'среда', 'четвртак', 'петак', 'субота'],
- weekdaysShort: ['нед.', 'пон.', 'уто.', 'сре.', 'чет.', 'пет.', 'суб.'],
- weekdaysMin: ['не', 'по', 'ут', 'ср', 'че', 'пе', 'су'],
+ months: 'јануар_фебруар_март_април_мај_јун_јул_август_септембар_октобар_новембар_децембар'.split('_'),
+ monthsShort: 'јан._феб._мар._апр._мај_јун_јул_авг._сеп._окт._нов._дец.'.split('_'),
+ monthsParseExact: true,
+ weekdays: 'недеља_понедељак_уторак_среда_четвртак_петак_субота'.split('_'),
+ weekdaysShort: 'нед._пон._уто._сре._чет._пет._суб.'.split('_'),
+ weekdaysMin: 'не_по_ут_ср_че_пе_су'.split('_'),
+ weekdaysParseExact : true,
longDateFormat: {
LT: 'H:mm',
LTS : 'H:mm:ss',
@@ -6296,11 +6583,13 @@
};
var sr = moment.defineLocale('sr', {
- months: ['januar', 'februar', 'mart', 'april', 'maj', 'jun', 'jul', 'avgust', 'septembar', 'oktobar', 'novembar', 'decembar'],
- monthsShort: ['jan.', 'feb.', 'mar.', 'apr.', 'maj', 'jun', 'jul', 'avg.', 'sep.', 'okt.', 'nov.', 'dec.'],
- weekdays: ['nedelja', 'ponedeljak', 'utorak', 'sreda', 'četvrtak', 'petak', 'subota'],
- weekdaysShort: ['ned.', 'pon.', 'uto.', 'sre.', 'čet.', 'pet.', 'sub.'],
- weekdaysMin: ['ne', 'po', 'ut', 'sr', 'če', 'pe', 'su'],
+ months: 'januar_februar_mart_april_maj_jun_jul_avgust_septembar_oktobar_novembar_decembar'.split('_'),
+ monthsShort: 'jan._feb._mar._apr._maj_jun_jul_avg._sep._okt._nov._dec.'.split('_'),
+ monthsParseExact: true,
+ weekdays: 'nedelja_ponedeljak_utorak_sreda_četvrtak_petak_subota'.split('_'),
+ weekdaysShort: 'ned._pon._uto._sre._čet._pet._sub.'.split('_'),
+ weekdaysMin: 'ne_po_ut_sr_če_pe_su'.split('_'),
+ weekdaysParseExact : true,
longDateFormat: {
LT: 'H:mm',
LTS : 'H:mm:ss',
@@ -6366,6 +6655,84 @@
});
//! moment.js locale configuration
+ //! locale : siSwati (ss)
+ //! author : Nicolai Davies : https://github.com/nicolaidavies
+
+
+ var ss = moment.defineLocale('ss', {
+ months : "Bhimbidvwane_Indlovana_Indlov'lenkhulu_Mabasa_Inkhwekhweti_Inhlaba_Kholwane_Ingci_Inyoni_Imphala_Lweti_Ingongoni".split('_'),
+ monthsShort : 'Bhi_Ina_Inu_Mab_Ink_Inh_Kho_Igc_Iny_Imp_Lwe_Igo'.split('_'),
+ weekdays : 'Lisontfo_Umsombuluko_Lesibili_Lesitsatfu_Lesine_Lesihlanu_Umgcibelo'.split('_'),
+ weekdaysShort : 'Lis_Umb_Lsb_Les_Lsi_Lsh_Umg'.split('_'),
+ weekdaysMin : 'Li_Us_Lb_Lt_Ls_Lh_Ug'.split('_'),
+ weekdaysParseExact : true,
+ longDateFormat : {
+ LT : 'h:mm A',
+ LTS : 'h:mm:ss A',
+ L : 'DD/MM/YYYY',
+ LL : 'D MMMM YYYY',
+ LLL : 'D MMMM YYYY h:mm A',
+ LLLL : 'dddd, D MMMM YYYY h:mm A'
+ },
+ calendar : {
+ sameDay : '[Namuhla nga] LT',
+ nextDay : '[Kusasa nga] LT',
+ nextWeek : 'dddd [nga] LT',
+ lastDay : '[Itolo nga] LT',
+ lastWeek : 'dddd [leliphelile] [nga] LT',
+ sameElse : 'L'
+ },
+ relativeTime : {
+ future : 'nga %s',
+ past : 'wenteka nga %s',
+ s : 'emizuzwana lomcane',
+ m : 'umzuzu',
+ mm : '%d emizuzu',
+ h : 'lihora',
+ hh : '%d emahora',
+ d : 'lilanga',
+ dd : '%d emalanga',
+ M : 'inyanga',
+ MM : '%d tinyanga',
+ y : 'umnyaka',
+ yy : '%d iminyaka'
+ },
+ meridiemParse: /ekuseni|emini|entsambama|ebusuku/,
+ meridiem : function (hours, minutes, isLower) {
+ if (hours < 11) {
+ return 'ekuseni';
+ } else if (hours < 15) {
+ return 'emini';
+ } else if (hours < 19) {
+ return 'entsambama';
+ } else {
+ return 'ebusuku';
+ }
+ },
+ meridiemHour : function (hour, meridiem) {
+ if (hour === 12) {
+ hour = 0;
+ }
+ if (meridiem === 'ekuseni') {
+ return hour;
+ } else if (meridiem === 'emini') {
+ return hour >= 11 ? hour : hour + 12;
+ } else if (meridiem === 'entsambama' || meridiem === 'ebusuku') {
+ if (hour === 0) {
+ return 0;
+ }
+ return hour + 12;
+ }
+ },
+ ordinalParse: /\d{1,2}/,
+ ordinal : '%d',
+ week : {
+ dow : 1, // Monday is the first day of the week.
+ doy : 4 // The week that contains Jan 4th is the first week of the year.
+ }
+ });
+
+ //! moment.js locale configuration
//! locale : swedish (sv)
//! author : Jens Alm : https://github.com/ulmus
@@ -6380,8 +6747,10 @@
LTS : 'HH:mm:ss',
L : 'YYYY-MM-DD',
LL : 'D MMMM YYYY',
- LLL : 'D MMMM YYYY HH:mm',
- LLLL : 'dddd D MMMM YYYY HH:mm'
+ LLL : 'D MMMM YYYY [kl.] HH:mm',
+ LLLL : 'dddd D MMMM YYYY [kl.] HH:mm',
+ lll : 'D MMM YYYY HH:mm',
+ llll : 'ddd D MMM YYYY HH:mm'
},
calendar : {
sameDay: '[Idag] LT',
@@ -6431,6 +6800,7 @@
weekdays : 'Jumapili_Jumatatu_Jumanne_Jumatano_Alhamisi_Ijumaa_Jumamosi'.split('_'),
weekdaysShort : 'Jpl_Jtat_Jnne_Jtan_Alh_Ijm_Jmos'.split('_'),
weekdaysMin : 'J2_J3_J4_J5_Al_Ij_J1'.split('_'),
+ weekdaysParseExact : true,
longDateFormat : {
LT : 'HH:mm',
LTS : 'HH:mm:ss',
@@ -6593,6 +6963,7 @@
var te = moment.defineLocale('te', {
months : 'జనవరి_ఫిబ్రవరి_మార్చి_ఏప్రిల్_మే_జూన్_జూలై_ఆగస్టు_సెప్టెంబర్_అక్టోబర్_నవంబర్_డిసెంబర్'.split('_'),
monthsShort : 'జన._ఫిబ్ర._మార్చి_ఏప్రి._మే_జూన్_జూలై_ఆగ._సెప్._అక్టో._నవ._డిసె.'.split('_'),
+ monthsParseExact : true,
weekdays : 'ఆదివారం_సోమవారం_మంగళవారం_బుధవారం_గురువారం_శుక్రవారం_శనివారం'.split('_'),
weekdaysShort : 'ఆది_సోమ_మంగళ_బుధ_గురు_శుక్ర_శని'.split('_'),
weekdaysMin : 'ఆ_సో_మం_బు_గు_శు_శ'.split('_'),
@@ -6670,9 +7041,11 @@
var th = moment.defineLocale('th', {
months : 'มกราคม_กุมภาพันธ์_มีนาคม_เมษายน_พฤษภาคม_มิถุนายน_กรกฎาคม_สิงหาคม_กันยายน_ตุลาคม_พฤศจิกายน_ธันวาคม'.split('_'),
monthsShort : 'มกรา_กุมภา_มีนา_เมษา_พฤษภา_มิถุนา_กรกฎา_สิงหา_กันยา_ตุลา_พฤศจิกา_ธันวา'.split('_'),
+ monthsParseExact: true,
weekdays : 'อาทิตย์_จันทร์_อังคาร_พุธ_พฤหัสบดี_ศุกร์_เสาร์'.split('_'),
weekdaysShort : 'อาทิตย์_จันทร์_อังคาร_พุธ_พฤหัส_ศุกร์_เสาร์'.split('_'), // yes, three characters difference
weekdaysMin : 'อา._จ._อ._พ._พฤ._ศ._ส.'.split('_'),
+ weekdaysParseExact : true,
longDateFormat : {
LT : 'H นาฬิกา m นาที',
LTS : 'H นาฬิกา m นาที s วินาที',
@@ -6834,6 +7207,7 @@
var tlh = moment.defineLocale('tlh', {
months : 'tera’ jar wa’_tera’ jar cha’_tera’ jar wej_tera’ jar loS_tera’ jar vagh_tera’ jar jav_tera’ jar Soch_tera’ jar chorgh_tera’ jar Hut_tera’ jar wa’maH_tera’ jar wa’maH wa’_tera’ jar wa’maH cha’'.split('_'),
monthsShort : 'jar wa’_jar cha’_jar wej_jar loS_jar vagh_jar jav_jar Soch_jar chorgh_jar Hut_jar wa’maH_jar wa’maH wa’_jar wa’maH cha’'.split('_'),
+ monthsParseExact : true,
weekdays : 'lojmItjaj_DaSjaj_povjaj_ghItlhjaj_loghjaj_buqjaj_ghInjaj'.split('_'),
weekdaysShort : 'lojmItjaj_DaSjaj_povjaj_ghItlhjaj_loghjaj_buqjaj_ghInjaj'.split('_'),
weekdaysMin : 'lojmItjaj_DaSjaj_povjaj_ghItlhjaj_loghjaj_buqjaj_ghInjaj'.split('_'),
@@ -6976,6 +7350,10 @@
LLL : 'D. MMMM [dallas] YYYY HH.mm',
LLLL : 'dddd, [li] D. MMMM [dallas] YYYY HH.mm'
},
+ meridiemParse: /d\'o|d\'a/i,
+ isPM : function (input) {
+ return 'd\'o' === input.toLowerCase();
+ },
meridiem : function (hours, minutes, isLower) {
if (hours > 11) {
return isLower ? 'd\'o' : 'D\'O';
@@ -7314,9 +7692,22 @@
var vi = moment.defineLocale('vi', {
months : 'tháng 1_tháng 2_tháng 3_tháng 4_tháng 5_tháng 6_tháng 7_tháng 8_tháng 9_tháng 10_tháng 11_tháng 12'.split('_'),
monthsShort : 'Th01_Th02_Th03_Th04_Th05_Th06_Th07_Th08_Th09_Th10_Th11_Th12'.split('_'),
+ monthsParseExact : true,
weekdays : 'chủ nhật_thứ hai_thứ ba_thứ tư_thứ năm_thứ sáu_thứ bảy'.split('_'),
weekdaysShort : 'CN_T2_T3_T4_T5_T6_T7'.split('_'),
weekdaysMin : 'CN_T2_T3_T4_T5_T6_T7'.split('_'),
+ weekdaysParseExact : true,
+ meridiemParse: /sa|ch/i,
+ isPM : function (input) {
+ return /^ch$/i.test(input);
+ },
+ meridiem : function (hours, minutes, isLower) {
+ if (hours < 12) {
+ return isLower ? 'sa' : 'SA';
+ } else {
+ return isLower ? 'ch' : 'CH';
+ }
+ },
longDateFormat : {
LT : 'HH:mm',
LTS : 'HH:mm:ss',
@@ -7355,6 +7746,63 @@
ordinalParse: /\d{1,2}/,
ordinal : function (number) {
return number;
+ },
+ week : {
+ dow : 1, // Monday is the first day of the week.
+ doy : 4 // The week that contains Jan 4th is the first week of the year.
+ }
+ });
+
+ //! moment.js locale configuration
+ //! locale : pseudo (x-pseudo)
+ //! author : Andrew Hood : https://github.com/andrewhood125
+
+ var x_pseudo = moment.defineLocale('x-pseudo', {
+ months : 'J~áñúá~rý_F~ébrú~árý_~Márc~h_Áp~ríl_~Máý_~Júñé~_Júl~ý_Áú~gúst~_Sép~témb~ér_Ó~ctób~ér_Ñ~óvém~bér_~Décé~mbér'.split('_'),
+ monthsShort : 'J~áñ_~Féb_~Már_~Ápr_~Máý_~Júñ_~Júl_~Áúg_~Sép_~Óct_~Ñóv_~Déc'.split('_'),
+ monthsParseExact : true,
+ weekdays : 'S~úñdá~ý_Mó~ñdáý~_Túé~sdáý~_Wéd~ñésd~áý_T~húrs~dáý_~Fríd~áý_S~átúr~dáý'.split('_'),
+ weekdaysShort : 'S~úñ_~Móñ_~Túé_~Wéd_~Thú_~Frí_~Sát'.split('_'),
+ weekdaysMin : 'S~ú_Mó~_Tú_~Wé_T~h_Fr~_Sá'.split('_'),
+ weekdaysParseExact : true,
+ longDateFormat : {
+ LT : 'HH:mm',
+ L : 'DD/MM/YYYY',
+ LL : 'D MMMM YYYY',
+ LLL : 'D MMMM YYYY HH:mm',
+ LLLL : 'dddd, D MMMM YYYY HH:mm'
+ },
+ calendar : {
+ sameDay : '[T~ódá~ý át] LT',
+ nextDay : '[T~ómó~rró~w át] LT',
+ nextWeek : 'dddd [át] LT',
+ lastDay : '[Ý~ést~érdá~ý át] LT',
+ lastWeek : '[L~ást] dddd [át] LT',
+ sameElse : 'L'
+ },
+ relativeTime : {
+ future : 'í~ñ %s',
+ past : '%s á~gó',
+ s : 'á ~féw ~sécó~ñds',
+ m : 'á ~míñ~úté',
+ mm : '%d m~íñú~tés',
+ h : 'á~ñ hó~úr',
+ hh : '%d h~óúrs',
+ d : 'á ~dáý',
+ dd : '%d d~áýs',
+ M : 'á ~móñ~th',
+ MM : '%d m~óñt~hs',
+ y : 'á ~ýéár',
+ yy : '%d ý~éárs'
+ },
+ ordinalParse: /\d{1,2}(th|st|nd|rd)/,
+ ordinal : function (number) {
+ var b = number % 10,
+ output = (~~(number % 100 / 10) === 1) ? 'th' :
+ (b === 1) ? 'st' :
+ (b === 2) ? 'nd' :
+ (b === 3) ? 'rd' : 'th';
+ return number + output;
},
week : {
dow : 1, // Monday is the first day of the week.
@@ -7429,7 +7877,7 @@
nextWeek : function () {
var startOfWeek, prefix;
startOfWeek = moment().startOf('week');
- prefix = this.unix() - startOfWeek.unix() >= 7 * 24 * 3600 ? '[下]' : '[本]';
+ prefix = this.diff(startOfWeek, 'days') >= 7 ? '[下]' : '[本]';
return this.minutes() === 0 ? prefix + 'dddAh点整' : prefix + 'dddAh点mm';
},
lastWeek : function () {
@@ -7555,15 +8003,15 @@
future : '%s內',
past : '%s前',
s : '幾秒',
- m : '一分鐘',
+ m : '1分鐘',
mm : '%d分鐘',
- h : '一小時',
+ h : '1小時',
hh : '%d小時',
- d : '一天',
+ d : '1天',
dd : '%d天',
- M : '一個月',
+ M : '1個月',
MM : '%d個月',
- y : '一年',
+ y : '1年',
yy : '%d年'
}
});
diff --git a/min/moment-with-locales.js b/min/moment-with-locales.js
index 1a5de41..b8f0313 100644
--- a/min/moment-with-locales.js
+++ b/min/moment-with-locales.js
@@ -17,7 +17,7 @@
}
function isArray(input) {
- return Object.prototype.toString.call(input) === '[object Array]';
+ return input instanceof Array || Object.prototype.toString.call(input) === '[object Array]';
}
function isDate(input) {
@@ -70,7 +70,9 @@
invalidMonth : null,
invalidFormat : false,
userInvalidated : false,
- iso : false
+ iso : false,
+ parsedDateParts : [],
+ meridiem : null
};
}
@@ -81,9 +83,30 @@
return m._pf;
}
+ var some;
+ if (Array.prototype.some) {
+ some = Array.prototype.some;
+ } else {
+ some = function (fun) {
+ var t = Object(this);
+ var len = t.length >>> 0;
+
+ for (var i = 0; i < len; i++) {
+ if (i in t && fun.call(this, t[i], i, t)) {
+ return true;
+ }
+ }
+
+ return false;
+ };
+ }
+
function valid__isValid(m) {
if (m._isValid == null) {
var flags = getParsingFlags(m);
+ var parsedParts = some.call(flags.parsedDateParts, function (i) {
+ return i != null;
+ });
m._isValid = !isNaN(m._d.getTime()) &&
flags.overflow < 0 &&
!flags.empty &&
@@ -91,7 +114,8 @@
!flags.invalidWeekday &&
!flags.nullInput &&
!flags.invalidFormat &&
- !flags.userInvalidated;
+ !flags.userInvalidated &&
+ (!flags.meridiem || (flags.meridiem && parsedParts));
if (m._strict) {
m._isValid = m._isValid &&
@@ -223,7 +247,105 @@
return diffs + lengthDiff;
}
- function Locale() {
+ function warn(msg) {
+ if (utils_hooks__hooks.suppressDeprecationWarnings === false &&
+ (typeof console !== 'undefined') && console.warn) {
+ console.warn('Deprecation warning: ' + msg);
+ }
+ }
+
+ function deprecate(msg, fn) {
+ var firstTime = true;
+
+ return extend(function () {
+ if (utils_hooks__hooks.deprecationHandler != null) {
+ utils_hooks__hooks.deprecationHandler(null, msg);
+ }
+ if (firstTime) {
+ warn(msg + '\nArguments: ' + Array.prototype.slice.call(arguments).join(', ') + '\n' + (new Error()).stack);
+ firstTime = false;
+ }
+ return fn.apply(this, arguments);
+ }, fn);
+ }
+
+ var deprecations = {};
+
+ function deprecateSimple(name, msg) {
+ if (utils_hooks__hooks.deprecationHandler != null) {
+ utils_hooks__hooks.deprecationHandler(name, msg);
+ }
+ if (!deprecations[name]) {
+ warn(msg);
+ deprecations[name] = true;
+ }
+ }
+
+ utils_hooks__hooks.suppressDeprecationWarnings = false;
+ utils_hooks__hooks.deprecationHandler = null;
+
+ function isFunction(input) {
+ return input instanceof Function || Object.prototype.toString.call(input) === '[object Function]';
+ }
+
+ function isObject(input) {
+ return Object.prototype.toString.call(input) === '[object Object]';
+ }
+
+ function locale_set__set (config) {
+ var prop, i;
+ for (i in config) {
+ prop = config[i];
+ if (isFunction(prop)) {
+ this[i] = prop;
+ } else {
+ this['_' + i] = prop;
+ }
+ }
+ this._config = config;
+ // Lenient ordinal parsing accepts just a number in addition to
+ // number + (possibly) stuff coming from _ordinalParseLenient.
+ this._ordinalParseLenient = new RegExp(this._ordinalParse.source + '|' + (/\d{1,2}/).source);
+ }
+
+ function mergeConfigs(parentConfig, childConfig) {
+ var res = extend({}, parentConfig), prop;
+ for (prop in childConfig) {
+ if (hasOwnProp(childConfig, prop)) {
+ if (isObject(parentConfig[prop]) && isObject(childConfig[prop])) {
+ res[prop] = {};
+ extend(res[prop], parentConfig[prop]);
+ extend(res[prop], childConfig[prop]);
+ } else if (childConfig[prop] != null) {
+ res[prop] = childConfig[prop];
+ } else {
+ delete res[prop];
+ }
+ }
+ }
+ return res;
+ }
+
+ function Locale(config) {
+ if (config != null) {
+ this.set(config);
+ }
+ }
+
+ var keys;
+
+ if (Object.keys) {
+ keys = Object.keys;
+ } else {
+ keys = function (obj) {
+ var i, res = [];
+ for (i in obj) {
+ if (hasOwnProp(obj, i)) {
+ res.push(i);
+ }
+ }
+ return res;
+ };
}
// internal storage for locale config files
@@ -264,7 +386,7 @@
function loadLocale(name) {
var oldLocale = null;
// TODO: Find a better way to register and load all the locales in Node
- if (!locales[name] && !isUndefined(module) &&
+ if (!locales[name] && (typeof module !== 'undefined') &&
module && module.exports) {
try {
oldLocale = globalLocale._abbr;
@@ -299,11 +421,25 @@
return globalLocale._abbr;
}
- function defineLocale (name, values) {
- if (values !== null) {
- values.abbr = name;
- locales[name] = locales[name] || new Locale();
- locales[name].set(values);
+ function defineLocale (name, config) {
+ if (config !== null) {
+ config.abbr = name;
+ if (locales[name] != null) {
+ deprecateSimple('defineLocaleOverride',
+ 'use moment.updateLocale(localeName, config) to change ' +
+ 'an existing locale. moment.defineLocale(localeName, ' +
+ 'config) should only be used for creating a new locale');
+ config = mergeConfigs(locales[name]._config, config);
+ } else if (config.parentLocale != null) {
+ if (locales[config.parentLocale] != null) {
+ config = mergeConfigs(locales[config.parentLocale]._config, config);
+ } else {
+ // treat as if there is no base config
+ deprecateSimple('parentLocaleUndefined',
+ 'specified parentLocale is not defined yet');
+ }
+ }
+ locales[name] = new Locale(config);
// backwards compat for now: also set the locale
locale_locales__getSetGlobalLocale(name);
@@ -316,6 +452,31 @@
}
}
+ function updateLocale(name, config) {
+ if (config != null) {
+ var locale;
+ if (locales[name] != null) {
+ config = mergeConfigs(locales[name]._config, config);
+ }
+ locale = new Locale(config);
+ locale.parentLocale = locales[name];
+ locales[name] = locale;
+
+ // backwards compat for now: also set the locale
+ locale_locales__getSetGlobalLocale(name);
+ } else {
+ // pass null for config to unupdate, useful for tests
+ if (locales[name] != null) {
+ if (locales[name].parentLocale != null) {
+ locales[name] = locales[name].parentLocale;
+ } else if (locales[name] != null) {
+ delete locales[name];
+ }
+ }
+ }
+ return locales[name];
+ }
+
// returns locale data
function locale_locales__getLocale (key) {
var locale;
@@ -338,6 +499,10 @@
}
return chooseLocale(key);
+ }
+
+ function locale_locales__listLocales() {
+ return keys(locales);
}
var aliases = {};
@@ -366,10 +531,6 @@
}
return normalizedInput;
- }
-
- function isFunction(input) {
- return input instanceof Function || Object.prototype.toString.call(input) === '[object Function]';
}
function makeGetSet (unit, keepTime) {
@@ -420,7 +581,7 @@
Math.pow(10, Math.max(0, zerosToFill)).toString().substr(1) + absNumber;
}
- var formattingTokens = /(\[[^\[]*\])|(\\)?([Hh]mm(ss)?|Mo|MM?M?M?|Do|DDDo|DD?D?D?|ddd?d?|do?|w[o|w]?|W[o|W]?|Qo?|YYYYYY|YYYYY|YYYY|YY|gg(ggg?)?|GG(GGG?)?|e|E|a|A|hh?|HH?|mm?|ss?|S{1,9}|x|X|zz?|ZZ?|.)/g;
+ var formattingTokens = /(\[[^\[]*\])|(\\)?([Hh]mm(ss)?|Mo|MM?M?M?|Do|DDDo|DD?D?D?|ddd?d?|do?|w[o|w]?|W[o|W]?|Qo?|YYYYYY|YYYYY|YYYY|YY|gg(ggg?)?|GG(GGG?)?|e|E|a|A|hh?|HH?|kk?|mm?|ss?|S{1,9}|x|X|zz?|ZZ?|.)/g;
var localFormattingTokens = /(\[[^\[]*\])|(\\)?(LTS|LT|LL?L?L?|l{1,4})/g;
@@ -473,7 +634,7 @@
}
return function (mom) {
- var output = '';
+ var output = '', i;
for (i = 0; i < length; i++) {
output += array[i] instanceof Function ? array[i].call(mom, format) : array[i];
}
@@ -532,13 +693,13 @@
// any word (or two) characters or numbers including two/three word month in arabic.
// includes scottish gaelic two word and hyphenated months
- var matchWord = /[0-9]*(a[mn]\s?)?['a-z\u00A0-\u05FF\u0700-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF\-]+|[\u0600-\u06FF\/]+(\s*?[\u0600-\u06FF]+){1,2}/i;
+ var matchWord = /[0-9]*['a-z\u00A0-\u05FF\u0700-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF]+|[\u0600-\u06FF\/]+(\s*?[\u0600-\u06FF]+){1,2}/i;
var regexes = {};
function addRegexToken (token, regex, strictRegex) {
- regexes[token] = isFunction(regex) ? regex : function (isStrict) {
+ regexes[token] = isFunction(regex) ? regex : function (isStrict, localeData) {
return (isStrict && strictRegex) ? strictRegex : regex;
};
}
@@ -553,9 +714,13 @@
// Code from http://stackoverflow.com/questions/3561493/is-there-a-regexp-escape-function-in-javascript
function unescapeFormat(s) {
- return s.replace('\\', '').replace(/\\(\[)|\\(\])|\[([^\]\[]*)\]|\\(.)/g, function (matched, p1, p2, p3, p4) {
+ return regexEscape(s.replace('\\', '').replace(/\\(\[)|\\(\])|\[([^\]\[]*)\]|\\(.)/g, function (matched, p1, p2, p3, p4) {
return p1 || p2 || p3 || p4;
- }).replace(/[-\/\\^$*+?.()|[\]{}]/g, '\\$&');
+ }));
+ }
+
+ function regexEscape(s) {
+ return s.replace(/[-\/\\^$*+?.()|[\]{}]/g, '\\$&');
}
var tokens = {};
@@ -598,6 +763,23 @@
var WEEK = 7;
var WEEKDAY = 8;
+ var indexOf;
+
+ if (Array.prototype.indexOf) {
+ indexOf = Array.prototype.indexOf;
+ } else {
+ indexOf = function (o) {
+ // I know
+ var i;
+ for (i = 0; i < this.length; ++i) {
+ if (this[i] === o) {
+ return i;
+ }
+ }
+ return -1;
+ };
+ }
+
function daysInMonth(year, month) {
return new Date(Date.UTC(year, month + 1, 0)).getUTCDate();
}
@@ -624,8 +806,12 @@
addRegexToken('M', match1to2);
addRegexToken('MM', match1to2, match2);
- addRegexToken('MMM', matchWord);
- addRegexToken('MMMM', matchWord);
+ addRegexToken('MMM', function (isStrict, locale) {
+ return locale.monthsShortRegex(isStrict);
+ });
+ addRegexToken('MMMM', function (isStrict, locale) {
+ return locale.monthsRegex(isStrict);
+ });
addParseToken(['M', 'MM'], function (input, array) {
array[MONTH] = toInt(input) - 1;
@@ -650,14 +836,59 @@
this._months[MONTHS_IN_FORMAT.test(format) ? 'format' : 'standalone'][m.month()];
}
- var defaultLocaleMonthsShort = 'Jan_Feb_Mar_Apr_May_Jun_Jul_Aug_Sept_Oct_Nov_Dec'.split('_');
+ var defaultLocaleMonthsShort = 'Jan_Feb_Mar_Apr_May_Jun_Jul_Aug_Sep_Oct_Nov_Dec'.split('_');
function localeMonthsShort (m, format) {
return isArray(this._monthsShort) ? this._monthsShort[m.month()] :
this._monthsShort[MONTHS_IN_FORMAT.test(format) ? 'format' : 'standalone'][m.month()];
}
+ function units_month__handleStrictParse(monthName, format, strict) {
+ var i, ii, mom, llc = monthName.toLocaleLowerCase();
+ if (!this._monthsParse) {
+ // this is not used
+ this._monthsParse = [];
+ this._longMonthsParse = [];
+ this._shortMonthsParse = [];
+ for (i = 0; i < 12; ++i) {
+ mom = create_utc__createUTC([2000, i]);
+ this._shortMonthsParse[i] = this.monthsShort(mom, '').toLocaleLowerCase();
+ this._longMonthsParse[i] = this.months(mom, '').toLocaleLowerCase();
+ }
+ }
+
+ if (strict) {
+ if (format === 'MMM') {
+ ii = indexOf.call(this._shortMonthsParse, llc);
+ return ii !== -1 ? ii : null;
+ } else {
+ ii = indexOf.call(this._longMonthsParse, llc);
+ return ii !== -1 ? ii : null;
+ }
+ } else {
+ if (format === 'MMM') {
+ ii = indexOf.call(this._shortMonthsParse, llc);
+ if (ii !== -1) {
+ return ii;
+ }
+ ii = indexOf.call(this._longMonthsParse, llc);
+ return ii !== -1 ? ii : null;
+ } else {
+ ii = indexOf.call(this._longMonthsParse, llc);
+ if (ii !== -1) {
+ return ii;
+ }
+ ii = indexOf.call(this._shortMonthsParse, llc);
+ return ii !== -1 ? ii : null;
+ }
+ }
+ }
+
function localeMonthsParse (monthName, format, strict) {
var i, mom, regex;
+
+ if (this._monthsParseExact) {
+ return units_month__handleStrictParse.call(this, monthName, format, strict);
+ }
if (!this._monthsParse) {
this._monthsParse = [];
@@ -665,6 +896,9 @@
this._shortMonthsParse = [];
}
+ // TODO: add sorting
+ // Sorting makes sure if one month (or abbr) is a prefix of another
+ // see sorting in computeMonthsParse
for (i = 0; i < 12; i++) {
// make the regex if we don't have it already
mom = create_utc__createUTC([2000, i]);
@@ -697,12 +931,15 @@
return mom;
}
- // TODO: Move this out of here!
if (typeof value === 'string') {
- value = mom.localeData().monthsParse(value);
- // TODO: Another silent failure?
- if (typeof value !== 'number') {
- return mom;
+ if (/^\d+$/.test(value)) {
+ value = toInt(value);
+ } else {
+ value = mom.localeData().monthsParse(value);
+ // TODO: Another silent failure?
+ if (typeof value !== 'number') {
+ return mom;
+ }
}
}
@@ -723,6 +960,72 @@
function getDaysInMonth () {
return daysInMonth(this.year(), this.month());
+ }
+
+ var defaultMonthsShortRegex = matchWord;
+ function monthsShortRegex (isStrict) {
+ if (this._monthsParseExact) {
+ if (!hasOwnProp(this, '_monthsRegex')) {
+ computeMonthsParse.call(this);
+ }
+ if (isStrict) {
+ return this._monthsShortStrictRegex;
+ } else {
+ return this._monthsShortRegex;
+ }
+ } else {
+ return this._monthsShortStrictRegex && isStrict ?
+ this._monthsShortStrictRegex : this._monthsShortRegex;
+ }
+ }
+
+ var defaultMonthsRegex = matchWord;
+ function monthsRegex (isStrict) {
+ if (this._monthsParseExact) {
+ if (!hasOwnProp(this, '_monthsRegex')) {
+ computeMonthsParse.call(this);
+ }
+ if (isStrict) {
+ return this._monthsStrictRegex;
+ } else {
+ return this._monthsRegex;
+ }
+ } else {
+ return this._monthsStrictRegex && isStrict ?
+ this._monthsStrictRegex : this._monthsRegex;
+ }
+ }
+
+ function computeMonthsParse () {
+ function cmpLenRev(a, b) {
+ return b.length - a.length;
+ }
+
+ var shortPieces = [], longPieces = [], mixedPieces = [],
+ i, mom;
+ for (i = 0; i < 12; i++) {
+ // make the regex if we don't have it already
+ mom = create_utc__createUTC([2000, i]);
+ shortPieces.push(this.monthsShort(mom, ''));
+ longPieces.push(this.months(mom, ''));
+ mixedPieces.push(this.months(mom, ''));
+ mixedPieces.push(this.monthsShort(mom, ''));
+ }
+ // Sorting makes sure if one month (or abbr) is a prefix of another it
+ // will match the longer piece.
+ shortPieces.sort(cmpLenRev);
+ longPieces.sort(cmpLenRev);
+ mixedPieces.sort(cmpLenRev);
+ for (i = 0; i < 12; i++) {
+ shortPieces[i] = regexEscape(shortPieces[i]);
+ longPieces[i] = regexEscape(longPieces[i]);
+ mixedPieces[i] = regexEscape(mixedPieces[i]);
+ }
+
+ this._monthsRegex = new RegExp('^(' + mixedPieces.join('|') + ')', 'i');
+ this._monthsShortRegex = this._monthsRegex;
+ this._monthsStrictRegex = new RegExp('^(' + longPieces.join('|') + ')', 'i');
+ this._monthsShortStrictRegex = new RegExp('^(' + shortPieces.join('|') + ')', 'i');
}
function checkOverflow (m) {
@@ -754,35 +1057,6 @@
return m;
}
-
- function warn(msg) {
- if (utils_hooks__hooks.suppressDeprecationWarnings === false && !isUndefined(console) && console.warn) {
- console.warn('Deprecation warning: ' + msg);
- }
- }
-
- function deprecate(msg, fn) {
- var firstTime = true;
-
- return extend(function () {
- if (firstTime) {
- warn(msg + '\nArguments: ' + Array.prototype.slice.call(arguments).join(', ') + '\n' + (new Error()).stack);
- firstTime = false;
- }
- return fn.apply(this, arguments);
- }, fn);
- }
-
- var deprecations = {};
-
- function deprecateSimple(name, msg) {
- if (!deprecations[name]) {
- warn(msg);
- deprecations[name] = true;
- }
- }
-
- utils_hooks__hooks.suppressDeprecationWarnings = false;
// iso 8601 regex
// 0000-00-00 0000-W00 or 0000-W00-0 + T + 00 or 00:00 or 00:00:00 or 00:00:00.000 + +00:00 or +0000 or +00)
@@ -924,6 +1198,11 @@
// FORMATTING
+ addFormatToken('Y', 0, 0, function () {
+ var y = this.year();
+ return y <= 9999 ? '' + y : '+' + y;
+ });
+
addFormatToken(0, ['YY', 2], 0, function () {
return this.year() % 100;
});
@@ -951,6 +1230,9 @@
addParseToken('YY', function (input, array) {
array[YEAR] = utils_hooks__hooks.parseTwoDigitYear(input);
});
+ addParseToken('Y', function (input, array) {
+ array[YEAR] = parseInt(input, 10);
+ });
// HELPERS
@@ -970,7 +1252,7 @@
// MOMENTS
- var getSetYear = makeGetSet('FullYear', false);
+ var getSetYear = makeGetSet('FullYear', true);
function getIsLeapYear () {
return isLeapYear(this.year());
@@ -1202,6 +1484,8 @@
for (i = 0; i < tokens.length; i++) {
token = tokens[i];
parsedInput = (string.match(getParseRegexForToken(token, config)) || [])[0];
+ // console.log('token', token, 'parsedInput', parsedInput,
+ // 'regex', getParseRegexForToken(token, config));
if (parsedInput) {
skipped = string.substr(0, string.indexOf(parsedInput));
if (skipped.length > 0) {
@@ -1237,6 +1521,9 @@
config._a[HOUR] > 0) {
getParsingFlags(config).bigHour = undefined;
}
+
+ getParsingFlags(config).parsedDateParts = config._a.slice(0);
+ getParsingFlags(config).meridiem = config._meridiem;
// handle meridiem
config._a[HOUR] = meridiemFixWrap(config._locale, config._a[HOUR], config._meridiem);
@@ -1377,7 +1664,7 @@
if (input === undefined) {
config._d = new Date(utils_hooks__hooks.now());
} else if (isDate(input)) {
- config._d = new Date(+input);
+ config._d = new Date(input.valueOf());
} else if (typeof input === 'string') {
configFromString(config);
} else if (isArray(input)) {
@@ -1419,7 +1706,7 @@
}
var prototypeMin = deprecate(
- 'moment().min is deprecated, use moment.min instead. https://github.com/moment/moment/issues/1548',
+ 'moment().min is deprecated, use moment.max instead. https://github.com/moment/moment/issues/1548',
function () {
var other = local__createLocal.apply(null, arguments);
if (this.isValid() && other.isValid()) {
@@ -1431,7 +1718,7 @@
);
var prototypeMax = deprecate(
- 'moment().max is deprecated, use moment.max instead. https://github.com/moment/moment/issues/1548',
+ 'moment().max is deprecated, use moment.min instead. https://github.com/moment/moment/issues/1548',
function () {
var other = local__createLocal.apply(null, arguments);
if (this.isValid() && other.isValid()) {
@@ -1477,8 +1764,8 @@
return pickBy('isAfter', args);
}
- var now = Date.now || function () {
- return +(new Date());
+ var now = function () {
+ return Date.now ? Date.now() : +(new Date());
};
function Duration (duration) {
@@ -1497,7 +1784,7 @@
this._milliseconds = +milliseconds +
seconds * 1e3 + // 1000
minutes * 6e4 + // 1000 * 60
- hours * 36e5; // 1000 * 60 * 60
+ hours * 1000 * 60 * 60; //using 1000 * 60 * 60 instead of 36e5 to avoid floating point rounding errors https://github.com/moment/moment/issues/2978
// Because of dateAddRemove treats 24 hours as different from a
// day when working around DST, we need to store them separately
this._days = +days +
@@ -1567,9 +1854,9 @@
var res, diff;
if (model._isUTC) {
res = model.clone();
- diff = (isMoment(input) || isDate(input) ? +input : +local__createLocal(input)) - (+res);
+ diff = (isMoment(input) || isDate(input) ? input.valueOf() : local__createLocal(input).valueOf()) - res.valueOf();
// Use low-level api, because this fn is low-level api.
- res._d.setTime(+res._d + diff);
+ res._d.setTime(res._d.valueOf() + diff);
utils_hooks__hooks.updateOffset(res, false);
return res;
} else {
@@ -1725,11 +2012,12 @@
}
// ASP.NET json date format regex
- var aspNetRegex = /(\-)?(?:(\d*)[. ])?(\d+)\:(\d+)(?:\:(\d+)\.?(\d{3})?)?/;
+ var aspNetRegex = /^(\-)?(?:(\d*)[. ])?(\d+)\:(\d+)(?:\:(\d+)\.?(\d{3})?\d*)?$/;
// from http://docs.closure-library.googlecode.com/git/closure_goog_date_date.js.source.html
// somewhat more in line with 4.4.3.2 2004 spec, but allows decimal anywhere
- var isoRegex = /^(-)?P(?:(?:([0-9,.]*)Y)?(?:([0-9,.]*)M)?(?:([0-9,.]*)D)?(?:T(?:([0-9,.]*)H)?(?:([0-9,.]*)M)?(?:([0-9,.]*)S)?)?|([0-9,.]*)W)$/;
+ // and further modified to allow for strings containing both week and day
+ var isoRegex = /^(-)?P(?:(-?[0-9,.]*)Y)?(?:(-?[0-9,.]*)M)?(?:(-?[0-9,.]*)W)?(?:(-?[0-9,.]*)D)?(?:T(?:(-?[0-9,.]*)H)?(?:(-?[0-9,.]*)M)?(?:(-?[0-9,.]*)S)?)?$/;
function create__createDuration (input, key) {
var duration = input,
@@ -1767,11 +2055,11 @@
duration = {
y : parseIso(match[2], sign),
M : parseIso(match[3], sign),
- d : parseIso(match[4], sign),
- h : parseIso(match[5], sign),
- m : parseIso(match[6], sign),
- s : parseIso(match[7], sign),
- w : parseIso(match[8], sign)
+ w : parseIso(match[4], sign),
+ d : parseIso(match[5], sign),
+ h : parseIso(match[6], sign),
+ m : parseIso(match[7], sign),
+ s : parseIso(match[8], sign)
};
} else if (duration == null) {// checks for null or undefined
duration = {};
@@ -1833,6 +2121,14 @@
}
return res;
+ }
+
+ function absRound (number) {
+ if (number < 0) {
+ return Math.round(-1 * number) * -1;
+ } else {
+ return Math.round(number);
+ }
}
// TODO: remove 'name' arg after deprecation is removed
@@ -1854,8 +2150,8 @@
function add_subtract__addSubtract (mom, duration, isAdding, updateOffset) {
var milliseconds = duration._milliseconds,
- days = duration._days,
- months = duration._months;
+ days = absRound(duration._days),
+ months = absRound(duration._months);
if (!mom.isValid()) {
// No op
@@ -1865,7 +2161,7 @@
updateOffset = updateOffset == null ? true : updateOffset;
if (milliseconds) {
- mom._d.setTime(+mom._d + milliseconds * isAdding);
+ mom._d.setTime(mom._d.valueOf() + milliseconds * isAdding);
}
if (days) {
get_set__set(mom, 'Date', get_set__get(mom, 'Date') + days * isAdding);
@@ -1910,9 +2206,9 @@
}
units = normalizeUnits(!isUndefined(units) ? units : 'millisecond');
if (units === 'millisecond') {
- return +this > +localInput;
+ return this.valueOf() > localInput.valueOf();
} else {
- return +localInput < +this.clone().startOf(units);
+ return localInput.valueOf() < this.clone().startOf(units).valueOf();
}
}
@@ -1923,14 +2219,16 @@
}
units = normalizeUnits(!isUndefined(units) ? units : 'millisecond');
if (units === 'millisecond') {
- return +this < +localInput;
+ return this.valueOf() < localInput.valueOf();
} else {
- return +this.clone().endOf(units) < +localInput;
- }
- }
-
- function isBetween (from, to, units) {
- return this.isAfter(from, units) && this.isBefore(to, units);
+ return this.clone().endOf(units).valueOf() < localInput.valueOf();
+ }
+ }
+
+ function isBetween (from, to, units, inclusivity) {
+ inclusivity = inclusivity || '()';
+ return (inclusivity[0] === '(' ? this.isAfter(from, units) : !this.isBefore(from, units)) &&
+ (inclusivity[1] === ')' ? this.isBefore(to, units) : !this.isAfter(to, units));
}
function isSame (input, units) {
@@ -1941,10 +2239,10 @@
}
units = normalizeUnits(units || 'millisecond');
if (units === 'millisecond') {
- return +this === +localInput;
+ return this.valueOf() === localInput.valueOf();
} else {
- inputMs = +localInput;
- return +(this.clone().startOf(units)) <= inputMs && inputMs <= +(this.clone().endOf(units));
+ inputMs = localInput.valueOf();
+ return this.clone().startOf(units).valueOf() <= inputMs && inputMs <= this.clone().endOf(units).valueOf();
}
}
@@ -2011,10 +2309,12 @@
adjust = (b - anchor) / (anchor2 - anchor);
}
- return -(wholeMonthDiff + adjust);
+ //check for negative zero, return zero if negative zero
+ return -(wholeMonthDiff + adjust) || 0;
}
utils_hooks__hooks.defaultFormat = 'YYYY-MM-DDTHH:mm:ssZ';
+ utils_hooks__hooks.defaultFormatUtc = 'YYYY-MM-DDTHH:mm:ss[Z]';
function toString () {
return this.clone().locale('en').format('ddd MMM DD YYYY HH:mm:ss [GMT]ZZ');
@@ -2035,7 +2335,10 @@
}
function moment_format__format (inputString) {
- var output = formatMoment(this, inputString || utils_hooks__hooks.defaultFormat);
+ if (!inputString) {
+ inputString = this.isUtc() ? utils_hooks__hooks.defaultFormatUtc : utils_hooks__hooks.defaultFormat;
+ }
+ var output = formatMoment(this, inputString);
return this.localeData().postformat(output);
}
@@ -2114,6 +2417,7 @@
case 'week':
case 'isoWeek':
case 'day':
+ case 'date':
this.hours(0);
/* falls through */
case 'hour':
@@ -2147,19 +2451,25 @@
if (units === undefined || units === 'millisecond') {
return this;
}
+
+ // 'date' is an alias for 'day', so it should be considered as such.
+ if (units === 'date') {
+ units = 'day';
+ }
+
return this.startOf(units).add(1, (units === 'isoWeek' ? 'week' : units)).subtract(1, 'ms');
}
function to_type__valueOf () {
- return +this._d - ((this._offset || 0) * 60000);
+ return this._d.valueOf() - ((this._offset || 0) * 60000);
}
function unix () {
- return Math.floor(+this / 1000);
+ return Math.floor(this.valueOf() / 1000);
}
function toDate () {
- return this._offset ? new Date(+this) : this._d;
+ return this._offset ? new Date(this.valueOf()) : this._d;
}
function toArray () {
@@ -2181,8 +2491,8 @@
}
function toJSON () {
- // JSON.stringify(new Date(NaN)) === 'null'
- return this.isValid() ? this.toISOString() : 'null';
+ // new Date(NaN).toJSON() === null
+ return this.isValid() ? this.toISOString() : null;
}
function moment_valid__isValid () {
@@ -2292,7 +2602,6 @@
var dayOfYearData = dayOfYearFromWeeks(weekYear, week, weekday, dow, doy),
date = createUTCDate(dayOfYearData.year, 0, dayOfYearData.dayOfYear);
- // console.log("got", weekYear, week, weekday, "set", date.toISOString());
this.year(date.getUTCFullYear());
this.month(date.getUTCMonth());
this.date(date.getUTCDate());
@@ -2429,9 +2738,15 @@
addRegexToken('d', match1to2);
addRegexToken('e', match1to2);
addRegexToken('E', match1to2);
- addRegexToken('dd', matchWord);
- addRegexToken('ddd', matchWord);
- addRegexToken('dddd', matchWord);
+ addRegexToken('dd', function (isStrict, locale) {
+ return locale.weekdaysMinRegex(isStrict);
+ });
+ addRegexToken('ddd', function (isStrict, locale) {
+ return locale.weekdaysShortRegex(isStrict);
+ });
+ addRegexToken('dddd', function (isStrict, locale) {
+ return locale.weekdaysRegex(isStrict);
+ });
addWeekParseToken(['dd', 'ddd', 'dddd'], function (input, week, config, token) {
var weekday = config._locale.weekdaysParse(input, token, config._strict);
@@ -2484,8 +2799,76 @@
return this._weekdaysMin[m.day()];
}
+ function day_of_week__handleStrictParse(weekdayName, format, strict) {
+ var i, ii, mom, llc = weekdayName.toLocaleLowerCase();
+ if (!this._weekdaysParse) {
+ this._weekdaysParse = [];
+ this._shortWeekdaysParse = [];
+ this._minWeekdaysParse = [];
+
+ for (i = 0; i < 7; ++i) {
+ mom = create_utc__createUTC([2000, 1]).day(i);
+ this._minWeekdaysParse[i] = this.weekdaysMin(mom, '').toLocaleLowerCase();
+ this._shortWeekdaysParse[i] = this.weekdaysShort(mom, '').toLocaleLowerCase();
+ this._weekdaysParse[i] = this.weekdays(mom, '').toLocaleLowerCase();
+ }
+ }
+
+ if (strict) {
+ if (format === 'dddd') {
+ ii = indexOf.call(this._weekdaysParse, llc);
+ return ii !== -1 ? ii : null;
+ } else if (format === 'ddd') {
+ ii = indexOf.call(this._shortWeekdaysParse, llc);
+ return ii !== -1 ? ii : null;
+ } else {
+ ii = indexOf.call(this._minWeekdaysParse, llc);
+ return ii !== -1 ? ii : null;
+ }
+ } else {
+ if (format === 'dddd') {
+ ii = indexOf.call(this._weekdaysParse, llc);
+ if (ii !== -1) {
+ return ii;
+ }
+ ii = indexOf.call(this._shortWeekdaysParse, llc);
+ if (ii !== -1) {
+ return ii;
+ }
+ ii = indexOf.call(this._minWeekdaysParse, llc);
+ return ii !== -1 ? ii : null;
+ } else if (format === 'ddd') {
+ ii = indexOf.call(this._shortWeekdaysParse, llc);
+ if (ii !== -1) {
+ return ii;
+ }
+ ii = indexOf.call(this._weekdaysParse, llc);
+ if (ii !== -1) {
+ return ii;
+ }
+ ii = indexOf.call(this._minWeekdaysParse, llc);
+ return ii !== -1 ? ii : null;
+ } else {
+ ii = indexOf.call(this._minWeekdaysParse, llc);
+ if (ii !== -1) {
+ return ii;
+ }
+ ii = indexOf.call(this._weekdaysParse, llc);
+ if (ii !== -1) {
+ return ii;
+ }
+ ii = indexOf.call(this._shortWeekdaysParse, llc);
+ return ii !== -1 ? ii : null;
+ }
+ }
+ }
+
function localeWeekdaysParse (weekdayName, format, strict) {
var i, mom, regex;
+
+ if (this._weekdaysParseExact) {
+ return day_of_week__handleStrictParse.call(this, weekdayName, format, strict);
+ }
if (!this._weekdaysParse) {
this._weekdaysParse = [];
@@ -2497,7 +2880,7 @@
for (i = 0; i < 7; i++) {
// make the regex if we don't have it already
- mom = local__createLocal([2000, 1]).day(i);
+ mom = create_utc__createUTC([2000, 1]).day(i);
if (strict && !this._fullWeekdaysParse[i]) {
this._fullWeekdaysParse[i] = new RegExp('^' + this.weekdays(mom, '').replace('.', '\.?') + '$', 'i');
this._shortWeekdaysParse[i] = new RegExp('^' + this.weekdaysShort(mom, '').replace('.', '\.?') + '$', 'i');
@@ -2553,6 +2936,99 @@
return input == null ? this.day() || 7 : this.day(this.day() % 7 ? input : input - 7);
}
+ var defaultWeekdaysRegex = matchWord;
+ function weekdaysRegex (isStrict) {
+ if (this._weekdaysParseExact) {
+ if (!hasOwnProp(this, '_weekdaysRegex')) {
+ computeWeekdaysParse.call(this);
+ }
+ if (isStrict) {
+ return this._weekdaysStrictRegex;
+ } else {
+ return this._weekdaysRegex;
+ }
+ } else {
+ return this._weekdaysStrictRegex && isStrict ?
+ this._weekdaysStrictRegex : this._weekdaysRegex;
+ }
+ }
+
+ var defaultWeekdaysShortRegex = matchWord;
+ function weekdaysShortRegex (isStrict) {
+ if (this._weekdaysParseExact) {
+ if (!hasOwnProp(this, '_weekdaysRegex')) {
+ computeWeekdaysParse.call(this);
+ }
+ if (isStrict) {
+ return this._weekdaysShortStrictRegex;
+ } else {
+ return this._weekdaysShortRegex;
+ }
+ } else {
+ return this._weekdaysShortStrictRegex && isStrict ?
+ this._weekdaysShortStrictRegex : this._weekdaysShortRegex;
+ }
+ }
+
+ var defaultWeekdaysMinRegex = matchWord;
+ function weekdaysMinRegex (isStrict) {
+ if (this._weekdaysParseExact) {
+ if (!hasOwnProp(this, '_weekdaysRegex')) {
+ computeWeekdaysParse.call(this);
+ }
+ if (isStrict) {
+ return this._weekdaysMinStrictRegex;
+ } else {
+ return this._weekdaysMinRegex;
+ }
+ } else {
+ return this._weekdaysMinStrictRegex && isStrict ?
+ this._weekdaysMinStrictRegex : this._weekdaysMinRegex;
+ }
+ }
+
+
+ function computeWeekdaysParse () {
+ function cmpLenRev(a, b) {
+ return b.length - a.length;
+ }
+
+ var minPieces = [], shortPieces = [], longPieces = [], mixedPieces = [],
+ i, mom, minp, shortp, longp;
+ for (i = 0; i < 7; i++) {
+ // make the regex if we don't have it already
+ mom = create_utc__createUTC([2000, 1]).day(i);
+ minp = this.weekdaysMin(mom, '');
+ shortp = this.weekdaysShort(mom, '');
+ longp = this.weekdays(mom, '');
+ minPieces.push(minp);
+ shortPieces.push(shortp);
+ longPieces.push(longp);
+ mixedPieces.push(minp);
+ mixedPieces.push(shortp);
+ mixedPieces.push(longp);
+ }
+ // Sorting makes sure if one weekday (or abbr) is a prefix of another it
+ // will match the longer piece.
+ minPieces.sort(cmpLenRev);
+ shortPieces.sort(cmpLenRev);
+ longPieces.sort(cmpLenRev);
+ mixedPieces.sort(cmpLenRev);
+ for (i = 0; i < 7; i++) {
+ shortPieces[i] = regexEscape(shortPieces[i]);
+ longPieces[i] = regexEscape(longPieces[i]);
+ mixedPieces[i] = regexEscape(mixedPieces[i]);
+ }
+
+ this._weekdaysRegex = new RegExp('^(' + mixedPieces.join('|') + ')', 'i');
+ this._weekdaysShortRegex = this._weekdaysRegex;
+ this._weekdaysMinRegex = this._weekdaysRegex;
+
+ this._weekdaysStrictRegex = new RegExp('^(' + longPieces.join('|') + ')', 'i');
+ this._weekdaysShortStrictRegex = new RegExp('^(' + shortPieces.join('|') + ')', 'i');
+ this._weekdaysMinStrictRegex = new RegExp('^(' + minPieces.join('|') + ')', 'i');
+ }
+
// FORMATTING
addFormatToken('DDD', ['DDDD', 3], 'DDDo', 'dayOfYear');
@@ -2584,8 +3060,13 @@
return this.hours() % 12 || 12;
}
+ function kFormat() {
+ return this.hours() || 24;
+ }
+
addFormatToken('H', ['HH', 2], 0, 'hour');
addFormatToken('h', ['hh', 2], 0, hFormat);
+ addFormatToken('k', ['kk', 2], 0, kFormat);
addFormatToken('hmm', 0, 0, function () {
return '' + hFormat.apply(this) + zeroFill(this.minutes(), 2);
@@ -3002,21 +3483,6 @@
return isFunction(format) ? format(output) : format.replace(/%s/i, output);
}
- function locale_set__set (config) {
- var prop, i;
- for (i in config) {
- prop = config[i];
- if (isFunction(prop)) {
- this[i] = prop;
- } else {
- this['_' + i] = prop;
- }
- }
- // Lenient ordinal parsing accepts just a number in addition to
- // number + (possibly) stuff coming from _ordinalParseLenient.
- this._ordinalParseLenient = new RegExp(this._ordinalParse.source + '|' + (/\d{1,2}/).source);
- }
-
var prototype__proto = Locale.prototype;
prototype__proto._calendar = defaultCalendar;
@@ -3036,11 +3502,15 @@
prototype__proto.set = locale_set__set;
// Month
- prototype__proto.months = localeMonths;
- prototype__proto._months = defaultLocaleMonths;
- prototype__proto.monthsShort = localeMonthsShort;
- prototype__proto._monthsShort = defaultLocaleMonthsShort;
- prototype__proto.monthsParse = localeMonthsParse;
+ prototype__proto.months = localeMonths;
+ prototype__proto._months = defaultLocaleMonths;
+ prototype__proto.monthsShort = localeMonthsShort;
+ prototype__proto._monthsShort = defaultLocaleMonthsShort;
+ prototype__proto.monthsParse = localeMonthsParse;
+ prototype__proto._monthsRegex = defaultMonthsRegex;
+ prototype__proto.monthsRegex = monthsRegex;
+ prototype__proto._monthsShortRegex = defaultMonthsShortRegex;
+ prototype__proto.monthsShortRegex = monthsShortRegex;
// Week
prototype__proto.week = localeWeek;
@@ -3057,6 +3527,13 @@
prototype__proto._weekdaysShort = defaultLocaleWeekdaysShort;
prototype__proto.weekdaysParse = localeWeekdaysParse;
+ prototype__proto._weekdaysRegex = defaultWeekdaysRegex;
+ prototype__proto.weekdaysRegex = weekdaysRegex;
+ prototype__proto._weekdaysShortRegex = defaultWeekdaysShortRegex;
+ prototype__proto.weekdaysShortRegex = weekdaysShortRegex;
+ prototype__proto._weekdaysMinRegex = defaultWeekdaysMinRegex;
+ prototype__proto.weekdaysMinRegex = weekdaysMinRegex;
+
// Hours
prototype__proto.isPM = localeIsPM;
prototype__proto._meridiemParse = defaultLocaleMeridiemParse;
@@ -3068,7 +3545,7 @@
return locale[field](utc, format);
}
- function list (format, index, field, count, setter) {
+ function listMonthsImpl (format, index, field) {
if (typeof format === 'number') {
index = format;
format = undefined;
@@ -3077,41 +3554,82 @@
format = format || '';
if (index != null) {
- return lists__get(format, index, field, setter);
+ return lists__get(format, index, field, 'month');
}
var i;
var out = [];
- for (i = 0; i < count; i++) {
- out[i] = lists__get(format, i, field, setter);
+ for (i = 0; i < 12; i++) {
+ out[i] = lists__get(format, i, field, 'month');
}
return out;
}
+ // ()
+ // (5)
+ // (fmt, 5)
+ // (fmt)
+ // (true)
+ // (true, 5)
+ // (true, fmt, 5)
+ // (true, fmt)
+ function listWeekdaysImpl (localeSorted, format, index, field) {
+ if (typeof localeSorted === 'boolean') {
+ if (typeof format === 'number') {
+ index = format;
+ format = undefined;
+ }
+
+ format = format || '';
+ } else {
+ format = localeSorted;
+ index = format;
+ localeSorted = false;
+
+ if (typeof format === 'number') {
+ index = format;
+ format = undefined;
+ }
+
+ format = format || '';
+ }
+
+ var locale = locale_locales__getLocale(),
+ shift = localeSorted ? locale._week.dow : 0;
+
+ if (index != null) {
+ return lists__get(format, (index + shift) % 7, field, 'day');
+ }
+
+ var i;
+ var out = [];
+ for (i = 0; i < 7; i++) {
+ out[i] = lists__get(format, (i + shift) % 7, field, 'day');
+ }
+ return out;
+ }
+
function lists__listMonths (format, index) {
- return list(format, index, 'months', 12, 'month');
+ return listMonthsImpl(format, index, 'months');
}
function lists__listMonthsShort (format, index) {
- return list(format, index, 'monthsShort', 12, 'month');
- }
-
- function lists__listWeekdays (format, index) {
- return list(format, index, 'weekdays', 7, 'day');
- }
-
- function lists__listWeekdaysShort (format, index) {
- return list(format, index, 'weekdaysShort', 7, 'day');
- }
-
- function lists__listWeekdaysMin (format, index) {
- return list(format, index, 'weekdaysMin', 7, 'day');
+ return listMonthsImpl(format, index, 'monthsShort');
+ }
+
+ function lists__listWeekdays (localeSorted, format, index) {
+ return listWeekdaysImpl(localeSorted, format, index, 'weekdays');
+ }
+
+ function lists__listWeekdaysShort (localeSorted, format, index) {
+ return listWeekdaysImpl(localeSorted, format, index, 'weekdaysShort');
+ }
+
+ function lists__listWeekdaysMin (localeSorted, format, index) {
+ return listWeekdaysImpl(localeSorted, format, index, 'weekdaysMin');
}
locale_locales__getSetGlobalLocale('en', {
- monthsParse : [/^jan/i, /^feb/i, /^mar/i, /^apr/i, /^may/i, /^jun/i, /^jul/i, /^aug/i, /^sep/i, /^oct/i, /^nov/i, /^dec/i],
- longMonthsParse : [/^january$/i, /^february$/i, /^march$/i, /^april$/i, /^may$/i, /^june$/i, /^july$/i, /^august$/i, /^september$/i, /^october$/i, /^november$/i, /^december$/i],
- shortMonthsParse : [/^jan$/i, /^feb$/i, /^mar$/i, /^apr$/i, /^may$/i, /^jun$/i, /^jul$/i, /^aug/i, /^sept?$/i, /^oct$/i, /^nov$/i, /^dec$/i],
ordinalParse: /\d{1,2}(th|st|nd|rd)/,
ordinal : function (number) {
var b = number % 10,
@@ -3481,12 +3999,12 @@
;
//! moment.js
- //! version : 2.11.0
+ //! version : 2.13.0
//! authors : Tim Wood, Iskren Chernev, Moment.js contributors
//! license : MIT
//! momentjs.com
- utils_hooks__hooks.version = '2.11.0';
+ utils_hooks__hooks.version = '2.13.0';
setHookCallback(local__createLocal);
@@ -3509,6 +4027,8 @@
utils_hooks__hooks.monthsShort = lists__listMonthsShort;
utils_hooks__hooks.weekdaysMin = lists__listWeekdaysMin;
utils_hooks__hooks.defineLocale = defineLocale;
+ utils_hooks__hooks.updateLocale = updateLocale;
+ utils_hooks__hooks.locales = locale_locales__listLocales;
utils_hooks__hooks.weekdaysShort = lists__listWeekdaysShort;
utils_hooks__hooks.normalizeUnits = normalizeUnits;
utils_hooks__hooks.relativeTimeThreshold = duration_humanize__getSetRelativeTimeThreshold;
@@ -3589,6 +4109,7 @@
weekdays : 'الأحد_الإتنين_الثلاثاء_الأربعاء_الخميس_الجمعة_السبت'.split('_'),
weekdaysShort : 'احد_اتنين_ثلاثاء_اربعاء_خميس_جمعة_سبت'.split('_'),
weekdaysMin : 'ح_ن_ث_ر_خ_ج_س'.split('_'),
+ weekdaysParseExact : true,
longDateFormat : {
LT : 'HH:mm',
LTS : 'HH:mm:ss',
@@ -3660,6 +4181,7 @@
weekdays : 'الأحد_الإثنين_الثلاثاء_الأربعاء_الخميس_الجمعة_السبت'.split('_'),
weekdaysShort : 'أحد_إثنين_ثلاثاء_أربعاء_خميس_جمعة_سبت'.split('_'),
weekdaysMin : 'ح_ن_ث_ر_خ_ج_س'.split('_'),
+ weekdaysParseExact : true,
longDateFormat : {
LT : 'HH:mm',
LTS : 'HH:mm:ss',
@@ -3727,6 +4249,7 @@
weekdays: 'الأحد_الإثنين_الثلاثاء_الأربعاء_الخميس_الجمعة_السبت'.split('_'),
weekdaysShort: 'أحد_إثنين_ثلاثاء_أربعاء_خميس_جمعة_سبت'.split('_'),
weekdaysMin: 'ح_ن_ث_ر_خ_ج_س'.split('_'),
+ weekdaysParseExact : true,
longDateFormat: {
LT: 'HH:mm',
LTS: 'HH:mm:ss',
@@ -3831,6 +4354,7 @@
weekdays : 'الأحد_الإثنين_الثلاثاء_الأربعاء_الخميس_الجمعة_السبت'.split('_'),
weekdaysShort : 'أحد_إثنين_ثلاثاء_أربعاء_خميس_جمعة_سبت'.split('_'),
weekdaysMin : 'ح_ن_ث_ر_خ_ج_س'.split('_'),
+ weekdaysParseExact : true,
longDateFormat : {
LT : 'HH:mm',
LTS : 'HH:mm:ss',
@@ -3920,6 +4444,7 @@
weekdays : 'Bazar_Bazar ertəsi_Çərşənbə axşamı_Çərşənbə_Cümə axşamı_Cümə_Şənbə'.split('_'),
weekdaysShort : 'Baz_BzE_ÇAx_Çər_CAx_Cüm_Şən'.split('_'),
weekdaysMin : 'Bz_BE_ÇA_Çə_CA_Cü_Şə'.split('_'),
+ weekdaysParseExact : true,
longDateFormat : {
LT : 'HH:mm',
LTS : 'HH:mm:ss',
@@ -4261,12 +4786,18 @@
});
},
meridiemParse: /রাত|সকাল|দুপুর|বিকাল|রাত/,
- isPM: function (input) {
- return /^(দুপুর|বিকাল|রাত)$/.test(input);
- },
- //Bengali is a vast language its spoken
- //in different forms in various parts of the world.
- //I have just generalized with most common one used
+ meridiemHour : function (hour, meridiem) {
+ if (hour === 12) {
+ hour = 0;
+ }
+ if ((meridiem === 'রাত' && hour >= 4) ||
+ (meridiem === 'দুপুর' && hour < 5) ||
+ meridiem === 'বিকাল') {
+ return hour + 12;
+ } else {
+ return hour;
+ }
+ },
meridiem : function (hour, minute, isLower) {
if (hour < 4) {
return 'রাত';
@@ -4363,8 +4894,17 @@
});
},
meridiemParse: /མཚན་མོ|ཞོགས་ཀས|ཉིན་གུང|དགོང་དག|མཚན་མོ/,
- isPM: function (input) {
- return /^(ཉིན་གུང|དགོང་དག|མཚན་མོ)$/.test(input);
+ meridiemHour : function (hour, meridiem) {
+ if (hour === 12) {
+ hour = 0;
+ }
+ if ((meridiem === 'མཚན་མོ' && hour >= 4) ||
+ (meridiem === 'ཉིན་གུང' && hour < 5) ||
+ meridiem === 'དགོང་དག') {
+ return hour + 12;
+ } else {
+ return hour;
+ }
},
meridiem : function (hour, minute, isLower) {
if (hour < 4) {
@@ -4439,6 +4979,7 @@
weekdays : 'Sul_Lun_Meurzh_Merc\'her_Yaou_Gwener_Sadorn'.split('_'),
weekdaysShort : 'Sul_Lun_Meu_Mer_Yao_Gwe_Sad'.split('_'),
weekdaysMin : 'Su_Lu_Me_Mer_Ya_Gw_Sa'.split('_'),
+ weekdaysParseExact : true,
longDateFormat : {
LT : 'h[e]mm A',
LTS : 'h[e]mm:ss A',
@@ -4542,9 +5083,11 @@
var bs = moment__default.defineLocale('bs', {
months : 'januar_februar_mart_april_maj_juni_juli_august_septembar_oktobar_novembar_decembar'.split('_'),
monthsShort : 'jan._feb._mar._apr._maj._jun._jul._aug._sep._okt._nov._dec.'.split('_'),
+ monthsParseExact: true,
weekdays : 'nedjelja_ponedjeljak_utorak_srijeda_četvrtak_petak_subota'.split('_'),
weekdaysShort : 'ned._pon._uto._sri._čet._pet._sub.'.split('_'),
weekdaysMin : 'ne_po_ut_sr_če_pe_su'.split('_'),
+ weekdaysParseExact : true,
longDateFormat : {
LT : 'H:mm',
LTS : 'H:mm:ss',
@@ -4618,9 +5161,11 @@
var ca = moment__default.defineLocale('ca', {
months : 'gener_febrer_març_abril_maig_juny_juliol_agost_setembre_octubre_novembre_desembre'.split('_'),
monthsShort : 'gen._febr._mar._abr._mai._jun._jul._ag._set._oct._nov._des.'.split('_'),
+ monthsParseExact : true,
weekdays : 'diumenge_dilluns_dimarts_dimecres_dijous_divendres_dissabte'.split('_'),
weekdaysShort : 'dg._dl._dt._dc._dj._dv._ds.'.split('_'),
weekdaysMin : 'Dg_Dl_Dt_Dc_Dj_Dv_Ds'.split('_'),
+ weekdaysParseExact : true,
longDateFormat : {
LT : 'H:mm',
LTS : 'H:mm:ss',
@@ -4901,6 +5446,7 @@
weekdays: 'Dydd Sul_Dydd Llun_Dydd Mawrth_Dydd Mercher_Dydd Iau_Dydd Gwener_Dydd Sadwrn'.split('_'),
weekdaysShort: 'Sul_Llun_Maw_Mer_Iau_Gwe_Sad'.split('_'),
weekdaysMin: 'Su_Ll_Ma_Me_Ia_Gw_Sa'.split('_'),
+ weekdaysParseExact : true,
// time formats are the same as en-gb
longDateFormat: {
LT: 'HH:mm',
@@ -5032,9 +5578,11 @@
var de_at = moment__default.defineLocale('de-at', {
months : 'Jänner_Februar_März_April_Mai_Juni_Juli_August_September_Oktober_November_Dezember'.split('_'),
monthsShort : 'Jän._Febr._Mrz._Apr._Mai_Jun._Jul._Aug._Sept._Okt._Nov._Dez.'.split('_'),
+ monthsParseExact : true,
weekdays : 'Sonntag_Montag_Dienstag_Mittwoch_Donnerstag_Freitag_Samstag'.split('_'),
weekdaysShort : 'So._Mo._Di._Mi._Do._Fr._Sa.'.split('_'),
weekdaysMin : 'So_Mo_Di_Mi_Do_Fr_Sa'.split('_'),
+ weekdaysParseExact : true,
longDateFormat : {
LT: 'HH:mm',
LTS: 'HH:mm:ss',
@@ -5097,9 +5645,11 @@
var de = moment__default.defineLocale('de', {
months : 'Januar_Februar_März_April_Mai_Juni_Juli_August_September_Oktober_November_Dezember'.split('_'),
monthsShort : 'Jan._Febr._Mrz._Apr._Mai_Jun._Jul._Aug._Sept._Okt._Nov._Dez.'.split('_'),
+ monthsParseExact : true,
weekdays : 'Sonntag_Montag_Dienstag_Mittwoch_Donnerstag_Freitag_Samstag'.split('_'),
weekdaysShort : 'So._Mo._Di._Mi._Do._Fr._Sa.'.split('_'),
weekdaysMin : 'So_Mo_Di_Mi_Do_Fr_Sa'.split('_'),
+ weekdaysParseExact : true,
longDateFormat : {
LT: 'HH:mm',
LTS: 'HH:mm:ss',
@@ -5183,7 +5733,7 @@
},
meridiemParse: /މކ|މފ/,
isPM : function (input) {
- return '' === input;
+ return 'މފ' === input;
},
meridiem : function (hour, minute, isLower) {
if (hour < 12) {
@@ -5315,10 +5865,7 @@
var en_au = moment__default.defineLocale('en-au', {
months : 'January_February_March_April_May_June_July_August_September_October_November_December'.split('_'),
- monthsShort : 'Jan_Feb_Mar_Apr_May_Jun_Jul_Aug_Sept_Oct_Nov_Dec'.split('_'),
- monthsParse : [/^jan/i, /^feb/i, /^mar/i, /^apr/i, /^may/i, /^jun/i, /^jul/i, /^aug/i, /^sep/i, /^oct/i, /^nov/i, /^dec/i],
- longMonthsParse : [/^january$/i, /^february$/i, /^march$/i, /^april$/i, /^may$/i, /^june$/i, /^july$/i, /^august$/i, /^september$/i, /^october$/i, /^november$/i, /^december$/i],
- shortMonthsParse : [/^jan$/i, /^feb$/i, /^mar$/i, /^apr$/i, /^may$/i, /^jun$/i, /^jul$/i, /^aug/i, /^sept?$/i, /^oct$/i, /^nov$/i, /^dec$/i],
+ monthsShort : 'Jan_Feb_Mar_Apr_May_Jun_Jul_Aug_Sep_Oct_Nov_Dec'.split('_'),
weekdays : 'Sunday_Monday_Tuesday_Wednesday_Thursday_Friday_Saturday'.split('_'),
weekdaysShort : 'Sun_Mon_Tue_Wed_Thu_Fri_Sat'.split('_'),
weekdaysMin : 'Su_Mo_Tu_We_Th_Fr_Sa'.split('_'),
@@ -5374,10 +5921,7 @@
var en_ca = moment__default.defineLocale('en-ca', {
months : 'January_February_March_April_May_June_July_August_September_October_November_December'.split('_'),
- monthsShort : 'Jan_Feb_Mar_Apr_May_Jun_Jul_Aug_Sept_Oct_Nov_Dec'.split('_'),
- monthsParse : [/^jan/i, /^feb/i, /^mar/i, /^apr/i, /^may/i, /^jun/i, /^jul/i, /^aug/i, /^sep/i, /^oct/i, /^nov/i, /^dec/i],
- longMonthsParse : [/^january$/i, /^february$/i, /^march$/i, /^april$/i, /^may$/i, /^june$/i, /^july$/i, /^august$/i, /^september$/i, /^october$/i, /^november$/i, /^december$/i],
- shortMonthsParse : [/^jan$/i, /^feb$/i, /^mar$/i, /^apr$/i, /^may$/i, /^jun$/i, /^jul$/i, /^aug/i, /^sept?$/i, /^oct$/i, /^nov$/i, /^dec$/i],
+ monthsShort : 'Jan_Feb_Mar_Apr_May_Jun_Jul_Aug_Sep_Oct_Nov_Dec'.split('_'),
weekdays : 'Sunday_Monday_Tuesday_Wednesday_Thursday_Friday_Saturday'.split('_'),
weekdaysShort : 'Sun_Mon_Tue_Wed_Thu_Fri_Sat'.split('_'),
weekdaysMin : 'Su_Mo_Tu_We_Th_Fr_Sa'.split('_'),
@@ -5385,9 +5929,9 @@
LT : 'h:mm A',
LTS : 'h:mm:ss A',
L : 'YYYY-MM-DD',
- LL : 'D MMMM, YYYY',
- LLL : 'D MMMM, YYYY h:mm A',
- LLLL : 'dddd, D MMMM, YYYY h:mm A'
+ LL : 'MMMM D, YYYY',
+ LLL : 'MMMM D, YYYY h:mm A',
+ LLLL : 'dddd, MMMM D, YYYY h:mm A'
},
calendar : {
sameDay : '[Today at] LT',
@@ -5429,10 +5973,7 @@
var en_gb = moment__default.defineLocale('en-gb', {
months : 'January_February_March_April_May_June_July_August_September_October_November_December'.split('_'),
- monthsShort : 'Jan_Feb_Mar_Apr_May_Jun_Jul_Aug_Sept_Oct_Nov_Dec'.split('_'),
- monthsParse : [/^jan/i, /^feb/i, /^mar/i, /^apr/i, /^may/i, /^jun/i, /^jul/i, /^aug/i, /^sep/i, /^oct/i, /^nov/i, /^dec/i],
- longMonthsParse : [/^january$/i, /^february$/i, /^march$/i, /^april$/i, /^may$/i, /^june$/i, /^july$/i, /^august$/i, /^september$/i, /^october$/i, /^november$/i, /^december$/i],
- shortMonthsParse : [/^jan$/i, /^feb$/i, /^mar$/i, /^apr$/i, /^may$/i, /^jun$/i, /^jul$/i, /^aug/i, /^sept?$/i, /^oct$/i, /^nov$/i, /^dec$/i],
+ monthsShort : 'Jan_Feb_Mar_Apr_May_Jun_Jul_Aug_Sep_Oct_Nov_Dec'.split('_'),
weekdays : 'Sunday_Monday_Tuesday_Wednesday_Thursday_Friday_Saturday'.split('_'),
weekdaysShort : 'Sun_Mon_Tue_Wed_Thu_Fri_Sat'.split('_'),
weekdaysMin : 'Su_Mo_Tu_We_Th_Fr_Sa'.split('_'),
@@ -5489,9 +6030,6 @@
var en_ie = moment__default.defineLocale('en-ie', {
months : 'January_February_March_April_May_June_July_August_September_October_November_December'.split('_'),
monthsShort : 'Jan_Feb_Mar_Apr_May_Jun_Jul_Aug_Sep_Oct_Nov_Dec'.split('_'),
- monthsParse : [/^jan/i, /^feb/i, /^mar/i, /^apr/i, /^may/i, /^jun/i, /^jul/i, /^aug/i, /^sep/i, /^oct/i, /^nov/i, /^dec/i],
- longMonthsParse : [/^january$/i, /^february$/i, /^march$/i, /^april$/i, /^may$/i, /^june$/i, /^july$/i, /^august$/i, /^september$/i, /^october$/i, /^november$/i, /^december$/i],
- shortMonthsParse : [/^jan$/i, /^feb$/i, /^mar$/i, /^apr$/i, /^may$/i, /^jun$/i, /^jul$/i, /^aug/i, /^sept?$/i, /^oct$/i, /^nov$/i, /^dec$/i],
weekdays : 'Sunday_Monday_Tuesday_Wednesday_Thursday_Friday_Saturday'.split('_'),
weekdaysShort : 'Sun_Mon_Tue_Wed_Thu_Fri_Sat'.split('_'),
weekdaysMin : 'Su_Mo_Tu_We_Th_Fr_Sa'.split('_'),
@@ -5546,10 +6084,7 @@
var en_nz = moment__default.defineLocale('en-nz', {
months : 'January_February_March_April_May_June_July_August_September_October_November_December'.split('_'),
- monthsShort : 'Jan_Feb_Mar_Apr_May_Jun_Jul_Aug_Sept_Oct_Nov_Dec'.split('_'),
- monthsParse : [/^jan/i, /^feb/i, /^mar/i, /^apr/i, /^may/i, /^jun/i, /^jul/i, /^aug/i, /^sep/i, /^oct/i, /^nov/i, /^dec/i],
- longMonthsParse : [/^january$/i, /^february$/i, /^march$/i, /^april$/i, /^may$/i, /^june$/i, /^july$/i, /^august$/i, /^september$/i, /^october$/i, /^november$/i, /^december$/i],
- shortMonthsParse : [/^jan$/i, /^feb$/i, /^mar$/i, /^apr$/i, /^may$/i, /^jun$/i, /^jul$/i, /^aug/i, /^sept?$/i, /^oct$/i, /^nov$/i, /^dec$/i],
+ monthsShort : 'Jan_Feb_Mar_Apr_May_Jun_Jul_Aug_Sep_Oct_Nov_Dec'.split('_'),
weekdays : 'Sunday_Monday_Tuesday_Wednesday_Thursday_Friday_Saturday'.split('_'),
weekdaysShort : 'Sun_Mon_Tue_Wed_Thu_Fri_Sat'.split('_'),
weekdaysMin : 'Su_Mo_Tu_We_Th_Fr_Sa'.split('_'),
@@ -5677,9 +6212,11 @@
return monthsShortDot[m.month()];
}
},
+ monthsParseExact : true,
weekdays : 'domingo_lunes_martes_miércoles_jueves_viernes_sábado'.split('_'),
weekdaysShort : 'dom._lun._mar._mié._jue._vie._sáb.'.split('_'),
weekdaysMin : 'do_lu_ma_mi_ju_vi_sá'.split('_'),
+ weekdaysParseExact : true,
longDateFormat : {
LT : 'H:mm',
LTS : 'H:mm:ss',
@@ -5805,9 +6342,11 @@
var eu = moment__default.defineLocale('eu', {
months : 'urtarrila_otsaila_martxoa_apirila_maiatza_ekaina_uztaila_abuztua_iraila_urria_azaroa_abendua'.split('_'),
monthsShort : 'urt._ots._mar._api._mai._eka._uzt._abu._ira._urr._aza._abe.'.split('_'),
+ monthsParseExact : true,
weekdays : 'igandea_astelehena_asteartea_asteazkena_osteguna_ostirala_larunbata'.split('_'),
weekdaysShort : 'ig._al._ar._az._og._ol._lr.'.split('_'),
weekdaysMin : 'ig_al_ar_az_og_ol_lr'.split('_'),
+ weekdaysParseExact : true,
longDateFormat : {
LT : 'HH:mm',
LTS : 'HH:mm:ss',
@@ -5885,6 +6424,7 @@
weekdays : 'یک\u200cشنبه_دوشنبه_سه\u200cشنبه_چهارشنبه_پنج\u200cشنبه_جمعه_شنبه'.split('_'),
weekdaysShort : 'یک\u200cشنبه_دوشنبه_سه\u200cشنبه_چهارشنبه_پنج\u200cشنبه_جمعه_شنبه'.split('_'),
weekdaysMin : 'ی_د_س_چ_پ_ج_ش'.split('_'),
+ weekdaysParseExact : true,
longDateFormat : {
LT : 'HH:mm',
LTS : 'HH:mm:ss',
@@ -6097,9 +6637,11 @@
var fr_ca = moment__default.defineLocale('fr-ca', {
months : 'janvier_février_mars_avril_mai_juin_juillet_août_septembre_octobre_novembre_décembre'.split('_'),
monthsShort : 'janv._févr._mars_avr._mai_juin_juil._août_sept._oct._nov._déc.'.split('_'),
+ monthsParseExact : true,
weekdays : 'dimanche_lundi_mardi_mercredi_jeudi_vendredi_samedi'.split('_'),
weekdaysShort : 'dim._lun._mar._mer._jeu._ven._sam.'.split('_'),
weekdaysMin : 'Di_Lu_Ma_Me_Je_Ve_Sa'.split('_'),
+ weekdaysParseExact : true,
longDateFormat : {
LT : 'HH:mm',
LTS : 'HH:mm:ss',
@@ -6144,9 +6686,11 @@
var fr_ch = moment__default.defineLocale('fr-ch', {
months : 'janvier_février_mars_avril_mai_juin_juillet_août_septembre_octobre_novembre_décembre'.split('_'),
monthsShort : 'janv._févr._mars_avr._mai_juin_juil._août_sept._oct._nov._déc.'.split('_'),
+ monthsParseExact : true,
weekdays : 'dimanche_lundi_mardi_mercredi_jeudi_vendredi_samedi'.split('_'),
weekdaysShort : 'dim._lun._mar._mer._jeu._ven._sam.'.split('_'),
weekdaysMin : 'Di_Lu_Ma_Me_Je_Ve_Sa'.split('_'),
+ weekdaysParseExact : true,
longDateFormat : {
LT : 'HH:mm',
LTS : 'HH:mm:ss',
@@ -6195,9 +6739,11 @@
var fr = moment__default.defineLocale('fr', {
months : 'janvier_février_mars_avril_mai_juin_juillet_août_septembre_octobre_novembre_décembre'.split('_'),
monthsShort : 'janv._févr._mars_avr._mai_juin_juil._août_sept._oct._nov._déc.'.split('_'),
+ monthsParseExact : true,
weekdays : 'dimanche_lundi_mardi_mercredi_jeudi_vendredi_samedi'.split('_'),
weekdaysShort : 'dim._lun._mar._mer._jeu._ven._sam.'.split('_'),
weekdaysMin : 'Di_Lu_Ma_Me_Je_Ve_Sa'.split('_'),
+ weekdaysParseExact : true,
longDateFormat : {
LT : 'HH:mm',
LTS : 'HH:mm:ss',
@@ -6255,9 +6801,11 @@
return fy__monthsShortWithDots[m.month()];
}
},
+ monthsParseExact : true,
weekdays : 'snein_moandei_tiisdei_woansdei_tongersdei_freed_sneon'.split('_'),
weekdaysShort : 'si._mo._ti._wo._to._fr._so.'.split('_'),
weekdaysMin : 'Si_Mo_Ti_Wo_To_Fr_So'.split('_'),
+ weekdaysParseExact : true,
longDateFormat : {
LT : 'HH:mm',
LTS : 'HH:mm:ss',
@@ -6304,18 +6852,7 @@
//! author : Jon Ashdown : https://github.com/jonashdown
var gd__months = [
- 'Am Faoilleach',
- 'An Gearran',
- 'Am Màrt',
- 'An Giblean',
- 'An Cèitean',
- 'An t-Ògmhios',
- 'An t-Iuchar',
- 'An Lùnastal',
- 'An t-Sultain',
- 'An Dàmhair',
- 'An t-Samhain',
- 'An Dùbhlachd'
+ 'Am Faoilleach', 'An Gearran', 'Am Màrt', 'An Giblean', 'An Cèitean', 'An t-Ògmhios', 'An t-Iuchar', 'An Lùnastal', 'An t-Sultain', 'An Dàmhair', 'An t-Samhain', 'An Dùbhlachd'
];
var gd__monthsShort = ['Faoi', 'Gear', 'Màrt', 'Gibl', 'Cèit', 'Ògmh', 'Iuch', 'Lùn', 'Sult', 'Dàmh', 'Samh', 'Dùbh'];
@@ -6329,6 +6866,7 @@
var gd = moment__default.defineLocale('gd', {
months : gd__months,
monthsShort : gd__monthsShort,
+ monthsParseExact : true,
weekdays : gd__weekdays,
weekdaysShort : weekdaysShort,
weekdaysMin : weekdaysMin,
@@ -6381,9 +6919,11 @@
var gl = moment__default.defineLocale('gl', {
months : 'Xaneiro_Febreiro_Marzo_Abril_Maio_Xuño_Xullo_Agosto_Setembro_Outubro_Novembro_Decembro'.split('_'),
monthsShort : 'Xan._Feb._Mar._Abr._Mai._Xuñ._Xul._Ago._Set._Out._Nov._Dec.'.split('_'),
+ monthsParseExact: true,
weekdays : 'Domingo_Luns_Martes_Mércores_Xoves_Venres_Sábado'.split('_'),
weekdaysShort : 'Dom._Lun._Mar._Mér._Xov._Ven._Sáb.'.split('_'),
weekdaysMin : 'Do_Lu_Ma_Mé_Xo_Ve_Sá'.split('_'),
+ weekdaysParseExact : true,
longDateFormat : {
LT : 'H:mm',
LTS : 'H:mm:ss',
@@ -6506,6 +7046,23 @@
}
return number + ' שנים';
}
+ },
+ meridiemParse: /אחה"צ|לפנה"צ|אחרי הצהריים|לפני הצהריים|לפנות בוקר|בבוקר|בערב/i,
+ isPM : function (input) {
+ return /^(אחה"צ|אחרי הצהריים|בערב)$/.test(input);
+ },
+ meridiem : function (hour, minute, isLower) {
+ if (hour < 5) {
+ return 'לפנות בוקר';
+ } else if (hour < 10) {
+ return 'בבוקר';
+ } else if (hour < 12) {
+ return isLower ? 'לפנה"צ' : 'לפני הצהריים';
+ } else if (hour < 18) {
+ return isLower ? 'אחה"צ' : 'אחרי הצהריים';
+ } else {
+ return 'בערב';
+ }
}
});
@@ -6541,6 +7098,7 @@
var hi = moment__default.defineLocale('hi', {
months : 'जनवरी_फ़रवरी_मार्च_अप्रैल_मई_जून_जुलाई_अगस्त_सितम्बर_अक्टूबर_नवम्बर_दिसम्बर'.split('_'),
monthsShort : 'जन._फ़र._मार्च_अप्रै._मई_जून_जुल._अग._सित._अक्टू._नव._दिस.'.split('_'),
+ monthsParseExact: true,
weekdays : 'रविवार_सोमवार_मंगलवार_बुधवार_गुरूवार_शुक्रवार_शनिवार'.split('_'),
weekdaysShort : 'रवि_सोम_मंगल_बुध_गुरू_शुक्र_शनि'.split('_'),
weekdaysMin : 'र_सो_मं_बु_गु_शु_श'.split('_'),
@@ -6684,9 +7242,11 @@
standalone: 'siječanj_veljača_ožujak_travanj_svibanj_lipanj_srpanj_kolovoz_rujan_listopad_studeni_prosinac'.split('_')
},
monthsShort : 'sij._velj._ožu._tra._svi._lip._srp._kol._ruj._lis._stu._pro.'.split('_'),
+ monthsParseExact: true,
weekdays : 'nedjelja_ponedjeljak_utorak_srijeda_četvrtak_petak_subota'.split('_'),
weekdaysShort : 'ned._pon._uto._sri._čet._pet._sub.'.split('_'),
weekdaysMin : 'ne_po_ut_sr_če_pe_su'.split('_'),
+ weekdaysParseExact : true,
longDateFormat : {
LT : 'H:mm',
LTS : 'H:mm:ss',
@@ -7087,7 +7647,7 @@
longDateFormat : {
LT : 'H:mm',
LTS : 'H:mm:ss',
- L : 'DD/MM/YYYY',
+ L : 'DD.MM.YYYY',
LL : 'D. MMMM YYYY',
LLL : 'D. MMMM YYYY [kl.] H:mm',
LLLL : 'dddd, D. MMMM YYYY [kl.] H:mm'
@@ -7218,6 +7778,17 @@
lastDay : '[昨日] LT',
lastWeek : '[前週]dddd LT',
sameElse : 'L'
+ },
+ ordinalParse : /\d{1,2}日/,
+ ordinal : function (number, period) {
+ switch (period) {
+ case 'd':
+ case 'D':
+ case 'DDD':
+ return number + '日';
+ default:
+ return number;
+ }
},
relativeTime : {
future : '%s後',
@@ -7414,11 +7985,11 @@
};
var kk = moment__default.defineLocale('kk', {
- months : 'Қаңтар_Ақпан_Наурыз_Сәуір_Мамыр_Маусым_Шілде_Тамыз_Қыркүйек_Қазан_Қараша_Желтоқсан'.split('_'),
- monthsShort : 'Қаң_Ақп_Нау_Сәу_Мам_Мау_Шіл_Там_Қыр_Қаз_Қар_Жел'.split('_'),
- weekdays : 'Жексенбі_Дүйсенбі_Сейсенбі_Сәрсенбі_Бейсенбі_Жұма_Сенбі'.split('_'),
- weekdaysShort : 'Жек_Дүй_Сей_Сәр_Бей_Жұм_Сен'.split('_'),
- weekdaysMin : 'Жк_Дй_Сй_Ср_Бй_Жм_Сн'.split('_'),
+ months : 'қаңтар_ақпан_наурыз_сәуір_мамыр_маусым_шілде_тамыз_қыркүйек_қазан_қараша_желтоқсан'.split('_'),
+ monthsShort : 'қаң_ақп_нау_сәу_мам_мау_шіл_там_қыр_қаз_қар_жел'.split('_'),
+ weekdays : 'жексенбі_дүйсенбі_сейсенбі_сәрсенбі_бейсенбі_жұма_сенбі'.split('_'),
+ weekdaysShort : 'жек_дүй_сей_сәр_бей_жұм_сен'.split('_'),
+ weekdaysMin : 'жк_дй_сй_ср_бй_жм_сн'.split('_'),
longDateFormat : {
LT : 'HH:mm',
LTS : 'HH:mm:ss',
@@ -7467,8 +8038,8 @@
//! author : Kruy Vanna : https://github.com/kruyvanna
var km = moment__default.defineLocale('km', {
- months: 'មករា_កុម្ភៈ_មិនា_មេសា_ឧសភា_មិថុនា_កក្កដា_សីហា_កញ្ញា_តុលា_វិច្ឆិកា_ធ្នូ'.split('_'),
- monthsShort: 'មករា_កុម្ភៈ_មិនា_មេសា_ឧសភា_មិថុនា_កក្កដា_សីហា_កញ្ញា_តុលា_វិច្ឆិកា_ធ្នូ'.split('_'),
+ months: 'មករា_កុម្ភៈ_មីនា_មេសា_ឧសភា_មិថុនា_កក្កដា_សីហា_កញ្ញា_តុលា_វិច្ឆិកា_ធ្នូ'.split('_'),
+ monthsShort: 'មករា_កុម្ភៈ_មីនា_មេសា_ឧសភា_មិថុនា_កក្កដា_សីហា_កញ្ញា_តុលា_វិច្ឆិកា_ធ្នូ'.split('_'),
weekdays: 'អាទិត្យ_ច័ន្ទ_អង្គារ_ពុធ_ព្រហស្បតិ៍_សុក្រ_សៅរ៍'.split('_'),
weekdaysShort: 'អាទិត្យ_ច័ន្ទ_អង្គារ_ពុធ_ព្រហស្បតិ៍_សុក្រ_សៅរ៍'.split('_'),
weekdaysMin: 'អាទិត្យ_ច័ន្ទ_អង្គារ_ពុធ_ព្រហស្បតិ៍_សុក្រ_សៅរ៍'.split('_'),
@@ -7542,17 +8113,17 @@
relativeTime : {
future : '%s 후',
past : '%s 전',
- s : '몇초',
+ s : '몇 초',
ss : '%d초',
m : '일분',
mm : '%d분',
- h : '한시간',
+ h : '한 시간',
hh : '%d시간',
d : '하루',
dd : '%d일',
- M : '한달',
+ M : '한 달',
MM : '%d달',
- y : '일년',
+ y : '일 년',
yy : '%d년'
},
ordinalParse : /\d{1,2}일/,
@@ -7563,6 +8134,83 @@
},
meridiem : function (hour, minute, isUpper) {
return hour < 12 ? '오전' : '오후';
+ }
+ });
+
+ //! moment.js locale configuration
+ //! locale : kyrgyz (ky)
+ //! author : Chyngyz Arystan uulu : https://github.com/chyngyz
+
+
+ var ky__suffixes = {
+ 0: '-чү',
+ 1: '-чи',
+ 2: '-чи',
+ 3: '-чү',
+ 4: '-чү',
+ 5: '-чи',
+ 6: '-чы',
+ 7: '-чи',
+ 8: '-чи',
+ 9: '-чу',
+ 10: '-чу',
+ 20: '-чы',
+ 30: '-чу',
+ 40: '-чы',
+ 50: '-чү',
+ 60: '-чы',
+ 70: '-чи',
+ 80: '-чи',
+ 90: '-чу',
+ 100: '-чү'
+ };
+
+ var ky = moment__default.defineLocale('ky', {
+ months : 'январь_февраль_март_апрель_май_июнь_июль_август_сентябрь_октябрь_ноябрь_декабрь'.split('_'),
+ monthsShort : 'янв_фев_март_апр_май_июнь_июль_авг_сен_окт_ноя_дек'.split('_'),
+ weekdays : 'Жекшемби_Дүйшөмбү_Шейшемби_Шаршемби_Бейшемби_Жума_Ишемби'.split('_'),
+ weekdaysShort : 'Жек_Дүй_Шей_Шар_Бей_Жум_Ише'.split('_'),
+ weekdaysMin : 'Жк_Дй_Шй_Шр_Бй_Жм_Иш'.split('_'),
+ longDateFormat : {
+ LT : 'HH:mm',
+ LTS : 'HH:mm:ss',
+ L : 'DD.MM.YYYY',
+ LL : 'D MMMM YYYY',
+ LLL : 'D MMMM YYYY HH:mm',
+ LLLL : 'dddd, D MMMM YYYY HH:mm'
+ },
+ calendar : {
+ sameDay : '[Бүгүн саат] LT',
+ nextDay : '[Эртең саат] LT',
+ nextWeek : 'dddd [саат] LT',
+ lastDay : '[Кече саат] LT',
+ lastWeek : '[Өткен аптанын] dddd [күнү] [саат] LT',
+ sameElse : 'L'
+ },
+ relativeTime : {
+ future : '%s ичинде',
+ past : '%s мурун',
+ s : 'бирнече секунд',
+ m : 'бир мүнөт',
+ mm : '%d мүнөт',
+ h : 'бир саат',
+ hh : '%d саат',
+ d : 'бир күн',
+ dd : '%d күн',
+ M : 'бир ай',
+ MM : '%d ай',
+ y : 'бир жыл',
+ yy : '%d жыл'
+ },
+ ordinalParse: /\d{1,2}-(чи|чы|чү|чу)/,
+ ordinal : function (number) {
+ var a = number % 10,
+ b = number >= 100 ? 100 : null;
+ return number + (ky__suffixes[number] || ky__suffixes[a] || ky__suffixes[b]);
+ },
+ week : {
+ dow : 1, // Monday is the first day of the week.
+ doy : 7 // The week that contains Jan 1st is the first week of the year.
}
});
@@ -7638,9 +8286,11 @@
var lb = moment__default.defineLocale('lb', {
months: 'Januar_Februar_Mäerz_Abrëll_Mee_Juni_Juli_August_September_Oktober_November_Dezember'.split('_'),
monthsShort: 'Jan._Febr._Mrz._Abr._Mee_Jun._Jul._Aug._Sept._Okt._Nov._Dez.'.split('_'),
+ monthsParseExact : true,
weekdays: 'Sonndeg_Méindeg_Dënschdeg_Mëttwoch_Donneschdeg_Freideg_Samschdeg'.split('_'),
weekdaysShort: 'So._Mé._Dë._Më._Do._Fr._Sa.'.split('_'),
weekdaysMin: 'So_Mé_Dë_Më_Do_Fr_Sa'.split('_'),
+ weekdaysParseExact : true,
longDateFormat: {
LT: 'H:mm [Auer]',
LTS: 'H:mm:ss [Auer]',
@@ -7699,6 +8349,7 @@
weekdays : 'ອາທິດ_ຈັນ_ອັງຄານ_ພຸດ_ພະຫັດ_ສຸກ_ເສົາ'.split('_'),
weekdaysShort : 'ທິດ_ຈັນ_ອັງຄານ_ພຸດ_ພະຫັດ_ສຸກ_ເສົາ'.split('_'),
weekdaysMin : 'ທ_ຈ_ອຄ_ພ_ພຫ_ສກ_ສ'.split('_'),
+ weekdaysParseExact : true,
longDateFormat : {
LT : 'HH:mm',
LTS : 'HH:mm:ss',
@@ -7806,6 +8457,7 @@
},
weekdaysShort : 'Sek_Pir_Ant_Tre_Ket_Pen_Šeš'.split('_'),
weekdaysMin : 'S_P_A_T_K_Pn_Š'.split('_'),
+ weekdaysParseExact : true,
longDateFormat : {
LT : 'HH:mm',
LTS : 'HH:mm:ss',
@@ -7897,6 +8549,7 @@
weekdays : 'svētdiena_pirmdiena_otrdiena_trešdiena_ceturtdiena_piektdiena_sestdiena'.split('_'),
weekdaysShort : 'Sv_P_O_T_C_Pk_S'.split('_'),
weekdaysMin : 'Sv_P_O_T_C_Pk_S'.split('_'),
+ weekdaysParseExact : true,
longDateFormat : {
LT : 'HH:mm',
LTS : 'HH:mm:ss',
@@ -7964,11 +8617,13 @@
};
var me = moment__default.defineLocale('me', {
- months: ['januar', 'februar', 'mart', 'april', 'maj', 'jun', 'jul', 'avgust', 'septembar', 'oktobar', 'novembar', 'decembar'],
- monthsShort: ['jan.', 'feb.', 'mar.', 'apr.', 'maj', 'jun', 'jul', 'avg.', 'sep.', 'okt.', 'nov.', 'dec.'],
- weekdays: ['nedjelja', 'ponedjeljak', 'utorak', 'srijeda', 'četvrtak', 'petak', 'subota'],
- weekdaysShort: ['ned.', 'pon.', 'uto.', 'sri.', 'čet.', 'pet.', 'sub.'],
- weekdaysMin: ['ne', 'po', 'ut', 'sr', 'če', 'pe', 'su'],
+ months: 'januar_februar_mart_april_maj_jun_jul_avgust_septembar_oktobar_novembar_decembar'.split('_'),
+ monthsShort: 'jan._feb._mar._apr._maj_jun_jul_avg._sep._okt._nov._dec.'.split('_'),
+ monthsParseExact : true,
+ weekdays: 'nedjelja_ponedjeljak_utorak_srijeda_četvrtak_petak_subota'.split('_'),
+ weekdaysShort: 'ned._pon._uto._sri._čet._pet._sub.'.split('_'),
+ weekdaysMin: 'ne_po_ut_sr_če_pe_su'.split('_'),
+ weekdaysParseExact : true,
longDateFormat: {
LT: 'H:mm',
LTS : 'H:mm:ss',
@@ -8120,6 +8775,7 @@
var ml = moment__default.defineLocale('ml', {
months : 'ജനുവരി_ഫെബ്രുവരി_മാർച്ച്_ഏപ്രിൽ_മേയ്_ജൂൺ_ജൂലൈ_ഓഗസ്റ്റ്_സെപ്റ്റംബർ_ഒക്ടോബർ_നവംബർ_ഡിസംബർ'.split('_'),
monthsShort : 'ജനു._ഫെബ്രു._മാർ._ഏപ്രി._മേയ്_ജൂൺ_ജൂലൈ._ഓഗ._സെപ്റ്റ._ഒക്ടോ._നവം._ഡിസം.'.split('_'),
+ monthsParseExact : true,
weekdays : 'ഞായറാഴ്ച_തിങ്കളാഴ്ച_ചൊവ്വാഴ്ച_ബുധനാഴ്ച_വ്യാഴാഴ്ച_വെള്ളിയാഴ്ച_ശനിയാഴ്ച'.split('_'),
weekdaysShort : 'ഞായർ_തിങ്കൾ_ചൊവ്വ_ബുധൻ_വ്യാഴം_വെള്ളി_ശനി'.split('_'),
weekdaysMin : 'ഞാ_തി_ചൊ_ബു_വ്യാ_വെ_ശ'.split('_'),
@@ -8155,8 +8811,17 @@
yy : '%d വർഷം'
},
meridiemParse: /രാത്രി|രാവിലെ|ഉച്ച കഴിഞ്ഞ്|വൈകുന്നേരം|രാത്രി/i,
- isPM : function (input) {
- return /^(ഉച്ച കഴിഞ്ഞ്|വൈകുന്നേരം|രാത്രി)$/.test(input);
+ meridiemHour : function (hour, meridiem) {
+ if (hour === 12) {
+ hour = 0;
+ }
+ if ((meridiem === 'രാത്രി' && hour >= 4) ||
+ meridiem === 'ഉച്ച കഴിഞ്ഞ്' ||
+ meridiem === 'വൈകുന്നേരം') {
+ return hour + 12;
+ } else {
+ return hour;
+ }
},
meridiem : function (hour, minute, isLower) {
if (hour < 4) {
@@ -8242,6 +8907,7 @@
var mr = moment__default.defineLocale('mr', {
months : 'जानेवारी_फेब्रुवारी_मार्च_एप्रिल_मे_जून_जुलै_ऑगस्ट_सप्टेंबर_ऑक्टोबर_नोव्हेंबर_डिसेंबर'.split('_'),
monthsShort: 'जाने._फेब्रु._मार्च._एप्रि._मे._जून._जुलै._ऑग._सप्टें._ऑक्टो._नोव्हें._डिसें.'.split('_'),
+ monthsParseExact : true,
weekdays : 'रविवार_सोमवार_मंगळवार_बुधवार_गुरूवार_शुक्रवार_शनिवार'.split('_'),
weekdaysShort : 'रवि_सोम_मंगळ_बुध_गुरू_शुक्र_शनि'.split('_'),
weekdaysMin : 'र_सो_मं_बु_गु_शु_श'.split('_'),
@@ -8552,9 +9218,11 @@
var nb = moment__default.defineLocale('nb', {
months : 'januar_februar_mars_april_mai_juni_juli_august_september_oktober_november_desember'.split('_'),
monthsShort : 'jan._feb._mars_april_mai_juni_juli_aug._sep._okt._nov._des.'.split('_'),
+ monthsParseExact : true,
weekdays : 'søndag_mandag_tirsdag_onsdag_torsdag_fredag_lørdag'.split('_'),
weekdaysShort : 'sø._ma._ti._on._to._fr._lø.'.split('_'),
weekdaysMin : 'sø_ma_ti_on_to_fr_lø'.split('_'),
+ weekdaysParseExact : true,
longDateFormat : {
LT : 'HH:mm',
LTS : 'HH:mm:ss',
@@ -8573,7 +9241,7 @@
},
relativeTime : {
future : 'om %s',
- past : 'for %s siden',
+ past : '%s siden',
s : 'noen sekunder',
m : 'ett minutt',
mm : '%d minutter',
@@ -8626,9 +9294,11 @@
var ne = moment__default.defineLocale('ne', {
months : 'जनवरी_फेब्रुवरी_मार्च_अप्रिल_मई_जुन_जुलाई_अगष्ट_सेप्टेम्बर_अक्टोबर_नोभेम्बर_डिसेम्बर'.split('_'),
monthsShort : 'जन._फेब्रु._मार्च_अप्रि._मई_जुन_जुलाई._अग._सेप्ट._अक्टो._नोभे._डिसे.'.split('_'),
+ monthsParseExact : true,
weekdays : 'आइतबार_सोमबार_मङ्गलबार_बुधबार_बिहिबार_शुक्रबार_शनिबार'.split('_'),
weekdaysShort : 'आइत._सोम._मङ्गल._बुध._बिहि._शुक्र._शनि.'.split('_'),
weekdaysMin : 'आ._सो._मं._बु._बि._शु._श.'.split('_'),
+ weekdaysParseExact : true,
longDateFormat : {
LT : 'Aको h:mm बजे',
LTS : 'Aको h:mm:ss बजे',
@@ -8720,9 +9390,11 @@
return nl__monthsShortWithDots[m.month()];
}
},
+ monthsParseExact : true,
weekdays : 'zondag_maandag_dinsdag_woensdag_donderdag_vrijdag_zaterdag'.split('_'),
weekdaysShort : 'zo._ma._di._wo._do._vr._za.'.split('_'),
weekdaysMin : 'Zo_Ma_Di_Wo_Do_Vr_Za'.split('_'),
+ weekdaysParseExact : true,
longDateFormat : {
LT : 'HH:mm',
LTS : 'HH:mm:ss',
@@ -8792,7 +9464,7 @@
},
relativeTime : {
future : 'om %s',
- past : 'for %s sidan',
+ past : '%s sidan',
s : 'nokre sekund',
m : 'eit minutt',
mm : '%d minutt',
@@ -8810,6 +9482,119 @@
week : {
dow : 1, // Monday is the first day of the week.
doy : 4 // The week that contains Jan 4th is the first week of the year.
+ }
+ });
+
+ //! moment.js locale configuration
+ //! locale : punjabi india (pa-in)
+ //! author : Harpreet Singh : https://github.com/harpreetkhalsagtbit
+
+ var pa_in__symbolMap = {
+ '1': '੧',
+ '2': '੨',
+ '3': '੩',
+ '4': '੪',
+ '5': '੫',
+ '6': '੬',
+ '7': '੭',
+ '8': '੮',
+ '9': '੯',
+ '0': '੦'
+ },
+ pa_in__numberMap = {
+ '੧': '1',
+ '੨': '2',
+ '੩': '3',
+ '੪': '4',
+ '੫': '5',
+ '੬': '6',
+ '੭': '7',
+ '੮': '8',
+ '੯': '9',
+ '੦': '0'
+ };
+
+ var pa_in = moment__default.defineLocale('pa-in', {
+ // There are months name as per Nanakshahi Calender but they are not used as rigidly in modern Punjabi.
+ months : 'ਜਨਵਰੀ_ਫ਼ਰਵਰੀ_ਮਾਰਚ_ਅਪ੍ਰੈਲ_ਮਈ_ਜੂਨ_ਜੁਲਾਈ_ਅਗਸਤ_ਸਤੰਬਰ_ਅਕਤੂਬਰ_ਨਵੰਬਰ_ਦਸੰਬਰ'.split('_'),
+ monthsShort : 'ਜਨਵਰੀ_ਫ਼ਰਵਰੀ_ਮਾਰਚ_ਅਪ੍ਰੈਲ_ਮਈ_ਜੂਨ_ਜੁਲਾਈ_ਅਗਸਤ_ਸਤੰਬਰ_ਅਕਤੂਬਰ_ਨਵੰਬਰ_ਦਸੰਬਰ'.split('_'),
+ weekdays : 'ਐਤਵਾਰ_ਸੋਮਵਾਰ_ਮੰਗਲਵਾਰ_ਬੁਧਵਾਰ_ਵੀਰਵਾਰ_ਸ਼ੁੱਕਰਵਾਰ_ਸ਼ਨੀਚਰਵਾਰ'.split('_'),
+ weekdaysShort : 'ਐਤ_ਸੋਮ_ਮੰਗਲ_ਬੁਧ_ਵੀਰ_ਸ਼ੁਕਰ_ਸ਼ਨੀ'.split('_'),
+ weekdaysMin : 'ਐਤ_ਸੋਮ_ਮੰਗਲ_ਬੁਧ_ਵੀਰ_ਸ਼ੁਕਰ_ਸ਼ਨੀ'.split('_'),
+ longDateFormat : {
+ LT : 'A h:mm ਵਜੇ',
+ LTS : 'A h:mm:ss ਵਜੇ',
+ L : 'DD/MM/YYYY',
+ LL : 'D MMMM YYYY',
+ LLL : 'D MMMM YYYY, A h:mm ਵਜੇ',
+ LLLL : 'dddd, D MMMM YYYY, A h:mm ਵਜੇ'
+ },
+ calendar : {
+ sameDay : '[ਅਜ] LT',
+ nextDay : '[ਕਲ] LT',
+ nextWeek : 'dddd, LT',
+ lastDay : '[ਕਲ] LT',
+ lastWeek : '[ਪਿਛਲੇ] dddd, LT',
+ sameElse : 'L'
+ },
+ relativeTime : {
+ future : '%s ਵਿੱਚ',
+ past : '%s ਪਿਛਲੇ',
+ s : 'ਕੁਝ ਸਕਿੰਟ',
+ m : 'ਇਕ ਮਿੰਟ',
+ mm : '%d ਮਿੰਟ',
+ h : 'ਇੱਕ ਘੰਟਾ',
+ hh : '%d ਘੰਟੇ',
+ d : 'ਇੱਕ ਦਿਨ',
+ dd : '%d ਦਿਨ',
+ M : 'ਇੱਕ ਮਹੀਨਾ',
+ MM : '%d ਮਹੀਨੇ',
+ y : 'ਇੱਕ ਸਾਲ',
+ yy : '%d ਸਾਲ'
+ },
+ preparse: function (string) {
+ return string.replace(/[੧੨੩੪੫੬੭੮੯੦]/g, function (match) {
+ return pa_in__numberMap[match];
+ });
+ },
+ postformat: function (string) {
+ return string.replace(/\d/g, function (match) {
+ return pa_in__symbolMap[match];
+ });
+ },
+ // Punjabi notation for meridiems are quite fuzzy in practice. While there exists
+ // a rigid notion of a 'Pahar' it is not used as rigidly in modern Punjabi.
+ meridiemParse: /ਰਾਤ|ਸਵੇਰ|ਦੁਪਹਿਰ|ਸ਼ਾਮ/,
+ meridiemHour : function (hour, meridiem) {
+ if (hour === 12) {
+ hour = 0;
+ }
+ if (meridiem === 'ਰਾਤ') {
+ return hour < 4 ? hour : hour + 12;
+ } else if (meridiem === 'ਸਵੇਰ') {
+ return hour;
+ } else if (meridiem === 'ਦੁਪਹਿਰ') {
+ return hour >= 10 ? hour : hour + 12;
+ } else if (meridiem === 'ਸ਼ਾਮ') {
+ return hour + 12;
+ }
+ },
+ meridiem : function (hour, minute, isLower) {
+ if (hour < 4) {
+ return 'ਰਾਤ';
+ } else if (hour < 10) {
+ return 'ਸਵੇਰ';
+ } else if (hour < 17) {
+ return 'ਦੁਪਹਿਰ';
+ } else if (hour < 20) {
+ return 'ਸ਼ਾਮ';
+ } else {
+ return 'ਰਾਤ';
+ }
+ },
+ week : {
+ dow : 0, // Sunday is the first day of the week.
+ doy : 6 // The week that contains Jan 1st is the first week of the year.
}
});
@@ -8914,9 +9699,10 @@
var pt_br = moment__default.defineLocale('pt-br', {
months : 'Janeiro_Fevereiro_Março_Abril_Maio_Junho_Julho_Agosto_Setembro_Outubro_Novembro_Dezembro'.split('_'),
monthsShort : 'Jan_Fev_Mar_Abr_Mai_Jun_Jul_Ago_Set_Out_Nov_Dez'.split('_'),
- weekdays : 'Domingo_Segunda-Feira_Terça-Feira_Quarta-Feira_Quinta-Feira_Sexta-Feira_Sábado'.split('_'),
+ weekdays : 'Domingo_Segunda-feira_Terça-feira_Quarta-feira_Quinta-feira_Sexta-feira_Sábado'.split('_'),
weekdaysShort : 'Dom_Seg_Ter_Qua_Qui_Sex_Sáb'.split('_'),
weekdaysMin : 'Dom_2ª_3ª_4ª_5ª_6ª_Sáb'.split('_'),
+ weekdaysParseExact : true,
longDateFormat : {
LT : 'HH:mm',
LTS : 'HH:mm:ss',
@@ -8966,6 +9752,7 @@
weekdays : 'Domingo_Segunda-Feira_Terça-Feira_Quarta-Feira_Quinta-Feira_Sexta-Feira_Sábado'.split('_'),
weekdaysShort : 'Dom_Seg_Ter_Qua_Qui_Sex_Sáb'.split('_'),
weekdaysMin : 'Dom_2ª_3ª_4ª_5ª_6ª_Sáb'.split('_'),
+ weekdaysParseExact : true,
longDateFormat : {
LT : 'HH:mm',
LTS : 'HH:mm:ss',
@@ -9032,6 +9819,7 @@
var ro = moment__default.defineLocale('ro', {
months : 'ianuarie_februarie_martie_aprilie_mai_iunie_iulie_august_septembrie_octombrie_noiembrie_decembrie'.split('_'),
monthsShort : 'ian._febr._mart._apr._mai_iun._iul._aug._sept._oct._nov._dec.'.split('_'),
+ monthsParseExact: true,
weekdays : 'duminică_luni_marți_miercuri_joi_vineri_sâmbătă'.split('_'),
weekdaysShort : 'Dum_Lun_Mar_Mie_Joi_Vin_Sâm'.split('_'),
weekdaysMin : 'Du_Lu_Ma_Mi_Jo_Vi_Sâ'.split('_'),
@@ -9076,6 +9864,7 @@
//! locale : russian (ru)
//! author : Viktorminator : https://github.com/Viktorminator
//! Author : Menelion Elensúle : https://github.com/Oire
+ //! author : Коренберг Марк : https://github.com/socketpair
function ru__plural(word, num) {
var forms = word.split('_');
@@ -9096,27 +9885,35 @@
return number + ' ' + ru__plural(format[key], +number);
}
}
- var monthsParse = [/^янв/i, /^фев/i, /^мар/i, /^апр/i, /^ма[й|я]/i, /^июн/i, /^июл/i, /^авг/i, /^сен/i, /^окт/i, /^ноя/i, /^дек/i];
-
+ var monthsParse = [/^янв/i, /^фев/i, /^мар/i, /^апр/i, /^ма[йя]/i, /^июн/i, /^июл/i, /^авг/i, /^сен/i, /^окт/i, /^ноя/i, /^дек/i];
+
+ // http://new.gramota.ru/spravka/rules/139-prop : § 103
+ // Сокращения месяцев: http://new.gramota.ru/spravka/buro/search-answer?s=242637
+ // CLDR data: http://www.unicode.org/cldr/charts/28/summary/ru.html#1753
var ru = moment__default.defineLocale('ru', {
months : {
- format: 'Января_Февраля_Марта_Апреля_Мая_Июня_Июля_Августа_Сентября_Октября_Ноября_Декабря'.split('_'),
- standalone: 'Январь_Февраль_Март_Апрель_Май_Июнь_Июль_Август_Сентябрь_Октябрь_Ноябрь_Декабрь'.split('_')
+ format: 'января_февраля_марта_апреля_мая_июня_июля_августа_сентября_октября_ноября_декабря'.split('_'),
+ standalone: 'январь_февраль_март_апрель_май_июнь_июль_август_сентябрь_октябрь_ноябрь_декабрь'.split('_')
},
monthsShort : {
- format: 'янв_фев_мар_апр_мая_июня_июля_авг_сен_окт_ноя_дек'.split('_'),
- standalone: 'янв_фев_март_апр_май_июнь_июль_авг_сен_окт_ноя_дек'.split('_')
+ // по CLDR именно "июл." и "июн.", но какой смысл менять букву на точку ?
+ format: 'янв._февр._мар._апр._мая_июня_июля_авг._сент._окт._нояб._дек.'.split('_'),
+ standalone: 'янв._февр._март_апр._май_июнь_июль_авг._сент._окт._нояб._дек.'.split('_')
},
weekdays : {
- standalone: 'Воскресенье_Понедельник_Вторник_Среда_Четверг_Пятница_Суббота'.split('_'),
- format: 'Воскресенье_Понедельник_Вторник_Среду_Четверг_Пятницу_Субботу'.split('_'),
+ standalone: 'воскресенье_понедельник_вторник_среда_четверг_пятница_суббота'.split('_'),
+ format: 'воскресенье_понедельник_вторник_среду_четверг_пятницу_субботу'.split('_'),
isFormat: /\[ ?[Вв] ?(?:прошлую|следующую|эту)? ?\] ?dddd/
},
- weekdaysShort : 'Вс_Пн_Вт_Ср_Чт_Пт_Сб'.split('_'),
- weekdaysMin : 'Вс_Пн_Вт_Ср_Чт_Пт_Сб'.split('_'),
+ weekdaysShort : 'вс_пн_вт_ср_чт_пт_сб'.split('_'),
+ weekdaysMin : 'вс_пн_вт_ср_чт_пт_сб'.split('_'),
monthsParse : monthsParse,
longMonthsParse : monthsParse,
shortMonthsParse : monthsParse,
+ monthsRegex: /^(сентябр[яь]|октябр[яь]|декабр[яь]|феврал[яь]|январ[яь]|апрел[яь]|августа?|ноябр[яь]|сент\.|февр\.|нояб\.|июнь|янв.|июль|дек.|авг.|апр.|марта|мар[.т]|окт.|июн[яь]|июл[яь]|ма[яй])/i,
+ monthsShortRegex: /^(сентябр[яь]|октябр[яь]|декабр[яь]|феврал[яь]|январ[яь]|апрел[яь]|августа?|ноябр[яь]|сент\.|февр\.|нояб\.|июнь|янв.|июль|дек.|авг.|апр.|марта|мар[.т]|окт.|июн[яь]|июл[яь]|ма[яй])/i,
+ monthsStrictRegex: /^(сентябр[яь]|октябр[яь]|декабр[яь]|феврал[яь]|январ[яь]|апрел[яь]|августа?|ноябр[яь]|марта?|июн[яь]|июл[яь]|ма[яй])/i,
+ monthsShortStrictRegex: /^(нояб\.|февр\.|сент\.|июль|янв\.|июн[яь]|мар[.т]|авг\.|апр\.|окт\.|дек\.|ма[яй])/i,
longDateFormat : {
LT : 'HH:mm',
LTS : 'HH:mm:ss',
@@ -9288,6 +10085,7 @@
weekdays : 'ඉරිදා_සඳුදා_අඟහරුවාදා_බදාදා_බ්රහස්පතින්දා_සිකුරාදා_සෙනසුරාදා'.split('_'),
weekdaysShort : 'ඉරි_සඳු_අඟ_බදා_බ්රහ_සිකු_සෙන'.split('_'),
weekdaysMin : 'ඉ_ස_අ_බ_බ්ර_සි_සෙ'.split('_'),
+ weekdaysParseExact : true,
longDateFormat : {
LT : 'a h:mm',
LTS : 'a h:mm:ss',
@@ -9322,6 +10120,10 @@
ordinalParse: /\d{1,2} වැනි/,
ordinal : function (number) {
return number + ' වැනි';
+ },
+ meridiemParse : /පෙර වරු|පස් වරු|පෙ.ව|ප.ව./,
+ isPM : function (input) {
+ return input === 'ප.ව.' || input === 'පස් වරු';
},
meridiem : function (hours, minutes, isLower) {
if (hours > 11) {
@@ -9549,9 +10351,11 @@
var sl = moment__default.defineLocale('sl', {
months : 'januar_februar_marec_april_maj_junij_julij_avgust_september_oktober_november_december'.split('_'),
monthsShort : 'jan._feb._mar._apr._maj._jun._jul._avg._sep._okt._nov._dec.'.split('_'),
+ monthsParseExact: true,
weekdays : 'nedelja_ponedeljek_torek_sreda_četrtek_petek_sobota'.split('_'),
weekdaysShort : 'ned._pon._tor._sre._čet._pet._sob.'.split('_'),
weekdaysMin : 'ne_po_to_sr_če_pe_so'.split('_'),
+ weekdaysParseExact : true,
longDateFormat : {
LT : 'H:mm',
LTS : 'H:mm:ss',
@@ -9632,6 +10436,7 @@
weekdays : 'E Diel_E Hënë_E Martë_E Mërkurë_E Enjte_E Premte_E Shtunë'.split('_'),
weekdaysShort : 'Die_Hën_Mar_Mër_Enj_Pre_Sht'.split('_'),
weekdaysMin : 'D_H_Ma_Më_E_P_Sh'.split('_'),
+ weekdaysParseExact : true,
meridiemParse: /PD|MD/,
isPM: function (input) {
return input.charAt(0) === 'M';
@@ -9706,11 +10511,13 @@
};
var sr_cyrl = moment__default.defineLocale('sr-cyrl', {
- months: ['јануар', 'фебруар', 'март', 'април', 'мај', 'јун', 'јул', 'август', 'септембар', 'октобар', 'новембар', 'децембар'],
- monthsShort: ['јан.', 'феб.', 'мар.', 'апр.', 'мај', 'јун', 'јул', 'авг.', 'сеп.', 'окт.', 'нов.', 'дец.'],
- weekdays: ['недеља', 'понедељак', 'уторак', 'среда', 'четвртак', 'петак', 'субота'],
- weekdaysShort: ['нед.', 'пон.', 'уто.', 'сре.', 'чет.', 'пет.', 'суб.'],
- weekdaysMin: ['не', 'по', 'ут', 'ср', 'че', 'пе', 'су'],
+ months: 'јануар_фебруар_март_април_мај_јун_јул_август_септембар_октобар_новембар_децембар'.split('_'),
+ monthsShort: 'јан._феб._мар._апр._мај_јун_јул_авг._сеп._окт._нов._дец.'.split('_'),
+ monthsParseExact: true,
+ weekdays: 'недеља_понедељак_уторак_среда_четвртак_петак_субота'.split('_'),
+ weekdaysShort: 'нед._пон._уто._сре._чет._пет._суб.'.split('_'),
+ weekdaysMin: 'не_по_ут_ср_че_пе_су'.split('_'),
+ weekdaysParseExact : true,
longDateFormat: {
LT: 'H:mm',
LTS : 'H:mm:ss',
@@ -9803,11 +10610,13 @@
};
var sr = moment__default.defineLocale('sr', {
- months: ['januar', 'februar', 'mart', 'april', 'maj', 'jun', 'jul', 'avgust', 'septembar', 'oktobar', 'novembar', 'decembar'],
- monthsShort: ['jan.', 'feb.', 'mar.', 'apr.', 'maj', 'jun', 'jul', 'avg.', 'sep.', 'okt.', 'nov.', 'dec.'],
- weekdays: ['nedelja', 'ponedeljak', 'utorak', 'sreda', 'četvrtak', 'petak', 'subota'],
- weekdaysShort: ['ned.', 'pon.', 'uto.', 'sre.', 'čet.', 'pet.', 'sub.'],
- weekdaysMin: ['ne', 'po', 'ut', 'sr', 'če', 'pe', 'su'],
+ months: 'januar_februar_mart_april_maj_jun_jul_avgust_septembar_oktobar_novembar_decembar'.split('_'),
+ monthsShort: 'jan._feb._mar._apr._maj_jun_jul_avg._sep._okt._nov._dec.'.split('_'),
+ monthsParseExact: true,
+ weekdays: 'nedelja_ponedeljak_utorak_sreda_četvrtak_petak_subota'.split('_'),
+ weekdaysShort: 'ned._pon._uto._sre._čet._pet._sub.'.split('_'),
+ weekdaysMin: 'ne_po_ut_sr_če_pe_su'.split('_'),
+ weekdaysParseExact : true,
longDateFormat: {
LT: 'H:mm',
LTS : 'H:mm:ss',
@@ -9873,6 +10682,84 @@
});
//! moment.js locale configuration
+ //! locale : siSwati (ss)
+ //! author : Nicolai Davies : https://github.com/nicolaidavies
+
+
+ var ss = moment__default.defineLocale('ss', {
+ months : "Bhimbidvwane_Indlovana_Indlov'lenkhulu_Mabasa_Inkhwekhweti_Inhlaba_Kholwane_Ingci_Inyoni_Imphala_Lweti_Ingongoni".split('_'),
+ monthsShort : 'Bhi_Ina_Inu_Mab_Ink_Inh_Kho_Igc_Iny_Imp_Lwe_Igo'.split('_'),
+ weekdays : 'Lisontfo_Umsombuluko_Lesibili_Lesitsatfu_Lesine_Lesihlanu_Umgcibelo'.split('_'),
+ weekdaysShort : 'Lis_Umb_Lsb_Les_Lsi_Lsh_Umg'.split('_'),
+ weekdaysMin : 'Li_Us_Lb_Lt_Ls_Lh_Ug'.split('_'),
+ weekdaysParseExact : true,
+ longDateFormat : {
+ LT : 'h:mm A',
+ LTS : 'h:mm:ss A',
+ L : 'DD/MM/YYYY',
+ LL : 'D MMMM YYYY',
+ LLL : 'D MMMM YYYY h:mm A',
+ LLLL : 'dddd, D MMMM YYYY h:mm A'
+ },
+ calendar : {
+ sameDay : '[Namuhla nga] LT',
+ nextDay : '[Kusasa nga] LT',
+ nextWeek : 'dddd [nga] LT',
+ lastDay : '[Itolo nga] LT',
+ lastWeek : 'dddd [leliphelile] [nga] LT',
+ sameElse : 'L'
+ },
+ relativeTime : {
+ future : 'nga %s',
+ past : 'wenteka nga %s',
+ s : 'emizuzwana lomcane',
+ m : 'umzuzu',
+ mm : '%d emizuzu',
+ h : 'lihora',
+ hh : '%d emahora',
+ d : 'lilanga',
+ dd : '%d emalanga',
+ M : 'inyanga',
+ MM : '%d tinyanga',
+ y : 'umnyaka',
+ yy : '%d iminyaka'
+ },
+ meridiemParse: /ekuseni|emini|entsambama|ebusuku/,
+ meridiem : function (hours, minutes, isLower) {
+ if (hours < 11) {
+ return 'ekuseni';
+ } else if (hours < 15) {
+ return 'emini';
+ } else if (hours < 19) {
+ return 'entsambama';
+ } else {
+ return 'ebusuku';
+ }
+ },
+ meridiemHour : function (hour, meridiem) {
+ if (hour === 12) {
+ hour = 0;
+ }
+ if (meridiem === 'ekuseni') {
+ return hour;
+ } else if (meridiem === 'emini') {
+ return hour >= 11 ? hour : hour + 12;
+ } else if (meridiem === 'entsambama' || meridiem === 'ebusuku') {
+ if (hour === 0) {
+ return 0;
+ }
+ return hour + 12;
+ }
+ },
+ ordinalParse: /\d{1,2}/,
+ ordinal : '%d',
+ week : {
+ dow : 1, // Monday is the first day of the week.
+ doy : 4 // The week that contains Jan 4th is the first week of the year.
+ }
+ });
+
+ //! moment.js locale configuration
//! locale : swedish (sv)
//! author : Jens Alm : https://github.com/ulmus
@@ -9887,8 +10774,10 @@
LTS : 'HH:mm:ss',
L : 'YYYY-MM-DD',
LL : 'D MMMM YYYY',
- LLL : 'D MMMM YYYY HH:mm',
- LLLL : 'dddd D MMMM YYYY HH:mm'
+ LLL : 'D MMMM YYYY [kl.] HH:mm',
+ LLLL : 'dddd D MMMM YYYY [kl.] HH:mm',
+ lll : 'D MMM YYYY HH:mm',
+ llll : 'ddd D MMM YYYY HH:mm'
},
calendar : {
sameDay: '[Idag] LT',
@@ -9938,6 +10827,7 @@
weekdays : 'Jumapili_Jumatatu_Jumanne_Jumatano_Alhamisi_Ijumaa_Jumamosi'.split('_'),
weekdaysShort : 'Jpl_Jtat_Jnne_Jtan_Alh_Ijm_Jmos'.split('_'),
weekdaysMin : 'J2_J3_J4_J5_Al_Ij_J1'.split('_'),
+ weekdaysParseExact : true,
longDateFormat : {
LT : 'HH:mm',
LTS : 'HH:mm:ss',
@@ -10100,6 +10990,7 @@
var te = moment__default.defineLocale('te', {
months : 'జనవరి_ఫిబ్రవరి_మార్చి_ఏప్రిల్_మే_జూన్_జూలై_ఆగస్టు_సెప్టెంబర్_అక్టోబర్_నవంబర్_డిసెంబర్'.split('_'),
monthsShort : 'జన._ఫిబ్ర._మార్చి_ఏప్రి._మే_జూన్_జూలై_ఆగ._సెప్._అక్టో._నవ._డిసె.'.split('_'),
+ monthsParseExact : true,
weekdays : 'ఆదివారం_సోమవారం_మంగళవారం_బుధవారం_గురువారం_శుక్రవారం_శనివారం'.split('_'),
weekdaysShort : 'ఆది_సోమ_మంగళ_బుధ_గురు_శుక్ర_శని'.split('_'),
weekdaysMin : 'ఆ_సో_మం_బు_గు_శు_శ'.split('_'),
@@ -10177,9 +11068,11 @@
var th = moment__default.defineLocale('th', {
months : 'มกราคม_กุมภาพันธ์_มีนาคม_เมษายน_พฤษภาคม_มิถุนายน_กรกฎาคม_สิงหาคม_กันยายน_ตุลาคม_พฤศจิกายน_ธันวาคม'.split('_'),
monthsShort : 'มกรา_กุมภา_มีนา_เมษา_พฤษภา_มิถุนา_กรกฎา_สิงหา_กันยา_ตุลา_พฤศจิกา_ธันวา'.split('_'),
+ monthsParseExact: true,
weekdays : 'อาทิตย์_จันทร์_อังคาร_พุธ_พฤหัสบดี_ศุกร์_เสาร์'.split('_'),
weekdaysShort : 'อาทิตย์_จันทร์_อังคาร_พุธ_พฤหัส_ศุกร์_เสาร์'.split('_'), // yes, three characters difference
weekdaysMin : 'อา._จ._อ._พ._พฤ._ศ._ส.'.split('_'),
+ weekdaysParseExact : true,
longDateFormat : {
LT : 'H นาฬิกา m นาที',
LTS : 'H นาฬิกา m นาที s วินาที',
@@ -10341,6 +11234,7 @@
var tlh = moment__default.defineLocale('tlh', {
months : 'tera’ jar wa’_tera’ jar cha’_tera’ jar wej_tera’ jar loS_tera’ jar vagh_tera’ jar jav_tera’ jar Soch_tera’ jar chorgh_tera’ jar Hut_tera’ jar wa’maH_tera’ jar wa’maH wa’_tera’ jar wa’maH cha’'.split('_'),
monthsShort : 'jar wa’_jar cha’_jar wej_jar loS_jar vagh_jar jav_jar Soch_jar chorgh_jar Hut_jar wa’maH_jar wa’maH wa’_jar wa’maH cha’'.split('_'),
+ monthsParseExact : true,
weekdays : 'lojmItjaj_DaSjaj_povjaj_ghItlhjaj_loghjaj_buqjaj_ghInjaj'.split('_'),
weekdaysShort : 'lojmItjaj_DaSjaj_povjaj_ghItlhjaj_loghjaj_buqjaj_ghInjaj'.split('_'),
weekdaysMin : 'lojmItjaj_DaSjaj_povjaj_ghItlhjaj_loghjaj_buqjaj_ghInjaj'.split('_'),
@@ -10483,6 +11377,10 @@
LLL : 'D. MMMM [dallas] YYYY HH.mm',
LLLL : 'dddd, [li] D. MMMM [dallas] YYYY HH.mm'
},
+ meridiemParse: /d\'o|d\'a/i,
+ isPM : function (input) {
+ return 'd\'o' === input.toLowerCase();
+ },
meridiem : function (hours, minutes, isLower) {
if (hours > 11) {
return isLower ? 'd\'o' : 'D\'O';
@@ -10821,9 +11719,22 @@
var vi = moment__default.defineLocale('vi', {
months : 'tháng 1_tháng 2_tháng 3_tháng 4_tháng 5_tháng 6_tháng 7_tháng 8_tháng 9_tháng 10_tháng 11_tháng 12'.split('_'),
monthsShort : 'Th01_Th02_Th03_Th04_Th05_Th06_Th07_Th08_Th09_Th10_Th11_Th12'.split('_'),
+ monthsParseExact : true,
weekdays : 'chủ nhật_thứ hai_thứ ba_thứ tư_thứ năm_thứ sáu_thứ bảy'.split('_'),
weekdaysShort : 'CN_T2_T3_T4_T5_T6_T7'.split('_'),
weekdaysMin : 'CN_T2_T3_T4_T5_T6_T7'.split('_'),
+ weekdaysParseExact : true,
+ meridiemParse: /sa|ch/i,
+ isPM : function (input) {
+ return /^ch$/i.test(input);
+ },
+ meridiem : function (hours, minutes, isLower) {
+ if (hours < 12) {
+ return isLower ? 'sa' : 'SA';
+ } else {
+ return isLower ? 'ch' : 'CH';
+ }
+ },
longDateFormat : {
LT : 'HH:mm',
LTS : 'HH:mm:ss',
@@ -10862,6 +11773,63 @@
ordinalParse: /\d{1,2}/,
ordinal : function (number) {
return number;
+ },
+ week : {
+ dow : 1, // Monday is the first day of the week.
+ doy : 4 // The week that contains Jan 4th is the first week of the year.
+ }
+ });
+
+ //! moment.js locale configuration
+ //! locale : pseudo (x-pseudo)
+ //! author : Andrew Hood : https://github.com/andrewhood125
+
+ var x_pseudo = moment__default.defineLocale('x-pseudo', {
+ months : 'J~áñúá~rý_F~ébrú~árý_~Márc~h_Áp~ríl_~Máý_~Júñé~_Júl~ý_Áú~gúst~_Sép~témb~ér_Ó~ctób~ér_Ñ~óvém~bér_~Décé~mbér'.split('_'),
+ monthsShort : 'J~áñ_~Féb_~Már_~Ápr_~Máý_~Júñ_~Júl_~Áúg_~Sép_~Óct_~Ñóv_~Déc'.split('_'),
+ monthsParseExact : true,
+ weekdays : 'S~úñdá~ý_Mó~ñdáý~_Túé~sdáý~_Wéd~ñésd~áý_T~húrs~dáý_~Fríd~áý_S~átúr~dáý'.split('_'),
+ weekdaysShort : 'S~úñ_~Móñ_~Túé_~Wéd_~Thú_~Frí_~Sát'.split('_'),
+ weekdaysMin : 'S~ú_Mó~_Tú_~Wé_T~h_Fr~_Sá'.split('_'),
+ weekdaysParseExact : true,
+ longDateFormat : {
+ LT : 'HH:mm',
+ L : 'DD/MM/YYYY',
+ LL : 'D MMMM YYYY',
+ LLL : 'D MMMM YYYY HH:mm',
+ LLLL : 'dddd, D MMMM YYYY HH:mm'
+ },
+ calendar : {
+ sameDay : '[T~ódá~ý át] LT',
+ nextDay : '[T~ómó~rró~w át] LT',
+ nextWeek : 'dddd [át] LT',
+ lastDay : '[Ý~ést~érdá~ý át] LT',
+ lastWeek : '[L~ást] dddd [át] LT',
+ sameElse : 'L'
+ },
+ relativeTime : {
+ future : 'í~ñ %s',
+ past : '%s á~gó',
+ s : 'á ~féw ~sécó~ñds',
+ m : 'á ~míñ~úté',
+ mm : '%d m~íñú~tés',
+ h : 'á~ñ hó~úr',
+ hh : '%d h~óúrs',
+ d : 'á ~dáý',
+ dd : '%d d~áýs',
+ M : 'á ~móñ~th',
+ MM : '%d m~óñt~hs',
+ y : 'á ~ýéár',
+ yy : '%d ý~éárs'
+ },
+ ordinalParse: /\d{1,2}(th|st|nd|rd)/,
+ ordinal : function (number) {
+ var b = number % 10,
+ output = (~~(number % 100 / 10) === 1) ? 'th' :
+ (b === 1) ? 'st' :
+ (b === 2) ? 'nd' :
+ (b === 3) ? 'rd' : 'th';
+ return number + output;
},
week : {
dow : 1, // Monday is the first day of the week.
@@ -10936,7 +11904,7 @@
nextWeek : function () {
var startOfWeek, prefix;
startOfWeek = moment__default().startOf('week');
- prefix = this.unix() - startOfWeek.unix() >= 7 * 24 * 3600 ? '[下]' : '[本]';
+ prefix = this.diff(startOfWeek, 'days') >= 7 ? '[下]' : '[本]';
return this.minutes() === 0 ? prefix + 'dddAh点整' : prefix + 'dddAh点mm';
},
lastWeek : function () {
@@ -11062,15 +12030,15 @@
future : '%s內',
past : '%s前',
s : '幾秒',
- m : '一分鐘',
+ m : '1分鐘',
mm : '%d分鐘',
- h : '一小時',
+ h : '1小時',
hh : '%d小時',
- d : '一天',
+ d : '1天',
dd : '%d天',
- M : '一個月',
+ M : '1個月',
MM : '%d個月',
- y : '一年',
+ y : '1年',
yy : '%d年'
}
});
diff --git a/min/tests.js b/min/tests.js
index 3e61026..baa29e5 100644
--- a/min/tests.js
+++ b/min/tests.js
@@ -5,6 +5,224 @@
typeof define === 'function' && define.amd ? define(['../../moment'], factory) :
factory(global.moment)
}(this, function (moment) { 'use strict';
+
+ function each(array, callback) {
+ var i;
+ for (i = 0; i < array.length; i++) {
+ callback(array[i], i, array);
+ }
+ }
+
+ function objectKeys(obj) {
+ if (Object.keys) {
+ return Object.keys(obj);
+ } else {
+ // IE8
+ var res = [], i;
+ for (i in obj) {
+ if (obj.hasOwnProperty(i)) {
+ res.push(i);
+ }
+ }
+ return res;
+ }
+ }
+
+ // Pick the first defined of two or three arguments.
+ function defaults(a, b, c) {
+ if (a != null) {
+ return a;
+ }
+ if (b != null) {
+ return b;
+ }
+ return c;
+ }
+
+ function defineCommonLocaleTests(locale, options) {
+ test('lenient ordinal parsing', function (assert) {
+ var i, ordinalStr, testMoment;
+ for (i = 1; i <= 31; ++i) {
+ ordinalStr = moment([2014, 0, i]).format('YYYY MM Do');
+ testMoment = moment(ordinalStr, 'YYYY MM Do');
+ assert.equal(testMoment.year(), 2014,
+ 'lenient ordinal parsing ' + i + ' year check');
+ assert.equal(testMoment.month(), 0,
+ 'lenient ordinal parsing ' + i + ' month check');
+ assert.equal(testMoment.date(), i,
+ 'lenient ordinal parsing ' + i + ' date check');
+ }
+ });
+
+ test('lenient ordinal parsing of number', function (assert) {
+ var i, testMoment;
+ for (i = 1; i <= 31; ++i) {
+ testMoment = moment('2014 01 ' + i, 'YYYY MM Do');
+ assert.equal(testMoment.year(), 2014,
+ 'lenient ordinal parsing of number ' + i + ' year check');
+ assert.equal(testMoment.month(), 0,
+ 'lenient ordinal parsing of number ' + i + ' month check');
+ assert.equal(testMoment.date(), i,
+ 'lenient ordinal parsing of number ' + i + ' date check');
+ }
+ });
+
+ test('strict ordinal parsing', function (assert) {
+ var i, ordinalStr, testMoment;
+ for (i = 1; i <= 31; ++i) {
+ ordinalStr = moment([2014, 0, i]).format('YYYY MM Do');
+ testMoment = moment(ordinalStr, 'YYYY MM Do', true);
+ assert.ok(testMoment.isValid(), 'strict ordinal parsing ' + i);
+ }
+ });
+
+ test('meridiem invariant', function (assert) {
+ var h, m, t1, t2;
+ for (h = 0; h < 24; ++h) {
+ for (m = 0; m < 60; m += 15) {
+ t1 = moment.utc([2000, 0, 1, h, m]);
+ t2 = moment.utc(t1.format('A h:mm'), 'A h:mm');
+ assert.equal(t2.format('HH:mm'), t1.format('HH:mm'),
+ 'meridiem at ' + t1.format('HH:mm'));
+ }
+ }
+ });
+
+ test('date format correctness', function (assert) {
+ var data, tokens;
+ data = moment.localeData()._longDateFormat;
+ tokens = objectKeys(data);
+ each(tokens, function (srchToken) {
+ // Check each format string to make sure it does not contain any
+ // tokens that need to be expanded.
+ each(tokens, function (baseToken) {
+ // strip escaped sequences
+ var format = data[baseToken].replace(/(\[[^\]]*\])/g, '');
+ assert.equal(false, !!~format.indexOf(srchToken),
+ 'contains ' + srchToken + ' in ' + baseToken);
+ });
+ });
+ });
+
+ test('month parsing correctness', function (assert) {
+ var i, m;
+
+ if (locale === 'tr') {
+ // I can't fix it :(
+ expect(0);
+ return;
+ }
+ function tester(format) {
+ var r;
+ r = moment(m.format(format), format);
+ assert.equal(r.month(), m.month(), 'month ' + i + ' fmt ' + format);
+ r = moment(m.format(format).toLocaleUpperCase(), format);
+ assert.equal(r.month(), m.month(), 'month ' + i + ' fmt ' + format + ' upper');
+ r = moment(m.format(format).toLocaleLowerCase(), format);
+ assert.equal(r.month(), m.month(), 'month ' + i + ' fmt ' + format + ' lower');
+
+ r = moment(m.format(format), format, true);
+ assert.equal(r.month(), m.month(), 'month ' + i + ' fmt ' + format + ' strict');
+ r = moment(m.format(format).toLocaleUpperCase(), format, true);
+ assert.equal(r.month(), m.month(), 'month ' + i + ' fmt ' + format + ' upper strict');
+ r = moment(m.format(format).toLocaleLowerCase(), format, true);
+ assert.equal(r.month(), m.month(), 'month ' + i + ' fmt ' + format + ' lower strict');
+ }
+
+ for (i = 0; i < 12; ++i) {
+ m = moment([2015, i, 15, 18]);
+ tester('MMM');
+ tester('MMM.');
+ tester('MMMM');
+ tester('MMMM.');
+ }
+ });
+
+ test('weekday parsing correctness', function (assert) {
+ var i, m;
+
+ if (locale === 'tr' || locale === 'az') {
+ // There is a lower-case letter (ı), that converted to upper then
+ // lower changes to i
+ expect(0);
+ return;
+ }
+ function tester(format) {
+ var r, baseMsg = 'weekday ' + m.weekday() + ' fmt ' + format;
+ r = moment(m.format(format), format);
+ assert.equal(r.weekday(), m.weekday(), baseMsg);
+ r = moment(m.format(format).toLocaleUpperCase(), format);
+ assert.equal(r.weekday(), m.weekday(), baseMsg + ' upper');
+ r = moment(m.format(format).toLocaleLowerCase(), format);
+ assert.equal(r.weekday(), m.weekday(), baseMsg + ' lower');
+
+ r = moment(m.format(format), format, true);
+ assert.equal(r.weekday(), m.weekday(), baseMsg + ' strict');
+ r = moment(m.format(format).toLocaleUpperCase(), format, true);
+ assert.equal(r.weekday(), m.weekday(), baseMsg + ' upper strict');
+ r = moment(m.format(format).toLocaleLowerCase(), format, true);
+ assert.equal(r.weekday(), m.weekday(), baseMsg + ' lower strict');
+ }
+
+ for (i = 0; i < 7; ++i) {
+ m = moment.utc([2015, i, 15, 18]);
+ tester('dd');
+ tester('ddd');
+ tester('dddd');
+ }
+ });
+ }
+
+ function setupDeprecationHandler(test, moment, scope) {
+ test._expectedDeprecations = null;
+ test._observedDeprecations = null;
+ test._oldSupress = moment.suppressDeprecationWarnings;
+ moment.suppressDeprecationWarnings = true;
+ test.expectedDeprecations = function () {
+ test._expectedDeprecations = arguments;
+ test._observedDeprecations = [];
+ };
+ moment.deprecationHandler = function (name, msg) {
+ var deprecationId = matchedDeprecation(name, msg, test._expectedDeprecations);
+ if (deprecationId === -1) {
+ throw new Error('Unexpected deprecation thrown name=' +
+ name + ' msg=' + msg);
+ }
+ test._observedDeprecations[deprecationId] = 1;
+ };
+ }
+
+ function teardownDeprecationHandler(test, moment, scope) {
+ moment.suppressDeprecationWarnings = test._oldSupress;
+
+ if (test._expectedDeprecations != null) {
+ var missedDeprecations = [];
+ each(test._expectedDeprecations, function (deprecationPattern, id) {
+ if (test._observedDeprecations[id] !== 1) {
+ missedDeprecations.push(deprecationPattern);
+ }
+ });
+ if (missedDeprecations.length !== 0) {
+ throw new Error('Expected deprecation warnings did not happen: ' +
+ missedDeprecations.join(' '));
+ }
+ }
+ }
+
+ function matchedDeprecation(name, msg, deprecations) {
+ if (deprecations == null) {
+ return -1;
+ }
+ for (var i = 0; i < deprecations.length; ++i) {
+ if (name != null && name === deprecations[i]) {
+ return i;
+ }
+ if (msg != null && msg.substring(0, deprecations[i].length) === deprecations[i]) {
+ return i;
+ }
+ }
+ return -1;
+ }
/*global QUnit:false*/
@@ -19,11 +237,13 @@
moment.createFromInputFallback = function (config) {
throw new Error('input not handled by moment: ' + config._i);
};
+ setupDeprecationHandler(test, moment, 'core');
if (lifecycle && lifecycle.setup) {
lifecycle.setup();
}
},
teardown : function () {
+ teardownDeprecationHandler(test, moment, 'core');
if (lifecycle && lifecycle.teardown) {
lifecycle.teardown();
}
@@ -38,17 +258,20 @@
moment.createFromInputFallback = function (config) {
throw new Error('input not handled by moment: ' + config._i);
};
+ setupDeprecationHandler(test, moment, 'locale');
if (lifecycle && lifecycle.setup) {
lifecycle.setup();
}
},
teardown : function () {
moment.locale('en');
+ teardownDeprecationHandler(test, moment, 'locale');
if (lifecycle && lifecycle.teardown) {
lifecycle.teardown();
}
}
});
+ defineCommonLocaleTests(name, -1, -1);
}
localeModule('af');
@@ -203,14 +426,14 @@
});
test('calendar day', function (assert) {
- var a = moment().hours(2).minutes(0).seconds(0);
-
- assert.equal(moment(a).calendar(), 'Vandag om 02:00', 'today at the same time');
- assert.equal(moment(a).add({m: 25}).calendar(), 'Vandag om 02:25', 'Now plus 25 min');
- assert.equal(moment(a).add({h: 1}).calendar(), 'Vandag om 03:00', 'Now plus 1 hour');
- assert.equal(moment(a).add({d: 1}).calendar(), 'Môre om 02:00', 'tomorrow at the same time');
- assert.equal(moment(a).subtract({h: 1}).calendar(), 'Vandag om 01:00', 'Now minus 1 hour');
- assert.equal(moment(a).subtract({d: 1}).calendar(), 'Gister om 02:00', 'yesterday at the same time');
+ var a = moment().hours(12).minutes(0).seconds(0);
+
+ assert.equal(moment(a).calendar(), 'Vandag om 12:00', 'today at the same time');
+ assert.equal(moment(a).add({m: 25}).calendar(), 'Vandag om 12:25', 'Now plus 25 min');
+ assert.equal(moment(a).add({h: 1}).calendar(), 'Vandag om 13:00', 'Now plus 1 hour');
+ assert.equal(moment(a).add({d: 1}).calendar(), 'Môre om 12:00', 'tomorrow at the same time');
+ assert.equal(moment(a).subtract({h: 1}).calendar(), 'Vandag om 11:00', 'Now minus 1 hour');
+ assert.equal(moment(a).subtract({d: 1}).calendar(), 'Gister om 12:00', 'yesterday at the same time');
});
test('calendar next week', function (assert) {
@@ -251,67 +474,6 @@
assert.equal(weeksFromNow.calendar(), weeksFromNow.format('L'), 'in 2 weeks');
});
- test('weeks year starting sunday', function (assert) {
- assert.equal(moment([2012, 0, 1]).week(), 52, 'Jan 1 2012 should be week 52');
- assert.equal(moment([2012, 0, 2]).week(), 1, 'Jan 2 2012 should be week 1');
- assert.equal(moment([2012, 0, 8]).week(), 1, 'Jan 8 2012 should be week 1');
- assert.equal(moment([2012, 0, 9]).week(), 2, 'Jan 9 2012 should be week 2');
- assert.equal(moment([2012, 0, 15]).week(), 2, 'Jan 15 2012 should be week 2');
- });
-
- test('weeks year starting monday', function (assert) {
- assert.equal(moment([2007, 0, 1]).week(), 1, 'Jan 1 2007 should be week 1');
- assert.equal(moment([2007, 0, 7]).week(), 1, 'Jan 7 2007 should be week 1');
- assert.equal(moment([2007, 0, 8]).week(), 2, 'Jan 8 2007 should be week 2');
- assert.equal(moment([2007, 0, 14]).week(), 2, 'Jan 14 2007 should be week 2');
- assert.equal(moment([2007, 0, 15]).week(), 3, 'Jan 15 2007 should be week 3');
- });
-
- test('weeks year starting tuesday', function (assert) {
- assert.equal(moment([2007, 11, 31]).week(), 1, 'Dec 31 2007 should be week 1');
- assert.equal(moment([2008, 0, 1]).week(), 1, 'Jan 1 2008 should be week 1');
- assert.equal(moment([2008, 0, 6]).week(), 1, 'Jan 6 2008 should be week 1');
- assert.equal(moment([2008, 0, 7]).week(), 2, 'Jan 7 2008 should be week 2');
- assert.equal(moment([2008, 0, 13]).week(), 2, 'Jan 13 2008 should be week 2');
- assert.equal(moment([2008, 0, 14]).week(), 3, 'Jan 14 2008 should be week 3');
- });
-
- test('weeks year starting wednesday', function (assert) {
- assert.equal(moment([2002, 11, 30]).week(), 1, 'Dec 30 2002 should be week 1');
- assert.equal(moment([2003, 0, 1]).week(), 1, 'Jan 1 2003 should be week 1');
- assert.equal(moment([2003, 0, 5]).week(), 1, 'Jan 5 2003 should be week 1');
- assert.equal(moment([2003, 0, 6]).week(), 2, 'Jan 6 2003 should be week 2');
- assert.equal(moment([2003, 0, 12]).week(), 2, 'Jan 12 2003 should be week 2');
- assert.equal(moment([2003, 0, 13]).week(), 3, 'Jan 13 2003 should be week 3');
- });
-
- test('weeks year starting thursday', function (assert) {
- assert.equal(moment([2008, 11, 29]).week(), 1, 'Dec 29 2008 should be week 1');
- assert.equal(moment([2009, 0, 1]).week(), 1, 'Jan 1 2009 should be week 1');
- assert.equal(moment([2009, 0, 4]).week(), 1, 'Jan 4 2009 should be week 1');
- assert.equal(moment([2009, 0, 5]).week(), 2, 'Jan 5 2009 should be week 2');
- assert.equal(moment([2009, 0, 11]).week(), 2, 'Jan 11 2009 should be week 2');
- assert.equal(moment([2009, 0, 13]).week(), 3, 'Jan 12 2009 should be week 3');
- });
-
- test('weeks year starting friday', function (assert) {
- assert.equal(moment([2009, 11, 28]).week(), 53, 'Dec 28 2009 should be week 53');
- assert.equal(moment([2010, 0, 1]).week(), 53, 'Jan 1 2010 should be week 53');
- assert.equal(moment([2010, 0, 3]).week(), 53, 'Jan 3 2010 should be week 53');
- assert.equal(moment([2010, 0, 4]).week(), 1, 'Jan 4 2010 should be week 1');
- assert.equal(moment([2010, 0, 10]).week(), 1, 'Jan 10 2010 should be week 1');
- assert.equal(moment([2010, 0, 11]).week(), 2, 'Jan 11 2010 should be week 2');
- });
-
- test('weeks year starting saturday', function (assert) {
- assert.equal(moment([2010, 11, 27]).week(), 52, 'Dec 27 2010 should be week 52');
- assert.equal(moment([2011, 0, 1]).week(), 52, 'Jan 1 2011 should be week 52');
- assert.equal(moment([2011, 0, 2]).week(), 52, 'Jan 2 2011 should be week 52');
- assert.equal(moment([2011, 0, 3]).week(), 1, 'Jan 3 2011 should be week 1');
- assert.equal(moment([2011, 0, 9]).week(), 1, 'Jan 9 2011 should be week 1');
- assert.equal(moment([2011, 0, 10]).week(), 2, 'Jan 10 2011 should be week 2');
- });
-
test('weeks year starting sunday formatted', function (assert) {
assert.equal(moment([2012, 0, 1]).format('w ww wo'), '52 52 52ste', 'Jan 1 2012 should be week 52');
assert.equal(moment([2012, 0, 2]).format('w ww wo'), '1 01 1ste', 'Jan 2 2012 should be week 1');
@@ -320,42 +482,6 @@
assert.equal(moment([2012, 0, 15]).format('w ww wo'), '2 02 2de', 'Jan 15 2012 should be week 2');
});
- test('lenient ordinal parsing', function (assert) {
- var i, ordinalStr, testMoment;
- for (i = 1; i <= 31; ++i) {
- ordinalStr = moment([2014, 0, i]).format('YYYY MM Do');
- testMoment = moment(ordinalStr, 'YYYY MM Do');
- assert.equal(testMoment.year(), 2014,
- 'lenient ordinal parsing ' + i + ' year check');
- assert.equal(testMoment.month(), 0,
- 'lenient ordinal parsing ' + i + ' month check');
- assert.equal(testMoment.date(), i,
- 'lenient ordinal parsing ' + i + ' date check');
- }
- });
-
- test('lenient ordinal parsing of number', function (assert) {
- var i, testMoment;
- for (i = 1; i <= 31; ++i) {
- testMoment = moment('2014 01 ' + i, 'YYYY MM Do');
- assert.equal(testMoment.year(), 2014,
- 'lenient ordinal parsing of number ' + i + ' year check');
- assert.equal(testMoment.month(), 0,
- 'lenient ordinal parsing of number ' + i + ' month check');
- assert.equal(testMoment.date(), i,
- 'lenient ordinal parsing of number ' + i + ' date check');
- }
- });
-
- test('strict ordinal parsing', function (assert) {
- var i, ordinalStr, testMoment;
- for (i = 1; i <= 31; ++i) {
- ordinalStr = moment([2014, 0, i]).format('YYYY MM Do');
- testMoment = moment(ordinalStr, 'YYYY MM Do', true);
- assert.ok(testMoment.isValid(), 'strict ordinal parsing ' + i);
- }
- });
-
}));
;(function (global, factory) {
@@ -364,6 +490,224 @@
typeof define === 'function' && define.amd ? define(['../../moment'], factory) :
factory(global.moment)
}(this, function (moment) { 'use strict';
+
+ function each(array, callback) {
+ var i;
+ for (i = 0; i < array.length; i++) {
+ callback(array[i], i, array);
+ }
+ }
+
+ function objectKeys(obj) {
+ if (Object.keys) {
+ return Object.keys(obj);
+ } else {
+ // IE8
+ var res = [], i;
+ for (i in obj) {
+ if (obj.hasOwnProperty(i)) {
+ res.push(i);
+ }
+ }
+ return res;
+ }
+ }
+
+ // Pick the first defined of two or three arguments.
+ function defaults(a, b, c) {
+ if (a != null) {
+ return a;
+ }
+ if (b != null) {
+ return b;
+ }
+ return c;
+ }
+
+ function defineCommonLocaleTests(locale, options) {
+ test('lenient ordinal parsing', function (assert) {
+ var i, ordinalStr, testMoment;
+ for (i = 1; i <= 31; ++i) {
+ ordinalStr = moment([2014, 0, i]).format('YYYY MM Do');
+ testMoment = moment(ordinalStr, 'YYYY MM Do');
+ assert.equal(testMoment.year(), 2014,
+ 'lenient ordinal parsing ' + i + ' year check');
+ assert.equal(testMoment.month(), 0,
+ 'lenient ordinal parsing ' + i + ' month check');
+ assert.equal(testMoment.date(), i,
+ 'lenient ordinal parsing ' + i + ' date check');
+ }
+ });
+
+ test('lenient ordinal parsing of number', function (assert) {
+ var i, testMoment;
+ for (i = 1; i <= 31; ++i) {
+ testMoment = moment('2014 01 ' + i, 'YYYY MM Do');
+ assert.equal(testMoment.year(), 2014,
+ 'lenient ordinal parsing of number ' + i + ' year check');
+ assert.equal(testMoment.month(), 0,
+ 'lenient ordinal parsing of number ' + i + ' month check');
+ assert.equal(testMoment.date(), i,
+ 'lenient ordinal parsing of number ' + i + ' date check');
+ }
+ });
+
+ test('strict ordinal parsing', function (assert) {
+ var i, ordinalStr, testMoment;
+ for (i = 1; i <= 31; ++i) {
+ ordinalStr = moment([2014, 0, i]).format('YYYY MM Do');
+ testMoment = moment(ordinalStr, 'YYYY MM Do', true);
+ assert.ok(testMoment.isValid(), 'strict ordinal parsing ' + i);
+ }
+ });
+
+ test('meridiem invariant', function (assert) {
+ var h, m, t1, t2;
+ for (h = 0; h < 24; ++h) {
+ for (m = 0; m < 60; m += 15) {
+ t1 = moment.utc([2000, 0, 1, h, m]);
+ t2 = moment.utc(t1.format('A h:mm'), 'A h:mm');
+ assert.equal(t2.format('HH:mm'), t1.format('HH:mm'),
+ 'meridiem at ' + t1.format('HH:mm'));
+ }
+ }
+ });
+
+ test('date format correctness', function (assert) {
+ var data, tokens;
+ data = moment.localeData()._longDateFormat;
+ tokens = objectKeys(data);
+ each(tokens, function (srchToken) {
+ // Check each format string to make sure it does not contain any
+ // tokens that need to be expanded.
+ each(tokens, function (baseToken) {
+ // strip escaped sequences
+ var format = data[baseToken].replace(/(\[[^\]]*\])/g, '');
+ assert.equal(false, !!~format.indexOf(srchToken),
+ 'contains ' + srchToken + ' in ' + baseToken);
+ });
+ });
+ });
+
+ test('month parsing correctness', function (assert) {
+ var i, m;
+
+ if (locale === 'tr') {
+ // I can't fix it :(
+ expect(0);
+ return;
+ }
+ function tester(format) {
+ var r;
+ r = moment(m.format(format), format);
+ assert.equal(r.month(), m.month(), 'month ' + i + ' fmt ' + format);
+ r = moment(m.format(format).toLocaleUpperCase(), format);
+ assert.equal(r.month(), m.month(), 'month ' + i + ' fmt ' + format + ' upper');
+ r = moment(m.format(format).toLocaleLowerCase(), format);
+ assert.equal(r.month(), m.month(), 'month ' + i + ' fmt ' + format + ' lower');
+
+ r = moment(m.format(format), format, true);
+ assert.equal(r.month(), m.month(), 'month ' + i + ' fmt ' + format + ' strict');
+ r = moment(m.format(format).toLocaleUpperCase(), format, true);
+ assert.equal(r.month(), m.month(), 'month ' + i + ' fmt ' + format + ' upper strict');
+ r = moment(m.format(format).toLocaleLowerCase(), format, true);
+ assert.equal(r.month(), m.month(), 'month ' + i + ' fmt ' + format + ' lower strict');
+ }
+
+ for (i = 0; i < 12; ++i) {
+ m = moment([2015, i, 15, 18]);
+ tester('MMM');
+ tester('MMM.');
+ tester('MMMM');
+ tester('MMMM.');
+ }
+ });
+
+ test('weekday parsing correctness', function (assert) {
+ var i, m;
+
+ if (locale === 'tr' || locale === 'az') {
+ // There is a lower-case letter (ı), that converted to upper then
+ // lower changes to i
+ expect(0);
+ return;
+ }
+ function tester(format) {
+ var r, baseMsg = 'weekday ' + m.weekday() + ' fmt ' + format;
+ r = moment(m.format(format), format);
+ assert.equal(r.weekday(), m.weekday(), baseMsg);
+ r = moment(m.format(format).toLocaleUpperCase(), format);
+ assert.equal(r.weekday(), m.weekday(), baseMsg + ' upper');
+ r = moment(m.format(format).toLocaleLowerCase(), format);
+ assert.equal(r.weekday(), m.weekday(), baseMsg + ' lower');
+
+ r = moment(m.format(format), format, true);
+ assert.equal(r.weekday(), m.weekday(), baseMsg + ' strict');
+ r = moment(m.format(format).toLocaleUpperCase(), format, true);
+ assert.equal(r.weekday(), m.weekday(), baseMsg + ' upper strict');
+ r = moment(m.format(format).toLocaleLowerCase(), format, true);
+ assert.equal(r.weekday(), m.weekday(), baseMsg + ' lower strict');
+ }
+
+ for (i = 0; i < 7; ++i) {
+ m = moment.utc([2015, i, 15, 18]);
+ tester('dd');
+ tester('ddd');
+ tester('dddd');
+ }
+ });
+ }
+
+ function setupDeprecationHandler(test, moment, scope) {
+ test._expectedDeprecations = null;
+ test._observedDeprecations = null;
+ test._oldSupress = moment.suppressDeprecationWarnings;
+ moment.suppressDeprecationWarnings = true;
+ test.expectedDeprecations = function () {
+ test._expectedDeprecations = arguments;
+ test._observedDeprecations = [];
+ };
+ moment.deprecationHandler = function (name, msg) {
+ var deprecationId = matchedDeprecation(name, msg, test._expectedDeprecations);
+ if (deprecationId === -1) {
+ throw new Error('Unexpected deprecation thrown name=' +
+ name + ' msg=' + msg);
+ }
+ test._observedDeprecations[deprecationId] = 1;
+ };
+ }
+
+ function teardownDeprecationHandler(test, moment, scope) {
+ moment.suppressDeprecationWarnings = test._oldSupress;
+
+ if (test._expectedDeprecations != null) {
+ var missedDeprecations = [];
+ each(test._expectedDeprecations, function (deprecationPattern, id) {
+ if (test._observedDeprecations[id] !== 1) {
+ missedDeprecations.push(deprecationPattern);
+ }
+ });
+ if (missedDeprecations.length !== 0) {
+ throw new Error('Expected deprecation warnings did not happen: ' +
+ missedDeprecations.join(' '));
+ }
+ }
+ }
+
+ function matchedDeprecation(name, msg, deprecations) {
+ if (deprecations == null) {
+ return -1;
+ }
+ for (var i = 0; i < deprecations.length; ++i) {
+ if (name != null && name === deprecations[i]) {
+ return i;
+ }
+ if (msg != null && msg.substring(0, deprecations[i].length) === deprecations[i]) {
+ return i;
+ }
+ }
+ return -1;
+ }
/*global QUnit:false*/
@@ -378,11 +722,13 @@
moment.createFromInputFallback = function (config) {
throw new Error('input not handled by moment: ' + config._i);
};
+ setupDeprecationHandler(test, moment, 'core');
if (lifecycle && lifecycle.setup) {
lifecycle.setup();
}
},
teardown : function () {
+ teardownDeprecationHandler(test, moment, 'core');
if (lifecycle && lifecycle.teardown) {
lifecycle.teardown();
}
@@ -397,17 +743,20 @@
moment.createFromInputFallback = function (config) {
throw new Error('input not handled by moment: ' + config._i);
};
+ setupDeprecationHandler(test, moment, 'locale');
if (lifecycle && lifecycle.setup) {
lifecycle.setup();
}
},
teardown : function () {
moment.locale('en');
+ teardownDeprecationHandler(test, moment, 'locale');
if (lifecycle && lifecycle.teardown) {
lifecycle.teardown();
}
}
});
+ defineCommonLocaleTests(name, -1, -1);
}
localeModule('ar-ma');
@@ -562,14 +911,14 @@
});
test('calendar day', function (assert) {
- var a = moment().hours(2).minutes(0).seconds(0);
-
- assert.equal(moment(a).calendar(), 'اليوم على الساعة 02:00', 'today at the same time');
- assert.equal(moment(a).add({m: 25}).calendar(), 'اليوم على الساعة 02:25', 'Now plus 25 min');
- assert.equal(moment(a).add({h: 1}).calendar(), 'اليوم على الساعة 03:00', 'Now plus 1 hour');
- assert.equal(moment(a).add({d: 1}).calendar(), 'غدا على الساعة 02:00', 'tomorrow at the same time');
- assert.equal(moment(a).subtract({h: 1}).calendar(), 'اليوم على الساعة 01:00', 'Now minus 1 hour');
- assert.equal(moment(a).subtract({d: 1}).calendar(), 'أمس على الساعة 02:00', 'yesterday at the same time');
+ var a = moment().hours(12).minutes(0).seconds(0);
+
+ assert.equal(moment(a).calendar(), 'اليوم على الساعة 12:00', 'today at the same time');
+ assert.equal(moment(a).add({m: 25}).calendar(), 'اليوم على الساعة 12:25', 'Now plus 25 min');
+ assert.equal(moment(a).add({h: 1}).calendar(), 'اليوم على الساعة 13:00', 'Now plus 1 hour');
+ assert.equal(moment(a).add({d: 1}).calendar(), 'غدا على الساعة 12:00', 'tomorrow at the same time');
+ assert.equal(moment(a).subtract({h: 1}).calendar(), 'اليوم على الساعة 11:00', 'Now minus 1 hour');
+ assert.equal(moment(a).subtract({d: 1}).calendar(), 'أمس على الساعة 12:00', 'yesterday at the same time');
});
test('calendar next week', function (assert) {
@@ -610,65 +959,6 @@
assert.equal(weeksFromNow.calendar(), weeksFromNow.format('L'), 'in 2 weeks');
});
- test('weeks year starting sunday', function (assert) {
- assert.equal(moment([2011, 11, 31]).week(), 1, 'Dec 31 2011 should be week 1');
- assert.equal(moment([2012, 0, 6]).week(), 1, 'Jan 6 2012 should be week 1');
- assert.equal(moment([2012, 0, 7]).week(), 2, 'Jan 7 2012 should be week 2');
- assert.equal(moment([2012, 0, 13]).week(), 2, 'Jan 13 2012 should be week 2');
- assert.equal(moment([2012, 0, 14]).week(), 3, 'Jan 14 2012 should be week 3');
- });
-
- test('weeks year starting monday', function (assert) {
- assert.equal(moment([2006, 11, 30]).week(), 1, 'Dec 30 2006 should be week 1');
- assert.equal(moment([2007, 0, 5]).week(), 1, 'Jan 5 2007 should be week 1');
- assert.equal(moment([2007, 0, 6]).week(), 2, 'Jan 6 2007 should be week 2');
- assert.equal(moment([2007, 0, 12]).week(), 2, 'Jan 12 2007 should be week 2');
- assert.equal(moment([2007, 0, 13]).week(), 3, 'Jan 13 2007 should be week 3');
- });
-
- test('weeks year starting tuesday', function (assert) {
- assert.equal(moment([2007, 11, 29]).week(), 1, 'Dec 29 2007 should be week 1');
- assert.equal(moment([2008, 0, 1]).week(), 1, 'Jan 1 2008 should be week 1');
- assert.equal(moment([2008, 0, 4]).week(), 1, 'Jan 4 2008 should be week 1');
- assert.equal(moment([2008, 0, 5]).week(), 2, 'Jan 5 2008 should be week 2');
- assert.equal(moment([2008, 0, 11]).week(), 2, 'Jan 11 2008 should be week 2');
- assert.equal(moment([2008, 0, 12]).week(), 3, 'Jan 12 2008 should be week 3');
- });
-
- test('weeks year starting wednesday', function (assert) {
- assert.equal(moment([2002, 11, 28]).week(), 1, 'Dec 28 2002 should be week 1');
- assert.equal(moment([2003, 0, 1]).week(), 1, 'Jan 1 2003 should be week 1');
- assert.equal(moment([2003, 0, 3]).week(), 1, 'Jan 3 2003 should be week 1');
- assert.equal(moment([2003, 0, 4]).week(), 2, 'Jan 4 2003 should be week 2');
- assert.equal(moment([2003, 0, 10]).week(), 2, 'Jan 10 2003 should be week 2');
- assert.equal(moment([2003, 0, 11]).week(), 3, 'Jan 11 2003 should be week 3');
- });
-
- test('weeks year starting thursday', function (assert) {
- assert.equal(moment([2008, 11, 27]).week(), 1, 'Dec 27 2008 should be week 1');
- assert.equal(moment([2009, 0, 1]).week(), 1, 'Jan 1 2009 should be week 1');
- assert.equal(moment([2009, 0, 2]).week(), 1, 'Jan 2 2009 should be week 1');
- assert.equal(moment([2009, 0, 3]).week(), 2, 'Jan 3 2009 should be week 2');
- assert.equal(moment([2009, 0, 9]).week(), 2, 'Jan 9 2009 should be week 2');
- assert.equal(moment([2009, 0, 10]).week(), 3, 'Jan 10 2009 should be week 3');
- });
-
- test('weeks year starting friday', function (assert) {
- assert.equal(moment([2009, 11, 26]).week(), 1, 'Dec 26 2009 should be week 1');
- assert.equal(moment([2010, 0, 1]).week(), 1, 'Jan 1 2010 should be week 1');
- assert.equal(moment([2010, 0, 2]).week(), 2, 'Jan 2 2010 should be week 2');
- assert.equal(moment([2010, 0, 8]).week(), 2, 'Jan 8 2010 should be week 2');
- assert.equal(moment([2010, 0, 9]).week(), 3, 'Jan 9 2010 should be week 3');
- });
-
- test('weeks year starting saturday', function (assert) {
- assert.equal(moment([2011, 0, 1]).week(), 1, 'Jan 1 2011 should be week 1');
- assert.equal(moment([2011, 0, 7]).week(), 1, 'Jan 7 2011 should be week 1');
- assert.equal(moment([2011, 0, 8]).week(), 2, 'Jan 8 2011 should be week 2');
- assert.equal(moment([2011, 0, 14]).week(), 2, 'Jan 14 2011 should be week 2');
- assert.equal(moment([2011, 0, 15]).week(), 3, 'Jan 15 2011 should be week 3');
- });
-
test('weeks year starting sunday formatted', function (assert) {
assert.equal(moment([2011, 11, 31]).format('w ww wo'), '1 01 1', 'Dec 31 2011 should be week 1');
assert.equal(moment([2012, 0, 6]).format('w ww wo'), '1 01 1', 'Jan 6 2012 should be week 1');
@@ -677,42 +967,6 @@
assert.equal(moment([2012, 0, 14]).format('w ww wo'), '3 03 3', 'Jan 14 2012 should be week 3');
});
- test('lenient ordinal parsing', function (assert) {
- var i, ordinalStr, testMoment;
- for (i = 1; i <= 31; ++i) {
- ordinalStr = moment([2014, 0, i]).format('YYYY MM Do');
- testMoment = moment(ordinalStr, 'YYYY MM Do');
- assert.equal(testMoment.year(), 2014,
- 'lenient ordinal parsing ' + i + ' year check');
- assert.equal(testMoment.month(), 0,
- 'lenient ordinal parsing ' + i + ' month check');
- assert.equal(testMoment.date(), i,
- 'lenient ordinal parsing ' + i + ' date check');
- }
- });
-
- test('lenient ordinal parsing of number', function (assert) {
- var i, testMoment;
- for (i = 1; i <= 31; ++i) {
- testMoment = moment('2014 01 ' + i, 'YYYY MM Do');
- assert.equal(testMoment.year(), 2014,
- 'lenient ordinal parsing of number ' + i + ' year check');
- assert.equal(testMoment.month(), 0,
- 'lenient ordinal parsing of number ' + i + ' month check');
- assert.equal(testMoment.date(), i,
- 'lenient ordinal parsing of number ' + i + ' date check');
- }
- });
-
- test('strict ordinal parsing', function (assert) {
- var i, ordinalStr, testMoment;
- for (i = 1; i <= 31; ++i) {
- ordinalStr = moment([2014, 0, i]).format('YYYY MM Do');
- testMoment = moment(ordinalStr, 'YYYY MM Do', true);
- assert.ok(testMoment.isValid(), 'strict ordinal parsing ' + i);
- }
- });
-
}));
;(function (global, factory) {
@@ -721,6 +975,224 @@
typeof define === 'function' && define.amd ? define(['../../moment'], factory) :
factory(global.moment)
}(this, function (moment) { 'use strict';
+
+ function each(array, callback) {
+ var i;
+ for (i = 0; i < array.length; i++) {
+ callback(array[i], i, array);
+ }
+ }
+
+ function objectKeys(obj) {
+ if (Object.keys) {
+ return Object.keys(obj);
+ } else {
+ // IE8
+ var res = [], i;
+ for (i in obj) {
+ if (obj.hasOwnProperty(i)) {
+ res.push(i);
+ }
+ }
+ return res;
+ }
+ }
+
+ // Pick the first defined of two or three arguments.
+ function defaults(a, b, c) {
+ if (a != null) {
+ return a;
+ }
+ if (b != null) {
+ return b;
+ }
+ return c;
+ }
+
+ function defineCommonLocaleTests(locale, options) {
+ test('lenient ordinal parsing', function (assert) {
+ var i, ordinalStr, testMoment;
+ for (i = 1; i <= 31; ++i) {
+ ordinalStr = moment([2014, 0, i]).format('YYYY MM Do');
+ testMoment = moment(ordinalStr, 'YYYY MM Do');
+ assert.equal(testMoment.year(), 2014,
+ 'lenient ordinal parsing ' + i + ' year check');
+ assert.equal(testMoment.month(), 0,
+ 'lenient ordinal parsing ' + i + ' month check');
+ assert.equal(testMoment.date(), i,
+ 'lenient ordinal parsing ' + i + ' date check');
+ }
+ });
+
+ test('lenient ordinal parsing of number', function (assert) {
+ var i, testMoment;
+ for (i = 1; i <= 31; ++i) {
+ testMoment = moment('2014 01 ' + i, 'YYYY MM Do');
+ assert.equal(testMoment.year(), 2014,
+ 'lenient ordinal parsing of number ' + i + ' year check');
+ assert.equal(testMoment.month(), 0,
+ 'lenient ordinal parsing of number ' + i + ' month check');
+ assert.equal(testMoment.date(), i,
+ 'lenient ordinal parsing of number ' + i + ' date check');
+ }
+ });
+
+ test('strict ordinal parsing', function (assert) {
+ var i, ordinalStr, testMoment;
+ for (i = 1; i <= 31; ++i) {
+ ordinalStr = moment([2014, 0, i]).format('YYYY MM Do');
+ testMoment = moment(ordinalStr, 'YYYY MM Do', true);
+ assert.ok(testMoment.isValid(), 'strict ordinal parsing ' + i);
+ }
+ });
+
+ test('meridiem invariant', function (assert) {
+ var h, m, t1, t2;
+ for (h = 0; h < 24; ++h) {
+ for (m = 0; m < 60; m += 15) {
+ t1 = moment.utc([2000, 0, 1, h, m]);
+ t2 = moment.utc(t1.format('A h:mm'), 'A h:mm');
+ assert.equal(t2.format('HH:mm'), t1.format('HH:mm'),
+ 'meridiem at ' + t1.format('HH:mm'));
+ }
+ }
+ });
+
+ test('date format correctness', function (assert) {
+ var data, tokens;
+ data = moment.localeData()._longDateFormat;
+ tokens = objectKeys(data);
+ each(tokens, function (srchToken) {
+ // Check each format string to make sure it does not contain any
+ // tokens that need to be expanded.
+ each(tokens, function (baseToken) {
+ // strip escaped sequences
+ var format = data[baseToken].replace(/(\[[^\]]*\])/g, '');
+ assert.equal(false, !!~format.indexOf(srchToken),
+ 'contains ' + srchToken + ' in ' + baseToken);
+ });
+ });
+ });
+
+ test('month parsing correctness', function (assert) {
+ var i, m;
+
+ if (locale === 'tr') {
+ // I can't fix it :(
+ expect(0);
+ return;
+ }
+ function tester(format) {
+ var r;
+ r = moment(m.format(format), format);
+ assert.equal(r.month(), m.month(), 'month ' + i + ' fmt ' + format);
+ r = moment(m.format(format).toLocaleUpperCase(), format);
+ assert.equal(r.month(), m.month(), 'month ' + i + ' fmt ' + format + ' upper');
+ r = moment(m.format(format).toLocaleLowerCase(), format);
+ assert.equal(r.month(), m.month(), 'month ' + i + ' fmt ' + format + ' lower');
+
+ r = moment(m.format(format), format, true);
+ assert.equal(r.month(), m.month(), 'month ' + i + ' fmt ' + format + ' strict');
+ r = moment(m.format(format).toLocaleUpperCase(), format, true);
+ assert.equal(r.month(), m.month(), 'month ' + i + ' fmt ' + format + ' upper strict');
+ r = moment(m.format(format).toLocaleLowerCase(), format, true);
+ assert.equal(r.month(), m.month(), 'month ' + i + ' fmt ' + format + ' lower strict');
+ }
+
+ for (i = 0; i < 12; ++i) {
+ m = moment([2015, i, 15, 18]);
+ tester('MMM');
+ tester('MMM.');
+ tester('MMMM');
+ tester('MMMM.');
+ }
+ });
+
+ test('weekday parsing correctness', function (assert) {
+ var i, m;
+
+ if (locale === 'tr' || locale === 'az') {
+ // There is a lower-case letter (ı), that converted to upper then
+ // lower changes to i
+ expect(0);
+ return;
+ }
+ function tester(format) {
+ var r, baseMsg = 'weekday ' + m.weekday() + ' fmt ' + format;
+ r = moment(m.format(format), format);
+ assert.equal(r.weekday(), m.weekday(), baseMsg);
+ r = moment(m.format(format).toLocaleUpperCase(), format);
+ assert.equal(r.weekday(), m.weekday(), baseMsg + ' upper');
+ r = moment(m.format(format).toLocaleLowerCase(), format);
+ assert.equal(r.weekday(), m.weekday(), baseMsg + ' lower');
+
+ r = moment(m.format(format), format, true);
+ assert.equal(r.weekday(), m.weekday(), baseMsg + ' strict');
+ r = moment(m.format(format).toLocaleUpperCase(), format, true);
+ assert.equal(r.weekday(), m.weekday(), baseMsg + ' upper strict');
+ r = moment(m.format(format).toLocaleLowerCase(), format, true);
+ assert.equal(r.weekday(), m.weekday(), baseMsg + ' lower strict');
+ }
+
+ for (i = 0; i < 7; ++i) {
+ m = moment.utc([2015, i, 15, 18]);
+ tester('dd');
+ tester('ddd');
+ tester('dddd');
+ }
+ });
+ }
+
+ function setupDeprecationHandler(test, moment, scope) {
+ test._expectedDeprecations = null;
+ test._observedDeprecations = null;
+ test._oldSupress = moment.suppressDeprecationWarnings;
+ moment.suppressDeprecationWarnings = true;
+ test.expectedDeprecations = function () {
+ test._expectedDeprecations = arguments;
+ test._observedDeprecations = [];
+ };
+ moment.deprecationHandler = function (name, msg) {
+ var deprecationId = matchedDeprecation(name, msg, test._expectedDeprecations);
+ if (deprecationId === -1) {
+ throw new Error('Unexpected deprecation thrown name=' +
+ name + ' msg=' + msg);
+ }
+ test._observedDeprecations[deprecationId] = 1;
+ };
+ }
+
+ function teardownDeprecationHandler(test, moment, scope) {
+ moment.suppressDeprecationWarnings = test._oldSupress;
+
+ if (test._expectedDeprecations != null) {
+ var missedDeprecations = [];
+ each(test._expectedDeprecations, function (deprecationPattern, id) {
+ if (test._observedDeprecations[id] !== 1) {
+ missedDeprecations.push(deprecationPattern);
+ }
+ });
+ if (missedDeprecations.length !== 0) {
+ throw new Error('Expected deprecation warnings did not happen: ' +
+ missedDeprecations.join(' '));
+ }
+ }
+ }
+
+ function matchedDeprecation(name, msg, deprecations) {
+ if (deprecations == null) {
+ return -1;
+ }
+ for (var i = 0; i < deprecations.length; ++i) {
+ if (name != null && name === deprecations[i]) {
+ return i;
+ }
+ if (msg != null && msg.substring(0, deprecations[i].length) === deprecations[i]) {
+ return i;
+ }
+ }
+ return -1;
+ }
/*global QUnit:false*/
@@ -735,11 +1207,13 @@
moment.createFromInputFallback = function (config) {
throw new Error('input not handled by moment: ' + config._i);
};
+ setupDeprecationHandler(test, moment, 'core');
if (lifecycle && lifecycle.setup) {
lifecycle.setup();
}
},
teardown : function () {
+ teardownDeprecationHandler(test, moment, 'core');
if (lifecycle && lifecycle.teardown) {
lifecycle.teardown();
}
@@ -754,17 +1228,20 @@
moment.createFromInputFallback = function (config) {
throw new Error('input not handled by moment: ' + config._i);
};
+ setupDeprecationHandler(test, moment, 'locale');
if (lifecycle && lifecycle.setup) {
lifecycle.setup();
}
},
teardown : function () {
moment.locale('en');
+ teardownDeprecationHandler(test, moment, 'locale');
if (lifecycle && lifecycle.teardown) {
lifecycle.teardown();
}
}
});
+ defineCommonLocaleTests(name, -1, -1);
}
localeModule('ar-sa');
@@ -919,14 +1396,14 @@
});
test('calendar day', function (assert) {
- var a = moment().hours(2).minutes(0).seconds(0);
-
- assert.equal(moment(a).calendar(), 'اليوم على الساعة ٠٢:٠٠', 'today at the same time');
- assert.equal(moment(a).add({m: 25}).calendar(), 'اليوم على الساعة ٠٢:٢٥', 'Now plus 25 min');
- assert.equal(moment(a).add({h: 1}).calendar(), 'اليوم على الساعة ٠٣:٠٠', 'Now plus 1 hour');
- assert.equal(moment(a).add({d: 1}).calendar(), 'غدا على الساعة ٠٢:٠٠', 'tomorrow at the same time');
- assert.equal(moment(a).subtract({h: 1}).calendar(), 'اليوم على الساعة ٠١:٠٠', 'Now minus 1 hour');
- assert.equal(moment(a).subtract({d: 1}).calendar(), 'أمس على الساعة ٠٢:٠٠', 'yesterday at the same time');
+ var a = moment().hours(12).minutes(0).seconds(0);
+
+ assert.equal(moment(a).calendar(), 'اليوم على الساعة ١٢:٠٠', 'today at the same time');
+ assert.equal(moment(a).add({m: 25}).calendar(), 'اليوم على الساعة ١٢:٢٥', 'Now plus 25 min');
+ assert.equal(moment(a).add({h: 1}).calendar(), 'اليوم على الساعة ١٣:٠٠', 'Now plus 1 hour');
+ assert.equal(moment(a).add({d: 1}).calendar(), 'غدا على الساعة ١٢:٠٠', 'tomorrow at the same time');
+ assert.equal(moment(a).subtract({h: 1}).calendar(), 'اليوم على الساعة ١١:٠٠', 'Now minus 1 hour');
+ assert.equal(moment(a).subtract({d: 1}).calendar(), 'أمس على الساعة ١٢:٠٠', 'yesterday at the same time');
});
test('calendar next week', function (assert) {
@@ -967,68 +1444,11 @@
assert.equal(weeksFromNow.calendar(), weeksFromNow.format('L'), 'in 2 weeks');
});
- test('weeks year starting sunday', function (assert) {
- assert.equal(moment([2011, 11, 31]).week(), 1, 'Dec 31 2011 should be week 1');
- assert.equal(moment([2012, 0, 6]).week(), 1, 'Jan 6 2012 should be week 1');
- assert.equal(moment([2012, 0, 7]).week(), 2, 'Jan 7 2012 should be week 2');
- assert.equal(moment([2012, 0, 13]).week(), 2, 'Jan 13 2012 should be week 2');
- assert.equal(moment([2012, 0, 14]).week(), 3, 'Jan 14 2012 should be week 3');
- });
-
- test('weeks year starting monday', function (assert) {
- assert.equal(moment([2006, 11, 30]).week(), 1, 'Dec 30 2006 should be week 1');
- assert.equal(moment([2007, 0, 5]).week(), 1, 'Jan 5 2007 should be week 1');
- assert.equal(moment([2007, 0, 6]).week(), 2, 'Jan 6 2007 should be week 2');
- assert.equal(moment([2007, 0, 12]).week(), 2, 'Jan 12 2007 should be week 2');
- assert.equal(moment([2007, 0, 13]).week(), 3, 'Jan 13 2007 should be week 3');
- });
-
- test('weeks year starting tuesday', function (assert) {
- assert.equal(moment([2007, 11, 29]).week(), 1, 'Dec 29 2007 should be week 1');
- assert.equal(moment([2008, 0, 1]).week(), 1, 'Jan 1 2008 should be week 1');
- assert.equal(moment([2008, 0, 4]).week(), 1, 'Jan 4 2008 should be week 1');
- assert.equal(moment([2008, 0, 5]).week(), 2, 'Jan 5 2008 should be week 2');
- assert.equal(moment([2008, 0, 11]).week(), 2, 'Jan 11 2008 should be week 2');
- assert.equal(moment([2008, 0, 12]).week(), 3, 'Jan 12 2008 should be week 3');
- });
-
- test('weeks year starting wednesday', function (assert) {
- assert.equal(moment([2002, 11, 28]).week(), 1, 'Dec 28 2002 should be week 1');
- assert.equal(moment([2003, 0, 1]).week(), 1, 'Jan 1 2003 should be week 1');
- assert.equal(moment([2003, 0, 3]).week(), 1, 'Jan 3 2003 should be week 1');
- assert.equal(moment([2003, 0, 4]).week(), 2, 'Jan 4 2003 should be week 2');
- assert.equal(moment([2003, 0, 10]).week(), 2, 'Jan 10 2003 should be week 2');
- assert.equal(moment([2003, 0, 11]).week(), 3, 'Jan 11 2003 should be week 3');
-
+ test('weeks year starting wednesday custom', function (assert) {
assert.equal(moment('2003 1 6', 'gggg w d').format('YYYY-MM-DD'), '٢٠٠٢-١٢-٢٨', 'Week 1 of 2003 should be Dec 28 2002');
assert.equal(moment('2003 1 0', 'gggg w e').format('YYYY-MM-DD'), '٢٠٠٢-١٢-٢٨', 'Week 1 of 2003 should be Dec 28 2002');
assert.equal(moment('2003 1 6', 'gggg w d').format('gggg w d'), '٢٠٠٣ ١ ٦', 'Saturday of week 1 of 2003 parsed should be formatted as 2003 1 6');
assert.equal(moment('2003 1 0', 'gggg w e').format('gggg w e'), '٢٠٠٣ ١ ٠', '1st day of week 1 of 2003 parsed should be formatted as 2003 1 0');
- });
-
- test('weeks year starting thursday', function (assert) {
- assert.equal(moment([2008, 11, 27]).week(), 1, 'Dec 27 2008 should be week 1');
- assert.equal(moment([2009, 0, 1]).week(), 1, 'Jan 1 2009 should be week 1');
- assert.equal(moment([2009, 0, 2]).week(), 1, 'Jan 2 2009 should be week 1');
- assert.equal(moment([2009, 0, 3]).week(), 2, 'Jan 3 2009 should be week 2');
- assert.equal(moment([2009, 0, 9]).week(), 2, 'Jan 9 2009 should be week 2');
- assert.equal(moment([2009, 0, 10]).week(), 3, 'Jan 10 2009 should be week 3');
- });
-
- test('weeks year starting friday', function (assert) {
- assert.equal(moment([2009, 11, 26]).week(), 1, 'Dec 26 2009 should be week 1');
- assert.equal(moment([2010, 0, 1]).week(), 1, 'Jan 1 2010 should be week 1');
- assert.equal(moment([2010, 0, 2]).week(), 2, 'Jan 2 2010 should be week 2');
- assert.equal(moment([2010, 0, 8]).week(), 2, 'Jan 8 2010 should be week 2');
- assert.equal(moment([2010, 0, 9]).week(), 3, 'Jan 9 2010 should be week 3');
- });
-
- test('weeks year starting saturday', function (assert) {
- assert.equal(moment([2011, 0, 1]).week(), 1, 'Jan 1 2011 should be week 1');
- assert.equal(moment([2011, 0, 7]).week(), 1, 'Jan 7 2011 should be week 1');
- assert.equal(moment([2011, 0, 8]).week(), 2, 'Jan 8 2011 should be week 2');
- assert.equal(moment([2011, 0, 14]).week(), 2, 'Jan 14 2011 should be week 2');
- assert.equal(moment([2011, 0, 15]).week(), 3, 'Jan 15 2011 should be week 3');
});
test('weeks year starting sunday formatted', function (assert) {
@@ -1039,42 +1459,6 @@
assert.equal(moment([2012, 0, 14]).format('w ww wo'), '٣ ٠٣ ٣', 'Jan 14 2012 should be week 3');
});
- test('lenient ordinal parsing', function (assert) {
- var i, ordinalStr, testMoment;
- for (i = 1; i <= 31; ++i) {
- ordinalStr = moment([2014, 0, i]).format('YYYY MM Do');
- testMoment = moment(ordinalStr, 'YYYY MM Do');
- assert.equal(testMoment.year(), 2014,
- 'lenient ordinal parsing ' + i + ' year check');
- assert.equal(testMoment.month(), 0,
- 'lenient ordinal parsing ' + i + ' month check');
- assert.equal(testMoment.date(), i,
- 'lenient ordinal parsing ' + i + ' date check');
- }
- });
-
- test('lenient ordinal parsing of number', function (assert) {
- var i, testMoment;
- for (i = 1; i <= 31; ++i) {
- testMoment = moment('2014 01 ' + i, 'YYYY MM Do');
- assert.equal(testMoment.year(), 2014,
- 'lenient ordinal parsing of number ' + i + ' year check');
- assert.equal(testMoment.month(), 0,
- 'lenient ordinal parsing of number ' + i + ' month check');
- assert.equal(testMoment.date(), i,
- 'lenient ordinal parsing of number ' + i + ' date check');
- }
- });
-
- test('strict ordinal parsing', function (assert) {
- var i, ordinalStr, testMoment;
- for (i = 1; i <= 31; ++i) {
- ordinalStr = moment([2014, 0, i]).format('YYYY MM Do');
- testMoment = moment(ordinalStr, 'YYYY MM Do', true);
- assert.ok(testMoment.isValid(), 'strict ordinal parsing ' + i);
- }
- });
-
}));
;(function (global, factory) {
@@ -1083,6 +1467,224 @@
typeof define === 'function' && define.amd ? define(['../../moment'], factory) :
factory(global.moment)
}(this, function (moment) { 'use strict';
+
+ function each(array, callback) {
+ var i;
+ for (i = 0; i < array.length; i++) {
+ callback(array[i], i, array);
+ }
+ }
+
+ function objectKeys(obj) {
+ if (Object.keys) {
+ return Object.keys(obj);
+ } else {
+ // IE8
+ var res = [], i;
+ for (i in obj) {
+ if (obj.hasOwnProperty(i)) {
+ res.push(i);
+ }
+ }
+ return res;
+ }
+ }
+
+ // Pick the first defined of two or three arguments.
+ function defaults(a, b, c) {
+ if (a != null) {
+ return a;
+ }
+ if (b != null) {
+ return b;
+ }
+ return c;
+ }
+
+ function defineCommonLocaleTests(locale, options) {
+ test('lenient ordinal parsing', function (assert) {
+ var i, ordinalStr, testMoment;
+ for (i = 1; i <= 31; ++i) {
+ ordinalStr = moment([2014, 0, i]).format('YYYY MM Do');
+ testMoment = moment(ordinalStr, 'YYYY MM Do');
+ assert.equal(testMoment.year(), 2014,
+ 'lenient ordinal parsing ' + i + ' year check');
+ assert.equal(testMoment.month(), 0,
+ 'lenient ordinal parsing ' + i + ' month check');
+ assert.equal(testMoment.date(), i,
+ 'lenient ordinal parsing ' + i + ' date check');
+ }
+ });
+
+ test('lenient ordinal parsing of number', function (assert) {
+ var i, testMoment;
+ for (i = 1; i <= 31; ++i) {
+ testMoment = moment('2014 01 ' + i, 'YYYY MM Do');
+ assert.equal(testMoment.year(), 2014,
+ 'lenient ordinal parsing of number ' + i + ' year check');
+ assert.equal(testMoment.month(), 0,
+ 'lenient ordinal parsing of number ' + i + ' month check');
+ assert.equal(testMoment.date(), i,
+ 'lenient ordinal parsing of number ' + i + ' date check');
+ }
+ });
+
+ test('strict ordinal parsing', function (assert) {
+ var i, ordinalStr, testMoment;
+ for (i = 1; i <= 31; ++i) {
+ ordinalStr = moment([2014, 0, i]).format('YYYY MM Do');
+ testMoment = moment(ordinalStr, 'YYYY MM Do', true);
+ assert.ok(testMoment.isValid(), 'strict ordinal parsing ' + i);
+ }
+ });
+
+ test('meridiem invariant', function (assert) {
+ var h, m, t1, t2;
+ for (h = 0; h < 24; ++h) {
+ for (m = 0; m < 60; m += 15) {
+ t1 = moment.utc([2000, 0, 1, h, m]);
+ t2 = moment.utc(t1.format('A h:mm'), 'A h:mm');
+ assert.equal(t2.format('HH:mm'), t1.format('HH:mm'),
+ 'meridiem at ' + t1.format('HH:mm'));
+ }
+ }
+ });
+
+ test('date format correctness', function (assert) {
+ var data, tokens;
+ data = moment.localeData()._longDateFormat;
+ tokens = objectKeys(data);
+ each(tokens, function (srchToken) {
+ // Check each format string to make sure it does not contain any
+ // tokens that need to be expanded.
+ each(tokens, function (baseToken) {
+ // strip escaped sequences
+ var format = data[baseToken].replace(/(\[[^\]]*\])/g, '');
+ assert.equal(false, !!~format.indexOf(srchToken),
+ 'contains ' + srchToken + ' in ' + baseToken);
+ });
+ });
+ });
+
+ test('month parsing correctness', function (assert) {
+ var i, m;
+
+ if (locale === 'tr') {
+ // I can't fix it :(
+ expect(0);
+ return;
+ }
+ function tester(format) {
+ var r;
+ r = moment(m.format(format), format);
+ assert.equal(r.month(), m.month(), 'month ' + i + ' fmt ' + format);
+ r = moment(m.format(format).toLocaleUpperCase(), format);
+ assert.equal(r.month(), m.month(), 'month ' + i + ' fmt ' + format + ' upper');
+ r = moment(m.format(format).toLocaleLowerCase(), format);
+ assert.equal(r.month(), m.month(), 'month ' + i + ' fmt ' + format + ' lower');
+
+ r = moment(m.format(format), format, true);
+ assert.equal(r.month(), m.month(), 'month ' + i + ' fmt ' + format + ' strict');
+ r = moment(m.format(format).toLocaleUpperCase(), format, true);
+ assert.equal(r.month(), m.month(), 'month ' + i + ' fmt ' + format + ' upper strict');
+ r = moment(m.format(format).toLocaleLowerCase(), format, true);
+ assert.equal(r.month(), m.month(), 'month ' + i + ' fmt ' + format + ' lower strict');
+ }
+
+ for (i = 0; i < 12; ++i) {
+ m = moment([2015, i, 15, 18]);
+ tester('MMM');
+ tester('MMM.');
+ tester('MMMM');
+ tester('MMMM.');
+ }
+ });
+
+ test('weekday parsing correctness', function (assert) {
+ var i, m;
+
+ if (locale === 'tr' || locale === 'az') {
+ // There is a lower-case letter (ı), that converted to upper then
+ // lower changes to i
+ expect(0);
+ return;
+ }
+ function tester(format) {
+ var r, baseMsg = 'weekday ' + m.weekday() + ' fmt ' + format;
+ r = moment(m.format(format), format);
+ assert.equal(r.weekday(), m.weekday(), baseMsg);
+ r = moment(m.format(format).toLocaleUpperCase(), format);
+ assert.equal(r.weekday(), m.weekday(), baseMsg + ' upper');
+ r = moment(m.format(format).toLocaleLowerCase(), format);
+ assert.equal(r.weekday(), m.weekday(), baseMsg + ' lower');
+
+ r = moment(m.format(format), format, true);
+ assert.equal(r.weekday(), m.weekday(), baseMsg + ' strict');
+ r = moment(m.format(format).toLocaleUpperCase(), format, true);
+ assert.equal(r.weekday(), m.weekday(), baseMsg + ' upper strict');
+ r = moment(m.format(format).toLocaleLowerCase(), format, true);
+ assert.equal(r.weekday(), m.weekday(), baseMsg + ' lower strict');
+ }
+
+ for (i = 0; i < 7; ++i) {
+ m = moment.utc([2015, i, 15, 18]);
+ tester('dd');
+ tester('ddd');
+ tester('dddd');
+ }
+ });
+ }
+
+ function setupDeprecationHandler(test, moment, scope) {
+ test._expectedDeprecations = null;
+ test._observedDeprecations = null;
+ test._oldSupress = moment.suppressDeprecationWarnings;
+ moment.suppressDeprecationWarnings = true;
+ test.expectedDeprecations = function () {
+ test._expectedDeprecations = arguments;
+ test._observedDeprecations = [];
+ };
+ moment.deprecationHandler = function (name, msg) {
+ var deprecationId = matchedDeprecation(name, msg, test._expectedDeprecations);
+ if (deprecationId === -1) {
+ throw new Error('Unexpected deprecation thrown name=' +
+ name + ' msg=' + msg);
+ }
+ test._observedDeprecations[deprecationId] = 1;
+ };
+ }
+
+ function teardownDeprecationHandler(test, moment, scope) {
+ moment.suppressDeprecationWarnings = test._oldSupress;
+
+ if (test._expectedDeprecations != null) {
+ var missedDeprecations = [];
+ each(test._expectedDeprecations, function (deprecationPattern, id) {
+ if (test._observedDeprecations[id] !== 1) {
+ missedDeprecations.push(deprecationPattern);
+ }
+ });
+ if (missedDeprecations.length !== 0) {
+ throw new Error('Expected deprecation warnings did not happen: ' +
+ missedDeprecations.join(' '));
+ }
+ }
+ }
+
+ function matchedDeprecation(name, msg, deprecations) {
+ if (deprecations == null) {
+ return -1;
+ }
+ for (var i = 0; i < deprecations.length; ++i) {
+ if (name != null && name === deprecations[i]) {
+ return i;
+ }
+ if (msg != null && msg.substring(0, deprecations[i].length) === deprecations[i]) {
+ return i;
+ }
+ }
+ return -1;
+ }
/*global QUnit:false*/
@@ -1097,11 +1699,13 @@
moment.createFromInputFallback = function (config) {
throw new Error('input not handled by moment: ' + config._i);
};
+ setupDeprecationHandler(test, moment, 'core');
if (lifecycle && lifecycle.setup) {
lifecycle.setup();
}
},
teardown : function () {
+ teardownDeprecationHandler(test, moment, 'core');
if (lifecycle && lifecycle.teardown) {
lifecycle.teardown();
}
@@ -1116,17 +1720,20 @@
moment.createFromInputFallback = function (config) {
throw new Error('input not handled by moment: ' + config._i);
};
+ setupDeprecationHandler(test, moment, 'locale');
if (lifecycle && lifecycle.setup) {
lifecycle.setup();
}
},
teardown : function () {
moment.locale('en');
+ teardownDeprecationHandler(test, moment, 'locale');
if (lifecycle && lifecycle.teardown) {
lifecycle.teardown();
}
}
});
+ defineCommonLocaleTests(name, -1, -1);
}
localeModule('ar-tn');
@@ -1345,24 +1952,14 @@
});
test('calendar day', function (assert) {
- var a = moment().hours(2).minutes(0).seconds(0);
-
- assert.equal(moment(a).calendar(), 'اليوم على الساعة 02:00', 'today at the same time');
- assert.equal(moment(a).add({
- m: 25
- }).calendar(), 'اليوم على الساعة 02:25', 'Now plus 25 min');
- assert.equal(moment(a).add({
- h: 1
- }).calendar(), 'اليوم على الساعة 03:00', 'Now plus 1 hour');
- assert.equal(moment(a).add({
- d: 1
- }).calendar(), 'غدا على الساعة 02:00', 'tomorrow at the same time');
- assert.equal(moment(a).subtract({
- h: 1
- }).calendar(), 'اليوم على الساعة 01:00', 'Now minus 1 hour');
- assert.equal(moment(a).subtract({
- d: 1
- }).calendar(), 'أمس على الساعة 02:00', 'yesterday at the same time');
+ var a = moment().hours(12).minutes(0).seconds(0);
+
+ assert.equal(moment(a).calendar(), 'اليوم على الساعة 12:00', 'today at the same time');
+ assert.equal(moment(a).add({m: 25}).calendar(), 'اليوم على الساعة 12:25', 'Now plus 25 min');
+ assert.equal(moment(a).add({h: 1}).calendar(), 'اليوم على الساعة 13:00', 'Now plus 1 hour');
+ assert.equal(moment(a).add({d: 1}).calendar(), 'غدا على الساعة 12:00', 'tomorrow at the same time');
+ assert.equal(moment(a).subtract({h: 1}).calendar(), 'اليوم على الساعة 11:00', 'Now minus 1 hour');
+ assert.equal(moment(a).subtract({d: 1}).calendar(), 'أمس على الساعة 12:00', 'yesterday at the same time');
});
test('calendar next week', function (assert) {
@@ -1415,67 +2012,6 @@
assert.equal(weeksFromNow.calendar(), weeksFromNow.format('L'), 'in 2 weeks');
});
- test('weeks year starting sunday', function (assert) {
- assert.equal(moment([2012, 0, 1]).week(), 52, 'Jan 1 2012 should be week 52');
- assert.equal(moment([2012, 0, 2]).week(), 1, 'Jan 2 2012 should be week 1');
- assert.equal(moment([2012, 0, 8]).week(), 1, 'Jan 8 2012 should be week 1');
- assert.equal(moment([2012, 0, 9]).week(), 2, 'Jan 9 2012 should be week 2');
- assert.equal(moment([2012, 0, 15]).week(), 2, 'Jan 15 2012 should be week 2');
- });
-
- test('weeks year starting monday', function (assert) {
- assert.equal(moment([2007, 0, 1]).week(), 1, 'Jan 1 2007 should be week 1');
- assert.equal(moment([2007, 0, 7]).week(), 1, 'Jan 7 2007 should be week 1');
- assert.equal(moment([2007, 0, 8]).week(), 2, 'Jan 8 2007 should be week 2');
- assert.equal(moment([2007, 0, 14]).week(), 2, 'Jan 14 2007 should be week 2');
- assert.equal(moment([2007, 0, 15]).week(), 3, 'Jan 15 2007 should be week 3');
- });
-
- test('weeks year starting tuesday', function (assert) {
- assert.equal(moment([2007, 11, 31]).week(), 1, 'Dec 31 2007 should be week 1');
- assert.equal(moment([2008, 0, 1]).week(), 1, 'Jan 1 2008 should be week 1');
- assert.equal(moment([2008, 0, 6]).week(), 1, 'Jan 6 2008 should be week 1');
- assert.equal(moment([2008, 0, 7]).week(), 2, 'Jan 7 2008 should be week 2');
- assert.equal(moment([2008, 0, 13]).week(), 2, 'Jan 13 2008 should be week 2');
- assert.equal(moment([2008, 0, 14]).week(), 3, 'Jan 14 2008 should be week 3');
- });
-
- test('weeks year starting wednesday', function (assert) {
- assert.equal(moment([2002, 11, 30]).week(), 1, 'Dec 30 2002 should be week 1');
- assert.equal(moment([2003, 0, 1]).week(), 1, 'Jan 1 2003 should be week 1');
- assert.equal(moment([2003, 0, 5]).week(), 1, 'Jan 5 2003 should be week 1');
- assert.equal(moment([2003, 0, 6]).week(), 2, 'Jan 6 2003 should be week 2');
- assert.equal(moment([2003, 0, 12]).week(), 2, 'Jan 12 2003 should be week 2');
- assert.equal(moment([2003, 0, 13]).week(), 3, 'Jan 13 2003 should be week 3');
- });
-
- test('weeks year starting thursday', function (assert) {
- assert.equal(moment([2008, 11, 29]).week(), 1, 'Dec 29 2008 should be week 1');
- assert.equal(moment([2009, 0, 1]).week(), 1, 'Jan 1 2009 should be week 1');
- assert.equal(moment([2009, 0, 4]).week(), 1, 'Jan 4 2009 should be week 1');
- assert.equal(moment([2009, 0, 5]).week(), 2, 'Jan 5 2009 should be week 2');
- assert.equal(moment([2009, 0, 11]).week(), 2, 'Jan 11 2009 should be week 2');
- assert.equal(moment([2009, 0, 13]).week(), 3, 'Jan 12 2009 should be week 3');
- });
-
- test('weeks year starting friday', function (assert) {
- assert.equal(moment([2009, 11, 28]).week(), 53, 'Dec 28 2009 should be week 53');
- assert.equal(moment([2010, 0, 1]).week(), 53, 'Jan 1 2010 should be week 53');
- assert.equal(moment([2010, 0, 3]).week(), 53, 'Jan 3 2010 should be week 53');
- assert.equal(moment([2010, 0, 4]).week(), 1, 'Jan 4 2010 should be week 1');
- assert.equal(moment([2010, 0, 10]).week(), 1, 'Jan 10 2010 should be week 1');
- assert.equal(moment([2010, 0, 11]).week(), 2, 'Jan 11 2010 should be week 2');
- });
-
- test('weeks year starting saturday', function (assert) {
- assert.equal(moment([2010, 11, 27]).week(), 52, 'Dec 27 2010 should be week 52');
- assert.equal(moment([2011, 0, 1]).week(), 52, 'Jan 1 2011 should be week 52');
- assert.equal(moment([2011, 0, 2]).week(), 52, 'Jan 2 2011 should be week 52');
- assert.equal(moment([2011, 0, 3]).week(), 1, 'Jan 3 2011 should be week 1');
- assert.equal(moment([2011, 0, 9]).week(), 1, 'Jan 9 2011 should be week 1');
- assert.equal(moment([2011, 0, 10]).week(), 2, 'Jan 10 2011 should be week 2');
- });
-
test('weeks year starting sunday formatted', function (assert) {
assert.equal(moment([2012, 0, 1]).format('w ww wo'), '52 52 52', 'Jan 1 2012 should be week 52');
assert.equal(moment([2012, 0, 2]).format('w ww wo'), '1 01 1', 'Jan 2 2012 should be week 1');
@@ -1484,42 +2020,6 @@
assert.equal(moment([2012, 0, 15]).format('w ww wo'), '2 02 2', 'Jan 15 2012 should be week 2');
});
- test('lenient ordinal parsing', function (assert) {
- var i, ordinalStr, testMoment;
- for (i = 1; i <= 31; ++i) {
- ordinalStr = moment([2014, 0, i]).format('YYYY MM Do');
- testMoment = moment(ordinalStr, 'YYYY MM Do');
- assert.equal(testMoment.year(), 2014,
- 'lenient ordinal parsing ' + i + ' year check');
- assert.equal(testMoment.month(), 0,
- 'lenient ordinal parsing ' + i + ' month check');
- assert.equal(testMoment.date(), i,
- 'lenient ordinal parsing ' + i + ' date check');
- }
- });
-
- test('lenient ordinal parsing of number', function (assert) {
- var i, testMoment;
- for (i = 1; i <= 31; ++i) {
- testMoment = moment('2014 01 ' + i, 'YYYY MM Do');
- assert.equal(testMoment.year(), 2014,
- 'lenient ordinal parsing of number ' + i + ' year check');
- assert.equal(testMoment.month(), 0,
- 'lenient ordinal parsing of number ' + i + ' month check');
- assert.equal(testMoment.date(), i,
- 'lenient ordinal parsing of number ' + i + ' date check');
- }
- });
-
- test('strict ordinal parsing', function (assert) {
- var i, ordinalStr, testMoment;
- for (i = 1; i <= 31; ++i) {
- ordinalStr = moment([2014, 0, i]).format('YYYY MM Do');
- testMoment = moment(ordinalStr, 'YYYY MM Do', true);
- assert.ok(testMoment.isValid(), 'strict ordinal parsing ' + i);
- }
- });
-
}));
;(function (global, factory) {
@@ -1528,6 +2028,224 @@
typeof define === 'function' && define.amd ? define(['../../moment'], factory) :
factory(global.moment)
}(this, function (moment) { 'use strict';
+
+ function each(array, callback) {
+ var i;
+ for (i = 0; i < array.length; i++) {
+ callback(array[i], i, array);
+ }
+ }
+
+ function objectKeys(obj) {
+ if (Object.keys) {
+ return Object.keys(obj);
+ } else {
+ // IE8
+ var res = [], i;
+ for (i in obj) {
+ if (obj.hasOwnProperty(i)) {
+ res.push(i);
+ }
+ }
+ return res;
+ }
+ }
+
+ // Pick the first defined of two or three arguments.
+ function defaults(a, b, c) {
+ if (a != null) {
+ return a;
+ }
+ if (b != null) {
+ return b;
+ }
+ return c;
+ }
+
+ function defineCommonLocaleTests(locale, options) {
+ test('lenient ordinal parsing', function (assert) {
+ var i, ordinalStr, testMoment;
+ for (i = 1; i <= 31; ++i) {
+ ordinalStr = moment([2014, 0, i]).format('YYYY MM Do');
+ testMoment = moment(ordinalStr, 'YYYY MM Do');
+ assert.equal(testMoment.year(), 2014,
+ 'lenient ordinal parsing ' + i + ' year check');
+ assert.equal(testMoment.month(), 0,
+ 'lenient ordinal parsing ' + i + ' month check');
+ assert.equal(testMoment.date(), i,
+ 'lenient ordinal parsing ' + i + ' date check');
+ }
+ });
+
+ test('lenient ordinal parsing of number', function (assert) {
+ var i, testMoment;
+ for (i = 1; i <= 31; ++i) {
+ testMoment = moment('2014 01 ' + i, 'YYYY MM Do');
+ assert.equal(testMoment.year(), 2014,
+ 'lenient ordinal parsing of number ' + i + ' year check');
+ assert.equal(testMoment.month(), 0,
+ 'lenient ordinal parsing of number ' + i + ' month check');
+ assert.equal(testMoment.date(), i,
+ 'lenient ordinal parsing of number ' + i + ' date check');
+ }
+ });
+
+ test('strict ordinal parsing', function (assert) {
+ var i, ordinalStr, testMoment;
+ for (i = 1; i <= 31; ++i) {
+ ordinalStr = moment([2014, 0, i]).format('YYYY MM Do');
+ testMoment = moment(ordinalStr, 'YYYY MM Do', true);
+ assert.ok(testMoment.isValid(), 'strict ordinal parsing ' + i);
+ }
+ });
+
+ test('meridiem invariant', function (assert) {
+ var h, m, t1, t2;
+ for (h = 0; h < 24; ++h) {
+ for (m = 0; m < 60; m += 15) {
+ t1 = moment.utc([2000, 0, 1, h, m]);
+ t2 = moment.utc(t1.format('A h:mm'), 'A h:mm');
+ assert.equal(t2.format('HH:mm'), t1.format('HH:mm'),
+ 'meridiem at ' + t1.format('HH:mm'));
+ }
+ }
+ });
+
+ test('date format correctness', function (assert) {
+ var data, tokens;
+ data = moment.localeData()._longDateFormat;
+ tokens = objectKeys(data);
+ each(tokens, function (srchToken) {
+ // Check each format string to make sure it does not contain any
+ // tokens that need to be expanded.
+ each(tokens, function (baseToken) {
+ // strip escaped sequences
+ var format = data[baseToken].replace(/(\[[^\]]*\])/g, '');
+ assert.equal(false, !!~format.indexOf(srchToken),
+ 'contains ' + srchToken + ' in ' + baseToken);
+ });
+ });
+ });
+
+ test('month parsing correctness', function (assert) {
+ var i, m;
+
+ if (locale === 'tr') {
+ // I can't fix it :(
+ expect(0);
+ return;
+ }
+ function tester(format) {
+ var r;
+ r = moment(m.format(format), format);
+ assert.equal(r.month(), m.month(), 'month ' + i + ' fmt ' + format);
+ r = moment(m.format(format).toLocaleUpperCase(), format);
+ assert.equal(r.month(), m.month(), 'month ' + i + ' fmt ' + format + ' upper');
+ r = moment(m.format(format).toLocaleLowerCase(), format);
+ assert.equal(r.month(), m.month(), 'month ' + i + ' fmt ' + format + ' lower');
+
+ r = moment(m.format(format), format, true);
+ assert.equal(r.month(), m.month(), 'month ' + i + ' fmt ' + format + ' strict');
+ r = moment(m.format(format).toLocaleUpperCase(), format, true);
+ assert.equal(r.month(), m.month(), 'month ' + i + ' fmt ' + format + ' upper strict');
+ r = moment(m.format(format).toLocaleLowerCase(), format, true);
+ assert.equal(r.month(), m.month(), 'month ' + i + ' fmt ' + format + ' lower strict');
+ }
+
+ for (i = 0; i < 12; ++i) {
+ m = moment([2015, i, 15, 18]);
+ tester('MMM');
+ tester('MMM.');
+ tester('MMMM');
+ tester('MMMM.');
+ }
+ });
+
+ test('weekday parsing correctness', function (assert) {
+ var i, m;
+
+ if (locale === 'tr' || locale === 'az') {
+ // There is a lower-case letter (ı), that converted to upper then
+ // lower changes to i
+ expect(0);
+ return;
+ }
+ function tester(format) {
+ var r, baseMsg = 'weekday ' + m.weekday() + ' fmt ' + format;
+ r = moment(m.format(format), format);
+ assert.equal(r.weekday(), m.weekday(), baseMsg);
+ r = moment(m.format(format).toLocaleUpperCase(), format);
+ assert.equal(r.weekday(), m.weekday(), baseMsg + ' upper');
+ r = moment(m.format(format).toLocaleLowerCase(), format);
+ assert.equal(r.weekday(), m.weekday(), baseMsg + ' lower');
+
+ r = moment(m.format(format), format, true);
+ assert.equal(r.weekday(), m.weekday(), baseMsg + ' strict');
+ r = moment(m.format(format).toLocaleUpperCase(), format, true);
+ assert.equal(r.weekday(), m.weekday(), baseMsg + ' upper strict');
+ r = moment(m.format(format).toLocaleLowerCase(), format, true);
+ assert.equal(r.weekday(), m.weekday(), baseMsg + ' lower strict');
+ }
+
+ for (i = 0; i < 7; ++i) {
+ m = moment.utc([2015, i, 15, 18]);
+ tester('dd');
+ tester('ddd');
+ tester('dddd');
+ }
+ });
+ }
+
+ function setupDeprecationHandler(test, moment, scope) {
+ test._expectedDeprecations = null;
+ test._observedDeprecations = null;
+ test._oldSupress = moment.suppressDeprecationWarnings;
+ moment.suppressDeprecationWarnings = true;
+ test.expectedDeprecations = function () {
+ test._expectedDeprecations = arguments;
+ test._observedDeprecations = [];
+ };
+ moment.deprecationHandler = function (name, msg) {
+ var deprecationId = matchedDeprecation(name, msg, test._expectedDeprecations);
+ if (deprecationId === -1) {
+ throw new Error('Unexpected deprecation thrown name=' +
+ name + ' msg=' + msg);
+ }
+ test._observedDeprecations[deprecationId] = 1;
+ };
+ }
+
+ function teardownDeprecationHandler(test, moment, scope) {
+ moment.suppressDeprecationWarnings = test._oldSupress;
+
+ if (test._expectedDeprecations != null) {
+ var missedDeprecations = [];
+ each(test._expectedDeprecations, function (deprecationPattern, id) {
+ if (test._observedDeprecations[id] !== 1) {
+ missedDeprecations.push(deprecationPattern);
+ }
+ });
+ if (missedDeprecations.length !== 0) {
+ throw new Error('Expected deprecation warnings did not happen: ' +
+ missedDeprecations.join(' '));
+ }
+ }
+ }
+
+ function matchedDeprecation(name, msg, deprecations) {
+ if (deprecations == null) {
+ return -1;
+ }
+ for (var i = 0; i < deprecations.length; ++i) {
+ if (name != null && name === deprecations[i]) {
+ return i;
+ }
+ if (msg != null && msg.substring(0, deprecations[i].length) === deprecations[i]) {
+ return i;
+ }
+ }
+ return -1;
+ }
/*global QUnit:false*/
@@ -1542,11 +2260,13 @@
moment.createFromInputFallback = function (config) {
throw new Error('input not handled by moment: ' + config._i);
};
+ setupDeprecationHandler(test, moment, 'core');
if (lifecycle && lifecycle.setup) {
lifecycle.setup();
}
},
teardown : function () {
+ teardownDeprecationHandler(test, moment, 'core');
if (lifecycle && lifecycle.teardown) {
lifecycle.teardown();
}
@@ -1561,17 +2281,20 @@
moment.createFromInputFallback = function (config) {
throw new Error('input not handled by moment: ' + config._i);
};
+ setupDeprecationHandler(test, moment, 'locale');
if (lifecycle && lifecycle.setup) {
lifecycle.setup();
}
},
teardown : function () {
moment.locale('en');
+ teardownDeprecationHandler(test, moment, 'locale');
if (lifecycle && lifecycle.teardown) {
lifecycle.teardown();
}
}
});
+ defineCommonLocaleTests(name, -1, -1);
}
localeModule('ar');
@@ -1741,14 +2464,14 @@
});
test('calendar day', function (assert) {
- var a = moment().hours(2).minutes(0).seconds(0);
-
- assert.equal(moment(a).calendar(), 'اليوم عند الساعة ٠٢:٠٠', 'today at the same time');
- assert.equal(moment(a).add({m: 25}).calendar(), 'اليوم عند الساعة ٠٢:٢٥', 'Now plus 25 min');
- assert.equal(moment(a).add({h: 1}).calendar(), 'اليوم عند الساعة ٠٣:٠٠', 'Now plus 1 hour');
- assert.equal(moment(a).add({d: 1}).calendar(), 'غدًا عند الساعة ٠٢:٠٠', 'tomorrow at the same time');
- assert.equal(moment(a).subtract({h: 1}).calendar(), 'اليوم عند الساعة ٠١:٠٠', 'Now minus 1 hour');
- assert.equal(moment(a).subtract({d: 1}).calendar(), 'أمس عند الساعة ٠٢:٠٠', 'yesterday at the same time');
+ var a = moment().hours(12).minutes(0).seconds(0);
+
+ assert.equal(moment(a).calendar(), 'اليوم عند الساعة ١٢:٠٠', 'today at the same time');
+ assert.equal(moment(a).add({m: 25}).calendar(), 'اليوم عند الساعة ١٢:٢٥', 'Now plus 25 min');
+ assert.equal(moment(a).add({h: 1}).calendar(), 'اليوم عند الساعة ١٣:٠٠', 'Now plus 1 hour');
+ assert.equal(moment(a).add({d: 1}).calendar(), 'غدًا عند الساعة ١٢:٠٠', 'tomorrow at the same time');
+ assert.equal(moment(a).subtract({h: 1}).calendar(), 'اليوم عند الساعة ١١:٠٠', 'Now minus 1 hour');
+ assert.equal(moment(a).subtract({d: 1}).calendar(), 'أمس عند الساعة ١٢:٠٠', 'yesterday at the same time');
});
test('calendar next week', function (assert) {
@@ -1789,68 +2512,11 @@
assert.equal(weeksFromNow.calendar(), weeksFromNow.format('L'), 'in 2 weeks');
});
- test('weeks year starting sunday', function (assert) {
- assert.equal(moment([2011, 11, 31]).week(), 1, 'Dec 31 2011 should be week 1');
- assert.equal(moment([2012, 0, 6]).week(), 1, 'Jan 6 2012 should be week 1');
- assert.equal(moment([2012, 0, 7]).week(), 2, 'Jan 7 2012 should be week 2');
- assert.equal(moment([2012, 0, 13]).week(), 2, 'Jan 13 2012 should be week 2');
- assert.equal(moment([2012, 0, 14]).week(), 3, 'Jan 14 2012 should be week 3');
- });
-
- test('weeks year starting monday', function (assert) {
- assert.equal(moment([2006, 11, 30]).week(), 1, 'Dec 30 2006 should be week 1');
- assert.equal(moment([2007, 0, 5]).week(), 1, 'Jan 5 2007 should be week 1');
- assert.equal(moment([2007, 0, 6]).week(), 2, 'Jan 6 2007 should be week 2');
- assert.equal(moment([2007, 0, 12]).week(), 2, 'Jan 12 2007 should be week 2');
- assert.equal(moment([2007, 0, 13]).week(), 3, 'Jan 13 2007 should be week 3');
- });
-
- test('weeks year starting tuesday', function (assert) {
- assert.equal(moment([2007, 11, 29]).week(), 1, 'Dec 29 2007 should be week 1');
- assert.equal(moment([2008, 0, 1]).week(), 1, 'Jan 1 2008 should be week 1');
- assert.equal(moment([2008, 0, 4]).week(), 1, 'Jan 4 2008 should be week 1');
- assert.equal(moment([2008, 0, 5]).week(), 2, 'Jan 5 2008 should be week 2');
- assert.equal(moment([2008, 0, 11]).week(), 2, 'Jan 11 2008 should be week 2');
- assert.equal(moment([2008, 0, 12]).week(), 3, 'Jan 12 2008 should be week 3');
- });
-
- test('weeks year starting wednesday', function (assert) {
- assert.equal(moment([2002, 11, 28]).week(), 1, 'Dec 28 2002 should be week 1');
- assert.equal(moment([2003, 0, 1]).week(), 1, 'Jan 1 2003 should be week 1');
- assert.equal(moment([2003, 0, 3]).week(), 1, 'Jan 3 2003 should be week 1');
- assert.equal(moment([2003, 0, 4]).week(), 2, 'Jan 4 2003 should be week 2');
- assert.equal(moment([2003, 0, 10]).week(), 2, 'Jan 10 2003 should be week 2');
- assert.equal(moment([2003, 0, 11]).week(), 3, 'Jan 11 2003 should be week 3');
-
+ test('weeks year starting wednesday custom', function (assert) {
assert.equal(moment('2003 1 6', 'gggg w d').format('YYYY-MM-DD'), '٢٠٠٢-١٢-٢٨', 'Week 1 of 2003 should be Dec 28 2002');
assert.equal(moment('2003 1 0', 'gggg w e').format('YYYY-MM-DD'), '٢٠٠٢-١٢-٢٨', 'Week 1 of 2003 should be Dec 28 2002');
assert.equal(moment('2003 1 6', 'gggg w d').format('gggg w d'), '٢٠٠٣ ١ ٦', 'Saturday of week 1 of 2003 parsed should be formatted as 2003 1 6');
assert.equal(moment('2003 1 0', 'gggg w e').format('gggg w e'), '٢٠٠٣ ١ ٠', '1st day of week 1 of 2003 parsed should be formatted as 2003 1 0');
- });
-
- test('weeks year starting thursday', function (assert) {
- assert.equal(moment([2008, 11, 27]).week(), 1, 'Dec 27 2008 should be week 1');
- assert.equal(moment([2009, 0, 1]).week(), 1, 'Jan 1 2009 should be week 1');
- assert.equal(moment([2009, 0, 2]).week(), 1, 'Jan 2 2009 should be week 1');
- assert.equal(moment([2009, 0, 3]).week(), 2, 'Jan 3 2009 should be week 2');
- assert.equal(moment([2009, 0, 9]).week(), 2, 'Jan 9 2009 should be week 2');
- assert.equal(moment([2009, 0, 10]).week(), 3, 'Jan 10 2009 should be week 3');
- });
-
- test('weeks year starting friday', function (assert) {
- assert.equal(moment([2009, 11, 26]).week(), 1, 'Dec 26 2009 should be week 1');
- assert.equal(moment([2010, 0, 1]).week(), 1, 'Jan 1 2010 should be week 1');
- assert.equal(moment([2010, 0, 2]).week(), 2, 'Jan 2 2010 should be week 2');
- assert.equal(moment([2010, 0, 8]).week(), 2, 'Jan 8 2010 should be week 2');
- assert.equal(moment([2010, 0, 9]).week(), 3, 'Jan 9 2010 should be week 3');
- });
-
- test('weeks year starting saturday', function (assert) {
- assert.equal(moment([2011, 0, 1]).week(), 1, 'Jan 1 2011 should be week 1');
- assert.equal(moment([2011, 0, 7]).week(), 1, 'Jan 7 2011 should be week 1');
- assert.equal(moment([2011, 0, 8]).week(), 2, 'Jan 8 2011 should be week 2');
- assert.equal(moment([2011, 0, 14]).week(), 2, 'Jan 14 2011 should be week 2');
- assert.equal(moment([2011, 0, 15]).week(), 3, 'Jan 15 2011 should be week 3');
});
test('weeks year starting sunday formatted', function (assert) {
@@ -1859,42 +2525,6 @@
assert.equal(moment([2012, 0, 7]).format('w ww wo'), '٢ ٠٢ ٢', 'Jan 7 2012 should be week 2');
assert.equal(moment([2012, 0, 13]).format('w ww wo'), '٢ ٠٢ ٢', 'Jan 13 2012 should be week 2');
assert.equal(moment([2012, 0, 14]).format('w ww wo'), '٣ ٠٣ ٣', 'Jan 14 2012 should be week 3');
- });
-
- test('lenient ordinal parsing', function (assert) {
- var i, ordinalStr, testMoment;
- for (i = 1; i <= 31; ++i) {
- ordinalStr = moment([2014, 0, i]).format('YYYY MM Do');
- testMoment = moment(ordinalStr, 'YYYY MM Do');
- assert.equal(testMoment.year(), 2014,
- 'lenient ordinal parsing ' + i + ' year check');
- assert.equal(testMoment.month(), 0,
- 'lenient ordinal parsing ' + i + ' month check');
- assert.equal(testMoment.date(), i,
- 'lenient ordinal parsing ' + i + ' date check');
- }
- });
-
- test('lenient ordinal parsing of number', function (assert) {
- var i, testMoment;
- for (i = 1; i <= 31; ++i) {
- testMoment = moment('2014 01 ' + i, 'YYYY MM Do');
- assert.equal(testMoment.year(), 2014,
- 'lenient ordinal parsing of number ' + i + ' year check');
- assert.equal(testMoment.month(), 0,
- 'lenient ordinal parsing of number ' + i + ' month check');
- assert.equal(testMoment.date(), i,
- 'lenient ordinal parsing of number ' + i + ' date check');
- }
- });
-
- test('strict ordinal parsing', function (assert) {
- var i, ordinalStr, testMoment;
- for (i = 1; i <= 31; ++i) {
- ordinalStr = moment([2014, 0, i]).format('YYYY MM Do');
- testMoment = moment(ordinalStr, 'YYYY MM Do', true);
- assert.ok(testMoment.isValid(), 'strict ordinal parsing ' + i);
- }
});
test('no leading zeros in long date formats', function (assert) {
@@ -1917,6 +2547,224 @@
factory(global.moment)
}(this, function (moment) { 'use strict';
+ function each(array, callback) {
+ var i;
+ for (i = 0; i < array.length; i++) {
+ callback(array[i], i, array);
+ }
+ }
+
+ function objectKeys(obj) {
+ if (Object.keys) {
+ return Object.keys(obj);
+ } else {
+ // IE8
+ var res = [], i;
+ for (i in obj) {
+ if (obj.hasOwnProperty(i)) {
+ res.push(i);
+ }
+ }
+ return res;
+ }
+ }
+
+ // Pick the first defined of two or three arguments.
+ function defaults(a, b, c) {
+ if (a != null) {
+ return a;
+ }
+ if (b != null) {
+ return b;
+ }
+ return c;
+ }
+
+ function defineCommonLocaleTests(locale, options) {
+ test('lenient ordinal parsing', function (assert) {
+ var i, ordinalStr, testMoment;
+ for (i = 1; i <= 31; ++i) {
+ ordinalStr = moment([2014, 0, i]).format('YYYY MM Do');
+ testMoment = moment(ordinalStr, 'YYYY MM Do');
+ assert.equal(testMoment.year(), 2014,
+ 'lenient ordinal parsing ' + i + ' year check');
+ assert.equal(testMoment.month(), 0,
+ 'lenient ordinal parsing ' + i + ' month check');
+ assert.equal(testMoment.date(), i,
+ 'lenient ordinal parsing ' + i + ' date check');
+ }
+ });
+
+ test('lenient ordinal parsing of number', function (assert) {
+ var i, testMoment;
+ for (i = 1; i <= 31; ++i) {
+ testMoment = moment('2014 01 ' + i, 'YYYY MM Do');
+ assert.equal(testMoment.year(), 2014,
+ 'lenient ordinal parsing of number ' + i + ' year check');
+ assert.equal(testMoment.month(), 0,
+ 'lenient ordinal parsing of number ' + i + ' month check');
+ assert.equal(testMoment.date(), i,
+ 'lenient ordinal parsing of number ' + i + ' date check');
+ }
+ });
+
+ test('strict ordinal parsing', function (assert) {
+ var i, ordinalStr, testMoment;
+ for (i = 1; i <= 31; ++i) {
+ ordinalStr = moment([2014, 0, i]).format('YYYY MM Do');
+ testMoment = moment(ordinalStr, 'YYYY MM Do', true);
+ assert.ok(testMoment.isValid(), 'strict ordinal parsing ' + i);
+ }
+ });
+
+ test('meridiem invariant', function (assert) {
+ var h, m, t1, t2;
+ for (h = 0; h < 24; ++h) {
+ for (m = 0; m < 60; m += 15) {
+ t1 = moment.utc([2000, 0, 1, h, m]);
+ t2 = moment.utc(t1.format('A h:mm'), 'A h:mm');
+ assert.equal(t2.format('HH:mm'), t1.format('HH:mm'),
+ 'meridiem at ' + t1.format('HH:mm'));
+ }
+ }
+ });
+
+ test('date format correctness', function (assert) {
+ var data, tokens;
+ data = moment.localeData()._longDateFormat;
+ tokens = objectKeys(data);
+ each(tokens, function (srchToken) {
+ // Check each format string to make sure it does not contain any
+ // tokens that need to be expanded.
+ each(tokens, function (baseToken) {
+ // strip escaped sequences
+ var format = data[baseToken].replace(/(\[[^\]]*\])/g, '');
+ assert.equal(false, !!~format.indexOf(srchToken),
+ 'contains ' + srchToken + ' in ' + baseToken);
+ });
+ });
+ });
+
+ test('month parsing correctness', function (assert) {
+ var i, m;
+
+ if (locale === 'tr') {
+ // I can't fix it :(
+ expect(0);
+ return;
+ }
+ function tester(format) {
+ var r;
+ r = moment(m.format(format), format);
+ assert.equal(r.month(), m.month(), 'month ' + i + ' fmt ' + format);
+ r = moment(m.format(format).toLocaleUpperCase(), format);
+ assert.equal(r.month(), m.month(), 'month ' + i + ' fmt ' + format + ' upper');
+ r = moment(m.format(format).toLocaleLowerCase(), format);
+ assert.equal(r.month(), m.month(), 'month ' + i + ' fmt ' + format + ' lower');
+
+ r = moment(m.format(format), format, true);
+ assert.equal(r.month(), m.month(), 'month ' + i + ' fmt ' + format + ' strict');
+ r = moment(m.format(format).toLocaleUpperCase(), format, true);
+ assert.equal(r.month(), m.month(), 'month ' + i + ' fmt ' + format + ' upper strict');
+ r = moment(m.format(format).toLocaleLowerCase(), format, true);
+ assert.equal(r.month(), m.month(), 'month ' + i + ' fmt ' + format + ' lower strict');
+ }
+
+ for (i = 0; i < 12; ++i) {
+ m = moment([2015, i, 15, 18]);
+ tester('MMM');
+ tester('MMM.');
+ tester('MMMM');
+ tester('MMMM.');
+ }
+ });
+
+ test('weekday parsing correctness', function (assert) {
+ var i, m;
+
+ if (locale === 'tr' || locale === 'az') {
+ // There is a lower-case letter (ı), that converted to upper then
+ // lower changes to i
+ expect(0);
+ return;
+ }
+ function tester(format) {
+ var r, baseMsg = 'weekday ' + m.weekday() + ' fmt ' + format;
+ r = moment(m.format(format), format);
+ assert.equal(r.weekday(), m.weekday(), baseMsg);
+ r = moment(m.format(format).toLocaleUpperCase(), format);
+ assert.equal(r.weekday(), m.weekday(), baseMsg + ' upper');
+ r = moment(m.format(format).toLocaleLowerCase(), format);
+ assert.equal(r.weekday(), m.weekday(), baseMsg + ' lower');
+
+ r = moment(m.format(format), format, true);
+ assert.equal(r.weekday(), m.weekday(), baseMsg + ' strict');
+ r = moment(m.format(format).toLocaleUpperCase(), format, true);
+ assert.equal(r.weekday(), m.weekday(), baseMsg + ' upper strict');
+ r = moment(m.format(format).toLocaleLowerCase(), format, true);
+ assert.equal(r.weekday(), m.weekday(), baseMsg + ' lower strict');
+ }
+
+ for (i = 0; i < 7; ++i) {
+ m = moment.utc([2015, i, 15, 18]);
+ tester('dd');
+ tester('ddd');
+ tester('dddd');
+ }
+ });
+ }
+
+ function setupDeprecationHandler(test, moment, scope) {
+ test._expectedDeprecations = null;
+ test._observedDeprecations = null;
+ test._oldSupress = moment.suppressDeprecationWarnings;
+ moment.suppressDeprecationWarnings = true;
+ test.expectedDeprecations = function () {
+ test._expectedDeprecations = arguments;
+ test._observedDeprecations = [];
+ };
+ moment.deprecationHandler = function (name, msg) {
+ var deprecationId = matchedDeprecation(name, msg, test._expectedDeprecations);
+ if (deprecationId === -1) {
+ throw new Error('Unexpected deprecation thrown name=' +
+ name + ' msg=' + msg);
+ }
+ test._observedDeprecations[deprecationId] = 1;
+ };
+ }
+
+ function teardownDeprecationHandler(test, moment, scope) {
+ moment.suppressDeprecationWarnings = test._oldSupress;
+
+ if (test._expectedDeprecations != null) {
+ var missedDeprecations = [];
+ each(test._expectedDeprecations, function (deprecationPattern, id) {
+ if (test._observedDeprecations[id] !== 1) {
+ missedDeprecations.push(deprecationPattern);
+ }
+ });
+ if (missedDeprecations.length !== 0) {
+ throw new Error('Expected deprecation warnings did not happen: ' +
+ missedDeprecations.join(' '));
+ }
+ }
+ }
+
+ function matchedDeprecation(name, msg, deprecations) {
+ if (deprecations == null) {
+ return -1;
+ }
+ for (var i = 0; i < deprecations.length; ++i) {
+ if (name != null && name === deprecations[i]) {
+ return i;
+ }
+ if (msg != null && msg.substring(0, deprecations[i].length) === deprecations[i]) {
+ return i;
+ }
+ }
+ return -1;
+ }
+
/*global QUnit:false*/
var test = QUnit.test;
@@ -1930,11 +2778,13 @@
moment.createFromInputFallback = function (config) {
throw new Error('input not handled by moment: ' + config._i);
};
+ setupDeprecationHandler(test, moment, 'core');
if (lifecycle && lifecycle.setup) {
lifecycle.setup();
}
},
teardown : function () {
+ teardownDeprecationHandler(test, moment, 'core');
if (lifecycle && lifecycle.teardown) {
lifecycle.teardown();
}
@@ -1949,17 +2799,20 @@
moment.createFromInputFallback = function (config) {
throw new Error('input not handled by moment: ' + config._i);
};
+ setupDeprecationHandler(test, moment, 'locale');
if (lifecycle && lifecycle.setup) {
lifecycle.setup();
}
},
teardown : function () {
moment.locale('en');
+ teardownDeprecationHandler(test, moment, 'locale');
if (lifecycle && lifecycle.teardown) {
lifecycle.teardown();
}
}
});
+ defineCommonLocaleTests(name, -1, -1);
}
localeModule('az');
@@ -2124,14 +2977,14 @@
});
test('calendar day', function (assert) {
- var a = moment().hours(2).minutes(0).seconds(0);
-
- assert.equal(moment(a).calendar(), 'bugün saat 02:00', 'today at the same time');
- assert.equal(moment(a).add({m: 25}).calendar(), 'bugün saat 02:25', 'Now plus 25 min');
- assert.equal(moment(a).add({h: 1}).calendar(), 'bugün saat 03:00', 'Now plus 1 hour');
- assert.equal(moment(a).add({d: 1}).calendar(), 'sabah saat 02:00', 'tomorrow at the same time');
- assert.equal(moment(a).subtract({h: 1}).calendar(), 'bugün saat 01:00', 'Now minus 1 hour');
- assert.equal(moment(a).subtract({d: 1}).calendar(), 'dünən 02:00', 'yesterday at the same time');
+ var a = moment().hours(12).minutes(0).seconds(0);
+
+ assert.equal(moment(a).calendar(), 'bugün saat 12:00', 'today at the same time');
+ assert.equal(moment(a).add({m: 25}).calendar(), 'bugün saat 12:25', 'Now plus 25 min');
+ assert.equal(moment(a).add({h: 1}).calendar(), 'bugün saat 13:00', 'Now plus 1 hour');
+ assert.equal(moment(a).add({d: 1}).calendar(), 'sabah saat 12:00', 'tomorrow at the same time');
+ assert.equal(moment(a).subtract({h: 1}).calendar(), 'bugün saat 11:00', 'Now minus 1 hour');
+ assert.equal(moment(a).subtract({d: 1}).calendar(), 'dünən 12:00', 'yesterday at the same time');
});
test('calendar next week', function (assert) {
@@ -2172,67 +3025,6 @@
assert.equal(weeksFromNow.calendar(), weeksFromNow.format('L'), 'in 2 weeks');
});
- test('weeks year starting sunday', function (assert) {
- assert.equal(moment([2011, 11, 26]).week(), 1, 'Dec 26 2011 should be week 1');
- assert.equal(moment([2012, 0, 1]).week(), 1, 'Jan 1 2012 should be week 1');
- assert.equal(moment([2012, 0, 2]).week(), 2, 'Jan 2 2012 should be week 2');
- assert.equal(moment([2012, 0, 8]).week(), 2, 'Jan 8 2012 should be week 2');
- assert.equal(moment([2012, 0, 9]).week(), 3, 'Jan 9 2012 should be week 3');
- });
-
- test('weeks year starting monday', function (assert) {
- assert.equal(moment([2007, 0, 1]).week(), 1, 'Jan 1 2007 should be week 1');
- assert.equal(moment([2007, 0, 7]).week(), 1, 'Jan 7 2007 should be week 1');
- assert.equal(moment([2007, 0, 8]).week(), 2, 'Jan 8 2007 should be week 2');
- assert.equal(moment([2007, 0, 14]).week(), 2, 'Jan 14 2007 should be week 2');
- assert.equal(moment([2007, 0, 15]).week(), 3, 'Jan 15 2007 should be week 3');
- });
-
- test('weeks year starting tuesday', function (assert) {
- assert.equal(moment([2007, 11, 31]).week(), 1, 'Dec 31 2007 should be week 1');
- assert.equal(moment([2008, 0, 1]).week(), 1, 'Jan 1 2008 should be week 1');
- assert.equal(moment([2008, 0, 6]).week(), 1, 'Jan 6 2008 should be week 1');
- assert.equal(moment([2008, 0, 7]).week(), 2, 'Jan 7 2008 should be week 2');
- assert.equal(moment([2008, 0, 13]).week(), 2, 'Jan 13 2008 should be week 2');
- assert.equal(moment([2008, 0, 14]).week(), 3, 'Jan 14 2008 should be week 3');
- });
-
- test('weeks year starting wednesday', function (assert) {
- assert.equal(moment([2002, 11, 30]).week(), 1, 'Dec 30 2002 should be week 1');
- assert.equal(moment([2003, 0, 1]).week(), 1, 'Jan 1 2003 should be week 1');
- assert.equal(moment([2003, 0, 5]).week(), 1, 'Jan 5 2003 should be week 1');
- assert.equal(moment([2003, 0, 6]).week(), 2, 'Jan 6 2003 should be week 2');
- assert.equal(moment([2003, 0, 12]).week(), 2, 'Jan 12 2003 should be week 2');
- assert.equal(moment([2003, 0, 13]).week(), 3, 'Jan 13 2003 should be week 3');
- });
-
- test('weeks year starting thursday', function (assert) {
- assert.equal(moment([2008, 11, 29]).week(), 1, 'Dec 29 2008 should be week 1');
- assert.equal(moment([2009, 0, 1]).week(), 1, 'Jan 1 2009 should be week 1');
- assert.equal(moment([2009, 0, 4]).week(), 1, 'Jan 4 2009 should be week 1');
- assert.equal(moment([2009, 0, 5]).week(), 2, 'Jan 5 2009 should be week 2');
- assert.equal(moment([2009, 0, 11]).week(), 2, 'Jan 11 2009 should be week 2');
- assert.equal(moment([2009, 0, 12]).week(), 3, 'Jan 12 2009 should be week 3');
- });
-
- test('weeks year starting friday', function (assert) {
- assert.equal(moment([2009, 11, 28]).week(), 1, 'Dec 28 2009 should be week 1');
- assert.equal(moment([2010, 0, 1]).week(), 1, 'Jan 1 2010 should be week 1');
- assert.equal(moment([2010, 0, 3]).week(), 1, 'Jan 3 2010 should be week 1');
- assert.equal(moment([2010, 0, 4]).week(), 2, 'Jan 4 2010 should be week 2');
- assert.equal(moment([2010, 0, 10]).week(), 2, 'Jan 10 2010 should be week 2');
- assert.equal(moment([2010, 0, 11]).week(), 3, 'Jan 11 2010 should be week 3');
- });
-
- test('weeks year starting saturday', function (assert) {
- assert.equal(moment([2010, 11, 27]).week(), 1, 'Dec 27 2010 should be week 1');
- assert.equal(moment([2011, 0, 1]).week(), 1, 'Jan 1 2011 should be week 1');
- assert.equal(moment([2011, 0, 2]).week(), 1, 'Jan 2 2011 should be week 1');
- assert.equal(moment([2011, 0, 3]).week(), 2, 'Jan 3 2011 should be week 2');
- assert.equal(moment([2011, 0, 9]).week(), 2, 'Jan 9 2011 should be week 2');
- assert.equal(moment([2011, 0, 10]).week(), 3, 'Jan 10 2011 should be week 3');
- });
-
test('weeks year starting sunday formatted', function (assert) {
assert.equal(moment([2011, 11, 26]).format('w ww wo'), '1 01 1-inci', 'Dec 26 2011 should be week 1');
assert.equal(moment([2012, 0, 1]).format('w ww wo'), '1 01 1-inci', 'Jan 1 2012 should be week 1');
@@ -2241,42 +3033,6 @@
assert.equal(moment([2012, 0, 9]).format('w ww wo'), '3 03 3-üncü', 'Jan 9 2012 should be week 3');
});
- test('lenient ordinal parsing', function (assert) {
- var i, ordinalStr, testMoment;
- for (i = 1; i <= 31; ++i) {
- ordinalStr = moment([2014, 0, i]).format('YYYY MM Do');
- testMoment = moment(ordinalStr, 'YYYY MM Do');
- assert.equal(testMoment.year(), 2014,
- 'lenient ordinal parsing ' + i + ' year check');
- assert.equal(testMoment.month(), 0,
- 'lenient ordinal parsing ' + i + ' month check');
- assert.equal(testMoment.date(), i,
- 'lenient ordinal parsing ' + i + ' date check');
- }
- });
-
- test('lenient ordinal parsing of number', function (assert) {
- var i, testMoment;
- for (i = 1; i <= 31; ++i) {
- testMoment = moment('2014 01 ' + i, 'YYYY MM Do');
- assert.equal(testMoment.year(), 2014,
- 'lenient ordinal parsing of number ' + i + ' year check');
- assert.equal(testMoment.month(), 0,
- 'lenient ordinal parsing of number ' + i + ' month check');
- assert.equal(testMoment.date(), i,
- 'lenient ordinal parsing of number ' + i + ' date check');
- }
- });
-
- test('strict ordinal parsing', function (assert) {
- var i, ordinalStr, testMoment;
- for (i = 1; i <= 31; ++i) {
- ordinalStr = moment([2014, 0, i]).format('YYYY MM Do');
- testMoment = moment(ordinalStr, 'YYYY MM Do', true);
- assert.ok(testMoment.isValid(), 'strict ordinal parsing ' + i);
- }
- });
-
}));
;(function (global, factory) {
@@ -2285,6 +3041,224 @@
typeof define === 'function' && define.amd ? define(['../../moment'], factory) :
factory(global.moment)
}(this, function (moment) { 'use strict';
+
+ function each(array, callback) {
+ var i;
+ for (i = 0; i < array.length; i++) {
+ callback(array[i], i, array);
+ }
+ }
+
+ function objectKeys(obj) {
+ if (Object.keys) {
+ return Object.keys(obj);
+ } else {
+ // IE8
+ var res = [], i;
+ for (i in obj) {
+ if (obj.hasOwnProperty(i)) {
+ res.push(i);
+ }
+ }
+ return res;
+ }
+ }
+
+ // Pick the first defined of two or three arguments.
+ function defaults(a, b, c) {
+ if (a != null) {
+ return a;
+ }
+ if (b != null) {
+ return b;
+ }
+ return c;
+ }
+
+ function defineCommonLocaleTests(locale, options) {
+ test('lenient ordinal parsing', function (assert) {
+ var i, ordinalStr, testMoment;
+ for (i = 1; i <= 31; ++i) {
+ ordinalStr = moment([2014, 0, i]).format('YYYY MM Do');
+ testMoment = moment(ordinalStr, 'YYYY MM Do');
+ assert.equal(testMoment.year(), 2014,
+ 'lenient ordinal parsing ' + i + ' year check');
+ assert.equal(testMoment.month(), 0,
+ 'lenient ordinal parsing ' + i + ' month check');
+ assert.equal(testMoment.date(), i,
+ 'lenient ordinal parsing ' + i + ' date check');
+ }
+ });
+
+ test('lenient ordinal parsing of number', function (assert) {
+ var i, testMoment;
+ for (i = 1; i <= 31; ++i) {
+ testMoment = moment('2014 01 ' + i, 'YYYY MM Do');
+ assert.equal(testMoment.year(), 2014,
+ 'lenient ordinal parsing of number ' + i + ' year check');
+ assert.equal(testMoment.month(), 0,
+ 'lenient ordinal parsing of number ' + i + ' month check');
+ assert.equal(testMoment.date(), i,
+ 'lenient ordinal parsing of number ' + i + ' date check');
+ }
+ });
+
+ test('strict ordinal parsing', function (assert) {
+ var i, ordinalStr, testMoment;
+ for (i = 1; i <= 31; ++i) {
+ ordinalStr = moment([2014, 0, i]).format('YYYY MM Do');
+ testMoment = moment(ordinalStr, 'YYYY MM Do', true);
+ assert.ok(testMoment.isValid(), 'strict ordinal parsing ' + i);
+ }
+ });
+
+ test('meridiem invariant', function (assert) {
+ var h, m, t1, t2;
+ for (h = 0; h < 24; ++h) {
+ for (m = 0; m < 60; m += 15) {
+ t1 = moment.utc([2000, 0, 1, h, m]);
+ t2 = moment.utc(t1.format('A h:mm'), 'A h:mm');
+ assert.equal(t2.format('HH:mm'), t1.format('HH:mm'),
+ 'meridiem at ' + t1.format('HH:mm'));
+ }
+ }
+ });
+
+ test('date format correctness', function (assert) {
+ var data, tokens;
+ data = moment.localeData()._longDateFormat;
+ tokens = objectKeys(data);
+ each(tokens, function (srchToken) {
+ // Check each format string to make sure it does not contain any
+ // tokens that need to be expanded.
+ each(tokens, function (baseToken) {
+ // strip escaped sequences
+ var format = data[baseToken].replace(/(\[[^\]]*\])/g, '');
+ assert.equal(false, !!~format.indexOf(srchToken),
+ 'contains ' + srchToken + ' in ' + baseToken);
+ });
+ });
+ });
+
+ test('month parsing correctness', function (assert) {
+ var i, m;
+
+ if (locale === 'tr') {
+ // I can't fix it :(
+ expect(0);
+ return;
+ }
+ function tester(format) {
+ var r;
+ r = moment(m.format(format), format);
+ assert.equal(r.month(), m.month(), 'month ' + i + ' fmt ' + format);
+ r = moment(m.format(format).toLocaleUpperCase(), format);
+ assert.equal(r.month(), m.month(), 'month ' + i + ' fmt ' + format + ' upper');
+ r = moment(m.format(format).toLocaleLowerCase(), format);
+ assert.equal(r.month(), m.month(), 'month ' + i + ' fmt ' + format + ' lower');
+
+ r = moment(m.format(format), format, true);
+ assert.equal(r.month(), m.month(), 'month ' + i + ' fmt ' + format + ' strict');
+ r = moment(m.format(format).toLocaleUpperCase(), format, true);
+ assert.equal(r.month(), m.month(), 'month ' + i + ' fmt ' + format + ' upper strict');
+ r = moment(m.format(format).toLocaleLowerCase(), format, true);
+ assert.equal(r.month(), m.month(), 'month ' + i + ' fmt ' + format + ' lower strict');
+ }
+
+ for (i = 0; i < 12; ++i) {
+ m = moment([2015, i, 15, 18]);
+ tester('MMM');
+ tester('MMM.');
+ tester('MMMM');
+ tester('MMMM.');
+ }
+ });
+
+ test('weekday parsing correctness', function (assert) {
+ var i, m;
+
+ if (locale === 'tr' || locale === 'az') {
+ // There is a lower-case letter (ı), that converted to upper then
+ // lower changes to i
+ expect(0);
+ return;
+ }
+ function tester(format) {
+ var r, baseMsg = 'weekday ' + m.weekday() + ' fmt ' + format;
+ r = moment(m.format(format), format);
+ assert.equal(r.weekday(), m.weekday(), baseMsg);
+ r = moment(m.format(format).toLocaleUpperCase(), format);
+ assert.equal(r.weekday(), m.weekday(), baseMsg + ' upper');
+ r = moment(m.format(format).toLocaleLowerCase(), format);
+ assert.equal(r.weekday(), m.weekday(), baseMsg + ' lower');
+
+ r = moment(m.format(format), format, true);
+ assert.equal(r.weekday(), m.weekday(), baseMsg + ' strict');
+ r = moment(m.format(format).toLocaleUpperCase(), format, true);
+ assert.equal(r.weekday(), m.weekday(), baseMsg + ' upper strict');
+ r = moment(m.format(format).toLocaleLowerCase(), format, true);
+ assert.equal(r.weekday(), m.weekday(), baseMsg + ' lower strict');
+ }
+
+ for (i = 0; i < 7; ++i) {
+ m = moment.utc([2015, i, 15, 18]);
+ tester('dd');
+ tester('ddd');
+ tester('dddd');
+ }
+ });
+ }
+
+ function setupDeprecationHandler(test, moment, scope) {
+ test._expectedDeprecations = null;
+ test._observedDeprecations = null;
+ test._oldSupress = moment.suppressDeprecationWarnings;
+ moment.suppressDeprecationWarnings = true;
+ test.expectedDeprecations = function () {
+ test._expectedDeprecations = arguments;
+ test._observedDeprecations = [];
+ };
+ moment.deprecationHandler = function (name, msg) {
+ var deprecationId = matchedDeprecation(name, msg, test._expectedDeprecations);
+ if (deprecationId === -1) {
+ throw new Error('Unexpected deprecation thrown name=' +
+ name + ' msg=' + msg);
+ }
+ test._observedDeprecations[deprecationId] = 1;
+ };
+ }
+
+ function teardownDeprecationHandler(test, moment, scope) {
+ moment.suppressDeprecationWarnings = test._oldSupress;
+
+ if (test._expectedDeprecations != null) {
+ var missedDeprecations = [];
+ each(test._expectedDeprecations, function (deprecationPattern, id) {
+ if (test._observedDeprecations[id] !== 1) {
+ missedDeprecations.push(deprecationPattern);
+ }
+ });
+ if (missedDeprecations.length !== 0) {
+ throw new Error('Expected deprecation warnings did not happen: ' +
+ missedDeprecations.join(' '));
+ }
+ }
+ }
+
+ function matchedDeprecation(name, msg, deprecations) {
+ if (deprecations == null) {
+ return -1;
+ }
+ for (var i = 0; i < deprecations.length; ++i) {
+ if (name != null && name === deprecations[i]) {
+ return i;
+ }
+ if (msg != null && msg.substring(0, deprecations[i].length) === deprecations[i]) {
+ return i;
+ }
+ }
+ return -1;
+ }
/*global QUnit:false*/
@@ -2299,11 +3273,13 @@
moment.createFromInputFallback = function (config) {
throw new Error('input not handled by moment: ' + config._i);
};
+ setupDeprecationHandler(test, moment, 'core');
if (lifecycle && lifecycle.setup) {
lifecycle.setup();
}
},
teardown : function () {
+ teardownDeprecationHandler(test, moment, 'core');
if (lifecycle && lifecycle.teardown) {
lifecycle.teardown();
}
@@ -2318,17 +3294,20 @@
moment.createFromInputFallback = function (config) {
throw new Error('input not handled by moment: ' + config._i);
};
+ setupDeprecationHandler(test, moment, 'locale');
if (lifecycle && lifecycle.setup) {
lifecycle.setup();
}
},
teardown : function () {
moment.locale('en');
+ teardownDeprecationHandler(test, moment, 'locale');
if (lifecycle && lifecycle.teardown) {
lifecycle.teardown();
}
}
});
+ defineCommonLocaleTests(name, -1, -1);
}
localeModule('be');
@@ -2519,14 +3498,14 @@
});
test('calendar day', function (assert) {
- var a = moment().hours(2).minutes(0).seconds(0);
-
- assert.equal(moment(a).calendar(), 'Сёння ў 02:00', 'today at the same time');
- assert.equal(moment(a).add({m: 25}).calendar(), 'Сёння ў 02:25', 'Now plus 25 min');
- assert.equal(moment(a).add({h: 1}).calendar(), 'Сёння ў 03:00', 'Now plus 1 hour');
- assert.equal(moment(a).add({d: 1}).calendar(), 'Заўтра ў 02:00', 'tomorrow at the same time');
- assert.equal(moment(a).subtract({h: 1}).calendar(), 'Сёння ў 01:00', 'Now minus 1 hour');
- assert.equal(moment(a).subtract({d: 1}).calendar(), 'Учора ў 02:00', 'yesterday at the same time');
+ var a = moment().hours(12).minutes(0).seconds(0);
+
+ assert.equal(moment(a).calendar(), 'Сёння ў 12:00', 'today at the same time');
+ assert.equal(moment(a).add({m: 25}).calendar(), 'Сёння ў 12:25', 'Now plus 25 min');
+ assert.equal(moment(a).add({h: 1}).calendar(), 'Сёння ў 13:00', 'Now plus 1 hour');
+ assert.equal(moment(a).add({d: 1}).calendar(), 'Заўтра ў 12:00', 'tomorrow at the same time');
+ assert.equal(moment(a).subtract({h: 1}).calendar(), 'Сёння ў 11:00', 'Now minus 1 hour');
+ assert.equal(moment(a).subtract({d: 1}).calendar(), 'Учора ў 12:00', 'yesterday at the same time');
});
test('calendar next week', function (assert) {
@@ -2586,67 +3565,6 @@
assert.equal(weeksFromNow.calendar(), weeksFromNow.format('L'), 'in 2 weeks');
});
- test('weeks year starting sunday', function (assert) {
- assert.equal(moment([2011, 11, 26]).week(), 1, 'Dec 26 2011 should be week 1');
- assert.equal(moment([2012, 0, 1]).week(), 1, 'Jan 1 2012 should be week 1');
- assert.equal(moment([2012, 0, 2]).week(), 2, 'Jan 2 2012 should be week 2');
- assert.equal(moment([2012, 0, 8]).week(), 2, 'Jan 8 2012 should be week 2');
- assert.equal(moment([2012, 0, 9]).week(), 3, 'Jan 9 2012 should be week 3');
- });
-
- test('weeks year starting monday', function (assert) {
- assert.equal(moment([2007, 0, 1]).week(), 1, 'Jan 1 2007 should be week 1');
- assert.equal(moment([2007, 0, 7]).week(), 1, 'Jan 7 2007 should be week 1');
- assert.equal(moment([2007, 0, 8]).week(), 2, 'Jan 8 2007 should be week 2');
- assert.equal(moment([2007, 0, 14]).week(), 2, 'Jan 14 2007 should be week 2');
- assert.equal(moment([2007, 0, 15]).week(), 3, 'Jan 15 2007 should be week 3');
- });
-
- test('weeks year starting tuesday', function (assert) {
- assert.equal(moment([2007, 11, 31]).week(), 1, 'Dec 31 2007 should be week 1');
- assert.equal(moment([2008, 0, 1]).week(), 1, 'Jan 1 2008 should be week 1');
- assert.equal(moment([2008, 0, 6]).week(), 1, 'Jan 6 2008 should be week 1');
- assert.equal(moment([2008, 0, 7]).week(), 2, 'Jan 7 2008 should be week 2');
- assert.equal(moment([2008, 0, 13]).week(), 2, 'Jan 13 2008 should be week 2');
- assert.equal(moment([2008, 0, 14]).week(), 3, 'Jan 14 2008 should be week 3');
- });
-
- test('weeks year starting wednesday', function (assert) {
- assert.equal(moment([2002, 11, 30]).week(), 1, 'Dec 30 2002 should be week 1');
- assert.equal(moment([2003, 0, 1]).week(), 1, 'Jan 1 2003 should be week 1');
- assert.equal(moment([2003, 0, 5]).week(), 1, 'Jan 5 2003 should be week 1');
- assert.equal(moment([2003, 0, 6]).week(), 2, 'Jan 6 2003 should be week 2');
- assert.equal(moment([2003, 0, 12]).week(), 2, 'Jan 12 2003 should be week 2');
- assert.equal(moment([2003, 0, 13]).week(), 3, 'Jan 13 2003 should be week 3');
- });
-
- test('weeks year starting thursday', function (assert) {
- assert.equal(moment([2008, 11, 29]).week(), 1, 'Dec 29 2008 should be week 1');
- assert.equal(moment([2009, 0, 1]).week(), 1, 'Jan 1 2009 should be week 1');
- assert.equal(moment([2009, 0, 4]).week(), 1, 'Jan 4 2009 should be week 1');
- assert.equal(moment([2009, 0, 5]).week(), 2, 'Jan 5 2009 should be week 2');
- assert.equal(moment([2009, 0, 11]).week(), 2, 'Jan 11 2009 should be week 2');
- assert.equal(moment([2009, 0, 12]).week(), 3, 'Jan 12 2009 should be week 3');
- });
-
- test('weeks year starting friday', function (assert) {
- assert.equal(moment([2009, 11, 28]).week(), 1, 'Dec 28 2009 should be week 1');
- assert.equal(moment([2010, 0, 1]).week(), 1, 'Jan 1 2010 should be week 1');
- assert.equal(moment([2010, 0, 3]).week(), 1, 'Jan 3 2010 should be week 1');
- assert.equal(moment([2010, 0, 4]).week(), 2, 'Jan 4 2010 should be week 2');
- assert.equal(moment([2010, 0, 10]).week(), 2, 'Jan 10 2010 should be week 2');
- assert.equal(moment([2010, 0, 11]).week(), 3, 'Jan 11 2010 should be week 3');
- });
-
- test('weeks year starting saturday', function (assert) {
- assert.equal(moment([2010, 11, 27]).week(), 1, 'Dec 27 2010 should be week 1');
- assert.equal(moment([2011, 0, 1]).week(), 1, 'Jan 1 2011 should be week 1');
- assert.equal(moment([2011, 0, 2]).week(), 1, 'Jan 2 2011 should be week 1');
- assert.equal(moment([2011, 0, 3]).week(), 2, 'Jan 3 2011 should be week 2');
- assert.equal(moment([2011, 0, 9]).week(), 2, 'Jan 9 2011 should be week 2');
- assert.equal(moment([2011, 0, 10]).week(), 3, 'Jan 10 2011 should be week 3');
- });
-
test('weeks year starting sunday formatted', function (assert) {
assert.equal(moment([2011, 11, 26]).format('w ww wo'), '1 01 1-ы', 'Dec 26 2011 should be week 1');
assert.equal(moment([2012, 0, 1]).format('w ww wo'), '1 01 1-ы', 'Jan 1 2012 should be week 1');
@@ -2655,42 +3573,6 @@
assert.equal(moment([2012, 0, 9]).format('w ww wo'), '3 03 3-і', 'Jan 9 2012 should be week 3');
});
- test('lenient ordinal parsing', function (assert) {
- var i, ordinalStr, testMoment;
- for (i = 1; i <= 31; ++i) {
- ordinalStr = moment([2014, 0, i]).format('YYYY MM Do');
- testMoment = moment(ordinalStr, 'YYYY MM Do');
- assert.equal(testMoment.year(), 2014,
- 'lenient ordinal parsing ' + i + ' year check');
- assert.equal(testMoment.month(), 0,
- 'lenient ordinal parsing ' + i + ' month check');
- assert.equal(testMoment.date(), i,
- 'lenient ordinal parsing ' + i + ' date check');
- }
- });
-
- test('lenient ordinal parsing of number', function (assert) {
- var i, testMoment;
- for (i = 1; i <= 31; ++i) {
- testMoment = moment('2014 01 ' + i, 'YYYY MM Do');
- assert.equal(testMoment.year(), 2014,
- 'lenient ordinal parsing of number ' + i + ' year check');
- assert.equal(testMoment.month(), 0,
- 'lenient ordinal parsing of number ' + i + ' month check');
- assert.equal(testMoment.date(), i,
- 'lenient ordinal parsing of number ' + i + ' date check');
- }
- });
-
- test('strict ordinal parsing', function (assert) {
- var i, ordinalStr, testMoment;
- for (i = 1; i <= 31; ++i) {
- ordinalStr = moment([2014, 0, i]).format('YYYY MM Do');
- testMoment = moment(ordinalStr, 'YYYY MM Do', true);
- assert.ok(testMoment.isValid(), 'strict ordinal parsing ' + i);
- }
- });
-
}));
;(function (global, factory) {
@@ -2699,6 +3581,224 @@
typeof define === 'function' && define.amd ? define(['../../moment'], factory) :
factory(global.moment)
}(this, function (moment) { 'use strict';
+
+ function each(array, callback) {
+ var i;
+ for (i = 0; i < array.length; i++) {
+ callback(array[i], i, array);
+ }
+ }
+
+ function objectKeys(obj) {
+ if (Object.keys) {
+ return Object.keys(obj);
+ } else {
+ // IE8
+ var res = [], i;
+ for (i in obj) {
+ if (obj.hasOwnProperty(i)) {
+ res.push(i);
+ }
+ }
+ return res;
+ }
+ }
+
+ // Pick the first defined of two or three arguments.
+ function defaults(a, b, c) {
+ if (a != null) {
+ return a;
+ }
+ if (b != null) {
+ return b;
+ }
+ return c;
+ }
+
+ function defineCommonLocaleTests(locale, options) {
+ test('lenient ordinal parsing', function (assert) {
+ var i, ordinalStr, testMoment;
+ for (i = 1; i <= 31; ++i) {
+ ordinalStr = moment([2014, 0, i]).format('YYYY MM Do');
+ testMoment = moment(ordinalStr, 'YYYY MM Do');
+ assert.equal(testMoment.year(), 2014,
+ 'lenient ordinal parsing ' + i + ' year check');
+ assert.equal(testMoment.month(), 0,
+ 'lenient ordinal parsing ' + i + ' month check');
+ assert.equal(testMoment.date(), i,
+ 'lenient ordinal parsing ' + i + ' date check');
+ }
+ });
+
+ test('lenient ordinal parsing of number', function (assert) {
+ var i, testMoment;
+ for (i = 1; i <= 31; ++i) {
+ testMoment = moment('2014 01 ' + i, 'YYYY MM Do');
+ assert.equal(testMoment.year(), 2014,
+ 'lenient ordinal parsing of number ' + i + ' year check');
+ assert.equal(testMoment.month(), 0,
+ 'lenient ordinal parsing of number ' + i + ' month check');
+ assert.equal(testMoment.date(), i,
+ 'lenient ordinal parsing of number ' + i + ' date check');
+ }
+ });
+
+ test('strict ordinal parsing', function (assert) {
+ var i, ordinalStr, testMoment;
+ for (i = 1; i <= 31; ++i) {
+ ordinalStr = moment([2014, 0, i]).format('YYYY MM Do');
+ testMoment = moment(ordinalStr, 'YYYY MM Do', true);
+ assert.ok(testMoment.isValid(), 'strict ordinal parsing ' + i);
+ }
+ });
+
+ test('meridiem invariant', function (assert) {
+ var h, m, t1, t2;
+ for (h = 0; h < 24; ++h) {
+ for (m = 0; m < 60; m += 15) {
+ t1 = moment.utc([2000, 0, 1, h, m]);
+ t2 = moment.utc(t1.format('A h:mm'), 'A h:mm');
+ assert.equal(t2.format('HH:mm'), t1.format('HH:mm'),
+ 'meridiem at ' + t1.format('HH:mm'));
+ }
+ }
+ });
+
+ test('date format correctness', function (assert) {
+ var data, tokens;
+ data = moment.localeData()._longDateFormat;
+ tokens = objectKeys(data);
+ each(tokens, function (srchToken) {
+ // Check each format string to make sure it does not contain any
+ // tokens that need to be expanded.
+ each(tokens, function (baseToken) {
+ // strip escaped sequences
+ var format = data[baseToken].replace(/(\[[^\]]*\])/g, '');
+ assert.equal(false, !!~format.indexOf(srchToken),
+ 'contains ' + srchToken + ' in ' + baseToken);
+ });
+ });
+ });
+
+ test('month parsing correctness', function (assert) {
+ var i, m;
+
+ if (locale === 'tr') {
+ // I can't fix it :(
+ expect(0);
+ return;
+ }
+ function tester(format) {
+ var r;
+ r = moment(m.format(format), format);
+ assert.equal(r.month(), m.month(), 'month ' + i + ' fmt ' + format);
+ r = moment(m.format(format).toLocaleUpperCase(), format);
+ assert.equal(r.month(), m.month(), 'month ' + i + ' fmt ' + format + ' upper');
+ r = moment(m.format(format).toLocaleLowerCase(), format);
+ assert.equal(r.month(), m.month(), 'month ' + i + ' fmt ' + format + ' lower');
+
+ r = moment(m.format(format), format, true);
+ assert.equal(r.month(), m.month(), 'month ' + i + ' fmt ' + format + ' strict');
+ r = moment(m.format(format).toLocaleUpperCase(), format, true);
+ assert.equal(r.month(), m.month(), 'month ' + i + ' fmt ' + format + ' upper strict');
+ r = moment(m.format(format).toLocaleLowerCase(), format, true);
+ assert.equal(r.month(), m.month(), 'month ' + i + ' fmt ' + format + ' lower strict');
+ }
+
+ for (i = 0; i < 12; ++i) {
+ m = moment([2015, i, 15, 18]);
+ tester('MMM');
+ tester('MMM.');
+ tester('MMMM');
+ tester('MMMM.');
+ }
+ });
+
+ test('weekday parsing correctness', function (assert) {
+ var i, m;
+
+ if (locale === 'tr' || locale === 'az') {
+ // There is a lower-case letter (ı), that converted to upper then
+ // lower changes to i
+ expect(0);
+ return;
+ }
+ function tester(format) {
+ var r, baseMsg = 'weekday ' + m.weekday() + ' fmt ' + format;
+ r = moment(m.format(format), format);
+ assert.equal(r.weekday(), m.weekday(), baseMsg);
+ r = moment(m.format(format).toLocaleUpperCase(), format);
+ assert.equal(r.weekday(), m.weekday(), baseMsg + ' upper');
+ r = moment(m.format(format).toLocaleLowerCase(), format);
+ assert.equal(r.weekday(), m.weekday(), baseMsg + ' lower');
+
+ r = moment(m.format(format), format, true);
+ assert.equal(r.weekday(), m.weekday(), baseMsg + ' strict');
+ r = moment(m.format(format).toLocaleUpperCase(), format, true);
+ assert.equal(r.weekday(), m.weekday(), baseMsg + ' upper strict');
+ r = moment(m.format(format).toLocaleLowerCase(), format, true);
+ assert.equal(r.weekday(), m.weekday(), baseMsg + ' lower strict');
+ }
+
+ for (i = 0; i < 7; ++i) {
+ m = moment.utc([2015, i, 15, 18]);
+ tester('dd');
+ tester('ddd');
+ tester('dddd');
+ }
+ });
+ }
+
+ function setupDeprecationHandler(test, moment, scope) {
+ test._expectedDeprecations = null;
+ test._observedDeprecations = null;
+ test._oldSupress = moment.suppressDeprecationWarnings;
+ moment.suppressDeprecationWarnings = true;
+ test.expectedDeprecations = function () {
+ test._expectedDeprecations = arguments;
+ test._observedDeprecations = [];
+ };
+ moment.deprecationHandler = function (name, msg) {
+ var deprecationId = matchedDeprecation(name, msg, test._expectedDeprecations);
+ if (deprecationId === -1) {
+ throw new Error('Unexpected deprecation thrown name=' +
+ name + ' msg=' + msg);
+ }
+ test._observedDeprecations[deprecationId] = 1;
+ };
+ }
+
+ function teardownDeprecationHandler(test, moment, scope) {
+ moment.suppressDeprecationWarnings = test._oldSupress;
+
+ if (test._expectedDeprecations != null) {
+ var missedDeprecations = [];
+ each(test._expectedDeprecations, function (deprecationPattern, id) {
+ if (test._observedDeprecations[id] !== 1) {
+ missedDeprecations.push(deprecationPattern);
+ }
+ });
+ if (missedDeprecations.length !== 0) {
+ throw new Error('Expected deprecation warnings did not happen: ' +
+ missedDeprecations.join(' '));
+ }
+ }
+ }
+
+ function matchedDeprecation(name, msg, deprecations) {
+ if (deprecations == null) {
+ return -1;
+ }
+ for (var i = 0; i < deprecations.length; ++i) {
+ if (name != null && name === deprecations[i]) {
+ return i;
+ }
+ if (msg != null && msg.substring(0, deprecations[i].length) === deprecations[i]) {
+ return i;
+ }
+ }
+ return -1;
+ }
/*global QUnit:false*/
@@ -2713,11 +3813,13 @@
moment.createFromInputFallback = function (config) {
throw new Error('input not handled by moment: ' + config._i);
};
+ setupDeprecationHandler(test, moment, 'core');
if (lifecycle && lifecycle.setup) {
lifecycle.setup();
}
},
teardown : function () {
+ teardownDeprecationHandler(test, moment, 'core');
if (lifecycle && lifecycle.teardown) {
lifecycle.teardown();
}
@@ -2732,17 +3834,20 @@
moment.createFromInputFallback = function (config) {
throw new Error('input not handled by moment: ' + config._i);
};
+ setupDeprecationHandler(test, moment, 'locale');
if (lifecycle && lifecycle.setup) {
lifecycle.setup();
}
},
teardown : function () {
moment.locale('en');
+ teardownDeprecationHandler(test, moment, 'locale');
if (lifecycle && lifecycle.teardown) {
lifecycle.teardown();
}
}
});
+ defineCommonLocaleTests(name, -1, -1);
}
localeModule('bg');
@@ -2897,14 +4002,14 @@
});
test('calendar day', function (assert) {
- var a = moment().hours(2).minutes(0).seconds(0);
-
- assert.equal(moment(a).calendar(), 'Днес в 2:00', 'today at the same time');
- assert.equal(moment(a).add({m: 25}).calendar(), 'Днес в 2:25', 'Now plus 25 min');
- assert.equal(moment(a).add({h: 1}).calendar(), 'Днес в 3:00', 'Now plus 1 hour');
- assert.equal(moment(a).add({d: 1}).calendar(), 'Утре в 2:00', 'tomorrow at the same time');
- assert.equal(moment(a).subtract({h: 1}).calendar(), 'Днес в 1:00', 'Now minus 1 hour');
- assert.equal(moment(a).subtract({d: 1}).calendar(), 'Вчера в 2:00', 'yesterday at the same time');
+ var a = moment().hours(12).minutes(0).seconds(0);
+
+ assert.equal(moment(a).calendar(), 'Днес в 12:00', 'today at the same time');
+ assert.equal(moment(a).add({m: 25}).calendar(), 'Днес в 12:25', 'Now plus 25 min');
+ assert.equal(moment(a).add({h: 1}).calendar(), 'Днес в 13:00', 'Now plus 1 hour');
+ assert.equal(moment(a).add({d: 1}).calendar(), 'Утре в 12:00', 'tomorrow at the same time');
+ assert.equal(moment(a).subtract({h: 1}).calendar(), 'Днес в 11:00', 'Now minus 1 hour');
+ assert.equal(moment(a).subtract({d: 1}).calendar(), 'Вчера в 12:00', 'yesterday at the same time');
});
test('calendar next week', function (assert) {
@@ -2960,67 +4065,6 @@
assert.equal(weeksFromNow.calendar(), weeksFromNow.format('L'), 'in 2 weeks');
});
- test('weeks year starting sunday', function (assert) {
- assert.equal(moment([2011, 11, 26]).week(), 1, 'Dec 26 2011 should be week 1');
- assert.equal(moment([2012, 0, 1]).week(), 1, 'Jan 1 2012 should be week 1');
- assert.equal(moment([2012, 0, 2]).week(), 2, 'Jan 2 2012 should be week 2');
- assert.equal(moment([2012, 0, 8]).week(), 2, 'Jan 8 2012 should be week 2');
- assert.equal(moment([2012, 0, 9]).week(), 3, 'Jan 9 2012 should be week 3');
- });
-
- test('weeks year starting monday', function (assert) {
- assert.equal(moment([2007, 0, 1]).week(), 1, 'Jan 1 2007 should be week 1');
- assert.equal(moment([2007, 0, 7]).week(), 1, 'Jan 7 2007 should be week 1');
- assert.equal(moment([2007, 0, 8]).week(), 2, 'Jan 8 2007 should be week 2');
- assert.equal(moment([2007, 0, 14]).week(), 2, 'Jan 14 2007 should be week 2');
- assert.equal(moment([2007, 0, 15]).week(), 3, 'Jan 15 2007 should be week 3');
- });
-
- test('weeks year starting tuesday', function (assert) {
- assert.equal(moment([2007, 11, 31]).week(), 1, 'Dec 31 2007 should be week 1');
- assert.equal(moment([2008, 0, 1]).week(), 1, 'Jan 1 2008 should be week 1');
- assert.equal(moment([2008, 0, 6]).week(), 1, 'Jan 6 2008 should be week 1');
- assert.equal(moment([2008, 0, 7]).week(), 2, 'Jan 7 2008 should be week 2');
- assert.equal(moment([2008, 0, 13]).week(), 2, 'Jan 13 2008 should be week 2');
- assert.equal(moment([2008, 0, 14]).week(), 3, 'Jan 14 2008 should be week 3');
- });
-
- test('weeks year starting wednesday', function (assert) {
- assert.equal(moment([2002, 11, 30]).week(), 1, 'Dec 30 2002 should be week 1');
- assert.equal(moment([2003, 0, 1]).week(), 1, 'Jan 1 2003 should be week 1');
- assert.equal(moment([2003, 0, 5]).week(), 1, 'Jan 5 2003 should be week 1');
- assert.equal(moment([2003, 0, 6]).week(), 2, 'Jan 6 2003 should be week 2');
- assert.equal(moment([2003, 0, 12]).week(), 2, 'Jan 12 2003 should be week 2');
- assert.equal(moment([2003, 0, 13]).week(), 3, 'Jan 13 2003 should be week 3');
- });
-
- test('weeks year starting thursday', function (assert) {
- assert.equal(moment([2008, 11, 29]).week(), 1, 'Dec 29 2008 should be week 1');
- assert.equal(moment([2009, 0, 1]).week(), 1, 'Jan 1 2009 should be week 1');
- assert.equal(moment([2009, 0, 4]).week(), 1, 'Jan 4 2009 should be week 1');
- assert.equal(moment([2009, 0, 5]).week(), 2, 'Jan 5 2009 should be week 2');
- assert.equal(moment([2009, 0, 11]).week(), 2, 'Jan 11 2009 should be week 2');
- assert.equal(moment([2009, 0, 12]).week(), 3, 'Jan 12 2009 should be week 3');
- });
-
- test('weeks year starting friday', function (assert) {
- assert.equal(moment([2009, 11, 28]).week(), 1, 'Dec 28 2009 should be week 1');
- assert.equal(moment([2010, 0, 1]).week(), 1, 'Jan 1 2010 should be week 1');
- assert.equal(moment([2010, 0, 3]).week(), 1, 'Jan 3 2010 should be week 1');
- assert.equal(moment([2010, 0, 4]).week(), 2, 'Jan 4 2010 should be week 2');
- assert.equal(moment([2010, 0, 10]).week(), 2, 'Jan 10 2010 should be week 2');
- assert.equal(moment([2010, 0, 11]).week(), 3, 'Jan 11 2010 should be week 3');
- });
-
- test('weeks year starting saturday', function (assert) {
- assert.equal(moment([2010, 11, 27]).week(), 1, 'Dec 27 2010 should be week 1');
- assert.equal(moment([2011, 0, 1]).week(), 1, 'Jan 1 2011 should be week 1');
- assert.equal(moment([2011, 0, 2]).week(), 1, 'Jan 2 2011 should be week 1');
- assert.equal(moment([2011, 0, 3]).week(), 2, 'Jan 3 2011 should be week 2');
- assert.equal(moment([2011, 0, 9]).week(), 2, 'Jan 9 2011 should be week 2');
- assert.equal(moment([2011, 0, 10]).week(), 3, 'Jan 10 2011 should be week 3');
- });
-
test('weeks year starting sunday formatted', function (assert) {
assert.equal(moment([2011, 11, 26]).format('w ww wo'), '1 01 1-ви', 'Dec 26 2011 should be week 1');
assert.equal(moment([2012, 0, 1]).format('w ww wo'), '1 01 1-ви', 'Jan 1 2012 should be week 1');
@@ -3029,42 +4073,6 @@
assert.equal(moment([2012, 0, 9]).format('w ww wo'), '3 03 3-ти', 'Jan 9 2012 should be week 3');
});
- test('lenient ordinal parsing', function (assert) {
- var i, ordinalStr, testMoment;
- for (i = 1; i <= 31; ++i) {
- ordinalStr = moment([2014, 0, i]).format('YYYY MM Do');
- testMoment = moment(ordinalStr, 'YYYY MM Do');
- assert.equal(testMoment.year(), 2014,
- 'lenient ordinal parsing ' + i + ' year check');
- assert.equal(testMoment.month(), 0,
- 'lenient ordinal parsing ' + i + ' month check');
- assert.equal(testMoment.date(), i,
- 'lenient ordinal parsing ' + i + ' date check');
- }
- });
-
- test('lenient ordinal parsing of number', function (assert) {
- var i, testMoment;
- for (i = 1; i <= 31; ++i) {
- testMoment = moment('2014 01 ' + i, 'YYYY MM Do');
- assert.equal(testMoment.year(), 2014,
- 'lenient ordinal parsing of number ' + i + ' year check');
- assert.equal(testMoment.month(), 0,
- 'lenient ordinal parsing of number ' + i + ' month check');
- assert.equal(testMoment.date(), i,
- 'lenient ordinal parsing of number ' + i + ' date check');
- }
- });
-
- test('strict ordinal parsing', function (assert) {
- var i, ordinalStr, testMoment;
- for (i = 1; i <= 31; ++i) {
- ordinalStr = moment([2014, 0, i]).format('YYYY MM Do');
- testMoment = moment(ordinalStr, 'YYYY MM Do', true);
- assert.ok(testMoment.isValid(), 'strict ordinal parsing ' + i);
- }
- });
-
}));
;(function (global, factory) {
@@ -3073,6 +4081,224 @@
typeof define === 'function' && define.amd ? define(['../../moment'], factory) :
factory(global.moment)
}(this, function (moment) { 'use strict';
+
+ function each(array, callback) {
+ var i;
+ for (i = 0; i < array.length; i++) {
+ callback(array[i], i, array);
+ }
+ }
+
+ function objectKeys(obj) {
+ if (Object.keys) {
+ return Object.keys(obj);
+ } else {
+ // IE8
+ var res = [], i;
+ for (i in obj) {
+ if (obj.hasOwnProperty(i)) {
+ res.push(i);
+ }
+ }
+ return res;
+ }
+ }
+
+ // Pick the first defined of two or three arguments.
+ function defaults(a, b, c) {
+ if (a != null) {
+ return a;
+ }
+ if (b != null) {
+ return b;
+ }
+ return c;
+ }
+
+ function defineCommonLocaleTests(locale, options) {
+ test('lenient ordinal parsing', function (assert) {
+ var i, ordinalStr, testMoment;
+ for (i = 1; i <= 31; ++i) {
+ ordinalStr = moment([2014, 0, i]).format('YYYY MM Do');
+ testMoment = moment(ordinalStr, 'YYYY MM Do');
+ assert.equal(testMoment.year(), 2014,
+ 'lenient ordinal parsing ' + i + ' year check');
+ assert.equal(testMoment.month(), 0,
+ 'lenient ordinal parsing ' + i + ' month check');
+ assert.equal(testMoment.date(), i,
+ 'lenient ordinal parsing ' + i + ' date check');
+ }
+ });
+
+ test('lenient ordinal parsing of number', function (assert) {
+ var i, testMoment;
+ for (i = 1; i <= 31; ++i) {
+ testMoment = moment('2014 01 ' + i, 'YYYY MM Do');
+ assert.equal(testMoment.year(), 2014,
+ 'lenient ordinal parsing of number ' + i + ' year check');
+ assert.equal(testMoment.month(), 0,
+ 'lenient ordinal parsing of number ' + i + ' month check');
+ assert.equal(testMoment.date(), i,
+ 'lenient ordinal parsing of number ' + i + ' date check');
+ }
+ });
+
+ test('strict ordinal parsing', function (assert) {
+ var i, ordinalStr, testMoment;
+ for (i = 1; i <= 31; ++i) {
+ ordinalStr = moment([2014, 0, i]).format('YYYY MM Do');
+ testMoment = moment(ordinalStr, 'YYYY MM Do', true);
+ assert.ok(testMoment.isValid(), 'strict ordinal parsing ' + i);
+ }
+ });
+
+ test('meridiem invariant', function (assert) {
+ var h, m, t1, t2;
+ for (h = 0; h < 24; ++h) {
+ for (m = 0; m < 60; m += 15) {
+ t1 = moment.utc([2000, 0, 1, h, m]);
+ t2 = moment.utc(t1.format('A h:mm'), 'A h:mm');
+ assert.equal(t2.format('HH:mm'), t1.format('HH:mm'),
+ 'meridiem at ' + t1.format('HH:mm'));
+ }
+ }
+ });
+
+ test('date format correctness', function (assert) {
+ var data, tokens;
+ data = moment.localeData()._longDateFormat;
+ tokens = objectKeys(data);
+ each(tokens, function (srchToken) {
+ // Check each format string to make sure it does not contain any
+ // tokens that need to be expanded.
+ each(tokens, function (baseToken) {
+ // strip escaped sequences
+ var format = data[baseToken].replace(/(\[[^\]]*\])/g, '');
+ assert.equal(false, !!~format.indexOf(srchToken),
+ 'contains ' + srchToken + ' in ' + baseToken);
+ });
+ });
+ });
+
+ test('month parsing correctness', function (assert) {
+ var i, m;
+
+ if (locale === 'tr') {
+ // I can't fix it :(
+ expect(0);
+ return;
+ }
+ function tester(format) {
+ var r;
+ r = moment(m.format(format), format);
+ assert.equal(r.month(), m.month(), 'month ' + i + ' fmt ' + format);
+ r = moment(m.format(format).toLocaleUpperCase(), format);
+ assert.equal(r.month(), m.month(), 'month ' + i + ' fmt ' + format + ' upper');
+ r = moment(m.format(format).toLocaleLowerCase(), format);
+ assert.equal(r.month(), m.month(), 'month ' + i + ' fmt ' + format + ' lower');
+
+ r = moment(m.format(format), format, true);
+ assert.equal(r.month(), m.month(), 'month ' + i + ' fmt ' + format + ' strict');
+ r = moment(m.format(format).toLocaleUpperCase(), format, true);
+ assert.equal(r.month(), m.month(), 'month ' + i + ' fmt ' + format + ' upper strict');
+ r = moment(m.format(format).toLocaleLowerCase(), format, true);
+ assert.equal(r.month(), m.month(), 'month ' + i + ' fmt ' + format + ' lower strict');
+ }
+
+ for (i = 0; i < 12; ++i) {
+ m = moment([2015, i, 15, 18]);
+ tester('MMM');
+ tester('MMM.');
+ tester('MMMM');
+ tester('MMMM.');
+ }
+ });
+
+ test('weekday parsing correctness', function (assert) {
+ var i, m;
+
+ if (locale === 'tr' || locale === 'az') {
+ // There is a lower-case letter (ı), that converted to upper then
+ // lower changes to i
+ expect(0);
+ return;
+ }
+ function tester(format) {
+ var r, baseMsg = 'weekday ' + m.weekday() + ' fmt ' + format;
+ r = moment(m.format(format), format);
+ assert.equal(r.weekday(), m.weekday(), baseMsg);
+ r = moment(m.format(format).toLocaleUpperCase(), format);
+ assert.equal(r.weekday(), m.weekday(), baseMsg + ' upper');
+ r = moment(m.format(format).toLocaleLowerCase(), format);
+ assert.equal(r.weekday(), m.weekday(), baseMsg + ' lower');
+
+ r = moment(m.format(format), format, true);
+ assert.equal(r.weekday(), m.weekday(), baseMsg + ' strict');
+ r = moment(m.format(format).toLocaleUpperCase(), format, true);
+ assert.equal(r.weekday(), m.weekday(), baseMsg + ' upper strict');
+ r = moment(m.format(format).toLocaleLowerCase(), format, true);
+ assert.equal(r.weekday(), m.weekday(), baseMsg + ' lower strict');
+ }
+
+ for (i = 0; i < 7; ++i) {
+ m = moment.utc([2015, i, 15, 18]);
+ tester('dd');
+ tester('ddd');
+ tester('dddd');
+ }
+ });
+ }
+
+ function setupDeprecationHandler(test, moment, scope) {
+ test._expectedDeprecations = null;
+ test._observedDeprecations = null;
+ test._oldSupress = moment.suppressDeprecationWarnings;
+ moment.suppressDeprecationWarnings = true;
+ test.expectedDeprecations = function () {
+ test._expectedDeprecations = arguments;
+ test._observedDeprecations = [];
+ };
+ moment.deprecationHandler = function (name, msg) {
+ var deprecationId = matchedDeprecation(name, msg, test._expectedDeprecations);
+ if (deprecationId === -1) {
+ throw new Error('Unexpected deprecation thrown name=' +
+ name + ' msg=' + msg);
+ }
+ test._observedDeprecations[deprecationId] = 1;
+ };
+ }
+
+ function teardownDeprecationHandler(test, moment, scope) {
+ moment.suppressDeprecationWarnings = test._oldSupress;
+
+ if (test._expectedDeprecations != null) {
+ var missedDeprecations = [];
+ each(test._expectedDeprecations, function (deprecationPattern, id) {
+ if (test._observedDeprecations[id] !== 1) {
+ missedDeprecations.push(deprecationPattern);
+ }
+ });
+ if (missedDeprecations.length !== 0) {
+ throw new Error('Expected deprecation warnings did not happen: ' +
+ missedDeprecations.join(' '));
+ }
+ }
+ }
+
+ function matchedDeprecation(name, msg, deprecations) {
+ if (deprecations == null) {
+ return -1;
+ }
+ for (var i = 0; i < deprecations.length; ++i) {
+ if (name != null && name === deprecations[i]) {
+ return i;
+ }
+ if (msg != null && msg.substring(0, deprecations[i].length) === deprecations[i]) {
+ return i;
+ }
+ }
+ return -1;
+ }
/*global QUnit:false*/
@@ -3087,11 +4313,13 @@
moment.createFromInputFallback = function (config) {
throw new Error('input not handled by moment: ' + config._i);
};
+ setupDeprecationHandler(test, moment, 'core');
if (lifecycle && lifecycle.setup) {
lifecycle.setup();
}
},
teardown : function () {
+ teardownDeprecationHandler(test, moment, 'core');
if (lifecycle && lifecycle.teardown) {
lifecycle.teardown();
}
@@ -3106,17 +4334,20 @@
moment.createFromInputFallback = function (config) {
throw new Error('input not handled by moment: ' + config._i);
};
+ setupDeprecationHandler(test, moment, 'locale');
if (lifecycle && lifecycle.setup) {
lifecycle.setup();
}
},
teardown : function () {
moment.locale('en');
+ teardownDeprecationHandler(test, moment, 'locale');
if (lifecycle && lifecycle.teardown) {
lifecycle.teardown();
}
}
});
+ defineCommonLocaleTests(name, -1, -1);
}
localeModule('bn');
@@ -3269,14 +4500,14 @@
});
test('calendar day', function (assert) {
- var a = moment().hours(2).minutes(0).seconds(0);
-
- assert.equal(moment(a).calendar(), 'আজ রাত ২:০০ সময়', 'today at the same time');
- assert.equal(moment(a).add({m: 25}).calendar(), 'আজ রাত ২:২৫ সময়', 'Now plus 25 min');
- assert.equal(moment(a).add({h: 3}).calendar(), 'আজ সকাল ৫:০০ সময়', 'Now plus 3 hour');
- assert.equal(moment(a).add({d: 1}).calendar(), 'আগামীকাল রাত ২:০০ সময়', 'tomorrow at the same time');
- assert.equal(moment(a).subtract({h: 1}).calendar(), 'আজ রাত ১:০০ সময়', 'Now minus 1 hour');
- assert.equal(moment(a).subtract({d: 1}).calendar(), 'গতকাল রাত ২:০০ সময়', 'yesterday at the same time');
+ var a = moment().hours(12).minutes(0).seconds(0);
+
+ assert.equal(moment(a).calendar(), 'আজ দুপুর ১২:০০ সময়', 'today at the same time');
+ assert.equal(moment(a).add({m: 25}).calendar(), 'আজ দুপুর ১২:২৫ সময়', 'Now plus 25 min');
+ assert.equal(moment(a).add({h: 3}).calendar(), 'আজ দুপুর ৩:০০ সময়', 'Now plus 3 hours');
+ assert.equal(moment(a).add({d: 1}).calendar(), 'আগামীকাল দুপুর ১২:০০ সময়', 'tomorrow at the same time');
+ assert.equal(moment(a).subtract({h: 1}).calendar(), 'আজ দুপুর ১১:০০ সময়', 'Now minus 1 hour');
+ assert.equal(moment(a).subtract({d: 1}).calendar(), 'গতকাল দুপুর ১২:০০ সময়', 'yesterday at the same time');
});
test('calendar next week', function (assert) {
@@ -3334,67 +4565,6 @@
assert.equal(moment([2011, 2, 23, 21, 20]).format('A'), 'রাত', 'night');
});
- test('weeks year starting sunday', function (assert) {
- assert.equal(moment([2012, 0, 1]).week(), 1, 'Jan 1 2012 should be week 1');
- assert.equal(moment([2012, 0, 7]).week(), 1, 'Jan 7 2012 should be week 1');
- assert.equal(moment([2012, 0, 8]).week(), 2, 'Jan 8 2012 should be week 2');
- assert.equal(moment([2012, 0, 14]).week(), 2, 'Jan 14 2012 should be week 2');
- assert.equal(moment([2012, 0, 15]).week(), 3, 'Jan 15 2012 should be week 3');
- });
-
- test('weeks year starting monday', function (assert) {
- assert.equal(moment([2006, 11, 31]).week(), 1, 'Dec 31 2006 should be week 1');
- assert.equal(moment([2007, 0, 1]).week(), 1, 'Jan 1 2007 should be week 1');
- assert.equal(moment([2007, 0, 6]).week(), 1, 'Jan 6 2007 should be week 1');
- assert.equal(moment([2007, 0, 7]).week(), 2, 'Jan 7 2007 should be week 2');
- assert.equal(moment([2007, 0, 13]).week(), 2, 'Jan 13 2007 should be week 2');
- assert.equal(moment([2007, 0, 14]).week(), 3, 'Jan 14 2007 should be week 3');
- });
-
- test('weeks year starting tuesday', function (assert) {
- assert.equal(moment([2007, 11, 29]).week(), 52, 'Dec 29 2007 should be week 52');
- assert.equal(moment([2008, 0, 1]).week(), 1, 'Jan 1 2008 should be week 1');
- assert.equal(moment([2008, 0, 5]).week(), 1, 'Jan 5 2008 should be week 1');
- assert.equal(moment([2008, 0, 6]).week(), 2, 'Jan 6 2008 should be week 2');
- assert.equal(moment([2008, 0, 12]).week(), 2, 'Jan 12 2008 should be week 2');
- assert.equal(moment([2008, 0, 13]).week(), 3, 'Jan 13 2008 should be week 3');
- });
-
- test('weeks year starting wednesday', function (assert) {
- assert.equal(moment([2002, 11, 29]).week(), 1, 'Dec 29 2002 should be week 1');
- assert.equal(moment([2003, 0, 1]).week(), 1, 'Jan 1 2003 should be week 1');
- assert.equal(moment([2003, 0, 4]).week(), 1, 'Jan 4 2003 should be week 1');
- assert.equal(moment([2003, 0, 5]).week(), 2, 'Jan 5 2003 should be week 2');
- assert.equal(moment([2003, 0, 11]).week(), 2, 'Jan 11 2003 should be week 2');
- assert.equal(moment([2003, 0, 12]).week(), 3, 'Jan 12 2003 should be week 3');
- });
-
- test('weeks year starting thursday', function (assert) {
- assert.equal(moment([2008, 11, 28]).week(), 1, 'Dec 28 2008 should be week 1');
- assert.equal(moment([2009, 0, 1]).week(), 1, 'Jan 1 2009 should be week 1');
- assert.equal(moment([2009, 0, 3]).week(), 1, 'Jan 3 2009 should be week 1');
- assert.equal(moment([2009, 0, 4]).week(), 2, 'Jan 4 2009 should be week 2');
- assert.equal(moment([2009, 0, 10]).week(), 2, 'Jan 10 2009 should be week 2');
- assert.equal(moment([2009, 0, 11]).week(), 3, 'Jan 11 2009 should be week 3');
- });
-
- test('weeks year starting friday', function (assert) {
- assert.equal(moment([2009, 11, 27]).week(), 1, 'Dec 27 2009 should be week 1');
- assert.equal(moment([2010, 0, 1]).week(), 1, 'Jan 1 2010 should be week 1');
- assert.equal(moment([2010, 0, 2]).week(), 1, 'Jan 2 2010 should be week 1');
- assert.equal(moment([2010, 0, 3]).week(), 2, 'Jan 3 2010 should be week 2');
- assert.equal(moment([2010, 0, 9]).week(), 2, 'Jan 9 2010 should be week 2');
- assert.equal(moment([2010, 0, 10]).week(), 3, 'Jan 10 2010 should be week 3');
- });
-
- test('weeks year starting saturday', function (assert) {
- assert.equal(moment([2010, 11, 26]).week(), 1, 'Dec 26 2010 should be week 1');
- assert.equal(moment([2011, 0, 1]).week(), 1, 'Jan 1 2011 should be week 1');
- assert.equal(moment([2011, 0, 2]).week(), 2, 'Jan 2 2011 should be week 2');
- assert.equal(moment([2011, 0, 8]).week(), 2, 'Jan 8 2011 should be week 2');
- assert.equal(moment([2011, 0, 9]).week(), 3, 'Jan 9 2011 should be week 3');
- });
-
test('weeks year starting sunday formatted', function (assert) {
assert.equal(moment([2012, 0, 1]).format('w ww wo'), '১ ০১ ১', 'Jan 1 2012 should be week 1');
assert.equal(moment([2012, 0, 7]).format('w ww wo'), '১ ০১ ১', 'Jan 7 2012 should be week 1');
@@ -3403,42 +4573,6 @@
assert.equal(moment([2012, 0, 15]).format('w ww wo'), '৩ ০৩ ৩', 'Jan 15 2012 should be week 3');
});
- test('lenient ordinal parsing', function (assert) {
- var i, ordinalStr, testMoment;
- for (i = 1; i <= 31; ++i) {
- ordinalStr = moment([2014, 0, i]).format('YYYY MM Do');
- testMoment = moment(ordinalStr, 'YYYY MM Do');
- assert.equal(testMoment.year(), 2014,
- 'lenient ordinal parsing ' + i + ' year check');
- assert.equal(testMoment.month(), 0,
- 'lenient ordinal parsing ' + i + ' month check');
- assert.equal(testMoment.date(), i,
- 'lenient ordinal parsing ' + i + ' date check');
- }
- });
-
- test('lenient ordinal parsing of number', function (assert) {
- var i, testMoment;
- for (i = 1; i <= 31; ++i) {
- testMoment = moment('2014 01 ' + i, 'YYYY MM Do');
- assert.equal(testMoment.year(), 2014,
- 'lenient ordinal parsing of number ' + i + ' year check');
- assert.equal(testMoment.month(), 0,
- 'lenient ordinal parsing of number ' + i + ' month check');
- assert.equal(testMoment.date(), i,
- 'lenient ordinal parsing of number ' + i + ' date check');
- }
- });
-
- test('strict ordinal parsing', function (assert) {
- var i, ordinalStr, testMoment;
- for (i = 1; i <= 31; ++i) {
- ordinalStr = moment([2014, 0, i]).format('YYYY MM Do');
- testMoment = moment(ordinalStr, 'YYYY MM Do', true);
- assert.ok(testMoment.isValid(), 'strict ordinal parsing ' + i);
- }
- });
-
}));
;(function (global, factory) {
@@ -3447,6 +4581,224 @@
typeof define === 'function' && define.amd ? define(['../../moment'], factory) :
factory(global.moment)
}(this, function (moment) { 'use strict';
+
+ function each(array, callback) {
+ var i;
+ for (i = 0; i < array.length; i++) {
+ callback(array[i], i, array);
+ }
+ }
+
+ function objectKeys(obj) {
+ if (Object.keys) {
+ return Object.keys(obj);
+ } else {
+ // IE8
+ var res = [], i;
+ for (i in obj) {
+ if (obj.hasOwnProperty(i)) {
+ res.push(i);
+ }
+ }
+ return res;
+ }
+ }
+
+ // Pick the first defined of two or three arguments.
+ function defaults(a, b, c) {
+ if (a != null) {
+ return a;
+ }
+ if (b != null) {
+ return b;
+ }
+ return c;
+ }
+
+ function defineCommonLocaleTests(locale, options) {
+ test('lenient ordinal parsing', function (assert) {
+ var i, ordinalStr, testMoment;
+ for (i = 1; i <= 31; ++i) {
+ ordinalStr = moment([2014, 0, i]).format('YYYY MM Do');
+ testMoment = moment(ordinalStr, 'YYYY MM Do');
+ assert.equal(testMoment.year(), 2014,
+ 'lenient ordinal parsing ' + i + ' year check');
+ assert.equal(testMoment.month(), 0,
+ 'lenient ordinal parsing ' + i + ' month check');
+ assert.equal(testMoment.date(), i,
+ 'lenient ordinal parsing ' + i + ' date check');
+ }
+ });
+
+ test('lenient ordinal parsing of number', function (assert) {
+ var i, testMoment;
+ for (i = 1; i <= 31; ++i) {
+ testMoment = moment('2014 01 ' + i, 'YYYY MM Do');
+ assert.equal(testMoment.year(), 2014,
+ 'lenient ordinal parsing of number ' + i + ' year check');
+ assert.equal(testMoment.month(), 0,
+ 'lenient ordinal parsing of number ' + i + ' month check');
+ assert.equal(testMoment.date(), i,
+ 'lenient ordinal parsing of number ' + i + ' date check');
+ }
+ });
+
+ test('strict ordinal parsing', function (assert) {
+ var i, ordinalStr, testMoment;
+ for (i = 1; i <= 31; ++i) {
+ ordinalStr = moment([2014, 0, i]).format('YYYY MM Do');
+ testMoment = moment(ordinalStr, 'YYYY MM Do', true);
+ assert.ok(testMoment.isValid(), 'strict ordinal parsing ' + i);
+ }
+ });
+
+ test('meridiem invariant', function (assert) {
+ var h, m, t1, t2;
+ for (h = 0; h < 24; ++h) {
+ for (m = 0; m < 60; m += 15) {
+ t1 = moment.utc([2000, 0, 1, h, m]);
+ t2 = moment.utc(t1.format('A h:mm'), 'A h:mm');
+ assert.equal(t2.format('HH:mm'), t1.format('HH:mm'),
+ 'meridiem at ' + t1.format('HH:mm'));
+ }
+ }
+ });
+
+ test('date format correctness', function (assert) {
+ var data, tokens;
+ data = moment.localeData()._longDateFormat;
+ tokens = objectKeys(data);
+ each(tokens, function (srchToken) {
+ // Check each format string to make sure it does not contain any
+ // tokens that need to be expanded.
+ each(tokens, function (baseToken) {
+ // strip escaped sequences
+ var format = data[baseToken].replace(/(\[[^\]]*\])/g, '');
+ assert.equal(false, !!~format.indexOf(srchToken),
+ 'contains ' + srchToken + ' in ' + baseToken);
+ });
+ });
+ });
+
+ test('month parsing correctness', function (assert) {
+ var i, m;
+
+ if (locale === 'tr') {
+ // I can't fix it :(
+ expect(0);
+ return;
+ }
+ function tester(format) {
+ var r;
+ r = moment(m.format(format), format);
+ assert.equal(r.month(), m.month(), 'month ' + i + ' fmt ' + format);
+ r = moment(m.format(format).toLocaleUpperCase(), format);
+ assert.equal(r.month(), m.month(), 'month ' + i + ' fmt ' + format + ' upper');
+ r = moment(m.format(format).toLocaleLowerCase(), format);
+ assert.equal(r.month(), m.month(), 'month ' + i + ' fmt ' + format + ' lower');
+
+ r = moment(m.format(format), format, true);
+ assert.equal(r.month(), m.month(), 'month ' + i + ' fmt ' + format + ' strict');
+ r = moment(m.format(format).toLocaleUpperCase(), format, true);
+ assert.equal(r.month(), m.month(), 'month ' + i + ' fmt ' + format + ' upper strict');
+ r = moment(m.format(format).toLocaleLowerCase(), format, true);
+ assert.equal(r.month(), m.month(), 'month ' + i + ' fmt ' + format + ' lower strict');
+ }
+
+ for (i = 0; i < 12; ++i) {
+ m = moment([2015, i, 15, 18]);
+ tester('MMM');
+ tester('MMM.');
+ tester('MMMM');
+ tester('MMMM.');
+ }
+ });
+
+ test('weekday parsing correctness', function (assert) {
+ var i, m;
+
+ if (locale === 'tr' || locale === 'az') {
+ // There is a lower-case letter (ı), that converted to upper then
+ // lower changes to i
+ expect(0);
+ return;
+ }
+ function tester(format) {
+ var r, baseMsg = 'weekday ' + m.weekday() + ' fmt ' + format;
+ r = moment(m.format(format), format);
+ assert.equal(r.weekday(), m.weekday(), baseMsg);
+ r = moment(m.format(format).toLocaleUpperCase(), format);
+ assert.equal(r.weekday(), m.weekday(), baseMsg + ' upper');
+ r = moment(m.format(format).toLocaleLowerCase(), format);
+ assert.equal(r.weekday(), m.weekday(), baseMsg + ' lower');
+
+ r = moment(m.format(format), format, true);
+ assert.equal(r.weekday(), m.weekday(), baseMsg + ' strict');
+ r = moment(m.format(format).toLocaleUpperCase(), format, true);
+ assert.equal(r.weekday(), m.weekday(), baseMsg + ' upper strict');
+ r = moment(m.format(format).toLocaleLowerCase(), format, true);
+ assert.equal(r.weekday(), m.weekday(), baseMsg + ' lower strict');
+ }
+
+ for (i = 0; i < 7; ++i) {
+ m = moment.utc([2015, i, 15, 18]);
+ tester('dd');
+ tester('ddd');
+ tester('dddd');
+ }
+ });
+ }
+
+ function setupDeprecationHandler(test, moment, scope) {
+ test._expectedDeprecations = null;
+ test._observedDeprecations = null;
+ test._oldSupress = moment.suppressDeprecationWarnings;
+ moment.suppressDeprecationWarnings = true;
+ test.expectedDeprecations = function () {
+ test._expectedDeprecations = arguments;
+ test._observedDeprecations = [];
+ };
+ moment.deprecationHandler = function (name, msg) {
+ var deprecationId = matchedDeprecation(name, msg, test._expectedDeprecations);
+ if (deprecationId === -1) {
+ throw new Error('Unexpected deprecation thrown name=' +
+ name + ' msg=' + msg);
+ }
+ test._observedDeprecations[deprecationId] = 1;
+ };
+ }
+
+ function teardownDeprecationHandler(test, moment, scope) {
+ moment.suppressDeprecationWarnings = test._oldSupress;
+
+ if (test._expectedDeprecations != null) {
+ var missedDeprecations = [];
+ each(test._expectedDeprecations, function (deprecationPattern, id) {
+ if (test._observedDeprecations[id] !== 1) {
+ missedDeprecations.push(deprecationPattern);
+ }
+ });
+ if (missedDeprecations.length !== 0) {
+ throw new Error('Expected deprecation warnings did not happen: ' +
+ missedDeprecations.join(' '));
+ }
+ }
+ }
+
+ function matchedDeprecation(name, msg, deprecations) {
+ if (deprecations == null) {
+ return -1;
+ }
+ for (var i = 0; i < deprecations.length; ++i) {
+ if (name != null && name === deprecations[i]) {
+ return i;
+ }
+ if (msg != null && msg.substring(0, deprecations[i].length) === deprecations[i]) {
+ return i;
+ }
+ }
+ return -1;
+ }
/*global QUnit:false*/
@@ -3461,11 +4813,13 @@
moment.createFromInputFallback = function (config) {
throw new Error('input not handled by moment: ' + config._i);
};
+ setupDeprecationHandler(test, moment, 'core');
if (lifecycle && lifecycle.setup) {
lifecycle.setup();
}
},
teardown : function () {
+ teardownDeprecationHandler(test, moment, 'core');
if (lifecycle && lifecycle.teardown) {
lifecycle.teardown();
}
@@ -3480,17 +4834,20 @@
moment.createFromInputFallback = function (config) {
throw new Error('input not handled by moment: ' + config._i);
};
+ setupDeprecationHandler(test, moment, 'locale');
if (lifecycle && lifecycle.setup) {
lifecycle.setup();
}
},
teardown : function () {
moment.locale('en');
+ teardownDeprecationHandler(test, moment, 'locale');
if (lifecycle && lifecycle.teardown) {
lifecycle.teardown();
}
}
});
+ defineCommonLocaleTests(name, -1, -1);
}
localeModule('bo');
@@ -3644,14 +5001,14 @@
});
test('calendar day', function (assert) {
- var a = moment().hours(2).minutes(0).seconds(0);
-
- assert.equal(moment(a).calendar(), 'དི་རིང མཚན་མོ ༢:༠༠', 'today at the same time');
- assert.equal(moment(a).add({m: 25}).calendar(), 'དི་རིང མཚན་མོ ༢:༢༥', 'Now plus 25 min');
- assert.equal(moment(a).add({h: 3}).calendar(), 'དི་རིང ཞོགས་ཀས ༥:༠༠', 'Now plus 3 hour');
- assert.equal(moment(a).add({d: 1}).calendar(), 'སང་ཉིན མཚན་མོ ༢:༠༠', 'tomorrow at the same time');
- assert.equal(moment(a).subtract({h: 1}).calendar(), 'དི་རིང མཚན་མོ ༡:༠༠', 'Now minus 1 hour');
- assert.equal(moment(a).subtract({d: 1}).calendar(), 'ཁ་སང མཚན་མོ ༢:༠༠', 'yesterday at the same time');
+ var a = moment().hours(12).minutes(0).seconds(0);
+
+ assert.equal(moment(a).calendar(), 'དི་རིང ཉིན་གུང ༡༢:༠༠', 'today at the same time');
+ assert.equal(moment(a).add({m: 25}).calendar(), 'དི་རིང ཉིན་གུང ༡༢:༢༥', 'Now plus 25 min');
+ assert.equal(moment(a).add({h: 3}).calendar(), 'དི་རིང ཉིན་གུང ༣:༠༠', 'Now plus 3 hours');
+ assert.equal(moment(a).add({d: 1}).calendar(), 'སང་ཉིན ཉིན་གུང ༡༢:༠༠', 'tomorrow at the same time');
+ assert.equal(moment(a).subtract({h: 1}).calendar(), 'དི་རིང ཉིན་གུང ༡༡:༠༠', 'Now minus 1 hour');
+ assert.equal(moment(a).subtract({d: 1}).calendar(), 'ཁ་སང ཉིན་གུང ༡༢:༠༠', 'yesterday at the same time');
});
test('calendar next week', function (assert) {
@@ -3709,67 +5066,6 @@
assert.equal(moment([2011, 2, 23, 21, 20]).format('A'), 'མཚན་མོ', 'night');
});
- test('weeks year starting sunday', function (assert) {
- assert.equal(moment([2012, 0, 1]).week(), 1, 'Jan 1 2012 should be week 1');
- assert.equal(moment([2012, 0, 7]).week(), 1, 'Jan 7 2012 should be week 1');
- assert.equal(moment([2012, 0, 8]).week(), 2, 'Jan 8 2012 should be week 2');
- assert.equal(moment([2012, 0, 14]).week(), 2, 'Jan 14 2012 should be week 2');
- assert.equal(moment([2012, 0, 15]).week(), 3, 'Jan 15 2012 should be week 3');
- });
-
- test('weeks year starting monday', function (assert) {
- assert.equal(moment([2006, 11, 31]).week(), 1, 'Dec 31 2006 should be week 1');
- assert.equal(moment([2007, 0, 1]).week(), 1, 'Jan 1 2007 should be week 1');
- assert.equal(moment([2007, 0, 6]).week(), 1, 'Jan 6 2007 should be week 1');
- assert.equal(moment([2007, 0, 7]).week(), 2, 'Jan 7 2007 should be week 2');
- assert.equal(moment([2007, 0, 13]).week(), 2, 'Jan 13 2007 should be week 2');
- assert.equal(moment([2007, 0, 14]).week(), 3, 'Jan 14 2007 should be week 3');
- });
-
- test('weeks year starting tuesday', function (assert) {
- assert.equal(moment([2007, 11, 29]).week(), 52, 'Dec 29 2007 should be week 52');
- assert.equal(moment([2008, 0, 1]).week(), 1, 'Jan 1 2008 should be week 1');
- assert.equal(moment([2008, 0, 5]).week(), 1, 'Jan 5 2008 should be week 1');
- assert.equal(moment([2008, 0, 6]).week(), 2, 'Jan 6 2008 should be week 2');
- assert.equal(moment([2008, 0, 12]).week(), 2, 'Jan 12 2008 should be week 2');
- assert.equal(moment([2008, 0, 13]).week(), 3, 'Jan 13 2008 should be week 3');
- });
-
- test('weeks year starting wednesday', function (assert) {
- assert.equal(moment([2002, 11, 29]).week(), 1, 'Dec 29 2002 should be week 1');
- assert.equal(moment([2003, 0, 1]).week(), 1, 'Jan 1 2003 should be week 1');
- assert.equal(moment([2003, 0, 4]).week(), 1, 'Jan 4 2003 should be week 1');
- assert.equal(moment([2003, 0, 5]).week(), 2, 'Jan 5 2003 should be week 2');
- assert.equal(moment([2003, 0, 11]).week(), 2, 'Jan 11 2003 should be week 2');
- assert.equal(moment([2003, 0, 12]).week(), 3, 'Jan 12 2003 should be week 3');
- });
-
- test('weeks year starting thursday', function (assert) {
- assert.equal(moment([2008, 11, 28]).week(), 1, 'Dec 28 2008 should be week 1');
- assert.equal(moment([2009, 0, 1]).week(), 1, 'Jan 1 2009 should be week 1');
- assert.equal(moment([2009, 0, 3]).week(), 1, 'Jan 3 2009 should be week 1');
- assert.equal(moment([2009, 0, 4]).week(), 2, 'Jan 4 2009 should be week 2');
- assert.equal(moment([2009, 0, 10]).week(), 2, 'Jan 10 2009 should be week 2');
- assert.equal(moment([2009, 0, 11]).week(), 3, 'Jan 11 2009 should be week 3');
- });
-
- test('weeks year starting friday', function (assert) {
- assert.equal(moment([2009, 11, 27]).week(), 1, 'Dec 27 2009 should be week 1');
- assert.equal(moment([2010, 0, 1]).week(), 1, 'Jan 1 2010 should be week 1');
- assert.equal(moment([2010, 0, 2]).week(), 1, 'Jan 2 2010 should be week 1');
- assert.equal(moment([2010, 0, 3]).week(), 2, 'Jan 3 2010 should be week 2');
- assert.equal(moment([2010, 0, 9]).week(), 2, 'Jan 9 2010 should be week 2');
- assert.equal(moment([2010, 0, 10]).week(), 3, 'Jan 10 2010 should be week 3');
- });
-
- test('weeks year starting saturday', function (assert) {
- assert.equal(moment([2010, 11, 26]).week(), 1, 'Dec 26 2010 should be week 1');
- assert.equal(moment([2011, 0, 1]).week(), 1, 'Jan 1 2011 should be week 1');
- assert.equal(moment([2011, 0, 2]).week(), 2, 'Jan 2 2011 should be week 2');
- assert.equal(moment([2011, 0, 8]).week(), 2, 'Jan 8 2011 should be week 2');
- assert.equal(moment([2011, 0, 9]).week(), 3, 'Jan 9 2011 should be week 3');
- });
-
test('weeks year starting sunday formatted', function (assert) {
assert.equal(moment([2012, 0, 1]).format('w ww wo'), '༡ ༠༡ ༡', 'Jan 1 2012 should be week 1');
assert.equal(moment([2012, 0, 7]).format('w ww wo'), '༡ ༠༡ ༡', 'Jan 7 2012 should be week 1');
@@ -3778,42 +5074,6 @@
assert.equal(moment([2012, 0, 15]).format('w ww wo'), '༣ ༠༣ ༣', 'Jan 15 2012 should be week 3');
});
- test('lenient ordinal parsing', function (assert) {
- var i, ordinalStr, testMoment;
- for (i = 1; i <= 31; ++i) {
- ordinalStr = moment([2014, 0, i]).format('YYYY MM Do');
- testMoment = moment(ordinalStr, 'YYYY MM Do');
- assert.equal(testMoment.year(), 2014,
- 'lenient ordinal parsing ' + i + ' year check');
- assert.equal(testMoment.month(), 0,
- 'lenient ordinal parsing ' + i + ' month check');
- assert.equal(testMoment.date(), i,
- 'lenient ordinal parsing ' + i + ' date check');
- }
- });
-
- test('lenient ordinal parsing of number', function (assert) {
- var i, testMoment;
- for (i = 1; i <= 31; ++i) {
- testMoment = moment('2014 01 ' + i, 'YYYY MM Do');
- assert.equal(testMoment.year(), 2014,
- 'lenient ordinal parsing of number ' + i + ' year check');
- assert.equal(testMoment.month(), 0,
- 'lenient ordinal parsing of number ' + i + ' month check');
- assert.equal(testMoment.date(), i,
- 'lenient ordinal parsing of number ' + i + ' date check');
- }
- });
-
- test('strict ordinal parsing', function (assert) {
- var i, ordinalStr, testMoment;
- for (i = 1; i <= 31; ++i) {
- ordinalStr = moment([2014, 0, i]).format('YYYY MM Do');
- testMoment = moment(ordinalStr, 'YYYY MM Do', true);
- assert.ok(testMoment.isValid(), 'strict ordinal parsing ' + i);
- }
- });
-
}));
;(function (global, factory) {
@@ -3822,6 +5082,224 @@
typeof define === 'function' && define.amd ? define(['../../moment'], factory) :
factory(global.moment)
}(this, function (moment) { 'use strict';
+
+ function each(array, callback) {
+ var i;
+ for (i = 0; i < array.length; i++) {
+ callback(array[i], i, array);
+ }
+ }
+
+ function objectKeys(obj) {
+ if (Object.keys) {
+ return Object.keys(obj);
+ } else {
+ // IE8
+ var res = [], i;
+ for (i in obj) {
+ if (obj.hasOwnProperty(i)) {
+ res.push(i);
+ }
+ }
+ return res;
+ }
+ }
+
+ // Pick the first defined of two or three arguments.
+ function defaults(a, b, c) {
+ if (a != null) {
+ return a;
+ }
+ if (b != null) {
+ return b;
+ }
+ return c;
+ }
+
+ function defineCommonLocaleTests(locale, options) {
+ test('lenient ordinal parsing', function (assert) {
+ var i, ordinalStr, testMoment;
+ for (i = 1; i <= 31; ++i) {
+ ordinalStr = moment([2014, 0, i]).format('YYYY MM Do');
+ testMoment = moment(ordinalStr, 'YYYY MM Do');
+ assert.equal(testMoment.year(), 2014,
+ 'lenient ordinal parsing ' + i + ' year check');
+ assert.equal(testMoment.month(), 0,
+ 'lenient ordinal parsing ' + i + ' month check');
+ assert.equal(testMoment.date(), i,
+ 'lenient ordinal parsing ' + i + ' date check');
+ }
+ });
+
+ test('lenient ordinal parsing of number', function (assert) {
+ var i, testMoment;
+ for (i = 1; i <= 31; ++i) {
+ testMoment = moment('2014 01 ' + i, 'YYYY MM Do');
+ assert.equal(testMoment.year(), 2014,
+ 'lenient ordinal parsing of number ' + i + ' year check');
+ assert.equal(testMoment.month(), 0,
+ 'lenient ordinal parsing of number ' + i + ' month check');
+ assert.equal(testMoment.date(), i,
+ 'lenient ordinal parsing of number ' + i + ' date check');
+ }
+ });
+
+ test('strict ordinal parsing', function (assert) {
+ var i, ordinalStr, testMoment;
+ for (i = 1; i <= 31; ++i) {
+ ordinalStr = moment([2014, 0, i]).format('YYYY MM Do');
+ testMoment = moment(ordinalStr, 'YYYY MM Do', true);
+ assert.ok(testMoment.isValid(), 'strict ordinal parsing ' + i);
+ }
+ });
+
+ test('meridiem invariant', function (assert) {
+ var h, m, t1, t2;
+ for (h = 0; h < 24; ++h) {
+ for (m = 0; m < 60; m += 15) {
+ t1 = moment.utc([2000, 0, 1, h, m]);
+ t2 = moment.utc(t1.format('A h:mm'), 'A h:mm');
+ assert.equal(t2.format('HH:mm'), t1.format('HH:mm'),
+ 'meridiem at ' + t1.format('HH:mm'));
+ }
+ }
+ });
+
+ test('date format correctness', function (assert) {
+ var data, tokens;
+ data = moment.localeData()._longDateFormat;
+ tokens = objectKeys(data);
+ each(tokens, function (srchToken) {
+ // Check each format string to make sure it does not contain any
+ // tokens that need to be expanded.
+ each(tokens, function (baseToken) {
+ // strip escaped sequences
+ var format = data[baseToken].replace(/(\[[^\]]*\])/g, '');
+ assert.equal(false, !!~format.indexOf(srchToken),
+ 'contains ' + srchToken + ' in ' + baseToken);
+ });
+ });
+ });
+
+ test('month parsing correctness', function (assert) {
+ var i, m;
+
+ if (locale === 'tr') {
+ // I can't fix it :(
+ expect(0);
+ return;
+ }
+ function tester(format) {
+ var r;
+ r = moment(m.format(format), format);
+ assert.equal(r.month(), m.month(), 'month ' + i + ' fmt ' + format);
+ r = moment(m.format(format).toLocaleUpperCase(), format);
+ assert.equal(r.month(), m.month(), 'month ' + i + ' fmt ' + format + ' upper');
+ r = moment(m.format(format).toLocaleLowerCase(), format);
+ assert.equal(r.month(), m.month(), 'month ' + i + ' fmt ' + format + ' lower');
+
+ r = moment(m.format(format), format, true);
+ assert.equal(r.month(), m.month(), 'month ' + i + ' fmt ' + format + ' strict');
+ r = moment(m.format(format).toLocaleUpperCase(), format, true);
+ assert.equal(r.month(), m.month(), 'month ' + i + ' fmt ' + format + ' upper strict');
+ r = moment(m.format(format).toLocaleLowerCase(), format, true);
+ assert.equal(r.month(), m.month(), 'month ' + i + ' fmt ' + format + ' lower strict');
+ }
+
+ for (i = 0; i < 12; ++i) {
+ m = moment([2015, i, 15, 18]);
+ tester('MMM');
+ tester('MMM.');
+ tester('MMMM');
+ tester('MMMM.');
+ }
+ });
+
+ test('weekday parsing correctness', function (assert) {
+ var i, m;
+
+ if (locale === 'tr' || locale === 'az') {
+ // There is a lower-case letter (ı), that converted to upper then
+ // lower changes to i
+ expect(0);
+ return;
+ }
+ function tester(format) {
+ var r, baseMsg = 'weekday ' + m.weekday() + ' fmt ' + format;
+ r = moment(m.format(format), format);
+ assert.equal(r.weekday(), m.weekday(), baseMsg);
+ r = moment(m.format(format).toLocaleUpperCase(), format);
+ assert.equal(r.weekday(), m.weekday(), baseMsg + ' upper');
+ r = moment(m.format(format).toLocaleLowerCase(), format);
+ assert.equal(r.weekday(), m.weekday(), baseMsg + ' lower');
+
+ r = moment(m.format(format), format, true);
+ assert.equal(r.weekday(), m.weekday(), baseMsg + ' strict');
+ r = moment(m.format(format).toLocaleUpperCase(), format, true);
+ assert.equal(r.weekday(), m.weekday(), baseMsg + ' upper strict');
+ r = moment(m.format(format).toLocaleLowerCase(), format, true);
+ assert.equal(r.weekday(), m.weekday(), baseMsg + ' lower strict');
+ }
+
+ for (i = 0; i < 7; ++i) {
+ m = moment.utc([2015, i, 15, 18]);
+ tester('dd');
+ tester('ddd');
+ tester('dddd');
+ }
+ });
+ }
+
+ function setupDeprecationHandler(test, moment, scope) {
+ test._expectedDeprecations = null;
+ test._observedDeprecations = null;
+ test._oldSupress = moment.suppressDeprecationWarnings;
+ moment.suppressDeprecationWarnings = true;
+ test.expectedDeprecations = function () {
+ test._expectedDeprecations = arguments;
+ test._observedDeprecations = [];
+ };
+ moment.deprecationHandler = function (name, msg) {
+ var deprecationId = matchedDeprecation(name, msg, test._expectedDeprecations);
+ if (deprecationId === -1) {
+ throw new Error('Unexpected deprecation thrown name=' +
+ name + ' msg=' + msg);
+ }
+ test._observedDeprecations[deprecationId] = 1;
+ };
+ }
+
+ function teardownDeprecationHandler(test, moment, scope) {
+ moment.suppressDeprecationWarnings = test._oldSupress;
+
+ if (test._expectedDeprecations != null) {
+ var missedDeprecations = [];
+ each(test._expectedDeprecations, function (deprecationPattern, id) {
+ if (test._observedDeprecations[id] !== 1) {
+ missedDeprecations.push(deprecationPattern);
+ }
+ });
+ if (missedDeprecations.length !== 0) {
+ throw new Error('Expected deprecation warnings did not happen: ' +
+ missedDeprecations.join(' '));
+ }
+ }
+ }
+
+ function matchedDeprecation(name, msg, deprecations) {
+ if (deprecations == null) {
+ return -1;
+ }
+ for (var i = 0; i < deprecations.length; ++i) {
+ if (name != null && name === deprecations[i]) {
+ return i;
+ }
+ if (msg != null && msg.substring(0, deprecations[i].length) === deprecations[i]) {
+ return i;
+ }
+ }
+ return -1;
+ }
/*global QUnit:false*/
@@ -3836,11 +5314,13 @@
moment.createFromInputFallback = function (config) {
throw new Error('input not handled by moment: ' + config._i);
};
+ setupDeprecationHandler(test, moment, 'core');
if (lifecycle && lifecycle.setup) {
lifecycle.setup();
}
},
teardown : function () {
+ teardownDeprecationHandler(test, moment, 'core');
if (lifecycle && lifecycle.teardown) {
lifecycle.teardown();
}
@@ -3855,17 +5335,20 @@
moment.createFromInputFallback = function (config) {
throw new Error('input not handled by moment: ' + config._i);
};
+ setupDeprecationHandler(test, moment, 'locale');
if (lifecycle && lifecycle.setup) {
lifecycle.setup();
}
},
teardown : function () {
moment.locale('en');
+ teardownDeprecationHandler(test, moment, 'locale');
if (lifecycle && lifecycle.teardown) {
lifecycle.teardown();
}
}
});
+ defineCommonLocaleTests(name, -1, -1);
}
localeModule('br');
@@ -4023,14 +5506,14 @@
test('calendar day', function (assert) {
moment.locale('br');
- var a = moment().hours(2).minutes(0).seconds(0);
-
- assert.equal(moment(a).calendar(), 'Hiziv da 2e00 AM', 'today at the same time');
- assert.equal(moment(a).add({m: 25}).calendar(), 'Hiziv da 2e25 AM', 'Now plus 25 min');
- assert.equal(moment(a).add({h: 1}).calendar(), 'Hiziv da 3e00 AM', 'Now plus 1 hour');
- assert.equal(moment(a).add({d: 1}).calendar(), 'Warc\'hoazh da 2e00 AM', 'tomorrow at the same time');
- assert.equal(moment(a).subtract({h: 1}).calendar(), 'Hiziv da 1e00 AM', 'Now minus 1 hour');
- assert.equal(moment(a).subtract({d: 1}).calendar(), 'Dec\'h da 2e00 AM', 'yesterday at the same time');
+ var a = moment().hours(12).minutes(0).seconds(0);
+
+ assert.equal(moment(a).calendar(), 'Hiziv da 12e00 PM', 'today at the same time');
+ assert.equal(moment(a).add({m: 25}).calendar(), 'Hiziv da 12e25 PM', 'Now plus 25 min');
+ assert.equal(moment(a).add({h: 1}).calendar(), 'Hiziv da 1e00 PM', 'Now plus 1 hour');
+ assert.equal(moment(a).add({d: 1}).calendar(), 'Warc\'hoazh da 12e00 PM', 'tomorrow at the same time');
+ assert.equal(moment(a).subtract({h: 1}).calendar(), 'Hiziv da 11e00 AM', 'Now minus 1 hour');
+ assert.equal(moment(a).subtract({d: 1}).calendar(), 'Dec\'h da 12e00 PM', 'yesterday at the same time');
});
test('calendar next week', function (assert) {
@@ -4093,42 +5576,6 @@
assert.equal(start.from(moment([2007, 1, 28]).add({y: 261}), true), '261 bloaz', 'mutation 261 years');
});
- test('lenient ordinal parsing', function (assert) {
- var i, ordinalStr, testMoment;
- for (i = 1; i <= 31; ++i) {
- ordinalStr = moment([2014, 0, i]).format('YYYY MM Do');
- testMoment = moment(ordinalStr, 'YYYY MM Do');
- assert.equal(testMoment.year(), 2014,
- 'lenient ordinal parsing ' + i + ' year check');
- assert.equal(testMoment.month(), 0,
- 'lenient ordinal parsing ' + i + ' month check');
- assert.equal(testMoment.date(), i,
- 'lenient ordinal parsing ' + i + ' date check');
- }
- });
-
- test('lenient ordinal parsing of number', function (assert) {
- var i, testMoment;
- for (i = 1; i <= 31; ++i) {
- testMoment = moment('2014 01 ' + i, 'YYYY MM Do');
- assert.equal(testMoment.year(), 2014,
- 'lenient ordinal parsing of number ' + i + ' year check');
- assert.equal(testMoment.month(), 0,
- 'lenient ordinal parsing of number ' + i + ' month check');
- assert.equal(testMoment.date(), i,
- 'lenient ordinal parsing of number ' + i + ' date check');
- }
- });
-
- test('strict ordinal parsing', function (assert) {
- var i, ordinalStr, testMoment;
- for (i = 1; i <= 31; ++i) {
- ordinalStr = moment([2014, 0, i]).format('YYYY MM Do');
- testMoment = moment(ordinalStr, 'YYYY MM Do', true);
- assert.ok(testMoment.isValid(), 'strict ordinal parsing ' + i);
- }
- });
-
}));
;(function (global, factory) {
@@ -4137,6 +5584,224 @@
typeof define === 'function' && define.amd ? define(['../../moment'], factory) :
factory(global.moment)
}(this, function (moment) { 'use strict';
+
+ function each(array, callback) {
+ var i;
+ for (i = 0; i < array.length; i++) {
+ callback(array[i], i, array);
+ }
+ }
+
+ function objectKeys(obj) {
+ if (Object.keys) {
+ return Object.keys(obj);
+ } else {
+ // IE8
+ var res = [], i;
+ for (i in obj) {
+ if (obj.hasOwnProperty(i)) {
+ res.push(i);
+ }
+ }
+ return res;
+ }
+ }
+
+ // Pick the first defined of two or three arguments.
+ function defaults(a, b, c) {
+ if (a != null) {
+ return a;
+ }
+ if (b != null) {
+ return b;
+ }
+ return c;
+ }
+
+ function defineCommonLocaleTests(locale, options) {
+ test('lenient ordinal parsing', function (assert) {
+ var i, ordinalStr, testMoment;
+ for (i = 1; i <= 31; ++i) {
+ ordinalStr = moment([2014, 0, i]).format('YYYY MM Do');
+ testMoment = moment(ordinalStr, 'YYYY MM Do');
+ assert.equal(testMoment.year(), 2014,
+ 'lenient ordinal parsing ' + i + ' year check');
+ assert.equal(testMoment.month(), 0,
+ 'lenient ordinal parsing ' + i + ' month check');
+ assert.equal(testMoment.date(), i,
+ 'lenient ordinal parsing ' + i + ' date check');
+ }
+ });
+
+ test('lenient ordinal parsing of number', function (assert) {
+ var i, testMoment;
+ for (i = 1; i <= 31; ++i) {
+ testMoment = moment('2014 01 ' + i, 'YYYY MM Do');
+ assert.equal(testMoment.year(), 2014,
+ 'lenient ordinal parsing of number ' + i + ' year check');
+ assert.equal(testMoment.month(), 0,
+ 'lenient ordinal parsing of number ' + i + ' month check');
+ assert.equal(testMoment.date(), i,
+ 'lenient ordinal parsing of number ' + i + ' date check');
+ }
+ });
+
+ test('strict ordinal parsing', function (assert) {
+ var i, ordinalStr, testMoment;
+ for (i = 1; i <= 31; ++i) {
+ ordinalStr = moment([2014, 0, i]).format('YYYY MM Do');
+ testMoment = moment(ordinalStr, 'YYYY MM Do', true);
+ assert.ok(testMoment.isValid(), 'strict ordinal parsing ' + i);
+ }
+ });
+
+ test('meridiem invariant', function (assert) {
+ var h, m, t1, t2;
+ for (h = 0; h < 24; ++h) {
+ for (m = 0; m < 60; m += 15) {
+ t1 = moment.utc([2000, 0, 1, h, m]);
+ t2 = moment.utc(t1.format('A h:mm'), 'A h:mm');
+ assert.equal(t2.format('HH:mm'), t1.format('HH:mm'),
+ 'meridiem at ' + t1.format('HH:mm'));
+ }
+ }
+ });
+
+ test('date format correctness', function (assert) {
+ var data, tokens;
+ data = moment.localeData()._longDateFormat;
+ tokens = objectKeys(data);
+ each(tokens, function (srchToken) {
+ // Check each format string to make sure it does not contain any
+ // tokens that need to be expanded.
+ each(tokens, function (baseToken) {
+ // strip escaped sequences
+ var format = data[baseToken].replace(/(\[[^\]]*\])/g, '');
+ assert.equal(false, !!~format.indexOf(srchToken),
+ 'contains ' + srchToken + ' in ' + baseToken);
+ });
+ });
+ });
+
+ test('month parsing correctness', function (assert) {
+ var i, m;
+
+ if (locale === 'tr') {
+ // I can't fix it :(
+ expect(0);
+ return;
+ }
+ function tester(format) {
+ var r;
+ r = moment(m.format(format), format);
+ assert.equal(r.month(), m.month(), 'month ' + i + ' fmt ' + format);
+ r = moment(m.format(format).toLocaleUpperCase(), format);
+ assert.equal(r.month(), m.month(), 'month ' + i + ' fmt ' + format + ' upper');
+ r = moment(m.format(format).toLocaleLowerCase(), format);
+ assert.equal(r.month(), m.month(), 'month ' + i + ' fmt ' + format + ' lower');
+
+ r = moment(m.format(format), format, true);
+ assert.equal(r.month(), m.month(), 'month ' + i + ' fmt ' + format + ' strict');
+ r = moment(m.format(format).toLocaleUpperCase(), format, true);
+ assert.equal(r.month(), m.month(), 'month ' + i + ' fmt ' + format + ' upper strict');
+ r = moment(m.format(format).toLocaleLowerCase(), format, true);
+ assert.equal(r.month(), m.month(), 'month ' + i + ' fmt ' + format + ' lower strict');
+ }
+
+ for (i = 0; i < 12; ++i) {
+ m = moment([2015, i, 15, 18]);
+ tester('MMM');
+ tester('MMM.');
+ tester('MMMM');
+ tester('MMMM.');
+ }
+ });
+
+ test('weekday parsing correctness', function (assert) {
+ var i, m;
+
+ if (locale === 'tr' || locale === 'az') {
+ // There is a lower-case letter (ı), that converted to upper then
+ // lower changes to i
+ expect(0);
+ return;
+ }
+ function tester(format) {
+ var r, baseMsg = 'weekday ' + m.weekday() + ' fmt ' + format;
+ r = moment(m.format(format), format);
+ assert.equal(r.weekday(), m.weekday(), baseMsg);
+ r = moment(m.format(format).toLocaleUpperCase(), format);
+ assert.equal(r.weekday(), m.weekday(), baseMsg + ' upper');
+ r = moment(m.format(format).toLocaleLowerCase(), format);
+ assert.equal(r.weekday(), m.weekday(), baseMsg + ' lower');
+
+ r = moment(m.format(format), format, true);
+ assert.equal(r.weekday(), m.weekday(), baseMsg + ' strict');
+ r = moment(m.format(format).toLocaleUpperCase(), format, true);
+ assert.equal(r.weekday(), m.weekday(), baseMsg + ' upper strict');
+ r = moment(m.format(format).toLocaleLowerCase(), format, true);
+ assert.equal(r.weekday(), m.weekday(), baseMsg + ' lower strict');
+ }
+
+ for (i = 0; i < 7; ++i) {
+ m = moment.utc([2015, i, 15, 18]);
+ tester('dd');
+ tester('ddd');
+ tester('dddd');
+ }
+ });
+ }
+
+ function setupDeprecationHandler(test, moment, scope) {
+ test._expectedDeprecations = null;
+ test._observedDeprecations = null;
+ test._oldSupress = moment.suppressDeprecationWarnings;
+ moment.suppressDeprecationWarnings = true;
+ test.expectedDeprecations = function () {
+ test._expectedDeprecations = arguments;
+ test._observedDeprecations = [];
+ };
+ moment.deprecationHandler = function (name, msg) {
+ var deprecationId = matchedDeprecation(name, msg, test._expectedDeprecations);
+ if (deprecationId === -1) {
+ throw new Error('Unexpected deprecation thrown name=' +
+ name + ' msg=' + msg);
+ }
+ test._observedDeprecations[deprecationId] = 1;
+ };
+ }
+
+ function teardownDeprecationHandler(test, moment, scope) {
+ moment.suppressDeprecationWarnings = test._oldSupress;
+
+ if (test._expectedDeprecations != null) {
+ var missedDeprecations = [];
+ each(test._expectedDeprecations, function (deprecationPattern, id) {
+ if (test._observedDeprecations[id] !== 1) {
+ missedDeprecations.push(deprecationPattern);
+ }
+ });
+ if (missedDeprecations.length !== 0) {
+ throw new Error('Expected deprecation warnings did not happen: ' +
+ missedDeprecations.join(' '));
+ }
+ }
+ }
+
+ function matchedDeprecation(name, msg, deprecations) {
+ if (deprecations == null) {
+ return -1;
+ }
+ for (var i = 0; i < deprecations.length; ++i) {
+ if (name != null && name === deprecations[i]) {
+ return i;
+ }
+ if (msg != null && msg.substring(0, deprecations[i].length) === deprecations[i]) {
+ return i;
+ }
+ }
+ return -1;
+ }
/*global QUnit:false*/
@@ -4151,11 +5816,13 @@
moment.createFromInputFallback = function (config) {
throw new Error('input not handled by moment: ' + config._i);
};
+ setupDeprecationHandler(test, moment, 'core');
if (lifecycle && lifecycle.setup) {
lifecycle.setup();
}
},
teardown : function () {
+ teardownDeprecationHandler(test, moment, 'core');
if (lifecycle && lifecycle.teardown) {
lifecycle.teardown();
}
@@ -4170,17 +5837,20 @@
moment.createFromInputFallback = function (config) {
throw new Error('input not handled by moment: ' + config._i);
};
+ setupDeprecationHandler(test, moment, 'locale');
if (lifecycle && lifecycle.setup) {
lifecycle.setup();
}
},
teardown : function () {
moment.locale('en');
+ teardownDeprecationHandler(test, moment, 'locale');
if (lifecycle && lifecycle.teardown) {
lifecycle.teardown();
}
}
});
+ defineCommonLocaleTests(name, -1, -1);
}
localeModule('bs');
@@ -4188,7 +5858,7 @@
test('parse', function (assert) {
var tests = 'januar jan._februar feb._mart mar._april apr._maj maj._juni jun._juli jul._august aug._septembar sep._oktobar okt._novembar nov._decembar dec.'.split('_'), i;
function equalTest(input, mmm, i) {
- assert.equal(moment(input, mmm).month(), i, input + ' should be month ' + (i + 1));
+ assert.equal(moment(input, mmm).month(), i, input + ' should be month ' + (i + 1) + ' inp ' + mmm);
}
for (i = 0; i < 12; i++) {
tests[i] = tests[i].split(' ');
@@ -4334,14 +6004,14 @@
});
test('calendar day', function (assert) {
- var a = moment().hours(2).minutes(0).seconds(0);
-
- assert.equal(moment(a).calendar(), 'danas u 2:00', 'today at the same time');
- assert.equal(moment(a).add({m: 25}).calendar(), 'danas u 2:25', 'Now plus 25 min');
- assert.equal(moment(a).add({h: 1}).calendar(), 'danas u 3:00', 'Now plus 1 hour');
- assert.equal(moment(a).add({d: 1}).calendar(), 'sutra u 2:00', 'tomorrow at the same time');
- assert.equal(moment(a).subtract({h: 1}).calendar(), 'danas u 1:00', 'Now minus 1 hour');
- assert.equal(moment(a).subtract({d: 1}).calendar(), 'jučer u 2:00', 'yesterday at the same time');
+ var a = moment().hours(12).minutes(0).seconds(0);
+
+ assert.equal(moment(a).calendar(), 'danas u 12:00', 'today at the same time');
+ assert.equal(moment(a).add({m: 25}).calendar(), 'danas u 12:25', 'Now plus 25 min');
+ assert.equal(moment(a).add({h: 1}).calendar(), 'danas u 13:00', 'Now plus 1 hour');
+ assert.equal(moment(a).add({d: 1}).calendar(), 'sutra u 12:00', 'tomorrow at the same time');
+ assert.equal(moment(a).subtract({h: 1}).calendar(), 'danas u 11:00', 'Now minus 1 hour');
+ assert.equal(moment(a).subtract({d: 1}).calendar(), 'jučer u 12:00', 'yesterday at the same time');
});
test('calendar next week', function (assert) {
@@ -4415,67 +6085,6 @@
assert.equal(weeksFromNow.calendar(), weeksFromNow.format('L'), 'in 2 weeks');
});
- test('weeks year starting sunday', function (assert) {
- assert.equal(moment([2011, 11, 26]).week(), 1, 'Dec 26 2011 should be week 1');
- assert.equal(moment([2012, 0, 1]).week(), 1, 'Jan 1 2012 should be week 1');
- assert.equal(moment([2012, 0, 2]).week(), 2, 'Jan 2 2012 should be week 2');
- assert.equal(moment([2012, 0, 8]).week(), 2, 'Jan 8 2012 should be week 2');
- assert.equal(moment([2012, 0, 9]).week(), 3, 'Jan 9 2012 should be week 3');
- });
-
- test('weeks year starting monday', function (assert) {
- assert.equal(moment([2007, 0, 1]).week(), 1, 'Jan 1 2007 should be week 1');
- assert.equal(moment([2007, 0, 7]).week(), 1, 'Jan 7 2007 should be week 1');
- assert.equal(moment([2007, 0, 8]).week(), 2, 'Jan 8 2007 should be week 2');
- assert.equal(moment([2007, 0, 14]).week(), 2, 'Jan 14 2007 should be week 2');
- assert.equal(moment([2007, 0, 15]).week(), 3, 'Jan 15 2007 should be week 3');
- });
-
- test('weeks year starting tuesday', function (assert) {
- assert.equal(moment([2007, 11, 31]).week(), 1, 'Dec 31 2007 should be week 1');
- assert.equal(moment([2008, 0, 1]).week(), 1, 'Jan 1 2008 should be week 1');
- assert.equal(moment([2008, 0, 6]).week(), 1, 'Jan 6 2008 should be week 1');
- assert.equal(moment([2008, 0, 7]).week(), 2, 'Jan 7 2008 should be week 2');
- assert.equal(moment([2008, 0, 13]).week(), 2, 'Jan 13 2008 should be week 2');
- assert.equal(moment([2008, 0, 14]).week(), 3, 'Jan 14 2008 should be week 3');
- });
-
- test('weeks year starting wednesday', function (assert) {
- assert.equal(moment([2002, 11, 30]).week(), 1, 'Dec 30 2002 should be week 1');
- assert.equal(moment([2003, 0, 1]).week(), 1, 'Jan 1 2003 should be week 1');
- assert.equal(moment([2003, 0, 5]).week(), 1, 'Jan 5 2003 should be week 1');
- assert.equal(moment([2003, 0, 6]).week(), 2, 'Jan 6 2003 should be week 2');
- assert.equal(moment([2003, 0, 12]).week(), 2, 'Jan 12 2003 should be week 2');
- assert.equal(moment([2003, 0, 13]).week(), 3, 'Jan 13 2003 should be week 3');
- });
-
- test('weeks year starting thursday', function (assert) {
- assert.equal(moment([2008, 11, 29]).week(), 1, 'Dec 29 2008 should be week 1');
- assert.equal(moment([2009, 0, 1]).week(), 1, 'Jan 1 2009 should be week 1');
- assert.equal(moment([2009, 0, 4]).week(), 1, 'Jan 4 2009 should be week 1');
- assert.equal(moment([2009, 0, 5]).week(), 2, 'Jan 5 2009 should be week 2');
- assert.equal(moment([2009, 0, 11]).week(), 2, 'Jan 11 2009 should be week 2');
- assert.equal(moment([2009, 0, 12]).week(), 3, 'Jan 12 2009 should be week 3');
- });
-
- test('weeks year starting friday', function (assert) {
- assert.equal(moment([2009, 11, 28]).week(), 1, 'Dec 28 2009 should be week 1');
- assert.equal(moment([2010, 0, 1]).week(), 1, 'Jan 1 2010 should be week 1');
- assert.equal(moment([2010, 0, 3]).week(), 1, 'Jan 3 2010 should be week 1');
- assert.equal(moment([2010, 0, 4]).week(), 2, 'Jan 4 2010 should be week 2');
- assert.equal(moment([2010, 0, 10]).week(), 2, 'Jan 10 2010 should be week 2');
- assert.equal(moment([2010, 0, 11]).week(), 3, 'Jan 11 2010 should be week 3');
- });
-
- test('weeks year starting saturday', function (assert) {
- assert.equal(moment([2010, 11, 27]).week(), 1, 'Dec 27 2010 should be week 1');
- assert.equal(moment([2011, 0, 1]).week(), 1, 'Jan 1 2011 should be week 1');
- assert.equal(moment([2011, 0, 2]).week(), 1, 'Jan 2 2011 should be week 1');
- assert.equal(moment([2011, 0, 3]).week(), 2, 'Jan 3 2011 should be week 2');
- assert.equal(moment([2011, 0, 9]).week(), 2, 'Jan 9 2011 should be week 2');
- assert.equal(moment([2011, 0, 10]).week(), 3, 'Jan 10 2011 should be week 3');
- });
-
test('weeks year starting sunday formatted', function (assert) {
assert.equal(moment([2011, 11, 26]).format('w ww wo'), '1 01 1.', 'Dec 26 2011 should be week 1');
assert.equal(moment([2012, 0, 1]).format('w ww wo'), '1 01 1.', 'Jan 1 2012 should be week 1');
@@ -4484,42 +6093,6 @@
assert.equal(moment([2012, 0, 9]).format('w ww wo'), '3 03 3.', 'Jan 9 2012 should be week 3');
});
- test('lenient ordinal parsing', function (assert) {
- var i, ordinalStr, testMoment;
- for (i = 1; i <= 31; ++i) {
- ordinalStr = moment([2014, 0, i]).format('YYYY MM Do');
- testMoment = moment(ordinalStr, 'YYYY MM Do');
- assert.equal(testMoment.year(), 2014,
- 'lenient ordinal parsing ' + i + ' year check');
- assert.equal(testMoment.month(), 0,
- 'lenient ordinal parsing ' + i + ' month check');
- assert.equal(testMoment.date(), i,
- 'lenient ordinal parsing ' + i + ' date check');
- }
- });
-
- test('lenient ordinal parsing of number', function (assert) {
- var i, testMoment;
- for (i = 1; i <= 31; ++i) {
- testMoment = moment('2014 01 ' + i, 'YYYY MM Do');
- assert.equal(testMoment.year(), 2014,
- 'lenient ordinal parsing of number ' + i + ' year check');
- assert.equal(testMoment.month(), 0,
- 'lenient ordinal parsing of number ' + i + ' month check');
- assert.equal(testMoment.date(), i,
- 'lenient ordinal parsing of number ' + i + ' date check');
- }
- });
-
- test('strict ordinal parsing', function (assert) {
- var i, ordinalStr, testMoment;
- for (i = 1; i <= 31; ++i) {
- ordinalStr = moment([2014, 0, i]).format('YYYY MM Do');
- testMoment = moment(ordinalStr, 'YYYY MM Do', true);
- assert.ok(testMoment.isValid(), 'strict ordinal parsing ' + i);
- }
- });
-
}));
;(function (global, factory) {
@@ -4528,6 +6101,224 @@
typeof define === 'function' && define.amd ? define(['../../moment'], factory) :
factory(global.moment)
}(this, function (moment) { 'use strict';
+
+ function each(array, callback) {
+ var i;
+ for (i = 0; i < array.length; i++) {
+ callback(array[i], i, array);
+ }
+ }
+
+ function objectKeys(obj) {
+ if (Object.keys) {
+ return Object.keys(obj);
+ } else {
+ // IE8
+ var res = [], i;
+ for (i in obj) {
+ if (obj.hasOwnProperty(i)) {
+ res.push(i);
+ }
+ }
+ return res;
+ }
+ }
+
+ // Pick the first defined of two or three arguments.
+ function defaults(a, b, c) {
+ if (a != null) {
+ return a;
+ }
+ if (b != null) {
+ return b;
+ }
+ return c;
+ }
+
+ function defineCommonLocaleTests(locale, options) {
+ test('lenient ordinal parsing', function (assert) {
+ var i, ordinalStr, testMoment;
+ for (i = 1; i <= 31; ++i) {
+ ordinalStr = moment([2014, 0, i]).format('YYYY MM Do');
+ testMoment = moment(ordinalStr, 'YYYY MM Do');
+ assert.equal(testMoment.year(), 2014,
+ 'lenient ordinal parsing ' + i + ' year check');
+ assert.equal(testMoment.month(), 0,
+ 'lenient ordinal parsing ' + i + ' month check');
+ assert.equal(testMoment.date(), i,
+ 'lenient ordinal parsing ' + i + ' date check');
+ }
+ });
+
+ test('lenient ordinal parsing of number', function (assert) {
+ var i, testMoment;
+ for (i = 1; i <= 31; ++i) {
+ testMoment = moment('2014 01 ' + i, 'YYYY MM Do');
+ assert.equal(testMoment.year(), 2014,
+ 'lenient ordinal parsing of number ' + i + ' year check');
+ assert.equal(testMoment.month(), 0,
+ 'lenient ordinal parsing of number ' + i + ' month check');
+ assert.equal(testMoment.date(), i,
+ 'lenient ordinal parsing of number ' + i + ' date check');
+ }
+ });
+
+ test('strict ordinal parsing', function (assert) {
+ var i, ordinalStr, testMoment;
+ for (i = 1; i <= 31; ++i) {
+ ordinalStr = moment([2014, 0, i]).format('YYYY MM Do');
+ testMoment = moment(ordinalStr, 'YYYY MM Do', true);
+ assert.ok(testMoment.isValid(), 'strict ordinal parsing ' + i);
+ }
+ });
+
+ test('meridiem invariant', function (assert) {
+ var h, m, t1, t2;
+ for (h = 0; h < 24; ++h) {
+ for (m = 0; m < 60; m += 15) {
+ t1 = moment.utc([2000, 0, 1, h, m]);
+ t2 = moment.utc(t1.format('A h:mm'), 'A h:mm');
+ assert.equal(t2.format('HH:mm'), t1.format('HH:mm'),
+ 'meridiem at ' + t1.format('HH:mm'));
+ }
+ }
+ });
+
+ test('date format correctness', function (assert) {
+ var data, tokens;
+ data = moment.localeData()._longDateFormat;
+ tokens = objectKeys(data);
+ each(tokens, function (srchToken) {
+ // Check each format string to make sure it does not contain any
+ // tokens that need to be expanded.
+ each(tokens, function (baseToken) {
+ // strip escaped sequences
+ var format = data[baseToken].replace(/(\[[^\]]*\])/g, '');
+ assert.equal(false, !!~format.indexOf(srchToken),
+ 'contains ' + srchToken + ' in ' + baseToken);
+ });
+ });
+ });
+
+ test('month parsing correctness', function (assert) {
+ var i, m;
+
+ if (locale === 'tr') {
+ // I can't fix it :(
+ expect(0);
+ return;
+ }
+ function tester(format) {
+ var r;
+ r = moment(m.format(format), format);
+ assert.equal(r.month(), m.month(), 'month ' + i + ' fmt ' + format);
+ r = moment(m.format(format).toLocaleUpperCase(), format);
+ assert.equal(r.month(), m.month(), 'month ' + i + ' fmt ' + format + ' upper');
+ r = moment(m.format(format).toLocaleLowerCase(), format);
+ assert.equal(r.month(), m.month(), 'month ' + i + ' fmt ' + format + ' lower');
+
+ r = moment(m.format(format), format, true);
+ assert.equal(r.month(), m.month(), 'month ' + i + ' fmt ' + format + ' strict');
+ r = moment(m.format(format).toLocaleUpperCase(), format, true);
+ assert.equal(r.month(), m.month(), 'month ' + i + ' fmt ' + format + ' upper strict');
+ r = moment(m.format(format).toLocaleLowerCase(), format, true);
+ assert.equal(r.month(), m.month(), 'month ' + i + ' fmt ' + format + ' lower strict');
+ }
+
+ for (i = 0; i < 12; ++i) {
+ m = moment([2015, i, 15, 18]);
+ tester('MMM');
+ tester('MMM.');
+ tester('MMMM');
+ tester('MMMM.');
+ }
+ });
+
+ test('weekday parsing correctness', function (assert) {
+ var i, m;
+
+ if (locale === 'tr' || locale === 'az') {
+ // There is a lower-case letter (ı), that converted to upper then
+ // lower changes to i
+ expect(0);
+ return;
+ }
+ function tester(format) {
+ var r, baseMsg = 'weekday ' + m.weekday() + ' fmt ' + format;
+ r = moment(m.format(format), format);
+ assert.equal(r.weekday(), m.weekday(), baseMsg);
+ r = moment(m.format(format).toLocaleUpperCase(), format);
+ assert.equal(r.weekday(), m.weekday(), baseMsg + ' upper');
+ r = moment(m.format(format).toLocaleLowerCase(), format);
+ assert.equal(r.weekday(), m.weekday(), baseMsg + ' lower');
+
+ r = moment(m.format(format), format, true);
+ assert.equal(r.weekday(), m.weekday(), baseMsg + ' strict');
+ r = moment(m.format(format).toLocaleUpperCase(), format, true);
+ assert.equal(r.weekday(), m.weekday(), baseMsg + ' upper strict');
+ r = moment(m.format(format).toLocaleLowerCase(), format, true);
+ assert.equal(r.weekday(), m.weekday(), baseMsg + ' lower strict');
+ }
+
+ for (i = 0; i < 7; ++i) {
+ m = moment.utc([2015, i, 15, 18]);
+ tester('dd');
+ tester('ddd');
+ tester('dddd');
+ }
+ });
+ }
+
+ function setupDeprecationHandler(test, moment, scope) {
+ test._expectedDeprecations = null;
+ test._observedDeprecations = null;
+ test._oldSupress = moment.suppressDeprecationWarnings;
+ moment.suppressDeprecationWarnings = true;
+ test.expectedDeprecations = function () {
+ test._expectedDeprecations = arguments;
+ test._observedDeprecations = [];
+ };
+ moment.deprecationHandler = function (name, msg) {
+ var deprecationId = matchedDeprecation(name, msg, test._expectedDeprecations);
+ if (deprecationId === -1) {
+ throw new Error('Unexpected deprecation thrown name=' +
+ name + ' msg=' + msg);
+ }
+ test._observedDeprecations[deprecationId] = 1;
+ };
+ }
+
+ function teardownDeprecationHandler(test, moment, scope) {
+ moment.suppressDeprecationWarnings = test._oldSupress;
+
+ if (test._expectedDeprecations != null) {
+ var missedDeprecations = [];
+ each(test._expectedDeprecations, function (deprecationPattern, id) {
+ if (test._observedDeprecations[id] !== 1) {
+ missedDeprecations.push(deprecationPattern);
+ }
+ });
+ if (missedDeprecations.length !== 0) {
+ throw new Error('Expected deprecation warnings did not happen: ' +
+ missedDeprecations.join(' '));
+ }
+ }
+ }
+
+ function matchedDeprecation(name, msg, deprecations) {
+ if (deprecations == null) {
+ return -1;
+ }
+ for (var i = 0; i < deprecations.length; ++i) {
+ if (name != null && name === deprecations[i]) {
+ return i;
+ }
+ if (msg != null && msg.substring(0, deprecations[i].length) === deprecations[i]) {
+ return i;
+ }
+ }
+ return -1;
+ }
/*global QUnit:false*/
@@ -4542,11 +6333,13 @@
moment.createFromInputFallback = function (config) {
throw new Error('input not handled by moment: ' + config._i);
};
+ setupDeprecationHandler(test, moment, 'core');
if (lifecycle && lifecycle.setup) {
lifecycle.setup();
}
},
teardown : function () {
+ teardownDeprecationHandler(test, moment, 'core');
if (lifecycle && lifecycle.teardown) {
lifecycle.teardown();
}
@@ -4561,17 +6354,20 @@
moment.createFromInputFallback = function (config) {
throw new Error('input not handled by moment: ' + config._i);
};
+ setupDeprecationHandler(test, moment, 'locale');
if (lifecycle && lifecycle.setup) {
lifecycle.setup();
}
},
teardown : function () {
moment.locale('en');
+ teardownDeprecationHandler(test, moment, 'locale');
if (lifecycle && lifecycle.teardown) {
lifecycle.teardown();
}
}
});
+ defineCommonLocaleTests(name, -1, -1);
}
localeModule('ca');
@@ -4725,15 +6521,15 @@
});
test('calendar day', function (assert) {
- var a = moment().hours(2).minutes(0).seconds(0);
-
- assert.equal(moment(a).calendar(), 'avui a les 2:00', 'today at the same time');
- assert.equal(moment(a).add({m: 25}).calendar(), 'avui a les 2:25', 'Now plus 25 min');
- assert.equal(moment(a).add({h: 1}).calendar(), 'avui a les 3:00', 'Now plus 1 hour');
- assert.equal(moment(a).add({d: 1}).calendar(), 'demà a les 2:00', 'tomorrow at the same time');
- assert.equal(moment(a).add({d: 1, h : -1}).calendar(), 'demà a la 1:00', 'tomorrow minus 1 hour');
- assert.equal(moment(a).subtract({h: 1}).calendar(), 'avui a la 1:00', 'Now minus 1 hour');
- assert.equal(moment(a).subtract({d: 1}).calendar(), 'ahir a les 2:00', 'yesterday at the same time');
+ var a = moment().hours(12).minutes(0).seconds(0);
+
+ assert.equal(moment(a).calendar(), 'avui a les 12:00', 'today at the same time');
+ assert.equal(moment(a).add({m: 25}).calendar(), 'avui a les 12:25', 'Now plus 25 min');
+ assert.equal(moment(a).add({h: 1}).calendar(), 'avui a les 13:00', 'Now plus 1 hour');
+ assert.equal(moment(a).add({d: 1}).calendar(), 'demà a les 12:00', 'tomorrow at the same time');
+ assert.equal(moment(a).add({d: 1, h : -1}).calendar(), 'demà a les 11:00', 'tomorrow minus 1 hour');
+ assert.equal(moment(a).subtract({h: 1}).calendar(), 'avui a les 11:00', 'Now minus 1 hour');
+ assert.equal(moment(a).subtract({d: 1}).calendar(), 'ahir a les 12:00', 'yesterday at the same time');
});
test('calendar next week', function (assert) {
@@ -4774,67 +6570,6 @@
assert.equal(weeksFromNow.calendar(), weeksFromNow.format('L'), 'in 2 weeks');
});
- test('weeks year starting sunday', function (assert) {
- assert.equal(moment([2012, 0, 1]).week(), 52, 'Jan 1 2012 should be week 52');
- assert.equal(moment([2012, 0, 2]).week(), 1, 'Jan 2 2012 should be week 1');
- assert.equal(moment([2012, 0, 8]).week(), 1, 'Jan 8 2012 should be week 1');
- assert.equal(moment([2012, 0, 9]).week(), 2, 'Jan 9 2012 should be week 2');
- assert.equal(moment([2012, 0, 15]).week(), 2, 'Jan 15 2012 should be week 2');
- });
-
- test('weeks year starting monday', function (assert) {
- assert.equal(moment([2007, 0, 1]).week(), 1, 'Jan 1 2007 should be week 1');
- assert.equal(moment([2007, 0, 7]).week(), 1, 'Jan 7 2007 should be week 1');
- assert.equal(moment([2007, 0, 8]).week(), 2, 'Jan 8 2007 should be week 2');
- assert.equal(moment([2007, 0, 14]).week(), 2, 'Jan 14 2007 should be week 2');
- assert.equal(moment([2007, 0, 15]).week(), 3, 'Jan 15 2007 should be week 3');
- });
-
- test('weeks year starting tuesday', function (assert) {
- assert.equal(moment([2007, 11, 31]).week(), 1, 'Dec 31 2007 should be week 1');
- assert.equal(moment([2008, 0, 1]).week(), 1, 'Jan 1 2008 should be week 1');
- assert.equal(moment([2008, 0, 6]).week(), 1, 'Jan 6 2008 should be week 1');
- assert.equal(moment([2008, 0, 7]).week(), 2, 'Jan 7 2008 should be week 2');
- assert.equal(moment([2008, 0, 13]).week(), 2, 'Jan 13 2008 should be week 2');
- assert.equal(moment([2008, 0, 14]).week(), 3, 'Jan 14 2008 should be week 3');
- });
-
- test('weeks year starting wednesday', function (assert) {
- assert.equal(moment([2002, 11, 30]).week(), 1, 'Dec 30 2002 should be week 1');
- assert.equal(moment([2003, 0, 1]).week(), 1, 'Jan 1 2003 should be week 1');
- assert.equal(moment([2003, 0, 5]).week(), 1, 'Jan 5 2003 should be week 1');
- assert.equal(moment([2003, 0, 6]).week(), 2, 'Jan 6 2003 should be week 2');
- assert.equal(moment([2003, 0, 12]).week(), 2, 'Jan 12 2003 should be week 2');
- assert.equal(moment([2003, 0, 13]).week(), 3, 'Jan 13 2003 should be week 3');
- });
-
- test('weeks year starting thursday', function (assert) {
- assert.equal(moment([2008, 11, 29]).week(), 1, 'Dec 29 2008 should be week 1');
- assert.equal(moment([2009, 0, 1]).week(), 1, 'Jan 1 2009 should be week 1');
- assert.equal(moment([2009, 0, 4]).week(), 1, 'Jan 4 2009 should be week 1');
- assert.equal(moment([2009, 0, 5]).week(), 2, 'Jan 5 2009 should be week 2');
- assert.equal(moment([2009, 0, 11]).week(), 2, 'Jan 11 2009 should be week 2');
- assert.equal(moment([2009, 0, 13]).week(), 3, 'Jan 12 2009 should be week 3');
- });
-
- test('weeks year starting friday', function (assert) {
- assert.equal(moment([2009, 11, 28]).week(), 53, 'Dec 28 2009 should be week 53');
- assert.equal(moment([2010, 0, 1]).week(), 53, 'Jan 1 2010 should be week 53');
- assert.equal(moment([2010, 0, 3]).week(), 53, 'Jan 3 2010 should be week 53');
- assert.equal(moment([2010, 0, 4]).week(), 1, 'Jan 4 2010 should be week 1');
- assert.equal(moment([2010, 0, 10]).week(), 1, 'Jan 10 2010 should be week 1');
- assert.equal(moment([2010, 0, 11]).week(), 2, 'Jan 11 2010 should be week 2');
- });
-
- test('weeks year starting saturday', function (assert) {
- assert.equal(moment([2010, 11, 27]).week(), 52, 'Dec 27 2010 should be week 52');
- assert.equal(moment([2011, 0, 1]).week(), 52, 'Jan 1 2011 should be week 52');
- assert.equal(moment([2011, 0, 2]).week(), 52, 'Jan 2 2011 should be week 52');
- assert.equal(moment([2011, 0, 3]).week(), 1, 'Jan 3 2011 should be week 1');
- assert.equal(moment([2011, 0, 9]).week(), 1, 'Jan 9 2011 should be week 1');
- assert.equal(moment([2011, 0, 10]).week(), 2, 'Jan 10 2011 should be week 2');
- });
-
test('weeks year starting sunday formatted', function (assert) {
assert.equal(moment([2012, 0, 1]).format('w ww wo'), '52 52 52a', 'Jan 1 2012 should be week 52');
assert.equal(moment([2012, 0, 2]).format('w ww wo'), '1 01 1a', 'Jan 2 2012 should be week 1');
@@ -4843,42 +6578,6 @@
assert.equal(moment([2012, 0, 15]).format('w ww wo'), '2 02 2a', 'Jan 15 2012 should be week 2');
});
- test('lenient ordinal parsing', function (assert) {
- var i, ordinalStr, testMoment;
- for (i = 1; i <= 31; ++i) {
- ordinalStr = moment([2014, 0, i]).format('YYYY MM Do');
- testMoment = moment(ordinalStr, 'YYYY MM Do');
- assert.equal(testMoment.year(), 2014,
- 'lenient ordinal parsing ' + i + ' year check');
- assert.equal(testMoment.month(), 0,
- 'lenient ordinal parsing ' + i + ' month check');
- assert.equal(testMoment.date(), i,
- 'lenient ordinal parsing ' + i + ' date check');
- }
- });
-
- test('lenient ordinal parsing of number', function (assert) {
- var i, testMoment;
- for (i = 1; i <= 31; ++i) {
- testMoment = moment('2014 01 ' + i, 'YYYY MM Do');
- assert.equal(testMoment.year(), 2014,
- 'lenient ordinal parsing of number ' + i + ' year check');
- assert.equal(testMoment.month(), 0,
- 'lenient ordinal parsing of number ' + i + ' month check');
- assert.equal(testMoment.date(), i,
- 'lenient ordinal parsing of number ' + i + ' date check');
- }
- });
-
- test('strict ordinal parsing', function (assert) {
- var i, ordinalStr, testMoment;
- for (i = 1; i <= 31; ++i) {
- ordinalStr = moment([2014, 0, i]).format('YYYY MM Do');
- testMoment = moment(ordinalStr, 'YYYY MM Do', true);
- assert.ok(testMoment.isValid(), 'strict ordinal parsing ' + i);
- }
- });
-
}));
;(function (global, factory) {
@@ -4887,6 +6586,224 @@
typeof define === 'function' && define.amd ? define(['../../moment'], factory) :
factory(global.moment)
}(this, function (moment) { 'use strict';
+
+ function each(array, callback) {
+ var i;
+ for (i = 0; i < array.length; i++) {
+ callback(array[i], i, array);
+ }
+ }
+
+ function objectKeys(obj) {
+ if (Object.keys) {
+ return Object.keys(obj);
+ } else {
+ // IE8
+ var res = [], i;
+ for (i in obj) {
+ if (obj.hasOwnProperty(i)) {
+ res.push(i);
+ }
+ }
+ return res;
+ }
+ }
+
+ // Pick the first defined of two or three arguments.
+ function defaults(a, b, c) {
+ if (a != null) {
+ return a;
+ }
+ if (b != null) {
+ return b;
+ }
+ return c;
+ }
+
+ function defineCommonLocaleTests(locale, options) {
+ test('lenient ordinal parsing', function (assert) {
+ var i, ordinalStr, testMoment;
+ for (i = 1; i <= 31; ++i) {
+ ordinalStr = moment([2014, 0, i]).format('YYYY MM Do');
+ testMoment = moment(ordinalStr, 'YYYY MM Do');
+ assert.equal(testMoment.year(), 2014,
+ 'lenient ordinal parsing ' + i + ' year check');
+ assert.equal(testMoment.month(), 0,
+ 'lenient ordinal parsing ' + i + ' month check');
+ assert.equal(testMoment.date(), i,
+ 'lenient ordinal parsing ' + i + ' date check');
+ }
+ });
+
+ test('lenient ordinal parsing of number', function (assert) {
+ var i, testMoment;
+ for (i = 1; i <= 31; ++i) {
+ testMoment = moment('2014 01 ' + i, 'YYYY MM Do');
+ assert.equal(testMoment.year(), 2014,
+ 'lenient ordinal parsing of number ' + i + ' year check');
+ assert.equal(testMoment.month(), 0,
+ 'lenient ordinal parsing of number ' + i + ' month check');
+ assert.equal(testMoment.date(), i,
+ 'lenient ordinal parsing of number ' + i + ' date check');
+ }
+ });
+
+ test('strict ordinal parsing', function (assert) {
+ var i, ordinalStr, testMoment;
+ for (i = 1; i <= 31; ++i) {
+ ordinalStr = moment([2014, 0, i]).format('YYYY MM Do');
+ testMoment = moment(ordinalStr, 'YYYY MM Do', true);
+ assert.ok(testMoment.isValid(), 'strict ordinal parsing ' + i);
+ }
+ });
+
+ test('meridiem invariant', function (assert) {
+ var h, m, t1, t2;
+ for (h = 0; h < 24; ++h) {
+ for (m = 0; m < 60; m += 15) {
+ t1 = moment.utc([2000, 0, 1, h, m]);
+ t2 = moment.utc(t1.format('A h:mm'), 'A h:mm');
+ assert.equal(t2.format('HH:mm'), t1.format('HH:mm'),
+ 'meridiem at ' + t1.format('HH:mm'));
+ }
+ }
+ });
+
+ test('date format correctness', function (assert) {
+ var data, tokens;
+ data = moment.localeData()._longDateFormat;
+ tokens = objectKeys(data);
+ each(tokens, function (srchToken) {
+ // Check each format string to make sure it does not contain any
+ // tokens that need to be expanded.
+ each(tokens, function (baseToken) {
+ // strip escaped sequences
+ var format = data[baseToken].replace(/(\[[^\]]*\])/g, '');
+ assert.equal(false, !!~format.indexOf(srchToken),
+ 'contains ' + srchToken + ' in ' + baseToken);
+ });
+ });
+ });
+
+ test('month parsing correctness', function (assert) {
+ var i, m;
+
+ if (locale === 'tr') {
+ // I can't fix it :(
+ expect(0);
+ return;
+ }
+ function tester(format) {
+ var r;
+ r = moment(m.format(format), format);
+ assert.equal(r.month(), m.month(), 'month ' + i + ' fmt ' + format);
+ r = moment(m.format(format).toLocaleUpperCase(), format);
+ assert.equal(r.month(), m.month(), 'month ' + i + ' fmt ' + format + ' upper');
+ r = moment(m.format(format).toLocaleLowerCase(), format);
+ assert.equal(r.month(), m.month(), 'month ' + i + ' fmt ' + format + ' lower');
+
+ r = moment(m.format(format), format, true);
+ assert.equal(r.month(), m.month(), 'month ' + i + ' fmt ' + format + ' strict');
+ r = moment(m.format(format).toLocaleUpperCase(), format, true);
+ assert.equal(r.month(), m.month(), 'month ' + i + ' fmt ' + format + ' upper strict');
+ r = moment(m.format(format).toLocaleLowerCase(), format, true);
+ assert.equal(r.month(), m.month(), 'month ' + i + ' fmt ' + format + ' lower strict');
+ }
+
+ for (i = 0; i < 12; ++i) {
+ m = moment([2015, i, 15, 18]);
+ tester('MMM');
+ tester('MMM.');
+ tester('MMMM');
+ tester('MMMM.');
+ }
+ });
+
+ test('weekday parsing correctness', function (assert) {
+ var i, m;
+
+ if (locale === 'tr' || locale === 'az') {
+ // There is a lower-case letter (ı), that converted to upper then
+ // lower changes to i
+ expect(0);
+ return;
+ }
+ function tester(format) {
+ var r, baseMsg = 'weekday ' + m.weekday() + ' fmt ' + format;
+ r = moment(m.format(format), format);
+ assert.equal(r.weekday(), m.weekday(), baseMsg);
+ r = moment(m.format(format).toLocaleUpperCase(), format);
+ assert.equal(r.weekday(), m.weekday(), baseMsg + ' upper');
+ r = moment(m.format(format).toLocaleLowerCase(), format);
+ assert.equal(r.weekday(), m.weekday(), baseMsg + ' lower');
+
+ r = moment(m.format(format), format, true);
+ assert.equal(r.weekday(), m.weekday(), baseMsg + ' strict');
+ r = moment(m.format(format).toLocaleUpperCase(), format, true);
+ assert.equal(r.weekday(), m.weekday(), baseMsg + ' upper strict');
+ r = moment(m.format(format).toLocaleLowerCase(), format, true);
+ assert.equal(r.weekday(), m.weekday(), baseMsg + ' lower strict');
+ }
+
+ for (i = 0; i < 7; ++i) {
+ m = moment.utc([2015, i, 15, 18]);
+ tester('dd');
+ tester('ddd');
+ tester('dddd');
+ }
+ });
+ }
+
+ function setupDeprecationHandler(test, moment, scope) {
+ test._expectedDeprecations = null;
+ test._observedDeprecations = null;
+ test._oldSupress = moment.suppressDeprecationWarnings;
+ moment.suppressDeprecationWarnings = true;
+ test.expectedDeprecations = function () {
+ test._expectedDeprecations = arguments;
+ test._observedDeprecations = [];
+ };
+ moment.deprecationHandler = function (name, msg) {
+ var deprecationId = matchedDeprecation(name, msg, test._expectedDeprecations);
+ if (deprecationId === -1) {
+ throw new Error('Unexpected deprecation thrown name=' +
+ name + ' msg=' + msg);
+ }
+ test._observedDeprecations[deprecationId] = 1;
+ };
+ }
+
+ function teardownDeprecationHandler(test, moment, scope) {
+ moment.suppressDeprecationWarnings = test._oldSupress;
+
+ if (test._expectedDeprecations != null) {
+ var missedDeprecations = [];
+ each(test._expectedDeprecations, function (deprecationPattern, id) {
+ if (test._observedDeprecations[id] !== 1) {
+ missedDeprecations.push(deprecationPattern);
+ }
+ });
+ if (missedDeprecations.length !== 0) {
+ throw new Error('Expected deprecation warnings did not happen: ' +
+ missedDeprecations.join(' '));
+ }
+ }
+ }
+
+ function matchedDeprecation(name, msg, deprecations) {
+ if (deprecations == null) {
+ return -1;
+ }
+ for (var i = 0; i < deprecations.length; ++i) {
+ if (name != null && name === deprecations[i]) {
+ return i;
+ }
+ if (msg != null && msg.substring(0, deprecations[i].length) === deprecations[i]) {
+ return i;
+ }
+ }
+ return -1;
+ }
/*global QUnit:false*/
@@ -4901,11 +6818,13 @@
moment.createFromInputFallback = function (config) {
throw new Error('input not handled by moment: ' + config._i);
};
+ setupDeprecationHandler(test, moment, 'core');
if (lifecycle && lifecycle.setup) {
lifecycle.setup();
}
},
teardown : function () {
+ teardownDeprecationHandler(test, moment, 'core');
if (lifecycle && lifecycle.teardown) {
lifecycle.teardown();
}
@@ -4920,17 +6839,20 @@
moment.createFromInputFallback = function (config) {
throw new Error('input not handled by moment: ' + config._i);
};
+ setupDeprecationHandler(test, moment, 'locale');
if (lifecycle && lifecycle.setup) {
lifecycle.setup();
}
},
teardown : function () {
moment.locale('en');
+ teardownDeprecationHandler(test, moment, 'locale');
if (lifecycle && lifecycle.teardown) {
lifecycle.teardown();
}
}
});
+ defineCommonLocaleTests(name, -1, -1);
}
localeModule('cs');
@@ -5127,14 +7049,14 @@
});
test('calendar day', function (assert) {
- var a = moment().hours(2).minutes(0).seconds(0);
-
- assert.equal(moment(a).calendar(), 'dnes v 2:00', 'today at the same time');
- assert.equal(moment(a).add({m: 25}).calendar(), 'dnes v 2:25', 'Now plus 25 min');
- assert.equal(moment(a).add({h: 1}).calendar(), 'dnes v 3:00', 'Now plus 1 hour');
- assert.equal(moment(a).add({d: 1}).calendar(), 'zítra v 2:00', 'tomorrow at the same time');
- assert.equal(moment(a).subtract({h: 1}).calendar(), 'dnes v 1:00', 'Now minus 1 hour');
- assert.equal(moment(a).subtract({d: 1}).calendar(), 'včera v 2:00', 'yesterday at the same time');
+ var a = moment().hours(12).minutes(0).seconds(0);
+
+ assert.equal(moment(a).calendar(), 'dnes v 12:00', 'today at the same time');
+ assert.equal(moment(a).add({m: 25}).calendar(), 'dnes v 12:25', 'Now plus 25 min');
+ assert.equal(moment(a).add({h: 1}).calendar(), 'dnes v 13:00', 'Now plus 1 hour');
+ assert.equal(moment(a).add({d: 1}).calendar(), 'zítra v 12:00', 'tomorrow at the same time');
+ assert.equal(moment(a).subtract({h: 1}).calendar(), 'dnes v 11:00', 'Now minus 1 hour');
+ assert.equal(moment(a).subtract({d: 1}).calendar(), 'včera v 12:00', 'yesterday at the same time');
});
test('calendar next week', function (assert) {
@@ -5230,67 +7152,6 @@
assert.equal(moment.duration(-1, 'minutes').humanize(true), 'před minutou', 'a minute ago');
});
- test('weeks year starting sunday', function (assert) {
- assert.equal(moment([2012, 0, 1]).week(), 52, 'Jan 1 2012 should be week 52');
- assert.equal(moment([2012, 0, 2]).week(), 1, 'Jan 2 2012 should be week 1');
- assert.equal(moment([2012, 0, 8]).week(), 1, 'Jan 8 2012 should be week 1');
- assert.equal(moment([2012, 0, 9]).week(), 2, 'Jan 9 2012 should be week 2');
- assert.equal(moment([2012, 0, 15]).week(), 2, 'Jan 15 2012 should be week 2');
- });
-
- test('weeks year starting monday', function (assert) {
- assert.equal(moment([2007, 0, 1]).week(), 1, 'Jan 1 2007 should be week 1');
- assert.equal(moment([2007, 0, 7]).week(), 1, 'Jan 7 2007 should be week 1');
- assert.equal(moment([2007, 0, 8]).week(), 2, 'Jan 8 2007 should be week 2');
- assert.equal(moment([2007, 0, 14]).week(), 2, 'Jan 14 2007 should be week 2');
- assert.equal(moment([2007, 0, 15]).week(), 3, 'Jan 15 2007 should be week 3');
- });
-
- test('weeks year starting tuesday', function (assert) {
- assert.equal(moment([2007, 11, 31]).week(), 1, 'Dec 31 2007 should be week 1');
- assert.equal(moment([2008, 0, 1]).week(), 1, 'Jan 1 2008 should be week 1');
- assert.equal(moment([2008, 0, 6]).week(), 1, 'Jan 6 2008 should be week 1');
- assert.equal(moment([2008, 0, 7]).week(), 2, 'Jan 7 2008 should be week 2');
- assert.equal(moment([2008, 0, 13]).week(), 2, 'Jan 13 2008 should be week 2');
- assert.equal(moment([2008, 0, 14]).week(), 3, 'Jan 14 2008 should be week 3');
- });
-
- test('weeks year starting wednesday', function (assert) {
- assert.equal(moment([2002, 11, 30]).week(), 1, 'Dec 30 2002 should be week 1');
- assert.equal(moment([2003, 0, 1]).week(), 1, 'Jan 1 2003 should be week 1');
- assert.equal(moment([2003, 0, 5]).week(), 1, 'Jan 5 2003 should be week 1');
- assert.equal(moment([2003, 0, 6]).week(), 2, 'Jan 6 2003 should be week 2');
- assert.equal(moment([2003, 0, 12]).week(), 2, 'Jan 12 2003 should be week 2');
- assert.equal(moment([2003, 0, 13]).week(), 3, 'Jan 13 2003 should be week 3');
- });
-
- test('weeks year starting thursday', function (assert) {
- assert.equal(moment([2008, 11, 29]).week(), 1, 'Dec 29 2008 should be week 1');
- assert.equal(moment([2009, 0, 1]).week(), 1, 'Jan 1 2009 should be week 1');
- assert.equal(moment([2009, 0, 4]).week(), 1, 'Jan 4 2009 should be week 1');
- assert.equal(moment([2009, 0, 5]).week(), 2, 'Jan 5 2009 should be week 2');
- assert.equal(moment([2009, 0, 11]).week(), 2, 'Jan 11 2009 should be week 2');
- assert.equal(moment([2009, 0, 13]).week(), 3, 'Jan 12 2009 should be week 3');
- });
-
- test('weeks year starting friday', function (assert) {
- assert.equal(moment([2009, 11, 28]).week(), 53, 'Dec 28 2009 should be week 53');
- assert.equal(moment([2010, 0, 1]).week(), 53, 'Jan 1 2010 should be week 53');
- assert.equal(moment([2010, 0, 3]).week(), 53, 'Jan 3 2010 should be week 53');
- assert.equal(moment([2010, 0, 4]).week(), 1, 'Jan 4 2010 should be week 1');
- assert.equal(moment([2010, 0, 10]).week(), 1, 'Jan 10 2010 should be week 1');
- assert.equal(moment([2010, 0, 11]).week(), 2, 'Jan 11 2010 should be week 2');
- });
-
- test('weeks year starting saturday', function (assert) {
- assert.equal(moment([2010, 11, 27]).week(), 52, 'Dec 27 2010 should be week 52');
- assert.equal(moment([2011, 0, 1]).week(), 52, 'Jan 1 2011 should be week 52');
- assert.equal(moment([2011, 0, 2]).week(), 52, 'Jan 2 2011 should be week 52');
- assert.equal(moment([2011, 0, 3]).week(), 1, 'Jan 3 2011 should be week 1');
- assert.equal(moment([2011, 0, 9]).week(), 1, 'Jan 9 2011 should be week 1');
- assert.equal(moment([2011, 0, 10]).week(), 2, 'Jan 10 2011 should be week 2');
- });
-
test('weeks year starting sunday formatted', function (assert) {
assert.equal(moment([2012, 0, 1]).format('w ww wo'), '52 52 52.', 'Jan 1 2012 should be week 52');
assert.equal(moment([2012, 0, 2]).format('w ww wo'), '1 01 1.', 'Jan 2 2012 should be week 1');
@@ -5299,42 +7160,6 @@
assert.equal(moment([2012, 0, 15]).format('w ww wo'), '2 02 2.', 'Jan 15 2012 should be week 2');
});
- test('lenient ordinal parsing', function (assert) {
- var i, ordinalStr, testMoment;
- for (i = 1; i <= 31; ++i) {
- ordinalStr = moment([2014, 0, i]).format('YYYY MM Do');
- testMoment = moment(ordinalStr, 'YYYY MM Do');
- assert.equal(testMoment.year(), 2014,
- 'lenient ordinal parsing ' + i + ' year check');
- assert.equal(testMoment.month(), 0,
- 'lenient ordinal parsing ' + i + ' month check');
- assert.equal(testMoment.date(), i,
- 'lenient ordinal parsing ' + i + ' date check');
- }
- });
-
- test('lenient ordinal parsing of number', function (assert) {
- var i, testMoment;
- for (i = 1; i <= 31; ++i) {
- testMoment = moment('2014 01 ' + i, 'YYYY MM Do');
- assert.equal(testMoment.year(), 2014,
- 'lenient ordinal parsing of number ' + i + ' year check');
- assert.equal(testMoment.month(), 0,
- 'lenient ordinal parsing of number ' + i + ' month check');
- assert.equal(testMoment.date(), i,
- 'lenient ordinal parsing of number ' + i + ' date check');
- }
- });
-
- test('strict ordinal parsing', function (assert) {
- var i, ordinalStr, testMoment;
- for (i = 1; i <= 31; ++i) {
- ordinalStr = moment([2014, 0, i]).format('YYYY MM Do');
- testMoment = moment(ordinalStr, 'YYYY MM Do', true);
- assert.ok(testMoment.isValid(), 'strict ordinal parsing ' + i);
- }
- });
-
}));
;(function (global, factory) {
@@ -5343,6 +7168,224 @@
typeof define === 'function' && define.amd ? define(['../../moment'], factory) :
factory(global.moment)
}(this, function (moment) { 'use strict';
+
+ function each(array, callback) {
+ var i;
+ for (i = 0; i < array.length; i++) {
+ callback(array[i], i, array);
+ }
+ }
+
+ function objectKeys(obj) {
+ if (Object.keys) {
+ return Object.keys(obj);
+ } else {
+ // IE8
+ var res = [], i;
+ for (i in obj) {
+ if (obj.hasOwnProperty(i)) {
+ res.push(i);
+ }
+ }
+ return res;
+ }
+ }
+
+ // Pick the first defined of two or three arguments.
+ function defaults(a, b, c) {
+ if (a != null) {
+ return a;
+ }
+ if (b != null) {
+ return b;
+ }
+ return c;
+ }
+
+ function defineCommonLocaleTests(locale, options) {
+ test('lenient ordinal parsing', function (assert) {
+ var i, ordinalStr, testMoment;
+ for (i = 1; i <= 31; ++i) {
+ ordinalStr = moment([2014, 0, i]).format('YYYY MM Do');
+ testMoment = moment(ordinalStr, 'YYYY MM Do');
+ assert.equal(testMoment.year(), 2014,
+ 'lenient ordinal parsing ' + i + ' year check');
+ assert.equal(testMoment.month(), 0,
+ 'lenient ordinal parsing ' + i + ' month check');
+ assert.equal(testMoment.date(), i,
+ 'lenient ordinal parsing ' + i + ' date check');
+ }
+ });
+
+ test('lenient ordinal parsing of number', function (assert) {
+ var i, testMoment;
+ for (i = 1; i <= 31; ++i) {
+ testMoment = moment('2014 01 ' + i, 'YYYY MM Do');
+ assert.equal(testMoment.year(), 2014,
+ 'lenient ordinal parsing of number ' + i + ' year check');
+ assert.equal(testMoment.month(), 0,
+ 'lenient ordinal parsing of number ' + i + ' month check');
+ assert.equal(testMoment.date(), i,
+ 'lenient ordinal parsing of number ' + i + ' date check');
+ }
+ });
+
+ test('strict ordinal parsing', function (assert) {
+ var i, ordinalStr, testMoment;
+ for (i = 1; i <= 31; ++i) {
+ ordinalStr = moment([2014, 0, i]).format('YYYY MM Do');
+ testMoment = moment(ordinalStr, 'YYYY MM Do', true);
+ assert.ok(testMoment.isValid(), 'strict ordinal parsing ' + i);
+ }
+ });
+
+ test('meridiem invariant', function (assert) {
+ var h, m, t1, t2;
+ for (h = 0; h < 24; ++h) {
+ for (m = 0; m < 60; m += 15) {
+ t1 = moment.utc([2000, 0, 1, h, m]);
+ t2 = moment.utc(t1.format('A h:mm'), 'A h:mm');
+ assert.equal(t2.format('HH:mm'), t1.format('HH:mm'),
+ 'meridiem at ' + t1.format('HH:mm'));
+ }
+ }
+ });
+
+ test('date format correctness', function (assert) {
+ var data, tokens;
+ data = moment.localeData()._longDateFormat;
+ tokens = objectKeys(data);
+ each(tokens, function (srchToken) {
+ // Check each format string to make sure it does not contain any
+ // tokens that need to be expanded.
+ each(tokens, function (baseToken) {
+ // strip escaped sequences
+ var format = data[baseToken].replace(/(\[[^\]]*\])/g, '');
+ assert.equal(false, !!~format.indexOf(srchToken),
+ 'contains ' + srchToken + ' in ' + baseToken);
+ });
+ });
+ });
+
+ test('month parsing correctness', function (assert) {
+ var i, m;
+
+ if (locale === 'tr') {
+ // I can't fix it :(
+ expect(0);
+ return;
+ }
+ function tester(format) {
+ var r;
+ r = moment(m.format(format), format);
+ assert.equal(r.month(), m.month(), 'month ' + i + ' fmt ' + format);
+ r = moment(m.format(format).toLocaleUpperCase(), format);
+ assert.equal(r.month(), m.month(), 'month ' + i + ' fmt ' + format + ' upper');
+ r = moment(m.format(format).toLocaleLowerCase(), format);
+ assert.equal(r.month(), m.month(), 'month ' + i + ' fmt ' + format + ' lower');
+
+ r = moment(m.format(format), format, true);
+ assert.equal(r.month(), m.month(), 'month ' + i + ' fmt ' + format + ' strict');
+ r = moment(m.format(format).toLocaleUpperCase(), format, true);
+ assert.equal(r.month(), m.month(), 'month ' + i + ' fmt ' + format + ' upper strict');
+ r = moment(m.format(format).toLocaleLowerCase(), format, true);
+ assert.equal(r.month(), m.month(), 'month ' + i + ' fmt ' + format + ' lower strict');
+ }
+
+ for (i = 0; i < 12; ++i) {
+ m = moment([2015, i, 15, 18]);
+ tester('MMM');
+ tester('MMM.');
+ tester('MMMM');
+ tester('MMMM.');
+ }
+ });
+
+ test('weekday parsing correctness', function (assert) {
+ var i, m;
+
+ if (locale === 'tr' || locale === 'az') {
+ // There is a lower-case letter (ı), that converted to upper then
+ // lower changes to i
+ expect(0);
+ return;
+ }
+ function tester(format) {
+ var r, baseMsg = 'weekday ' + m.weekday() + ' fmt ' + format;
+ r = moment(m.format(format), format);
+ assert.equal(r.weekday(), m.weekday(), baseMsg);
+ r = moment(m.format(format).toLocaleUpperCase(), format);
+ assert.equal(r.weekday(), m.weekday(), baseMsg + ' upper');
+ r = moment(m.format(format).toLocaleLowerCase(), format);
+ assert.equal(r.weekday(), m.weekday(), baseMsg + ' lower');
+
+ r = moment(m.format(format), format, true);
+ assert.equal(r.weekday(), m.weekday(), baseMsg + ' strict');
+ r = moment(m.format(format).toLocaleUpperCase(), format, true);
+ assert.equal(r.weekday(), m.weekday(), baseMsg + ' upper strict');
+ r = moment(m.format(format).toLocaleLowerCase(), format, true);
+ assert.equal(r.weekday(), m.weekday(), baseMsg + ' lower strict');
+ }
+
+ for (i = 0; i < 7; ++i) {
+ m = moment.utc([2015, i, 15, 18]);
+ tester('dd');
+ tester('ddd');
+ tester('dddd');
+ }
+ });
+ }
+
+ function setupDeprecationHandler(test, moment, scope) {
+ test._expectedDeprecations = null;
+ test._observedDeprecations = null;
+ test._oldSupress = moment.suppressDeprecationWarnings;
+ moment.suppressDeprecationWarnings = true;
+ test.expectedDeprecations = function () {
+ test._expectedDeprecations = arguments;
+ test._observedDeprecations = [];
+ };
+ moment.deprecationHandler = function (name, msg) {
+ var deprecationId = matchedDeprecation(name, msg, test._expectedDeprecations);
+ if (deprecationId === -1) {
+ throw new Error('Unexpected deprecation thrown name=' +
+ name + ' msg=' + msg);
+ }
+ test._observedDeprecations[deprecationId] = 1;
+ };
+ }
+
+ function teardownDeprecationHandler(test, moment, scope) {
+ moment.suppressDeprecationWarnings = test._oldSupress;
+
+ if (test._expectedDeprecations != null) {
+ var missedDeprecations = [];
+ each(test._expectedDeprecations, function (deprecationPattern, id) {
+ if (test._observedDeprecations[id] !== 1) {
+ missedDeprecations.push(deprecationPattern);
+ }
+ });
+ if (missedDeprecations.length !== 0) {
+ throw new Error('Expected deprecation warnings did not happen: ' +
+ missedDeprecations.join(' '));
+ }
+ }
+ }
+
+ function matchedDeprecation(name, msg, deprecations) {
+ if (deprecations == null) {
+ return -1;
+ }
+ for (var i = 0; i < deprecations.length; ++i) {
+ if (name != null && name === deprecations[i]) {
+ return i;
+ }
+ if (msg != null && msg.substring(0, deprecations[i].length) === deprecations[i]) {
+ return i;
+ }
+ }
+ return -1;
+ }
/*global QUnit:false*/
@@ -5357,11 +7400,13 @@
moment.createFromInputFallback = function (config) {
throw new Error('input not handled by moment: ' + config._i);
};
+ setupDeprecationHandler(test, moment, 'core');
if (lifecycle && lifecycle.setup) {
lifecycle.setup();
}
},
teardown : function () {
+ teardownDeprecationHandler(test, moment, 'core');
if (lifecycle && lifecycle.teardown) {
lifecycle.teardown();
}
@@ -5376,17 +7421,20 @@
moment.createFromInputFallback = function (config) {
throw new Error('input not handled by moment: ' + config._i);
};
+ setupDeprecationHandler(test, moment, 'locale');
if (lifecycle && lifecycle.setup) {
lifecycle.setup();
}
},
teardown : function () {
moment.locale('en');
+ teardownDeprecationHandler(test, moment, 'locale');
if (lifecycle && lifecycle.teardown) {
lifecycle.teardown();
}
}
});
+ defineCommonLocaleTests(name, -1, -1);
}
localeModule('cv');
@@ -5542,13 +7590,13 @@
});
test('calendar day', function (assert) {
- var a = moment().hours(2).minutes(0).seconds(0);
- assert.equal(moment(a).calendar(), 'Паян 02:00 сехетре', 'today at the same time');
- assert.equal(moment(a).add({m: 25}).calendar(), 'Паян 02:25 сехетре', 'Now plus 25 min');
- assert.equal(moment(a).add({h: 1}).calendar(), 'Паян 03:00 сехетре', 'Now plus 1 hour');
- assert.equal(moment(a).add({d: 1}).calendar(), 'Ыран 02:00 сехетре', 'tomorrow at the same time');
- assert.equal(moment(a).subtract({h: 1}).calendar(), 'Паян 01:00 сехетре', 'Now minus 1 hour');
- assert.equal(moment(a).subtract({d: 1}).calendar(), 'Ӗнер 02:00 сехетре', 'yesterday at the same time');
+ var a = moment().hours(12).minutes(0).seconds(0);
+ assert.equal(moment(a).calendar(), 'Паян 12:00 сехетре', 'today at the same time');
+ assert.equal(moment(a).add({m: 25}).calendar(), 'Паян 12:25 сехетре', 'Now plus 25 min');
+ assert.equal(moment(a).add({h: 1}).calendar(), 'Паян 13:00 сехетре', 'Now plus 1 hour');
+ assert.equal(moment(a).add({d: 1}).calendar(), 'Ыран 12:00 сехетре', 'tomorrow at the same time');
+ assert.equal(moment(a).subtract({h: 1}).calendar(), 'Паян 11:00 сехетре', 'Now minus 1 hour');
+ assert.equal(moment(a).subtract({d: 1}).calendar(), 'Ӗнер 12:00 сехетре', 'yesterday at the same time');
});
test('calendar next week', function (assert) {
@@ -5594,67 +7642,6 @@
// Monday is the first day of the week.
// The week that contains Jan 1st is the first week of the year.
- test('weeks year starting sunday', function (assert) {
- assert.equal(moment([2011, 11, 26]).week(), 1, 'Dec 26 2011 should be week 1');
- assert.equal(moment([2012, 0, 1]).week(), 1, 'Jan 1 2012 should be week 1');
- assert.equal(moment([2012, 0, 2]).week(), 2, 'Jan 2 2012 should be week 2');
- assert.equal(moment([2012, 0, 8]).week(), 2, 'Jan 8 2012 should be week 2');
- assert.equal(moment([2012, 0, 9]).week(), 3, 'Jan 9 2012 should be week 3');
- });
-
- test('weeks year starting monday', function (assert) {
- assert.equal(moment([2007, 0, 1]).week(), 1, 'Jan 1 2007 should be week 1');
- assert.equal(moment([2007, 0, 7]).week(), 1, 'Jan 7 2007 should be week 1');
- assert.equal(moment([2007, 0, 8]).week(), 2, 'Jan 8 2007 should be week 2');
- assert.equal(moment([2007, 0, 14]).week(), 2, 'Jan 14 2007 should be week 2');
- assert.equal(moment([2007, 0, 15]).week(), 3, 'Jan 15 2007 should be week 3');
- });
-
- test('weeks year starting tuesday', function (assert) {
- assert.equal(moment([2007, 11, 31]).week(), 1, 'Dec 31 2007 should be week 1');
- assert.equal(moment([2008, 0, 1]).week(), 1, 'Jan 1 2008 should be week 1');
- assert.equal(moment([2008, 0, 6]).week(), 1, 'Jan 6 2008 should be week 1');
- assert.equal(moment([2008, 0, 7]).week(), 2, 'Jan 7 2008 should be week 2');
- assert.equal(moment([2008, 0, 13]).week(), 2, 'Jan 13 2008 should be week 2');
- assert.equal(moment([2008, 0, 14]).week(), 3, 'Jan 14 2008 should be week 3');
- });
-
- test('weeks year starting wednesday', function (assert) {
- assert.equal(moment([2002, 11, 30]).week(), 1, 'Dec 30 2002 should be week 1');
- assert.equal(moment([2003, 0, 1]).week(), 1, 'Jan 1 2003 should be week 1');
- assert.equal(moment([2003, 0, 5]).week(), 1, 'Jan 5 2003 should be week 1');
- assert.equal(moment([2003, 0, 6]).week(), 2, 'Jan 6 2003 should be week 2');
- assert.equal(moment([2003, 0, 12]).week(), 2, 'Jan 12 2003 should be week 2');
- assert.equal(moment([2003, 0, 13]).week(), 3, 'Jan 13 2003 should be week 3');
- });
-
- test('weeks year starting thursday', function (assert) {
- assert.equal(moment([2008, 11, 29]).week(), 1, 'Dec 29 2008 should be week 1');
- assert.equal(moment([2009, 0, 1]).week(), 1, 'Jan 1 2009 should be week 1');
- assert.equal(moment([2009, 0, 4]).week(), 1, 'Jan 4 2009 should be week 1');
- assert.equal(moment([2009, 0, 5]).week(), 2, 'Jan 5 2009 should be week 2');
- assert.equal(moment([2009, 0, 11]).week(), 2, 'Jan 11 2009 should be week 2');
- assert.equal(moment([2009, 0, 12]).week(), 3, 'Jan 12 2009 should be week 3');
- });
-
- test('weeks year starting friday', function (assert) {
- assert.equal(moment([2009, 11, 28]).week(), 1, 'Dec 28 2009 should be week 1');
- assert.equal(moment([2010, 0, 1]).week(), 1, 'Jan 1 2010 should be week 1');
- assert.equal(moment([2010, 0, 3]).week(), 1, 'Jan 3 2010 should be week 1');
- assert.equal(moment([2010, 0, 4]).week(), 2, 'Jan 4 2010 should be week 2');
- assert.equal(moment([2010, 0, 10]).week(), 2, 'Jan 10 2010 should be week 2');
- assert.equal(moment([2010, 0, 11]).week(), 3, 'Jan 11 2010 should be week 3');
- });
-
- test('weeks year starting saturday', function (assert) {
- assert.equal(moment([2010, 11, 27]).week(), 1, 'Dec 27 2010 should be week 1');
- assert.equal(moment([2011, 0, 1]).week(), 1, 'Jan 1 2011 should be week 1');
- assert.equal(moment([2011, 0, 2]).week(), 1, 'Jan 2 2011 should be week 1');
- assert.equal(moment([2011, 0, 3]).week(), 2, 'Jan 3 2011 should be week 2');
- assert.equal(moment([2011, 0, 9]).week(), 2, 'Jan 9 2011 should be week 2');
- assert.equal(moment([2011, 0, 10]).week(), 3, 'Jan 10 2011 should be week 3');
- });
-
test('weeks year starting sunday formatted', function (assert) {
assert.equal(moment([2011, 11, 26]).format('w ww wo'), '1 01 1-мӗш', 'Dec 26 2011 should be week 1');
assert.equal(moment([2012, 0, 1]).format('w ww wo'), '1 01 1-мӗш', 'Jan 1 2012 should be week 1');
@@ -5663,42 +7650,6 @@
assert.equal(moment([2012, 0, 9]).format('w ww wo'), '3 03 3-мӗш', 'Jan 9 2012 should be week 3');
});
- test('lenient ordinal parsing', function (assert) {
- var i, ordinalStr, testMoment;
- for (i = 1; i <= 31; ++i) {
- ordinalStr = moment([2014, 0, i]).format('YYYY MM Do');
- testMoment = moment(ordinalStr, 'YYYY MM Do');
- assert.equal(testMoment.year(), 2014,
- 'lenient ordinal parsing ' + i + ' year check');
- assert.equal(testMoment.month(), 0,
- 'lenient ordinal parsing ' + i + ' month check');
- assert.equal(testMoment.date(), i,
- 'lenient ordinal parsing ' + i + ' date check');
- }
- });
-
- test('lenient ordinal parsing of number', function (assert) {
- var i, testMoment;
- for (i = 1; i <= 31; ++i) {
- testMoment = moment('2014 01 ' + i, 'YYYY MM Do');
- assert.equal(testMoment.year(), 2014,
- 'lenient ordinal parsing of number ' + i + ' year check');
- assert.equal(testMoment.month(), 0,
- 'lenient ordinal parsing of number ' + i + ' month check');
- assert.equal(testMoment.date(), i,
- 'lenient ordinal parsing of number ' + i + ' date check');
- }
- });
-
- test('strict ordinal parsing', function (assert) {
- var i, ordinalStr, testMoment;
- for (i = 1; i <= 31; ++i) {
- ordinalStr = moment([2014, 0, i]).format('YYYY MM Do');
- testMoment = moment(ordinalStr, 'YYYY MM Do', true);
- assert.ok(testMoment.isValid(), 'strict ordinal parsing ' + i);
- }
- });
-
}));
;(function (global, factory) {
@@ -5707,6 +7658,224 @@
typeof define === 'function' && define.amd ? define(['../../moment'], factory) :
factory(global.moment)
}(this, function (moment) { 'use strict';
+
+ function each(array, callback) {
+ var i;
+ for (i = 0; i < array.length; i++) {
+ callback(array[i], i, array);
+ }
+ }
+
+ function objectKeys(obj) {
+ if (Object.keys) {
+ return Object.keys(obj);
+ } else {
+ // IE8
+ var res = [], i;
+ for (i in obj) {
+ if (obj.hasOwnProperty(i)) {
+ res.push(i);
+ }
+ }
+ return res;
+ }
+ }
+
+ // Pick the first defined of two or three arguments.
+ function defaults(a, b, c) {
+ if (a != null) {
+ return a;
+ }
+ if (b != null) {
+ return b;
+ }
+ return c;
+ }
+
+ function defineCommonLocaleTests(locale, options) {
+ test('lenient ordinal parsing', function (assert) {
+ var i, ordinalStr, testMoment;
+ for (i = 1; i <= 31; ++i) {
+ ordinalStr = moment([2014, 0, i]).format('YYYY MM Do');
+ testMoment = moment(ordinalStr, 'YYYY MM Do');
+ assert.equal(testMoment.year(), 2014,
+ 'lenient ordinal parsing ' + i + ' year check');
+ assert.equal(testMoment.month(), 0,
+ 'lenient ordinal parsing ' + i + ' month check');
+ assert.equal(testMoment.date(), i,
+ 'lenient ordinal parsing ' + i + ' date check');
+ }
+ });
+
+ test('lenient ordinal parsing of number', function (assert) {
+ var i, testMoment;
+ for (i = 1; i <= 31; ++i) {
+ testMoment = moment('2014 01 ' + i, 'YYYY MM Do');
+ assert.equal(testMoment.year(), 2014,
+ 'lenient ordinal parsing of number ' + i + ' year check');
+ assert.equal(testMoment.month(), 0,
+ 'lenient ordinal parsing of number ' + i + ' month check');
+ assert.equal(testMoment.date(), i,
+ 'lenient ordinal parsing of number ' + i + ' date check');
+ }
+ });
+
+ test('strict ordinal parsing', function (assert) {
+ var i, ordinalStr, testMoment;
+ for (i = 1; i <= 31; ++i) {
+ ordinalStr = moment([2014, 0, i]).format('YYYY MM Do');
+ testMoment = moment(ordinalStr, 'YYYY MM Do', true);
+ assert.ok(testMoment.isValid(), 'strict ordinal parsing ' + i);
+ }
+ });
+
+ test('meridiem invariant', function (assert) {
+ var h, m, t1, t2;
+ for (h = 0; h < 24; ++h) {
+ for (m = 0; m < 60; m += 15) {
+ t1 = moment.utc([2000, 0, 1, h, m]);
+ t2 = moment.utc(t1.format('A h:mm'), 'A h:mm');
+ assert.equal(t2.format('HH:mm'), t1.format('HH:mm'),
+ 'meridiem at ' + t1.format('HH:mm'));
+ }
+ }
+ });
+
+ test('date format correctness', function (assert) {
+ var data, tokens;
+ data = moment.localeData()._longDateFormat;
+ tokens = objectKeys(data);
+ each(tokens, function (srchToken) {
+ // Check each format string to make sure it does not contain any
+ // tokens that need to be expanded.
+ each(tokens, function (baseToken) {
+ // strip escaped sequences
+ var format = data[baseToken].replace(/(\[[^\]]*\])/g, '');
+ assert.equal(false, !!~format.indexOf(srchToken),
+ 'contains ' + srchToken + ' in ' + baseToken);
+ });
+ });
+ });
+
+ test('month parsing correctness', function (assert) {
+ var i, m;
+
+ if (locale === 'tr') {
+ // I can't fix it :(
+ expect(0);
+ return;
+ }
+ function tester(format) {
+ var r;
+ r = moment(m.format(format), format);
+ assert.equal(r.month(), m.month(), 'month ' + i + ' fmt ' + format);
+ r = moment(m.format(format).toLocaleUpperCase(), format);
+ assert.equal(r.month(), m.month(), 'month ' + i + ' fmt ' + format + ' upper');
+ r = moment(m.format(format).toLocaleLowerCase(), format);
+ assert.equal(r.month(), m.month(), 'month ' + i + ' fmt ' + format + ' lower');
+
+ r = moment(m.format(format), format, true);
+ assert.equal(r.month(), m.month(), 'month ' + i + ' fmt ' + format + ' strict');
+ r = moment(m.format(format).toLocaleUpperCase(), format, true);
+ assert.equal(r.month(), m.month(), 'month ' + i + ' fmt ' + format + ' upper strict');
+ r = moment(m.format(format).toLocaleLowerCase(), format, true);
+ assert.equal(r.month(), m.month(), 'month ' + i + ' fmt ' + format + ' lower strict');
+ }
+
+ for (i = 0; i < 12; ++i) {
+ m = moment([2015, i, 15, 18]);
+ tester('MMM');
+ tester('MMM.');
+ tester('MMMM');
+ tester('MMMM.');
+ }
+ });
+
+ test('weekday parsing correctness', function (assert) {
+ var i, m;
+
+ if (locale === 'tr' || locale === 'az') {
+ // There is a lower-case letter (ı), that converted to upper then
+ // lower changes to i
+ expect(0);
+ return;
+ }
+ function tester(format) {
+ var r, baseMsg = 'weekday ' + m.weekday() + ' fmt ' + format;
+ r = moment(m.format(format), format);
+ assert.equal(r.weekday(), m.weekday(), baseMsg);
+ r = moment(m.format(format).toLocaleUpperCase(), format);
+ assert.equal(r.weekday(), m.weekday(), baseMsg + ' upper');
+ r = moment(m.format(format).toLocaleLowerCase(), format);
+ assert.equal(r.weekday(), m.weekday(), baseMsg + ' lower');
+
+ r = moment(m.format(format), format, true);
+ assert.equal(r.weekday(), m.weekday(), baseMsg + ' strict');
+ r = moment(m.format(format).toLocaleUpperCase(), format, true);
+ assert.equal(r.weekday(), m.weekday(), baseMsg + ' upper strict');
+ r = moment(m.format(format).toLocaleLowerCase(), format, true);
+ assert.equal(r.weekday(), m.weekday(), baseMsg + ' lower strict');
+ }
+
+ for (i = 0; i < 7; ++i) {
+ m = moment.utc([2015, i, 15, 18]);
+ tester('dd');
+ tester('ddd');
+ tester('dddd');
+ }
+ });
+ }
+
+ function setupDeprecationHandler(test, moment, scope) {
+ test._expectedDeprecations = null;
+ test._observedDeprecations = null;
+ test._oldSupress = moment.suppressDeprecationWarnings;
+ moment.suppressDeprecationWarnings = true;
+ test.expectedDeprecations = function () {
+ test._expectedDeprecations = arguments;
+ test._observedDeprecations = [];
+ };
+ moment.deprecationHandler = function (name, msg) {
+ var deprecationId = matchedDeprecation(name, msg, test._expectedDeprecations);
+ if (deprecationId === -1) {
+ throw new Error('Unexpected deprecation thrown name=' +
+ name + ' msg=' + msg);
+ }
+ test._observedDeprecations[deprecationId] = 1;
+ };
+ }
+
+ function teardownDeprecationHandler(test, moment, scope) {
+ moment.suppressDeprecationWarnings = test._oldSupress;
+
+ if (test._expectedDeprecations != null) {
+ var missedDeprecations = [];
+ each(test._expectedDeprecations, function (deprecationPattern, id) {
+ if (test._observedDeprecations[id] !== 1) {
+ missedDeprecations.push(deprecationPattern);
+ }
+ });
+ if (missedDeprecations.length !== 0) {
+ throw new Error('Expected deprecation warnings did not happen: ' +
+ missedDeprecations.join(' '));
+ }
+ }
+ }
+
+ function matchedDeprecation(name, msg, deprecations) {
+ if (deprecations == null) {
+ return -1;
+ }
+ for (var i = 0; i < deprecations.length; ++i) {
+ if (name != null && name === deprecations[i]) {
+ return i;
+ }
+ if (msg != null && msg.substring(0, deprecations[i].length) === deprecations[i]) {
+ return i;
+ }
+ }
+ return -1;
+ }
/*global QUnit:false*/
@@ -5721,11 +7890,13 @@
moment.createFromInputFallback = function (config) {
throw new Error('input not handled by moment: ' + config._i);
};
+ setupDeprecationHandler(test, moment, 'core');
if (lifecycle && lifecycle.setup) {
lifecycle.setup();
}
},
teardown : function () {
+ teardownDeprecationHandler(test, moment, 'core');
if (lifecycle && lifecycle.teardown) {
lifecycle.teardown();
}
@@ -5740,17 +7911,20 @@
moment.createFromInputFallback = function (config) {
throw new Error('input not handled by moment: ' + config._i);
};
+ setupDeprecationHandler(test, moment, 'locale');
if (lifecycle && lifecycle.setup) {
lifecycle.setup();
}
},
teardown : function () {
moment.locale('en');
+ teardownDeprecationHandler(test, moment, 'locale');
if (lifecycle && lifecycle.teardown) {
lifecycle.teardown();
}
}
});
+ defineCommonLocaleTests(name, -1, -1);
}
localeModule('cy');
@@ -5900,18 +8074,18 @@
assert.equal(moment().add({d: 5}).fromNow(), 'mewn 5 diwrnod', 'in 5 days');
});
- test('same day', function (assert) {
- var a = moment().hours(2).minutes(0).seconds(0);
-
- assert.equal(moment(a).calendar(), 'Heddiw am 02:00', 'today at the same time');
- assert.equal(moment(a).add({m: 25}).calendar(), 'Heddiw am 02:25', 'Now plus 25 min');
- assert.equal(moment(a).add({h: 1}).calendar(), 'Heddiw am 03:00', 'Now plus 1 hour');
- assert.equal(moment(a).add({d: 1}).calendar(), 'Yfory am 02:00', 'tomorrow at the same time');
- assert.equal(moment(a).subtract({h: 1}).calendar(), 'Heddiw am 01:00', 'Now minus 1 hour');
- assert.equal(moment(a).subtract({d: 1}).calendar(), 'Ddoe am 02:00', 'yesterday at the same time');
- });
-
- test('same next week', function (assert) {
+ test('calendar day', function (assert) {
+ var a = moment().hours(12).minutes(0).seconds(0);
+
+ assert.equal(moment(a).calendar(), 'Heddiw am 12:00', 'today at the same time');
+ assert.equal(moment(a).add({m: 25}).calendar(), 'Heddiw am 12:25', 'Now plus 25 min');
+ assert.equal(moment(a).add({h: 1}).calendar(), 'Heddiw am 13:00', 'Now plus 1 hour');
+ assert.equal(moment(a).add({d: 1}).calendar(), 'Yfory am 12:00', 'tomorrow at the same time');
+ assert.equal(moment(a).subtract({h: 1}).calendar(), 'Heddiw am 11:00', 'Now minus 1 hour');
+ assert.equal(moment(a).subtract({d: 1}).calendar(), 'Ddoe am 12:00', 'yesterday at the same time');
+ });
+
+ test('calendar next week', function (assert) {
var i, m;
for (i = 2; i < 7; i++) {
@@ -5924,7 +8098,7 @@
}
});
- test('same last week', function (assert) {
+ test('calendar last week', function (assert) {
var i, m;
for (i = 2; i < 7; i++) {
@@ -5937,7 +8111,7 @@
}
});
- test('same all else', function (assert) {
+ test('calendar all else', function (assert) {
var weeksAgo = moment().subtract({w: 1}),
weeksFromNow = moment().add({w: 1});
@@ -5949,67 +8123,6 @@
assert.equal(weeksAgo.calendar(), weeksAgo.format('L'), '2 weeks ago');
assert.equal(weeksFromNow.calendar(), weeksFromNow.format('L'), 'in 2 weeks');
- });
-
- test('weeks year starting sunday', function (assert) {
- assert.equal(moment([2012, 0, 1]).week(), 52, 'Jan 1 2012 should be week 52');
- assert.equal(moment([2012, 0, 2]).week(), 1, 'Jan 2 2012 should be week 1');
- assert.equal(moment([2012, 0, 8]).week(), 1, 'Jan 8 2012 should be week 1');
- assert.equal(moment([2012, 0, 9]).week(), 2, 'Jan 9 2012 should be week 2');
- assert.equal(moment([2012, 0, 15]).week(), 2, 'Jan 15 2012 should be week 2');
- });
-
- test('weeks year starting monday', function (assert) {
- assert.equal(moment([2007, 0, 1]).week(), 1, 'Jan 1 2007 should be week 1');
- assert.equal(moment([2007, 0, 7]).week(), 1, 'Jan 7 2007 should be week 1');
- assert.equal(moment([2007, 0, 8]).week(), 2, 'Jan 8 2007 should be week 2');
- assert.equal(moment([2007, 0, 14]).week(), 2, 'Jan 14 2007 should be week 2');
- assert.equal(moment([2007, 0, 15]).week(), 3, 'Jan 15 2007 should be week 3');
- });
-
- test('weeks year starting tuesday', function (assert) {
- assert.equal(moment([2007, 11, 31]).week(), 1, 'Dec 31 2007 should be week 1');
- assert.equal(moment([2008, 0, 1]).week(), 1, 'Jan 1 2008 should be week 1');
- assert.equal(moment([2008, 0, 6]).week(), 1, 'Jan 6 2008 should be week 1');
- assert.equal(moment([2008, 0, 7]).week(), 2, 'Jan 7 2008 should be week 2');
- assert.equal(moment([2008, 0, 13]).week(), 2, 'Jan 13 2008 should be week 2');
- assert.equal(moment([2008, 0, 14]).week(), 3, 'Jan 14 2008 should be week 3');
- });
-
- test('weeks year starting wednesday', function (assert) {
- assert.equal(moment([2002, 11, 30]).week(), 1, 'Dec 30 2002 should be week 1');
- assert.equal(moment([2003, 0, 1]).week(), 1, 'Jan 1 2003 should be week 1');
- assert.equal(moment([2003, 0, 5]).week(), 1, 'Jan 5 2003 should be week 1');
- assert.equal(moment([2003, 0, 6]).week(), 2, 'Jan 6 2003 should be week 2');
- assert.equal(moment([2003, 0, 12]).week(), 2, 'Jan 12 2003 should be week 2');
- assert.equal(moment([2003, 0, 13]).week(), 3, 'Jan 13 2003 should be week 3');
- });
-
- test('weeks year starting thursday', function (assert) {
- assert.equal(moment([2008, 11, 29]).week(), 1, 'Dec 29 2008 should be week 1');
- assert.equal(moment([2009, 0, 1]).week(), 1, 'Jan 1 2009 should be week 1');
- assert.equal(moment([2009, 0, 4]).week(), 1, 'Jan 4 2009 should be week 1');
- assert.equal(moment([2009, 0, 5]).week(), 2, 'Jan 5 2009 should be week 2');
- assert.equal(moment([2009, 0, 11]).week(), 2, 'Jan 11 2009 should be week 2');
- assert.equal(moment([2009, 0, 13]).week(), 3, 'Jan 12 2009 should be week 3');
- });
-
- test('weeks year starting friday', function (assert) {
- assert.equal(moment([2009, 11, 28]).week(), 53, 'Dec 28 2009 should be week 53');
- assert.equal(moment([2010, 0, 1]).week(), 53, 'Jan 1 2010 should be week 53');
- assert.equal(moment([2010, 0, 3]).week(), 53, 'Jan 3 2010 should be week 53');
- assert.equal(moment([2010, 0, 4]).week(), 1, 'Jan 4 2010 should be week 1');
- assert.equal(moment([2010, 0, 10]).week(), 1, 'Jan 10 2010 should be week 1');
- assert.equal(moment([2010, 0, 11]).week(), 2, 'Jan 11 2010 should be week 2');
- });
-
- test('weeks year starting saturday', function (assert) {
- assert.equal(moment([2010, 11, 27]).week(), 52, 'Dec 27 2010 should be week 52');
- assert.equal(moment([2011, 0, 1]).week(), 52, 'Jan 1 2011 should be week 52');
- assert.equal(moment([2011, 0, 2]).week(), 52, 'Jan 2 2011 should be week 52');
- assert.equal(moment([2011, 0, 3]).week(), 1, 'Jan 3 2011 should be week 1');
- assert.equal(moment([2011, 0, 9]).week(), 1, 'Jan 9 2011 should be week 1');
- assert.equal(moment([2011, 0, 10]).week(), 2, 'Jan 10 2011 should be week 2');
});
test('weeks year starting sunday formatted', function (assert) {
@@ -6020,42 +8133,6 @@
assert.equal(moment([2012, 0, 15]).format('w ww wo'), '2 02 2il', 'Jan 15 2012 should be week 2');
});
- test('lenient ordinal parsing', function (assert) {
- var i, ordinalStr, testMoment;
- for (i = 1; i <= 31; ++i) {
- ordinalStr = moment([2014, 0, i]).format('YYYY MM Do');
- testMoment = moment(ordinalStr, 'YYYY MM Do');
- assert.equal(testMoment.year(), 2014,
- 'lenient ordinal parsing ' + i + ' year check');
- assert.equal(testMoment.month(), 0,
- 'lenient ordinal parsing ' + i + ' month check');
- assert.equal(testMoment.date(), i,
- 'lenient ordinal parsing ' + i + ' date check');
- }
- });
-
- test('lenient ordinal parsing of number', function (assert) {
- var i, testMoment;
- for (i = 1; i <= 31; ++i) {
- testMoment = moment('2014 01 ' + i, 'YYYY MM Do');
- assert.equal(testMoment.year(), 2014,
- 'lenient ordinal parsing of number ' + i + ' year check');
- assert.equal(testMoment.month(), 0,
- 'lenient ordinal parsing of number ' + i + ' month check');
- assert.equal(testMoment.date(), i,
- 'lenient ordinal parsing of number ' + i + ' date check');
- }
- });
-
- test('strict ordinal parsing', function (assert) {
- var i, ordinalStr, testMoment;
- for (i = 1; i <= 31; ++i) {
- ordinalStr = moment([2014, 0, i]).format('YYYY MM Do');
- testMoment = moment(ordinalStr, 'YYYY MM Do', true);
- assert.ok(testMoment.isValid(), 'strict ordinal parsing ' + i);
- }
- });
-
}));
;(function (global, factory) {
@@ -6064,6 +8141,224 @@
typeof define === 'function' && define.amd ? define(['../../moment'], factory) :
factory(global.moment)
}(this, function (moment) { 'use strict';
+
+ function each(array, callback) {
+ var i;
+ for (i = 0; i < array.length; i++) {
+ callback(array[i], i, array);
+ }
+ }
+
+ function objectKeys(obj) {
+ if (Object.keys) {
+ return Object.keys(obj);
+ } else {
+ // IE8
+ var res = [], i;
+ for (i in obj) {
+ if (obj.hasOwnProperty(i)) {
+ res.push(i);
+ }
+ }
+ return res;
+ }
+ }
+
+ // Pick the first defined of two or three arguments.
+ function defaults(a, b, c) {
+ if (a != null) {
+ return a;
+ }
+ if (b != null) {
+ return b;
+ }
+ return c;
+ }
+
+ function defineCommonLocaleTests(locale, options) {
+ test('lenient ordinal parsing', function (assert) {
+ var i, ordinalStr, testMoment;
+ for (i = 1; i <= 31; ++i) {
+ ordinalStr = moment([2014, 0, i]).format('YYYY MM Do');
+ testMoment = moment(ordinalStr, 'YYYY MM Do');
+ assert.equal(testMoment.year(), 2014,
+ 'lenient ordinal parsing ' + i + ' year check');
+ assert.equal(testMoment.month(), 0,
+ 'lenient ordinal parsing ' + i + ' month check');
+ assert.equal(testMoment.date(), i,
+ 'lenient ordinal parsing ' + i + ' date check');
+ }
+ });
+
+ test('lenient ordinal parsing of number', function (assert) {
+ var i, testMoment;
+ for (i = 1; i <= 31; ++i) {
+ testMoment = moment('2014 01 ' + i, 'YYYY MM Do');
+ assert.equal(testMoment.year(), 2014,
+ 'lenient ordinal parsing of number ' + i + ' year check');
+ assert.equal(testMoment.month(), 0,
+ 'lenient ordinal parsing of number ' + i + ' month check');
+ assert.equal(testMoment.date(), i,
+ 'lenient ordinal parsing of number ' + i + ' date check');
+ }
+ });
+
+ test('strict ordinal parsing', function (assert) {
+ var i, ordinalStr, testMoment;
+ for (i = 1; i <= 31; ++i) {
+ ordinalStr = moment([2014, 0, i]).format('YYYY MM Do');
+ testMoment = moment(ordinalStr, 'YYYY MM Do', true);
+ assert.ok(testMoment.isValid(), 'strict ordinal parsing ' + i);
+ }
+ });
+
+ test('meridiem invariant', function (assert) {
+ var h, m, t1, t2;
+ for (h = 0; h < 24; ++h) {
+ for (m = 0; m < 60; m += 15) {
+ t1 = moment.utc([2000, 0, 1, h, m]);
+ t2 = moment.utc(t1.format('A h:mm'), 'A h:mm');
+ assert.equal(t2.format('HH:mm'), t1.format('HH:mm'),
+ 'meridiem at ' + t1.format('HH:mm'));
+ }
+ }
+ });
+
+ test('date format correctness', function (assert) {
+ var data, tokens;
+ data = moment.localeData()._longDateFormat;
+ tokens = objectKeys(data);
+ each(tokens, function (srchToken) {
+ // Check each format string to make sure it does not contain any
+ // tokens that need to be expanded.
+ each(tokens, function (baseToken) {
+ // strip escaped sequences
+ var format = data[baseToken].replace(/(\[[^\]]*\])/g, '');
+ assert.equal(false, !!~format.indexOf(srchToken),
+ 'contains ' + srchToken + ' in ' + baseToken);
+ });
+ });
+ });
+
+ test('month parsing correctness', function (assert) {
+ var i, m;
+
+ if (locale === 'tr') {
+ // I can't fix it :(
+ expect(0);
+ return;
+ }
+ function tester(format) {
+ var r;
+ r = moment(m.format(format), format);
+ assert.equal(r.month(), m.month(), 'month ' + i + ' fmt ' + format);
+ r = moment(m.format(format).toLocaleUpperCase(), format);
+ assert.equal(r.month(), m.month(), 'month ' + i + ' fmt ' + format + ' upper');
+ r = moment(m.format(format).toLocaleLowerCase(), format);
+ assert.equal(r.month(), m.month(), 'month ' + i + ' fmt ' + format + ' lower');
+
+ r = moment(m.format(format), format, true);
+ assert.equal(r.month(), m.month(), 'month ' + i + ' fmt ' + format + ' strict');
+ r = moment(m.format(format).toLocaleUpperCase(), format, true);
+ assert.equal(r.month(), m.month(), 'month ' + i + ' fmt ' + format + ' upper strict');
+ r = moment(m.format(format).toLocaleLowerCase(), format, true);
+ assert.equal(r.month(), m.month(), 'month ' + i + ' fmt ' + format + ' lower strict');
+ }
+
+ for (i = 0; i < 12; ++i) {
+ m = moment([2015, i, 15, 18]);
+ tester('MMM');
+ tester('MMM.');
+ tester('MMMM');
+ tester('MMMM.');
+ }
+ });
+
+ test('weekday parsing correctness', function (assert) {
+ var i, m;
+
+ if (locale === 'tr' || locale === 'az') {
+ // There is a lower-case letter (ı), that converted to upper then
+ // lower changes to i
+ expect(0);
+ return;
+ }
+ function tester(format) {
+ var r, baseMsg = 'weekday ' + m.weekday() + ' fmt ' + format;
+ r = moment(m.format(format), format);
+ assert.equal(r.weekday(), m.weekday(), baseMsg);
+ r = moment(m.format(format).toLocaleUpperCase(), format);
+ assert.equal(r.weekday(), m.weekday(), baseMsg + ' upper');
+ r = moment(m.format(format).toLocaleLowerCase(), format);
+ assert.equal(r.weekday(), m.weekday(), baseMsg + ' lower');
+
+ r = moment(m.format(format), format, true);
+ assert.equal(r.weekday(), m.weekday(), baseMsg + ' strict');
+ r = moment(m.format(format).toLocaleUpperCase(), format, true);
+ assert.equal(r.weekday(), m.weekday(), baseMsg + ' upper strict');
+ r = moment(m.format(format).toLocaleLowerCase(), format, true);
+ assert.equal(r.weekday(), m.weekday(), baseMsg + ' lower strict');
+ }
+
+ for (i = 0; i < 7; ++i) {
+ m = moment.utc([2015, i, 15, 18]);
+ tester('dd');
+ tester('ddd');
+ tester('dddd');
+ }
+ });
+ }
+
+ function setupDeprecationHandler(test, moment, scope) {
+ test._expectedDeprecations = null;
+ test._observedDeprecations = null;
+ test._oldSupress = moment.suppressDeprecationWarnings;
+ moment.suppressDeprecationWarnings = true;
+ test.expectedDeprecations = function () {
+ test._expectedDeprecations = arguments;
+ test._observedDeprecations = [];
+ };
+ moment.deprecationHandler = function (name, msg) {
+ var deprecationId = matchedDeprecation(name, msg, test._expectedDeprecations);
+ if (deprecationId === -1) {
+ throw new Error('Unexpected deprecation thrown name=' +
+ name + ' msg=' + msg);
+ }
+ test._observedDeprecations[deprecationId] = 1;
+ };
+ }
+
+ function teardownDeprecationHandler(test, moment, scope) {
+ moment.suppressDeprecationWarnings = test._oldSupress;
+
+ if (test._expectedDeprecations != null) {
+ var missedDeprecations = [];
+ each(test._expectedDeprecations, function (deprecationPattern, id) {
+ if (test._observedDeprecations[id] !== 1) {
+ missedDeprecations.push(deprecationPattern);
+ }
+ });
+ if (missedDeprecations.length !== 0) {
+ throw new Error('Expected deprecation warnings did not happen: ' +
+ missedDeprecations.join(' '));
+ }
+ }
+ }
+
+ function matchedDeprecation(name, msg, deprecations) {
+ if (deprecations == null) {
+ return -1;
+ }
+ for (var i = 0; i < deprecations.length; ++i) {
+ if (name != null && name === deprecations[i]) {
+ return i;
+ }
+ if (msg != null && msg.substring(0, deprecations[i].length) === deprecations[i]) {
+ return i;
+ }
+ }
+ return -1;
+ }
/*global QUnit:false*/
@@ -6078,11 +8373,13 @@
moment.createFromInputFallback = function (config) {
throw new Error('input not handled by moment: ' + config._i);
};
+ setupDeprecationHandler(test, moment, 'core');
if (lifecycle && lifecycle.setup) {
lifecycle.setup();
}
},
teardown : function () {
+ teardownDeprecationHandler(test, moment, 'core');
if (lifecycle && lifecycle.teardown) {
lifecycle.teardown();
}
@@ -6097,17 +8394,20 @@
moment.createFromInputFallback = function (config) {
throw new Error('input not handled by moment: ' + config._i);
};
+ setupDeprecationHandler(test, moment, 'locale');
if (lifecycle && lifecycle.setup) {
lifecycle.setup();
}
},
teardown : function () {
moment.locale('en');
+ teardownDeprecationHandler(test, moment, 'locale');
if (lifecycle && lifecycle.teardown) {
lifecycle.teardown();
}
}
});
+ defineCommonLocaleTests(name, -1, -1);
}
localeModule('da');
@@ -6260,65 +8560,56 @@
assert.equal(moment().add({d: 5}).fromNow(), 'om 5 dage', 'in 5 days');
});
- test('weeks year starting sunday', function (assert) {
- assert.equal(moment([2012, 0, 1]).week(), 52, 'Jan 1 2012 should be week 52');
- assert.equal(moment([2012, 0, 2]).week(), 1, 'Jan 2 2012 should be week 1');
- assert.equal(moment([2012, 0, 8]).week(), 1, 'Jan 8 2012 should be week 1');
- assert.equal(moment([2012, 0, 9]).week(), 2, 'Jan 9 2012 should be week 2');
- assert.equal(moment([2012, 0, 15]).week(), 2, 'Jan 15 2012 should be week 2');
- });
-
- test('weeks year starting monday', function (assert) {
- assert.equal(moment([2007, 0, 1]).week(), 1, 'Jan 1 2007 should be week 1');
- assert.equal(moment([2007, 0, 7]).week(), 1, 'Jan 7 2007 should be week 1');
- assert.equal(moment([2007, 0, 8]).week(), 2, 'Jan 8 2007 should be week 2');
- assert.equal(moment([2007, 0, 14]).week(), 2, 'Jan 14 2007 should be week 2');
- assert.equal(moment([2007, 0, 15]).week(), 3, 'Jan 15 2007 should be week 3');
- });
-
- test('weeks year starting tuesday', function (assert) {
- assert.equal(moment([2007, 11, 31]).week(), 1, 'Dec 31 2007 should be week 1');
- assert.equal(moment([2008, 0, 1]).week(), 1, 'Jan 1 2008 should be week 1');
- assert.equal(moment([2008, 0, 6]).week(), 1, 'Jan 6 2008 should be week 1');
- assert.equal(moment([2008, 0, 7]).week(), 2, 'Jan 7 2008 should be week 2');
- assert.equal(moment([2008, 0, 13]).week(), 2, 'Jan 13 2008 should be week 2');
- assert.equal(moment([2008, 0, 14]).week(), 3, 'Jan 14 2008 should be week 3');
- });
-
- test('weeks year starting wednesday', function (assert) {
- assert.equal(moment([2002, 11, 30]).week(), 1, 'Dec 30 2002 should be week 1');
- assert.equal(moment([2003, 0, 1]).week(), 1, 'Jan 1 2003 should be week 1');
- assert.equal(moment([2003, 0, 5]).week(), 1, 'Jan 5 2003 should be week 1');
- assert.equal(moment([2003, 0, 6]).week(), 2, 'Jan 6 2003 should be week 2');
- assert.equal(moment([2003, 0, 12]).week(), 2, 'Jan 12 2003 should be week 2');
- assert.equal(moment([2003, 0, 13]).week(), 3, 'Jan 13 2003 should be week 3');
- });
-
- test('weeks year starting thursday', function (assert) {
- assert.equal(moment([2008, 11, 29]).week(), 1, 'Dec 29 2008 should be week 1');
- assert.equal(moment([2009, 0, 1]).week(), 1, 'Jan 1 2009 should be week 1');
- assert.equal(moment([2009, 0, 4]).week(), 1, 'Jan 4 2009 should be week 1');
- assert.equal(moment([2009, 0, 5]).week(), 2, 'Jan 5 2009 should be week 2');
- assert.equal(moment([2009, 0, 11]).week(), 2, 'Jan 11 2009 should be week 2');
- assert.equal(moment([2009, 0, 13]).week(), 3, 'Jan 12 2009 should be week 3');
- });
-
- test('weeks year starting friday', function (assert) {
- assert.equal(moment([2009, 11, 28]).week(), 53, 'Dec 28 2009 should be week 53');
- assert.equal(moment([2010, 0, 1]).week(), 53, 'Jan 1 2010 should be week 53');
- assert.equal(moment([2010, 0, 3]).week(), 53, 'Jan 3 2010 should be week 53');
- assert.equal(moment([2010, 0, 4]).week(), 1, 'Jan 4 2010 should be week 1');
- assert.equal(moment([2010, 0, 10]).week(), 1, 'Jan 10 2010 should be week 1');
- assert.equal(moment([2010, 0, 11]).week(), 2, 'Jan 11 2010 should be week 2');
- });
-
- test('weeks year starting saturday', function (assert) {
- assert.equal(moment([2010, 11, 27]).week(), 52, 'Dec 27 2010 should be week 52');
- assert.equal(moment([2011, 0, 1]).week(), 52, 'Jan 1 2011 should be week 52');
- assert.equal(moment([2011, 0, 2]).week(), 52, 'Jan 2 2011 should be week 52');
- assert.equal(moment([2011, 0, 3]).week(), 1, 'Jan 3 2011 should be week 1');
- assert.equal(moment([2011, 0, 9]).week(), 1, 'Jan 9 2011 should be week 1');
- assert.equal(moment([2011, 0, 10]).week(), 2, 'Jan 10 2011 should be week 2');
+
+ test('calendar day', function (assert) {
+ var a = moment().hours(12).minutes(0).seconds(0);
+
+ assert.equal(moment(a).calendar(), 'I dag kl. 12:00', 'today at the same time');
+ assert.equal(moment(a).add({m: 25}).calendar(), 'I dag kl. 12:25', 'Now plus 25 min');
+ assert.equal(moment(a).add({h: 1}).calendar(), 'I dag kl. 13:00', 'Now plus 1 hour');
+ assert.equal(moment(a).add({d: 1}).calendar(), 'I morgen kl. 12:00', 'tomorrow at the same time');
+ assert.equal(moment(a).subtract({h: 1}).calendar(), 'I dag kl. 11:00', 'Now minus 1 hour');
+ assert.equal(moment(a).subtract({d: 1}).calendar(), 'I går kl. 12:00', 'yesterday at the same time');
+ });
+
+ test('calendar next week', function (assert) {
+ var i, m;
+
+ for (i = 2; i < 7; i++) {
+ m = moment().add({d: i});
+ assert.equal(m.calendar(), m.format('dddd [kl.] LT'), 'Today + ' + i + ' days current time');
+ m.hours(0).minutes(0).seconds(0).milliseconds(0);
+ assert.equal(m.calendar(), m.format('dddd [kl.] LT'), 'Today + ' + i + ' days beginning of day');
+ m.hours(23).minutes(59).seconds(59).milliseconds(999);
+ assert.equal(m.calendar(), m.format('dddd [kl.] LT'), 'Today + ' + i + ' days end of day');
+ }
+ });
+
+ test('calendar last week', function (assert) {
+ var i, m;
+
+ for (i = 2; i < 7; i++) {
+ m = moment().subtract({d: i});
+ assert.equal(m.calendar(), m.format('[sidste] dddd [kl] LT'), 'Today - ' + i + ' days current time');
+ m.hours(0).minutes(0).seconds(0).milliseconds(0);
+ assert.equal(m.calendar(), m.format('[sidste] dddd [kl] LT'), 'Today - ' + i + ' days beginning of day');
+ m.hours(23).minutes(59).seconds(59).milliseconds(999);
+ assert.equal(m.calendar(), m.format('[sidste] dddd [kl] LT'), 'Today - ' + i + ' days end of day');
+ }
+ });
+
+ test('calendar all else', function (assert) {
+ var weeksAgo = moment().subtract({w: 1}),
+ weeksFromNow = moment().add({w: 1});
+
+ assert.equal(weeksAgo.calendar(), weeksAgo.format('L'), '1 week ago');
+ assert.equal(weeksFromNow.calendar(), weeksFromNow.format('L'), 'in 1 week');
+
+ weeksAgo = moment().subtract({w: 2});
+ weeksFromNow = moment().add({w: 2});
+
+ assert.equal(weeksAgo.calendar(), weeksAgo.format('L'), '2 weeks ago');
+ assert.equal(weeksFromNow.calendar(), weeksFromNow.format('L'), 'in 2 weeks');
});
test('weeks year starting sunday formatted', function (assert) {
@@ -6329,42 +8620,6 @@
assert.equal(moment([2012, 0, 15]).format('w ww wo'), '2 02 2.', 'Jan 15 2012 should be week 2');
});
- test('lenient ordinal parsing', function (assert) {
- var i, ordinalStr, testMoment;
- for (i = 1; i <= 31; ++i) {
- ordinalStr = moment([2014, 0, i]).format('YYYY MM Do');
- testMoment = moment(ordinalStr, 'YYYY MM Do');
- assert.equal(testMoment.year(), 2014,
- 'lenient ordinal parsing ' + i + ' year check');
- assert.equal(testMoment.month(), 0,
- 'lenient ordinal parsing ' + i + ' month check');
- assert.equal(testMoment.date(), i,
- 'lenient ordinal parsing ' + i + ' date check');
- }
- });
-
- test('lenient ordinal parsing of number', function (assert) {
- var i, testMoment;
- for (i = 1; i <= 31; ++i) {
- testMoment = moment('2014 01 ' + i, 'YYYY MM Do');
- assert.equal(testMoment.year(), 2014,
- 'lenient ordinal parsing of number ' + i + ' year check');
- assert.equal(testMoment.month(), 0,
- 'lenient ordinal parsing of number ' + i + ' month check');
- assert.equal(testMoment.date(), i,
- 'lenient ordinal parsing of number ' + i + ' date check');
- }
- });
-
- test('strict ordinal parsing', function (assert) {
- var i, ordinalStr, testMoment;
- for (i = 1; i <= 31; ++i) {
- ordinalStr = moment([2014, 0, i]).format('YYYY MM Do');
- testMoment = moment(ordinalStr, 'YYYY MM Do', true);
- assert.ok(testMoment.isValid(), 'strict ordinal parsing ' + i);
- }
- });
-
}));
;(function (global, factory) {
@@ -6373,6 +8628,224 @@
typeof define === 'function' && define.amd ? define(['../../moment'], factory) :
factory(global.moment)
}(this, function (moment) { 'use strict';
+
+ function each(array, callback) {
+ var i;
+ for (i = 0; i < array.length; i++) {
+ callback(array[i], i, array);
+ }
+ }
+
+ function objectKeys(obj) {
+ if (Object.keys) {
+ return Object.keys(obj);
+ } else {
+ // IE8
+ var res = [], i;
+ for (i in obj) {
+ if (obj.hasOwnProperty(i)) {
+ res.push(i);
+ }
+ }
+ return res;
+ }
+ }
+
+ // Pick the first defined of two or three arguments.
+ function defaults(a, b, c) {
+ if (a != null) {
+ return a;
+ }
+ if (b != null) {
+ return b;
+ }
+ return c;
+ }
+
+ function defineCommonLocaleTests(locale, options) {
+ test('lenient ordinal parsing', function (assert) {
+ var i, ordinalStr, testMoment;
+ for (i = 1; i <= 31; ++i) {
+ ordinalStr = moment([2014, 0, i]).format('YYYY MM Do');
+ testMoment = moment(ordinalStr, 'YYYY MM Do');
+ assert.equal(testMoment.year(), 2014,
+ 'lenient ordinal parsing ' + i + ' year check');
+ assert.equal(testMoment.month(), 0,
+ 'lenient ordinal parsing ' + i + ' month check');
+ assert.equal(testMoment.date(), i,
+ 'lenient ordinal parsing ' + i + ' date check');
+ }
+ });
+
+ test('lenient ordinal parsing of number', function (assert) {
+ var i, testMoment;
+ for (i = 1; i <= 31; ++i) {
+ testMoment = moment('2014 01 ' + i, 'YYYY MM Do');
+ assert.equal(testMoment.year(), 2014,
+ 'lenient ordinal parsing of number ' + i + ' year check');
+ assert.equal(testMoment.month(), 0,
+ 'lenient ordinal parsing of number ' + i + ' month check');
+ assert.equal(testMoment.date(), i,
+ 'lenient ordinal parsing of number ' + i + ' date check');
+ }
+ });
+
+ test('strict ordinal parsing', function (assert) {
+ var i, ordinalStr, testMoment;
+ for (i = 1; i <= 31; ++i) {
+ ordinalStr = moment([2014, 0, i]).format('YYYY MM Do');
+ testMoment = moment(ordinalStr, 'YYYY MM Do', true);
+ assert.ok(testMoment.isValid(), 'strict ordinal parsing ' + i);
+ }
+ });
+
+ test('meridiem invariant', function (assert) {
+ var h, m, t1, t2;
+ for (h = 0; h < 24; ++h) {
+ for (m = 0; m < 60; m += 15) {
+ t1 = moment.utc([2000, 0, 1, h, m]);
+ t2 = moment.utc(t1.format('A h:mm'), 'A h:mm');
+ assert.equal(t2.format('HH:mm'), t1.format('HH:mm'),
+ 'meridiem at ' + t1.format('HH:mm'));
+ }
+ }
+ });
+
+ test('date format correctness', function (assert) {
+ var data, tokens;
+ data = moment.localeData()._longDateFormat;
+ tokens = objectKeys(data);
+ each(tokens, function (srchToken) {
+ // Check each format string to make sure it does not contain any
+ // tokens that need to be expanded.
+ each(tokens, function (baseToken) {
+ // strip escaped sequences
+ var format = data[baseToken].replace(/(\[[^\]]*\])/g, '');
+ assert.equal(false, !!~format.indexOf(srchToken),
+ 'contains ' + srchToken + ' in ' + baseToken);
+ });
+ });
+ });
+
+ test('month parsing correctness', function (assert) {
+ var i, m;
+
+ if (locale === 'tr') {
+ // I can't fix it :(
+ expect(0);
+ return;
+ }
+ function tester(format) {
+ var r;
+ r = moment(m.format(format), format);
+ assert.equal(r.month(), m.month(), 'month ' + i + ' fmt ' + format);
+ r = moment(m.format(format).toLocaleUpperCase(), format);
+ assert.equal(r.month(), m.month(), 'month ' + i + ' fmt ' + format + ' upper');
+ r = moment(m.format(format).toLocaleLowerCase(), format);
+ assert.equal(r.month(), m.month(), 'month ' + i + ' fmt ' + format + ' lower');
+
+ r = moment(m.format(format), format, true);
+ assert.equal(r.month(), m.month(), 'month ' + i + ' fmt ' + format + ' strict');
+ r = moment(m.format(format).toLocaleUpperCase(), format, true);
+ assert.equal(r.month(), m.month(), 'month ' + i + ' fmt ' + format + ' upper strict');
+ r = moment(m.format(format).toLocaleLowerCase(), format, true);
+ assert.equal(r.month(), m.month(), 'month ' + i + ' fmt ' + format + ' lower strict');
+ }
+
+ for (i = 0; i < 12; ++i) {
+ m = moment([2015, i, 15, 18]);
+ tester('MMM');
+ tester('MMM.');
+ tester('MMMM');
+ tester('MMMM.');
+ }
+ });
+
+ test('weekday parsing correctness', function (assert) {
+ var i, m;
+
+ if (locale === 'tr' || locale === 'az') {
+ // There is a lower-case letter (ı), that converted to upper then
+ // lower changes to i
+ expect(0);
+ return;
+ }
+ function tester(format) {
+ var r, baseMsg = 'weekday ' + m.weekday() + ' fmt ' + format;
+ r = moment(m.format(format), format);
+ assert.equal(r.weekday(), m.weekday(), baseMsg);
+ r = moment(m.format(format).toLocaleUpperCase(), format);
+ assert.equal(r.weekday(), m.weekday(), baseMsg + ' upper');
+ r = moment(m.format(format).toLocaleLowerCase(), format);
+ assert.equal(r.weekday(), m.weekday(), baseMsg + ' lower');
+
+ r = moment(m.format(format), format, true);
+ assert.equal(r.weekday(), m.weekday(), baseMsg + ' strict');
+ r = moment(m.format(format).toLocaleUpperCase(), format, true);
+ assert.equal(r.weekday(), m.weekday(), baseMsg + ' upper strict');
+ r = moment(m.format(format).toLocaleLowerCase(), format, true);
+ assert.equal(r.weekday(), m.weekday(), baseMsg + ' lower strict');
+ }
+
+ for (i = 0; i < 7; ++i) {
+ m = moment.utc([2015, i, 15, 18]);
+ tester('dd');
+ tester('ddd');
+ tester('dddd');
+ }
+ });
+ }
+
+ function setupDeprecationHandler(test, moment, scope) {
+ test._expectedDeprecations = null;
+ test._observedDeprecations = null;
+ test._oldSupress = moment.suppressDeprecationWarnings;
+ moment.suppressDeprecationWarnings = true;
+ test.expectedDeprecations = function () {
+ test._expectedDeprecations = arguments;
+ test._observedDeprecations = [];
+ };
+ moment.deprecationHandler = function (name, msg) {
+ var deprecationId = matchedDeprecation(name, msg, test._expectedDeprecations);
+ if (deprecationId === -1) {
+ throw new Error('Unexpected deprecation thrown name=' +
+ name + ' msg=' + msg);
+ }
+ test._observedDeprecations[deprecationId] = 1;
+ };
+ }
+
+ function teardownDeprecationHandler(test, moment, scope) {
+ moment.suppressDeprecationWarnings = test._oldSupress;
+
+ if (test._expectedDeprecations != null) {
+ var missedDeprecations = [];
+ each(test._expectedDeprecations, function (deprecationPattern, id) {
+ if (test._observedDeprecations[id] !== 1) {
+ missedDeprecations.push(deprecationPattern);
+ }
+ });
+ if (missedDeprecations.length !== 0) {
+ throw new Error('Expected deprecation warnings did not happen: ' +
+ missedDeprecations.join(' '));
+ }
+ }
+ }
+
+ function matchedDeprecation(name, msg, deprecations) {
+ if (deprecations == null) {
+ return -1;
+ }
+ for (var i = 0; i < deprecations.length; ++i) {
+ if (name != null && name === deprecations[i]) {
+ return i;
+ }
+ if (msg != null && msg.substring(0, deprecations[i].length) === deprecations[i]) {
+ return i;
+ }
+ }
+ return -1;
+ }
/*global QUnit:false*/
@@ -6387,11 +8860,13 @@
moment.createFromInputFallback = function (config) {
throw new Error('input not handled by moment: ' + config._i);
};
+ setupDeprecationHandler(test, moment, 'core');
if (lifecycle && lifecycle.setup) {
lifecycle.setup();
}
},
teardown : function () {
+ teardownDeprecationHandler(test, moment, 'core');
if (lifecycle && lifecycle.teardown) {
lifecycle.teardown();
}
@@ -6406,17 +8881,20 @@
moment.createFromInputFallback = function (config) {
throw new Error('input not handled by moment: ' + config._i);
};
+ setupDeprecationHandler(test, moment, 'locale');
if (lifecycle && lifecycle.setup) {
lifecycle.setup();
}
},
teardown : function () {
moment.locale('en');
+ teardownDeprecationHandler(test, moment, 'locale');
if (lifecycle && lifecycle.teardown) {
lifecycle.teardown();
}
}
});
+ defineCommonLocaleTests(name, -1, -1);
}
localeModule('de-at');
@@ -6567,14 +9045,14 @@
});
test('calendar day', function (assert) {
- var a = moment().hours(2).minutes(0).seconds(0);
-
- assert.equal(moment(a).calendar(), 'heute um 02:00 Uhr', 'today at the same time');
- assert.equal(moment(a).add({m: 25}).calendar(), 'heute um 02:25 Uhr', 'Now plus 25 min');
- assert.equal(moment(a).add({h: 1}).calendar(), 'heute um 03:00 Uhr', 'Now plus 1 hour');
- assert.equal(moment(a).add({d: 1}).calendar(), 'morgen um 02:00 Uhr', 'tomorrow at the same time');
- assert.equal(moment(a).subtract({h: 1}).calendar(), 'heute um 01:00 Uhr', 'Now minus 1 hour');
- assert.equal(moment(a).subtract({d: 1}).calendar(), 'gestern um 02:00 Uhr', 'yesterday at the same time');
+ var a = moment().hours(12).minutes(0).seconds(0);
+
+ assert.equal(moment(a).calendar(), 'heute um 12:00 Uhr', 'today at the same time');
+ assert.equal(moment(a).add({m: 25}).calendar(), 'heute um 12:25 Uhr', 'Now plus 25 min');
+ assert.equal(moment(a).add({h: 1}).calendar(), 'heute um 13:00 Uhr', 'Now plus 1 hour');
+ assert.equal(moment(a).add({d: 1}).calendar(), 'morgen um 12:00 Uhr', 'tomorrow at the same time');
+ assert.equal(moment(a).subtract({h: 1}).calendar(), 'heute um 11:00 Uhr', 'Now minus 1 hour');
+ assert.equal(moment(a).subtract({d: 1}).calendar(), 'gestern um 12:00 Uhr', 'yesterday at the same time');
});
test('calendar next week', function (assert) {
@@ -6615,67 +9093,6 @@
assert.equal(weeksFromNow.calendar(), weeksFromNow.format('L'), 'in 2 weeks');
});
- test('weeks year starting sunday', function (assert) {
- assert.equal(moment([2012, 0, 1]).week(), 52, 'Jan 1 2012 should be week 52');
- assert.equal(moment([2012, 0, 2]).week(), 1, 'Jan 2 2012 should be week 1');
- assert.equal(moment([2012, 0, 8]).week(), 1, 'Jan 8 2012 should be week 1');
- assert.equal(moment([2012, 0, 9]).week(), 2, 'Jan 9 2012 should be week 2');
- assert.equal(moment([2012, 0, 15]).week(), 2, 'Jan 15 2012 should be week 2');
- });
-
- test('weeks year starting monday', function (assert) {
- assert.equal(moment([2007, 0, 1]).week(), 1, 'Jan 1 2007 should be week 1');
- assert.equal(moment([2007, 0, 7]).week(), 1, 'Jan 7 2007 should be week 1');
- assert.equal(moment([2007, 0, 8]).week(), 2, 'Jan 8 2007 should be week 2');
- assert.equal(moment([2007, 0, 14]).week(), 2, 'Jan 14 2007 should be week 2');
- assert.equal(moment([2007, 0, 15]).week(), 3, 'Jan 15 2007 should be week 3');
- });
-
- test('weeks year starting tuesday', function (assert) {
- assert.equal(moment([2007, 11, 31]).week(), 1, 'Dec 31 2007 should be week 1');
- assert.equal(moment([2008, 0, 1]).week(), 1, 'Jan 1 2008 should be week 1');
- assert.equal(moment([2008, 0, 6]).week(), 1, 'Jan 6 2008 should be week 1');
- assert.equal(moment([2008, 0, 7]).week(), 2, 'Jan 7 2008 should be week 2');
- assert.equal(moment([2008, 0, 13]).week(), 2, 'Jan 13 2008 should be week 2');
- assert.equal(moment([2008, 0, 14]).week(), 3, 'Jan 14 2008 should be week 3');
- });
-
- test('weeks year starting wednesday', function (assert) {
- assert.equal(moment([2002, 11, 30]).week(), 1, 'Dec 30 2002 should be week 1');
- assert.equal(moment([2003, 0, 1]).week(), 1, 'Jan 1 2003 should be week 1');
- assert.equal(moment([2003, 0, 5]).week(), 1, 'Jan 5 2003 should be week 1');
- assert.equal(moment([2003, 0, 6]).week(), 2, 'Jan 6 2003 should be week 2');
- assert.equal(moment([2003, 0, 12]).week(), 2, 'Jan 12 2003 should be week 2');
- assert.equal(moment([2003, 0, 13]).week(), 3, 'Jan 13 2003 should be week 3');
- });
-
- test('weeks year starting thursday', function (assert) {
- assert.equal(moment([2008, 11, 29]).week(), 1, 'Dec 29 2008 should be week 1');
- assert.equal(moment([2009, 0, 1]).week(), 1, 'Jan 1 2009 should be week 1');
- assert.equal(moment([2009, 0, 4]).week(), 1, 'Jan 4 2009 should be week 1');
- assert.equal(moment([2009, 0, 5]).week(), 2, 'Jan 5 2009 should be week 2');
- assert.equal(moment([2009, 0, 11]).week(), 2, 'Jan 11 2009 should be week 2');
- assert.equal(moment([2009, 0, 13]).week(), 3, 'Jan 12 2009 should be week 3');
- });
-
- test('weeks year starting friday', function (assert) {
- assert.equal(moment([2009, 11, 28]).week(), 53, 'Dec 28 2009 should be week 53');
- assert.equal(moment([2010, 0, 1]).week(), 53, 'Jan 1 2010 should be week 53');
- assert.equal(moment([2010, 0, 3]).week(), 53, 'Jan 3 2010 should be week 53');
- assert.equal(moment([2010, 0, 4]).week(), 1, 'Jan 4 2010 should be week 1');
- assert.equal(moment([2010, 0, 10]).week(), 1, 'Jan 10 2010 should be week 1');
- assert.equal(moment([2010, 0, 11]).week(), 2, 'Jan 11 2010 should be week 2');
- });
-
- test('weeks year starting saturday', function (assert) {
- assert.equal(moment([2010, 11, 27]).week(), 52, 'Dec 27 2010 should be week 52');
- assert.equal(moment([2011, 0, 1]).week(), 52, 'Jan 1 2011 should be week 52');
- assert.equal(moment([2011, 0, 2]).week(), 52, 'Jan 2 2011 should be week 52');
- assert.equal(moment([2011, 0, 3]).week(), 1, 'Jan 3 2011 should be week 1');
- assert.equal(moment([2011, 0, 9]).week(), 1, 'Jan 9 2011 should be week 1');
- assert.equal(moment([2011, 0, 10]).week(), 2, 'Jan 10 2011 should be week 2');
- });
-
test('weeks year starting sunday formatted', function (assert) {
assert.equal(moment([2012, 0, 1]).format('w ww wo'), '52 52 52.', 'Jan 1 2012 should be week 52');
assert.equal(moment([2012, 0, 2]).format('w ww wo'), '1 01 1.', 'Jan 2 2012 should be week 1');
@@ -6684,42 +9101,6 @@
assert.equal(moment([2012, 0, 15]).format('w ww wo'), '2 02 2.', 'Jan 15 2012 should be week 2');
});
- test('lenient ordinal parsing', function (assert) {
- var i, ordinalStr, testMoment;
- for (i = 1; i <= 31; ++i) {
- ordinalStr = moment([2014, 0, i]).format('YYYY MM Do');
- testMoment = moment(ordinalStr, 'YYYY MM Do');
- assert.equal(testMoment.year(), 2014,
- 'lenient ordinal parsing ' + i + ' year check');
- assert.equal(testMoment.month(), 0,
- 'lenient ordinal parsing ' + i + ' month check');
- assert.equal(testMoment.date(), i,
- 'lenient ordinal parsing ' + i + ' date check');
- }
- });
-
- test('lenient ordinal parsing of number', function (assert) {
- var i, testMoment;
- for (i = 1; i <= 31; ++i) {
- testMoment = moment('2014 01 ' + i, 'YYYY MM Do');
- assert.equal(testMoment.year(), 2014,
- 'lenient ordinal parsing of number ' + i + ' year check');
- assert.equal(testMoment.month(), 0,
- 'lenient ordinal parsing of number ' + i + ' month check');
- assert.equal(testMoment.date(), i,
- 'lenient ordinal parsing of number ' + i + ' date check');
- }
- });
-
- test('strict ordinal parsing', function (assert) {
- var i, ordinalStr, testMoment;
- for (i = 1; i <= 31; ++i) {
- ordinalStr = moment([2014, 0, i]).format('YYYY MM Do');
- testMoment = moment(ordinalStr, 'YYYY MM Do', true);
- assert.ok(testMoment.isValid(), 'strict ordinal parsing ' + i);
- }
- });
-
}));
;(function (global, factory) {
@@ -6728,6 +9109,224 @@
typeof define === 'function' && define.amd ? define(['../../moment'], factory) :
factory(global.moment)
}(this, function (moment) { 'use strict';
+
+ function each(array, callback) {
+ var i;
+ for (i = 0; i < array.length; i++) {
+ callback(array[i], i, array);
+ }
+ }
+
+ function objectKeys(obj) {
+ if (Object.keys) {
+ return Object.keys(obj);
+ } else {
+ // IE8
+ var res = [], i;
+ for (i in obj) {
+ if (obj.hasOwnProperty(i)) {
+ res.push(i);
+ }
+ }
+ return res;
+ }
+ }
+
+ // Pick the first defined of two or three arguments.
+ function defaults(a, b, c) {
+ if (a != null) {
+ return a;
+ }
+ if (b != null) {
+ return b;
+ }
+ return c;
+ }
+
+ function defineCommonLocaleTests(locale, options) {
+ test('lenient ordinal parsing', function (assert) {
+ var i, ordinalStr, testMoment;
+ for (i = 1; i <= 31; ++i) {
+ ordinalStr = moment([2014, 0, i]).format('YYYY MM Do');
+ testMoment = moment(ordinalStr, 'YYYY MM Do');
+ assert.equal(testMoment.year(), 2014,
+ 'lenient ordinal parsing ' + i + ' year check');
+ assert.equal(testMoment.month(), 0,
+ 'lenient ordinal parsing ' + i + ' month check');
+ assert.equal(testMoment.date(), i,
+ 'lenient ordinal parsing ' + i + ' date check');
+ }
+ });
+
+ test('lenient ordinal parsing of number', function (assert) {
+ var i, testMoment;
+ for (i = 1; i <= 31; ++i) {
+ testMoment = moment('2014 01 ' + i, 'YYYY MM Do');
+ assert.equal(testMoment.year(), 2014,
+ 'lenient ordinal parsing of number ' + i + ' year check');
+ assert.equal(testMoment.month(), 0,
+ 'lenient ordinal parsing of number ' + i + ' month check');
+ assert.equal(testMoment.date(), i,
+ 'lenient ordinal parsing of number ' + i + ' date check');
+ }
+ });
+
+ test('strict ordinal parsing', function (assert) {
+ var i, ordinalStr, testMoment;
+ for (i = 1; i <= 31; ++i) {
+ ordinalStr = moment([2014, 0, i]).format('YYYY MM Do');
+ testMoment = moment(ordinalStr, 'YYYY MM Do', true);
+ assert.ok(testMoment.isValid(), 'strict ordinal parsing ' + i);
+ }
+ });
+
+ test('meridiem invariant', function (assert) {
+ var h, m, t1, t2;
+ for (h = 0; h < 24; ++h) {
+ for (m = 0; m < 60; m += 15) {
+ t1 = moment.utc([2000, 0, 1, h, m]);
+ t2 = moment.utc(t1.format('A h:mm'), 'A h:mm');
+ assert.equal(t2.format('HH:mm'), t1.format('HH:mm'),
+ 'meridiem at ' + t1.format('HH:mm'));
+ }
+ }
+ });
+
+ test('date format correctness', function (assert) {
+ var data, tokens;
+ data = moment.localeData()._longDateFormat;
+ tokens = objectKeys(data);
+ each(tokens, function (srchToken) {
+ // Check each format string to make sure it does not contain any
+ // tokens that need to be expanded.
+ each(tokens, function (baseToken) {
+ // strip escaped sequences
+ var format = data[baseToken].replace(/(\[[^\]]*\])/g, '');
+ assert.equal(false, !!~format.indexOf(srchToken),
+ 'contains ' + srchToken + ' in ' + baseToken);
+ });
+ });
+ });
+
+ test('month parsing correctness', function (assert) {
+ var i, m;
+
+ if (locale === 'tr') {
+ // I can't fix it :(
+ expect(0);
+ return;
+ }
+ function tester(format) {
+ var r;
+ r = moment(m.format(format), format);
+ assert.equal(r.month(), m.month(), 'month ' + i + ' fmt ' + format);
+ r = moment(m.format(format).toLocaleUpperCase(), format);
+ assert.equal(r.month(), m.month(), 'month ' + i + ' fmt ' + format + ' upper');
+ r = moment(m.format(format).toLocaleLowerCase(), format);
+ assert.equal(r.month(), m.month(), 'month ' + i + ' fmt ' + format + ' lower');
+
+ r = moment(m.format(format), format, true);
+ assert.equal(r.month(), m.month(), 'month ' + i + ' fmt ' + format + ' strict');
+ r = moment(m.format(format).toLocaleUpperCase(), format, true);
+ assert.equal(r.month(), m.month(), 'month ' + i + ' fmt ' + format + ' upper strict');
+ r = moment(m.format(format).toLocaleLowerCase(), format, true);
+ assert.equal(r.month(), m.month(), 'month ' + i + ' fmt ' + format + ' lower strict');
+ }
+
+ for (i = 0; i < 12; ++i) {
+ m = moment([2015, i, 15, 18]);
+ tester('MMM');
+ tester('MMM.');
+ tester('MMMM');
+ tester('MMMM.');
+ }
+ });
+
+ test('weekday parsing correctness', function (assert) {
+ var i, m;
+
+ if (locale === 'tr' || locale === 'az') {
+ // There is a lower-case letter (ı), that converted to upper then
+ // lower changes to i
+ expect(0);
+ return;
+ }
+ function tester(format) {
+ var r, baseMsg = 'weekday ' + m.weekday() + ' fmt ' + format;
+ r = moment(m.format(format), format);
+ assert.equal(r.weekday(), m.weekday(), baseMsg);
+ r = moment(m.format(format).toLocaleUpperCase(), format);
+ assert.equal(r.weekday(), m.weekday(), baseMsg + ' upper');
+ r = moment(m.format(format).toLocaleLowerCase(), format);
+ assert.equal(r.weekday(), m.weekday(), baseMsg + ' lower');
+
+ r = moment(m.format(format), format, true);
+ assert.equal(r.weekday(), m.weekday(), baseMsg + ' strict');
+ r = moment(m.format(format).toLocaleUpperCase(), format, true);
+ assert.equal(r.weekday(), m.weekday(), baseMsg + ' upper strict');
+ r = moment(m.format(format).toLocaleLowerCase(), format, true);
+ assert.equal(r.weekday(), m.weekday(), baseMsg + ' lower strict');
+ }
+
+ for (i = 0; i < 7; ++i) {
+ m = moment.utc([2015, i, 15, 18]);
+ tester('dd');
+ tester('ddd');
+ tester('dddd');
+ }
+ });
+ }
+
+ function setupDeprecationHandler(test, moment, scope) {
+ test._expectedDeprecations = null;
+ test._observedDeprecations = null;
+ test._oldSupress = moment.suppressDeprecationWarnings;
+ moment.suppressDeprecationWarnings = true;
+ test.expectedDeprecations = function () {
+ test._expectedDeprecations = arguments;
+ test._observedDeprecations = [];
+ };
+ moment.deprecationHandler = function (name, msg) {
+ var deprecationId = matchedDeprecation(name, msg, test._expectedDeprecations);
+ if (deprecationId === -1) {
+ throw new Error('Unexpected deprecation thrown name=' +
+ name + ' msg=' + msg);
+ }
+ test._observedDeprecations[deprecationId] = 1;
+ };
+ }
+
+ function teardownDeprecationHandler(test, moment, scope) {
+ moment.suppressDeprecationWarnings = test._oldSupress;
+
+ if (test._expectedDeprecations != null) {
+ var missedDeprecations = [];
+ each(test._expectedDeprecations, function (deprecationPattern, id) {
+ if (test._observedDeprecations[id] !== 1) {
+ missedDeprecations.push(deprecationPattern);
+ }
+ });
+ if (missedDeprecations.length !== 0) {
+ throw new Error('Expected deprecation warnings did not happen: ' +
+ missedDeprecations.join(' '));
+ }
+ }
+ }
+
+ function matchedDeprecation(name, msg, deprecations) {
+ if (deprecations == null) {
+ return -1;
+ }
+ for (var i = 0; i < deprecations.length; ++i) {
+ if (name != null && name === deprecations[i]) {
+ return i;
+ }
+ if (msg != null && msg.substring(0, deprecations[i].length) === deprecations[i]) {
+ return i;
+ }
+ }
+ return -1;
+ }
/*global QUnit:false*/
@@ -6742,11 +9341,13 @@
moment.createFromInputFallback = function (config) {
throw new Error('input not handled by moment: ' + config._i);
};
+ setupDeprecationHandler(test, moment, 'core');
if (lifecycle && lifecycle.setup) {
lifecycle.setup();
}
},
teardown : function () {
+ teardownDeprecationHandler(test, moment, 'core');
if (lifecycle && lifecycle.teardown) {
lifecycle.teardown();
}
@@ -6761,17 +9362,20 @@
moment.createFromInputFallback = function (config) {
throw new Error('input not handled by moment: ' + config._i);
};
+ setupDeprecationHandler(test, moment, 'locale');
if (lifecycle && lifecycle.setup) {
lifecycle.setup();
}
},
teardown : function () {
moment.locale('en');
+ teardownDeprecationHandler(test, moment, 'locale');
if (lifecycle && lifecycle.teardown) {
lifecycle.teardown();
}
}
});
+ defineCommonLocaleTests(name, -1, -1);
}
localeModule('de');
@@ -6921,14 +9525,14 @@
});
test('calendar day', function (assert) {
- var a = moment().hours(2).minutes(0).seconds(0);
-
- assert.equal(moment(a).calendar(), 'heute um 02:00 Uhr', 'today at the same time');
- assert.equal(moment(a).add({m: 25}).calendar(), 'heute um 02:25 Uhr', 'Now plus 25 min');
- assert.equal(moment(a).add({h: 1}).calendar(), 'heute um 03:00 Uhr', 'Now plus 1 hour');
- assert.equal(moment(a).add({d: 1}).calendar(), 'morgen um 02:00 Uhr', 'tomorrow at the same time');
- assert.equal(moment(a).subtract({h: 1}).calendar(), 'heute um 01:00 Uhr', 'Now minus 1 hour');
- assert.equal(moment(a).subtract({d: 1}).calendar(), 'gestern um 02:00 Uhr', 'yesterday at the same time');
+ var a = moment().hours(12).minutes(0).seconds(0);
+
+ assert.equal(moment(a).calendar(), 'heute um 12:00 Uhr', 'today at the same time');
+ assert.equal(moment(a).add({m: 25}).calendar(), 'heute um 12:25 Uhr', 'Now plus 25 min');
+ assert.equal(moment(a).add({h: 1}).calendar(), 'heute um 13:00 Uhr', 'Now plus 1 hour');
+ assert.equal(moment(a).add({d: 1}).calendar(), 'morgen um 12:00 Uhr', 'tomorrow at the same time');
+ assert.equal(moment(a).subtract({h: 1}).calendar(), 'heute um 11:00 Uhr', 'Now minus 1 hour');
+ assert.equal(moment(a).subtract({d: 1}).calendar(), 'gestern um 12:00 Uhr', 'yesterday at the same time');
});
test('calendar next week', function (assert) {
@@ -6969,67 +9573,6 @@
assert.equal(weeksFromNow.calendar(), weeksFromNow.format('L'), 'in 2 weeks');
});
- test('weeks year starting sunday', function (assert) {
- assert.equal(moment([2012, 0, 1]).week(), 52, 'Jan 1 2012 should be week 52');
- assert.equal(moment([2012, 0, 2]).week(), 1, 'Jan 2 2012 should be week 1');
- assert.equal(moment([2012, 0, 8]).week(), 1, 'Jan 8 2012 should be week 1');
- assert.equal(moment([2012, 0, 9]).week(), 2, 'Jan 9 2012 should be week 2');
- assert.equal(moment([2012, 0, 15]).week(), 2, 'Jan 15 2012 should be week 2');
- });
-
- test('weeks year starting monday', function (assert) {
- assert.equal(moment([2007, 0, 1]).week(), 1, 'Jan 1 2007 should be week 1');
- assert.equal(moment([2007, 0, 7]).week(), 1, 'Jan 7 2007 should be week 1');
- assert.equal(moment([2007, 0, 8]).week(), 2, 'Jan 8 2007 should be week 2');
- assert.equal(moment([2007, 0, 14]).week(), 2, 'Jan 14 2007 should be week 2');
- assert.equal(moment([2007, 0, 15]).week(), 3, 'Jan 15 2007 should be week 3');
- });
-
- test('weeks year starting tuesday', function (assert) {
- assert.equal(moment([2007, 11, 31]).week(), 1, 'Dec 31 2007 should be week 1');
- assert.equal(moment([2008, 0, 1]).week(), 1, 'Jan 1 2008 should be week 1');
- assert.equal(moment([2008, 0, 6]).week(), 1, 'Jan 6 2008 should be week 1');
- assert.equal(moment([2008, 0, 7]).week(), 2, 'Jan 7 2008 should be week 2');
- assert.equal(moment([2008, 0, 13]).week(), 2, 'Jan 13 2008 should be week 2');
- assert.equal(moment([2008, 0, 14]).week(), 3, 'Jan 14 2008 should be week 3');
- });
-
- test('weeks year starting wednesday', function (assert) {
- assert.equal(moment([2002, 11, 30]).week(), 1, 'Dec 30 2002 should be week 1');
- assert.equal(moment([2003, 0, 1]).week(), 1, 'Jan 1 2003 should be week 1');
- assert.equal(moment([2003, 0, 5]).week(), 1, 'Jan 5 2003 should be week 1');
- assert.equal(moment([2003, 0, 6]).week(), 2, 'Jan 6 2003 should be week 2');
- assert.equal(moment([2003, 0, 12]).week(), 2, 'Jan 12 2003 should be week 2');
- assert.equal(moment([2003, 0, 13]).week(), 3, 'Jan 13 2003 should be week 3');
- });
-
- test('weeks year starting thursday', function (assert) {
- assert.equal(moment([2008, 11, 29]).week(), 1, 'Dec 29 2008 should be week 1');
- assert.equal(moment([2009, 0, 1]).week(), 1, 'Jan 1 2009 should be week 1');
- assert.equal(moment([2009, 0, 4]).week(), 1, 'Jan 4 2009 should be week 1');
- assert.equal(moment([2009, 0, 5]).week(), 2, 'Jan 5 2009 should be week 2');
- assert.equal(moment([2009, 0, 11]).week(), 2, 'Jan 11 2009 should be week 2');
- assert.equal(moment([2009, 0, 13]).week(), 3, 'Jan 12 2009 should be week 3');
- });
-
- test('weeks year starting friday', function (assert) {
- assert.equal(moment([2009, 11, 28]).week(), 53, 'Dec 28 2009 should be week 53');
- assert.equal(moment([2010, 0, 1]).week(), 53, 'Jan 1 2010 should be week 53');
- assert.equal(moment([2010, 0, 3]).week(), 53, 'Jan 3 2010 should be week 53');
- assert.equal(moment([2010, 0, 4]).week(), 1, 'Jan 4 2010 should be week 1');
- assert.equal(moment([2010, 0, 10]).week(), 1, 'Jan 10 2010 should be week 1');
- assert.equal(moment([2010, 0, 11]).week(), 2, 'Jan 11 2010 should be week 2');
- });
-
- test('weeks year starting saturday', function (assert) {
- assert.equal(moment([2010, 11, 27]).week(), 52, 'Dec 27 2010 should be week 52');
- assert.equal(moment([2011, 0, 1]).week(), 52, 'Jan 1 2011 should be week 52');
- assert.equal(moment([2011, 0, 2]).week(), 52, 'Jan 2 2011 should be week 52');
- assert.equal(moment([2011, 0, 3]).week(), 1, 'Jan 3 2011 should be week 1');
- assert.equal(moment([2011, 0, 9]).week(), 1, 'Jan 9 2011 should be week 1');
- assert.equal(moment([2011, 0, 10]).week(), 2, 'Jan 10 2011 should be week 2');
- });
-
test('weeks year starting sunday formatted', function (assert) {
assert.equal(moment([2012, 0, 1]).format('w ww wo'), '52 52 52.', 'Jan 1 2012 should be week 52');
assert.equal(moment([2012, 0, 2]).format('w ww wo'), '1 01 1.', 'Jan 2 2012 should be week 1');
@@ -7038,42 +9581,6 @@
assert.equal(moment([2012, 0, 15]).format('w ww wo'), '2 02 2.', 'Jan 15 2012 should be week 2');
});
- test('lenient ordinal parsing', function (assert) {
- var i, ordinalStr, testMoment;
- for (i = 1; i <= 31; ++i) {
- ordinalStr = moment([2014, 0, i]).format('YYYY MM Do');
- testMoment = moment(ordinalStr, 'YYYY MM Do');
- assert.equal(testMoment.year(), 2014,
- 'lenient ordinal parsing ' + i + ' year check');
- assert.equal(testMoment.month(), 0,
- 'lenient ordinal parsing ' + i + ' month check');
- assert.equal(testMoment.date(), i,
- 'lenient ordinal parsing ' + i + ' date check');
- }
- });
-
- test('lenient ordinal parsing of number', function (assert) {
- var i, testMoment;
- for (i = 1; i <= 31; ++i) {
- testMoment = moment('2014 01 ' + i, 'YYYY MM Do');
- assert.equal(testMoment.year(), 2014,
- 'lenient ordinal parsing of number ' + i + ' year check');
- assert.equal(testMoment.month(), 0,
- 'lenient ordinal parsing of number ' + i + ' month check');
- assert.equal(testMoment.date(), i,
- 'lenient ordinal parsing of number ' + i + ' date check');
- }
- });
-
- test('strict ordinal parsing', function (assert) {
- var i, ordinalStr, testMoment;
- for (i = 1; i <= 31; ++i) {
- ordinalStr = moment([2014, 0, i]).format('YYYY MM Do');
- testMoment = moment(ordinalStr, 'YYYY MM Do', true);
- assert.ok(testMoment.isValid(), 'strict ordinal parsing ' + i);
- }
- });
-
}));
;(function (global, factory) {
@@ -7082,6 +9589,224 @@
typeof define === 'function' && define.amd ? define(['../../moment'], factory) :
factory(global.moment)
}(this, function (moment) { 'use strict';
+
+ function each(array, callback) {
+ var i;
+ for (i = 0; i < array.length; i++) {
+ callback(array[i], i, array);
+ }
+ }
+
+ function objectKeys(obj) {
+ if (Object.keys) {
+ return Object.keys(obj);
+ } else {
+ // IE8
+ var res = [], i;
+ for (i in obj) {
+ if (obj.hasOwnProperty(i)) {
+ res.push(i);
+ }
+ }
+ return res;
+ }
+ }
+
+ // Pick the first defined of two or three arguments.
+ function defaults(a, b, c) {
+ if (a != null) {
+ return a;
+ }
+ if (b != null) {
+ return b;
+ }
+ return c;
+ }
+
+ function defineCommonLocaleTests(locale, options) {
+ test('lenient ordinal parsing', function (assert) {
+ var i, ordinalStr, testMoment;
+ for (i = 1; i <= 31; ++i) {
+ ordinalStr = moment([2014, 0, i]).format('YYYY MM Do');
+ testMoment = moment(ordinalStr, 'YYYY MM Do');
+ assert.equal(testMoment.year(), 2014,
+ 'lenient ordinal parsing ' + i + ' year check');
+ assert.equal(testMoment.month(), 0,
+ 'lenient ordinal parsing ' + i + ' month check');
+ assert.equal(testMoment.date(), i,
+ 'lenient ordinal parsing ' + i + ' date check');
+ }
+ });
+
+ test('lenient ordinal parsing of number', function (assert) {
+ var i, testMoment;
+ for (i = 1; i <= 31; ++i) {
+ testMoment = moment('2014 01 ' + i, 'YYYY MM Do');
+ assert.equal(testMoment.year(), 2014,
+ 'lenient ordinal parsing of number ' + i + ' year check');
+ assert.equal(testMoment.month(), 0,
+ 'lenient ordinal parsing of number ' + i + ' month check');
+ assert.equal(testMoment.date(), i,
+ 'lenient ordinal parsing of number ' + i + ' date check');
+ }
+ });
+
+ test('strict ordinal parsing', function (assert) {
+ var i, ordinalStr, testMoment;
+ for (i = 1; i <= 31; ++i) {
+ ordinalStr = moment([2014, 0, i]).format('YYYY MM Do');
+ testMoment = moment(ordinalStr, 'YYYY MM Do', true);
+ assert.ok(testMoment.isValid(), 'strict ordinal parsing ' + i);
+ }
+ });
+
+ test('meridiem invariant', function (assert) {
+ var h, m, t1, t2;
+ for (h = 0; h < 24; ++h) {
+ for (m = 0; m < 60; m += 15) {
+ t1 = moment.utc([2000, 0, 1, h, m]);
+ t2 = moment.utc(t1.format('A h:mm'), 'A h:mm');
+ assert.equal(t2.format('HH:mm'), t1.format('HH:mm'),
+ 'meridiem at ' + t1.format('HH:mm'));
+ }
+ }
+ });
+
+ test('date format correctness', function (assert) {
+ var data, tokens;
+ data = moment.localeData()._longDateFormat;
+ tokens = objectKeys(data);
+ each(tokens, function (srchToken) {
+ // Check each format string to make sure it does not contain any
+ // tokens that need to be expanded.
+ each(tokens, function (baseToken) {
+ // strip escaped sequences
+ var format = data[baseToken].replace(/(\[[^\]]*\])/g, '');
+ assert.equal(false, !!~format.indexOf(srchToken),
+ 'contains ' + srchToken + ' in ' + baseToken);
+ });
+ });
+ });
+
+ test('month parsing correctness', function (assert) {
+ var i, m;
+
+ if (locale === 'tr') {
+ // I can't fix it :(
+ expect(0);
+ return;
+ }
+ function tester(format) {
+ var r;
+ r = moment(m.format(format), format);
+ assert.equal(r.month(), m.month(), 'month ' + i + ' fmt ' + format);
+ r = moment(m.format(format).toLocaleUpperCase(), format);
+ assert.equal(r.month(), m.month(), 'month ' + i + ' fmt ' + format + ' upper');
+ r = moment(m.format(format).toLocaleLowerCase(), format);
+ assert.equal(r.month(), m.month(), 'month ' + i + ' fmt ' + format + ' lower');
+
+ r = moment(m.format(format), format, true);
+ assert.equal(r.month(), m.month(), 'month ' + i + ' fmt ' + format + ' strict');
+ r = moment(m.format(format).toLocaleUpperCase(), format, true);
+ assert.equal(r.month(), m.month(), 'month ' + i + ' fmt ' + format + ' upper strict');
+ r = moment(m.format(format).toLocaleLowerCase(), format, true);
+ assert.equal(r.month(), m.month(), 'month ' + i + ' fmt ' + format + ' lower strict');
+ }
+
+ for (i = 0; i < 12; ++i) {
+ m = moment([2015, i, 15, 18]);
+ tester('MMM');
+ tester('MMM.');
+ tester('MMMM');
+ tester('MMMM.');
+ }
+ });
+
+ test('weekday parsing correctness', function (assert) {
+ var i, m;
+
+ if (locale === 'tr' || locale === 'az') {
+ // There is a lower-case letter (ı), that converted to upper then
+ // lower changes to i
+ expect(0);
+ return;
+ }
+ function tester(format) {
+ var r, baseMsg = 'weekday ' + m.weekday() + ' fmt ' + format;
+ r = moment(m.format(format), format);
+ assert.equal(r.weekday(), m.weekday(), baseMsg);
+ r = moment(m.format(format).toLocaleUpperCase(), format);
+ assert.equal(r.weekday(), m.weekday(), baseMsg + ' upper');
+ r = moment(m.format(format).toLocaleLowerCase(), format);
+ assert.equal(r.weekday(), m.weekday(), baseMsg + ' lower');
+
+ r = moment(m.format(format), format, true);
+ assert.equal(r.weekday(), m.weekday(), baseMsg + ' strict');
+ r = moment(m.format(format).toLocaleUpperCase(), format, true);
+ assert.equal(r.weekday(), m.weekday(), baseMsg + ' upper strict');
+ r = moment(m.format(format).toLocaleLowerCase(), format, true);
+ assert.equal(r.weekday(), m.weekday(), baseMsg + ' lower strict');
+ }
+
+ for (i = 0; i < 7; ++i) {
+ m = moment.utc([2015, i, 15, 18]);
+ tester('dd');
+ tester('ddd');
+ tester('dddd');
+ }
+ });
+ }
+
+ function setupDeprecationHandler(test, moment, scope) {
+ test._expectedDeprecations = null;
+ test._observedDeprecations = null;
+ test._oldSupress = moment.suppressDeprecationWarnings;
+ moment.suppressDeprecationWarnings = true;
+ test.expectedDeprecations = function () {
+ test._expectedDeprecations = arguments;
+ test._observedDeprecations = [];
+ };
+ moment.deprecationHandler = function (name, msg) {
+ var deprecationId = matchedDeprecation(name, msg, test._expectedDeprecations);
+ if (deprecationId === -1) {
+ throw new Error('Unexpected deprecation thrown name=' +
+ name + ' msg=' + msg);
+ }
+ test._observedDeprecations[deprecationId] = 1;
+ };
+ }
+
+ function teardownDeprecationHandler(test, moment, scope) {
+ moment.suppressDeprecationWarnings = test._oldSupress;
+
+ if (test._expectedDeprecations != null) {
+ var missedDeprecations = [];
+ each(test._expectedDeprecations, function (deprecationPattern, id) {
+ if (test._observedDeprecations[id] !== 1) {
+ missedDeprecations.push(deprecationPattern);
+ }
+ });
+ if (missedDeprecations.length !== 0) {
+ throw new Error('Expected deprecation warnings did not happen: ' +
+ missedDeprecations.join(' '));
+ }
+ }
+ }
+
+ function matchedDeprecation(name, msg, deprecations) {
+ if (deprecations == null) {
+ return -1;
+ }
+ for (var i = 0; i < deprecations.length; ++i) {
+ if (name != null && name === deprecations[i]) {
+ return i;
+ }
+ if (msg != null && msg.substring(0, deprecations[i].length) === deprecations[i]) {
+ return i;
+ }
+ }
+ return -1;
+ }
/*global QUnit:false*/
@@ -7096,11 +9821,13 @@
moment.createFromInputFallback = function (config) {
throw new Error('input not handled by moment: ' + config._i);
};
+ setupDeprecationHandler(test, moment, 'core');
if (lifecycle && lifecycle.setup) {
lifecycle.setup();
}
},
teardown : function () {
+ teardownDeprecationHandler(test, moment, 'core');
if (lifecycle && lifecycle.teardown) {
lifecycle.teardown();
}
@@ -7115,17 +9842,20 @@
moment.createFromInputFallback = function (config) {
throw new Error('input not handled by moment: ' + config._i);
};
+ setupDeprecationHandler(test, moment, 'locale');
if (lifecycle && lifecycle.setup) {
lifecycle.setup();
}
},
teardown : function () {
moment.locale('en');
+ teardownDeprecationHandler(test, moment, 'locale');
if (lifecycle && lifecycle.teardown) {
lifecycle.teardown();
}
}
});
+ defineCommonLocaleTests(name, -1, -1);
}
localeModule('dv');
@@ -7231,6 +9961,106 @@
}
});
+
+ test('from', function (assert) {
+ var start = moment([2007, 1, 28]);
+ assert.equal(start.from(moment([2007, 1, 28]).add({s: 44}), true), 'ސިކުންތުކޮޅެއް', '44 seconds = a few seconds');
+ assert.equal(start.from(moment([2007, 1, 28]).add({s: 45}), true), 'މިނިޓެއް', '45 seconds = a minute');
+ assert.equal(start.from(moment([2007, 1, 28]).add({s: 89}), true), 'މިނިޓެއް', '89 seconds = a minute');
+ assert.equal(start.from(moment([2007, 1, 28]).add({s: 90}), true), 'މިނިޓު 2', '90 seconds = 2 minutes');
+ assert.equal(start.from(moment([2007, 1, 28]).add({m: 44}), true), 'މިނިޓު 44', '44 minutes = 44 minutes');
+ assert.equal(start.from(moment([2007, 1, 28]).add({m: 45}), true), 'ގަޑިއިރެއް', '45 minutes = an hour');
+ assert.equal(start.from(moment([2007, 1, 28]).add({m: 89}), true), 'ގަޑިއިރެއް', '89 minutes = an hour');
+ assert.equal(start.from(moment([2007, 1, 28]).add({m: 90}), true), 'ގަޑިއިރު 2', '90 minutes = 2 hours');
+ assert.equal(start.from(moment([2007, 1, 28]).add({h: 5}), true), 'ގަޑިއިރު 5', '5 hours = 5 hours');
+ assert.equal(start.from(moment([2007, 1, 28]).add({h: 21}), true), 'ގަޑިއިރު 21', '21 hours = 21 hours');
+ assert.equal(start.from(moment([2007, 1, 28]).add({h: 22}), true), 'ދުވަހެއް', '22 hours = a day');
+ assert.equal(start.from(moment([2007, 1, 28]).add({h: 35}), true), 'ދުވަހެއް', '35 hours = a day');
+ assert.equal(start.from(moment([2007, 1, 28]).add({h: 36}), true), 'ދުވަސް 2', '36 hours = 2 days');
+ assert.equal(start.from(moment([2007, 1, 28]).add({d: 1}), true), 'ދުވަހެއް', '1 day = a day');
+ assert.equal(start.from(moment([2007, 1, 28]).add({d: 5}), true), 'ދުވަސް 5', '5 days = 5 days');
+ assert.equal(start.from(moment([2007, 1, 28]).add({d: 25}), true), 'ދުވަސް 25', '25 days = 25 days');
+ assert.equal(start.from(moment([2007, 1, 28]).add({d: 26}), true), 'މަހެއް', '26 days = a month');
+ assert.equal(start.from(moment([2007, 1, 28]).add({d: 30}), true), 'މަހެއް', '30 days = a month');
+ assert.equal(start.from(moment([2007, 1, 28]).add({d: 43}), true), 'މަހެއް', '43 days = a month');
+ assert.equal(start.from(moment([2007, 1, 28]).add({d: 46}), true), 'މަސް 2', '46 days = 2 months');
+ assert.equal(start.from(moment([2007, 1, 28]).add({d: 74}), true), 'މަސް 2', '75 days = 2 months');
+ assert.equal(start.from(moment([2007, 1, 28]).add({d: 76}), true), 'މަސް 3', '76 days = 3 months');
+ assert.equal(start.from(moment([2007, 1, 28]).add({M: 1}), true), 'މަހެއް', '1 month = a month');
+ assert.equal(start.from(moment([2007, 1, 28]).add({M: 5}), true), 'މަސް 5', '5 months = 5 months');
+ assert.equal(start.from(moment([2007, 1, 28]).add({d: 345}), true), 'އަހަރެއް', '345 days = a year');
+ assert.equal(start.from(moment([2007, 1, 28]).add({d: 548}), true), 'އަހަރު 2', '548 days = 2 years');
+ assert.equal(start.from(moment([2007, 1, 28]).add({y: 1}), true), 'އަހަރެއް', '1 year = a year');
+ assert.equal(start.from(moment([2007, 1, 28]).add({y: 5}), true), 'އަހަރު 5', '5 years = 5 years');
+ });
+
+ test('suffix', function (assert) {
+ assert.equal(moment(30000).from(0), 'ތެރޭގައި ސިކުންތުކޮޅެއް', 'prefix');
+ assert.equal(moment(0).from(30000), 'ކުރިން ސިކުންތުކޮޅެއް', 'suffix');
+ });
+
+ test('fromNow', function (assert) {
+ assert.equal(moment().add({s: 30}).fromNow(), 'ތެރޭގައި ސިކުންތުކޮޅެއް', 'in a few seconds');
+ assert.equal(moment().add({d: 5}).fromNow(), 'ތެރޭގައި ދުވަސް 5', 'in 5 days');
+ });
+
+ test('calendar day', function (assert) {
+ var a = moment().hours(12).minutes(0).seconds(0);
+
+ assert.equal(moment(a).calendar(), 'މިއަދު 12:00', 'today at the same time');
+ assert.equal(moment(a).add({m: 25}).calendar(), 'މިއަދު 12:25', 'Now plus 25 min');
+ assert.equal(moment(a).add({h: 1}).calendar(), 'މިއަދު 13:00', 'Now plus 1 hour');
+ assert.equal(moment(a).add({d: 1}).calendar(), 'މާދަމާ 12:00', 'tomorrow at the same time');
+ assert.equal(moment(a).subtract({h: 1}).calendar(), 'މިއަދު 11:00', 'Now minus 1 hour');
+ assert.equal(moment(a).subtract({d: 1}).calendar(), 'އިއްޔެ 12:00', 'yesterday at the same time');
+ });
+
+ test('calendar next week', function (assert) {
+ var i, m;
+ for (i = 2; i < 7; i++) {
+ m = moment().add({d: i});
+ assert.equal(m.calendar(), m.format('dddd LT'), 'Today + ' + i + ' days current time');
+ m.hours(0).minutes(0).seconds(0).milliseconds(0);
+ assert.equal(m.calendar(), m.format('dddd LT'), 'Today + ' + i + ' days beginning of day');
+ m.hours(23).minutes(59).seconds(59).milliseconds(999);
+ assert.equal(m.calendar(), m.format('dddd LT'), 'Today + ' + i + ' days end of day');
+ }
+ });
+
+ test('calendar last week', function (assert) {
+ var i, m;
+ for (i = 2; i < 7; i++) {
+ m = moment().subtract({d: i});
+ assert.equal(m.calendar(), m.format('[ފާއިތުވި] dddd LT'), 'Today + ' + i + ' days current time');
+ m.hours(0).minutes(0).seconds(0).milliseconds(0);
+ assert.equal(m.calendar(), m.format('[ފާއިތުވި] dddd LT'), 'Today + ' + i + ' days beginning of day');
+ m.hours(23).minutes(59).seconds(59).milliseconds(999);
+ assert.equal(m.calendar(), m.format('[ފާއިތުވި] dddd LT'), 'Today + ' + i + ' days end of day');
+ }
+ });
+
+ test('calendar all else', function (assert) {
+ var weeksAgo = moment().subtract({w: 1}),
+ weeksFromNow = moment().add({w: 1});
+
+ assert.equal(weeksAgo.calendar(), weeksAgo.format('L'), '1 week ago');
+ assert.equal(weeksFromNow.calendar(), weeksFromNow.format('L'), 'in 1 week');
+
+ weeksAgo = moment().subtract({w: 2});
+ weeksFromNow = moment().add({w: 2});
+
+ assert.equal(weeksAgo.calendar(), weeksAgo.format('L'), '2 weeks ago');
+ assert.equal(weeksFromNow.calendar(), weeksFromNow.format('L'), 'in 2 weeks');
+ });
+
+ test('weeks year starting sunday formatted', function (assert) {
+ assert.equal(moment([2012, 0, 1]).format('w ww wo'), '1 01 1', 'Jan 1 2012 should be week 1');
+ assert.equal(moment([2012, 0, 2]).format('w ww wo'), '1 01 1', 'Jan 2 2012 should be week 1');
+ assert.equal(moment([2012, 0, 8]).format('w ww wo'), '2 02 2', 'Jan 8 2012 should be week 2');
+ assert.equal(moment([2012, 0, 9]).format('w ww wo'), '2 02 2', 'Jan 9 2012 should be week 2');
+ assert.equal(moment([2012, 0, 15]).format('w ww wo'), '3 03 3', 'Jan 15 2012 should be week 3');
+ });
+
}));
;(function (global, factory) {
@@ -7239,6 +10069,224 @@
typeof define === 'function' && define.amd ? define(['../../moment'], factory) :
factory(global.moment)
}(this, function (moment) { 'use strict';
+
+ function each(array, callback) {
+ var i;
+ for (i = 0; i < array.length; i++) {
+ callback(array[i], i, array);
+ }
+ }
+
+ function objectKeys(obj) {
+ if (Object.keys) {
+ return Object.keys(obj);
+ } else {
+ // IE8
+ var res = [], i;
+ for (i in obj) {
+ if (obj.hasOwnProperty(i)) {
+ res.push(i);
+ }
+ }
+ return res;
+ }
+ }
+
+ // Pick the first defined of two or three arguments.
+ function defaults(a, b, c) {
+ if (a != null) {
+ return a;
+ }
+ if (b != null) {
+ return b;
+ }
+ return c;
+ }
+
+ function defineCommonLocaleTests(locale, options) {
+ test('lenient ordinal parsing', function (assert) {
+ var i, ordinalStr, testMoment;
+ for (i = 1; i <= 31; ++i) {
+ ordinalStr = moment([2014, 0, i]).format('YYYY MM Do');
+ testMoment = moment(ordinalStr, 'YYYY MM Do');
+ assert.equal(testMoment.year(), 2014,
+ 'lenient ordinal parsing ' + i + ' year check');
+ assert.equal(testMoment.month(), 0,
+ 'lenient ordinal parsing ' + i + ' month check');
+ assert.equal(testMoment.date(), i,
+ 'lenient ordinal parsing ' + i + ' date check');
+ }
+ });
+
+ test('lenient ordinal parsing of number', function (assert) {
+ var i, testMoment;
+ for (i = 1; i <= 31; ++i) {
+ testMoment = moment('2014 01 ' + i, 'YYYY MM Do');
+ assert.equal(testMoment.year(), 2014,
+ 'lenient ordinal parsing of number ' + i + ' year check');
+ assert.equal(testMoment.month(), 0,
+ 'lenient ordinal parsing of number ' + i + ' month check');
+ assert.equal(testMoment.date(), i,
+ 'lenient ordinal parsing of number ' + i + ' date check');
+ }
+ });
+
+ test('strict ordinal parsing', function (assert) {
+ var i, ordinalStr, testMoment;
+ for (i = 1; i <= 31; ++i) {
+ ordinalStr = moment([2014, 0, i]).format('YYYY MM Do');
+ testMoment = moment(ordinalStr, 'YYYY MM Do', true);
+ assert.ok(testMoment.isValid(), 'strict ordinal parsing ' + i);
+ }
+ });
+
+ test('meridiem invariant', function (assert) {
+ var h, m, t1, t2;
+ for (h = 0; h < 24; ++h) {
+ for (m = 0; m < 60; m += 15) {
+ t1 = moment.utc([2000, 0, 1, h, m]);
+ t2 = moment.utc(t1.format('A h:mm'), 'A h:mm');
+ assert.equal(t2.format('HH:mm'), t1.format('HH:mm'),
+ 'meridiem at ' + t1.format('HH:mm'));
+ }
+ }
+ });
+
+ test('date format correctness', function (assert) {
+ var data, tokens;
+ data = moment.localeData()._longDateFormat;
+ tokens = objectKeys(data);
+ each(tokens, function (srchToken) {
+ // Check each format string to make sure it does not contain any
+ // tokens that need to be expanded.
+ each(tokens, function (baseToken) {
+ // strip escaped sequences
+ var format = data[baseToken].replace(/(\[[^\]]*\])/g, '');
+ assert.equal(false, !!~format.indexOf(srchToken),
+ 'contains ' + srchToken + ' in ' + baseToken);
+ });
+ });
+ });
+
+ test('month parsing correctness', function (assert) {
+ var i, m;
+
+ if (locale === 'tr') {
+ // I can't fix it :(
+ expect(0);
+ return;
+ }
+ function tester(format) {
+ var r;
+ r = moment(m.format(format), format);
+ assert.equal(r.month(), m.month(), 'month ' + i + ' fmt ' + format);
+ r = moment(m.format(format).toLocaleUpperCase(), format);
+ assert.equal(r.month(), m.month(), 'month ' + i + ' fmt ' + format + ' upper');
+ r = moment(m.format(format).toLocaleLowerCase(), format);
+ assert.equal(r.month(), m.month(), 'month ' + i + ' fmt ' + format + ' lower');
+
+ r = moment(m.format(format), format, true);
+ assert.equal(r.month(), m.month(), 'month ' + i + ' fmt ' + format + ' strict');
+ r = moment(m.format(format).toLocaleUpperCase(), format, true);
+ assert.equal(r.month(), m.month(), 'month ' + i + ' fmt ' + format + ' upper strict');
+ r = moment(m.format(format).toLocaleLowerCase(), format, true);
+ assert.equal(r.month(), m.month(), 'month ' + i + ' fmt ' + format + ' lower strict');
+ }
+
+ for (i = 0; i < 12; ++i) {
+ m = moment([2015, i, 15, 18]);
+ tester('MMM');
+ tester('MMM.');
+ tester('MMMM');
+ tester('MMMM.');
+ }
+ });
+
+ test('weekday parsing correctness', function (assert) {
+ var i, m;
+
+ if (locale === 'tr' || locale === 'az') {
+ // There is a lower-case letter (ı), that converted to upper then
+ // lower changes to i
+ expect(0);
+ return;
+ }
+ function tester(format) {
+ var r, baseMsg = 'weekday ' + m.weekday() + ' fmt ' + format;
+ r = moment(m.format(format), format);
+ assert.equal(r.weekday(), m.weekday(), baseMsg);
+ r = moment(m.format(format).toLocaleUpperCase(), format);
+ assert.equal(r.weekday(), m.weekday(), baseMsg + ' upper');
+ r = moment(m.format(format).toLocaleLowerCase(), format);
+ assert.equal(r.weekday(), m.weekday(), baseMsg + ' lower');
+
+ r = moment(m.format(format), format, true);
+ assert.equal(r.weekday(), m.weekday(), baseMsg + ' strict');
+ r = moment(m.format(format).toLocaleUpperCase(), format, true);
+ assert.equal(r.weekday(), m.weekday(), baseMsg + ' upper strict');
+ r = moment(m.format(format).toLocaleLowerCase(), format, true);
+ assert.equal(r.weekday(), m.weekday(), baseMsg + ' lower strict');
+ }
+
+ for (i = 0; i < 7; ++i) {
+ m = moment.utc([2015, i, 15, 18]);
+ tester('dd');
+ tester('ddd');
+ tester('dddd');
+ }
+ });
+ }
+
+ function setupDeprecationHandler(test, moment, scope) {
+ test._expectedDeprecations = null;
+ test._observedDeprecations = null;
+ test._oldSupress = moment.suppressDeprecationWarnings;
+ moment.suppressDeprecationWarnings = true;
+ test.expectedDeprecations = function () {
+ test._expectedDeprecations = arguments;
+ test._observedDeprecations = [];
+ };
+ moment.deprecationHandler = function (name, msg) {
+ var deprecationId = matchedDeprecation(name, msg, test._expectedDeprecations);
+ if (deprecationId === -1) {
+ throw new Error('Unexpected deprecation thrown name=' +
+ name + ' msg=' + msg);
+ }
+ test._observedDeprecations[deprecationId] = 1;
+ };
+ }
+
+ function teardownDeprecationHandler(test, moment, scope) {
+ moment.suppressDeprecationWarnings = test._oldSupress;
+
+ if (test._expectedDeprecations != null) {
+ var missedDeprecations = [];
+ each(test._expectedDeprecations, function (deprecationPattern, id) {
+ if (test._observedDeprecations[id] !== 1) {
+ missedDeprecations.push(deprecationPattern);
+ }
+ });
+ if (missedDeprecations.length !== 0) {
+ throw new Error('Expected deprecation warnings did not happen: ' +
+ missedDeprecations.join(' '));
+ }
+ }
+ }
+
+ function matchedDeprecation(name, msg, deprecations) {
+ if (deprecations == null) {
+ return -1;
+ }
+ for (var i = 0; i < deprecations.length; ++i) {
+ if (name != null && name === deprecations[i]) {
+ return i;
+ }
+ if (msg != null && msg.substring(0, deprecations[i].length) === deprecations[i]) {
+ return i;
+ }
+ }
+ return -1;
+ }
/*global QUnit:false*/
@@ -7253,11 +10301,13 @@
moment.createFromInputFallback = function (config) {
throw new Error('input not handled by moment: ' + config._i);
};
+ setupDeprecationHandler(test, moment, 'core');
if (lifecycle && lifecycle.setup) {
lifecycle.setup();
}
},
teardown : function () {
+ teardownDeprecationHandler(test, moment, 'core');
if (lifecycle && lifecycle.teardown) {
lifecycle.teardown();
}
@@ -7272,17 +10322,20 @@
moment.createFromInputFallback = function (config) {
throw new Error('input not handled by moment: ' + config._i);
};
+ setupDeprecationHandler(test, moment, 'locale');
if (lifecycle && lifecycle.setup) {
lifecycle.setup();
}
},
teardown : function () {
moment.locale('en');
+ teardownDeprecationHandler(test, moment, 'locale');
if (lifecycle && lifecycle.teardown) {
lifecycle.teardown();
}
}
});
+ defineCommonLocaleTests(name, -1, -1);
}
localeModule('el');
@@ -7484,14 +10537,14 @@
});
test('calendar day', function (assert) {
- var a = moment().hours(2).minutes(0).seconds(0);
-
- assert.equal(moment(a).calendar(), 'Σήμερα στις 2:00 ΠΜ', 'today at the same time');
- assert.equal(moment(a).add({m: 25}).calendar(), 'Σήμερα στις 2:25 ΠΜ', 'Now plus 25 min');
- assert.equal(moment(a).add({h: 1}).calendar(), 'Σήμερα στις 3:00 ΠΜ', 'Now plus 1 hour');
- assert.equal(moment(a).add({d: 1}).calendar(), 'Αύριο στις 2:00 ΠΜ', 'tomorrow at the same time');
- assert.equal(moment(a).subtract({h: 1}).calendar(), 'Σήμερα στη 1:00 ΠΜ', 'Now minus 1 hour');
- assert.equal(moment(a).subtract({d: 1}).calendar(), 'Χθες στις 2:00 ΠΜ', 'yesterday at the same time');
+ var a = moment().hours(12).minutes(0).seconds(0);
+
+ assert.equal(moment(a).calendar(), 'Σήμερα στις 12:00 ΜΜ', 'today at the same time');
+ assert.equal(moment(a).add({m: 25}).calendar(), 'Σήμερα στις 12:25 ΜΜ', 'Now plus 25 min');
+ assert.equal(moment(a).add({h: 1}).calendar(), 'Σήμερα στη 1:00 ΜΜ', 'Now plus 1 hour');
+ assert.equal(moment(a).add({d: 1}).calendar(), 'Αύριο στις 12:00 ΜΜ', 'tomorrow at the same time');
+ assert.equal(moment(a).subtract({h: 1}).calendar(), 'Σήμερα στις 11:00 ΠΜ', 'Now minus 1 hour');
+ assert.equal(moment(a).subtract({d: 1}).calendar(), 'Χθες στις 12:00 ΜΜ', 'yesterday at the same time');
});
test('calendar next week', function (assert) {
@@ -7535,69 +10588,6 @@
assert.equal(weeksFromNow.calendar(), weeksFromNow.format('L'), 'in 2 weeks');
});
- test('weeks year starting sunday', function (assert) {
- assert.equal(moment([2012, 0, 1]).week(), 52, 'Jan 1 2012 should be week 52');
- assert.equal(moment([2012, 0, 7]).week(), 1, 'Jan 7 2012 should be week 1');
- assert.equal(moment([2012, 0, 8]).week(), 1, 'Jan 8 2012 should be week 1');
- assert.equal(moment([2012, 0, 14]).week(), 2, 'Jan 14 2012 should be week 2');
- assert.equal(moment([2012, 0, 15]).week(), 2, 'Jan 15 2012 should be week 2');
- });
-
- test('weeks year starting monday', function (assert) {
- assert.equal(moment([2006, 11, 31]).week(), 52, 'Dec 31 2006 should be week 52');
- assert.equal(moment([2007, 0, 1]).week(), 1, 'Jan 1 2007 should be week 1');
- assert.equal(moment([2007, 0, 6]).week(), 1, 'Jan 6 2007 should be week 1');
- assert.equal(moment([2007, 0, 7]).week(), 1, 'Jan 7 2007 should be week 1');
- assert.equal(moment([2007, 0, 13]).week(), 2, 'Jan 13 2007 should be week 2');
- assert.equal(moment([2007, 0, 14]).week(), 2, 'Jan 14 2007 should be week 2');
- });
-
- test('weeks year starting tuesday', function (assert) {
- assert.equal(moment([2007, 11, 30]).week(), 52, 'Dec 30 2007 should be week 52');
- assert.equal(moment([2008, 0, 1]).week(), 1, 'Jan 1 2008 should be week 1');
- assert.equal(moment([2008, 0, 5]).week(), 1, 'Jan 5 2008 should be week 1');
- assert.equal(moment([2008, 0, 6]).week(), 1, 'Jan 6 2008 should be week 1');
- assert.equal(moment([2008, 0, 12]).week(), 2, 'Jan 12 2008 should be week 2');
- assert.equal(moment([2008, 0, 13]).week(), 2, 'Jan 13 2008 should be week 2');
- });
-
- test('weeks year starting wednesday', function (assert) {
- assert.equal(moment([2002, 11, 29]).week(), 52, 'Dec 29 2002 should be week 52');
- assert.equal(moment([2003, 0, 1]).week(), 1, 'Jan 1 2003 should be week 1');
- assert.equal(moment([2003, 0, 4]).week(), 1, 'Jan 4 2003 should be week 1');
- assert.equal(moment([2003, 0, 5]).week(), 1, 'Jan 5 2003 should be week 1');
- assert.equal(moment([2003, 0, 11]).week(), 2, 'Jan 11 2003 should be week 2');
- assert.equal(moment([2003, 0, 12]).week(), 2, 'Jan 12 2003 should be week 2');
- });
-
- test('weeks year starting thursday', function (assert) {
- assert.equal(moment([2008, 11, 28]).week(), 52, 'Dec 28 2008 should be week 52');
- assert.equal(moment([2009, 0, 1]).week(), 1, 'Jan 1 2009 should be week 1');
- assert.equal(moment([2009, 0, 3]).week(), 1, 'Jan 3 2009 should be week 1');
- assert.equal(moment([2009, 0, 4]).week(), 1, 'Jan 4 2009 should be week 1');
- assert.equal(moment([2009, 0, 10]).week(), 2, 'Jan 10 2009 should be week 2');
- assert.equal(moment([2009, 0, 11]).week(), 2, 'Jan 11 2009 should be week 2');
- });
-
- test('weeks year starting friday', function (assert) {
- assert.equal(moment([2009, 11, 27]).week(), 52, 'Dec 27 2009 should be week 52');
- assert.equal(moment([2010, 0, 1]).week(), 53, 'Jan 1 2010 should be week 53');
- assert.equal(moment([2010, 0, 2]).week(), 53, 'Jan 2 2010 should be week 53');
- assert.equal(moment([2010, 0, 3]).week(), 53, 'Jan 3 2010 should be week 1');
- assert.equal(moment([2010, 0, 9]).week(), 1, 'Jan 9 2010 should be week 1');
- assert.equal(moment([2010, 0, 10]).week(), 1, 'Jan 10 2010 should be week 1');
- assert.equal(moment([2010, 0, 11]).week(), 2, 'Jan 11 2010 should be week 2');
- });
-
- test('weeks year starting saturday', function (assert) {
- assert.equal(moment([2010, 11, 26]).week(), 51, 'Dec 26 2010 should be week 51');
- assert.equal(moment([2011, 0, 1]).week(), 52, 'Jan 1 2011 should be week 52');
- assert.equal(moment([2011, 0, 2]).week(), 52, 'Jan 2 2011 should be week 52');
- assert.equal(moment([2011, 0, 8]).week(), 1, 'Jan 8 2011 should be week 1');
- assert.equal(moment([2011, 0, 9]).week(), 1, 'Jan 9 2011 should be week 1');
- assert.equal(moment([2011, 0, 10]).week(), 2, 'Jan 10 2011 should be week 2');
- });
-
test('weeks year starting sunday format', function (assert) {
assert.equal(moment([2012, 0, 1]).format('w ww wo'), '52 52 52η', 'Jan 1 2012 should be week 52');
assert.equal(moment([2012, 0, 7]).format('w ww wo'), '1 01 1η', 'Jan 7 2012 should be week 1');
@@ -7606,42 +10596,6 @@
assert.equal(moment([2012, 0, 15]).format('w ww wo'), '2 02 2η', 'Jan 15 2012 should be week 2');
});
- test('lenient ordinal parsing', function (assert) {
- var i, ordinalStr, testMoment;
- for (i = 1; i <= 31; ++i) {
- ordinalStr = moment([2014, 0, i]).format('YYYY MM Do');
- testMoment = moment(ordinalStr, 'YYYY MM Do');
- assert.equal(testMoment.year(), 2014,
- 'lenient ordinal parsing ' + i + ' year check');
- assert.equal(testMoment.month(), 0,
- 'lenient ordinal parsing ' + i + ' month check');
- assert.equal(testMoment.date(), i,
- 'lenient ordinal parsing ' + i + ' date check');
- }
- });
-
- test('lenient ordinal parsing of number', function (assert) {
- var i, testMoment;
- for (i = 1; i <= 31; ++i) {
- testMoment = moment('2014 01 ' + i, 'YYYY MM Do');
- assert.equal(testMoment.year(), 2014,
- 'lenient ordinal parsing of number ' + i + ' year check');
- assert.equal(testMoment.month(), 0,
- 'lenient ordinal parsing of number ' + i + ' month check');
- assert.equal(testMoment.date(), i,
- 'lenient ordinal parsing of number ' + i + ' date check');
- }
- });
-
- test('strict ordinal parsing', function (assert) {
- var i, ordinalStr, testMoment;
- for (i = 1; i <= 31; ++i) {
- ordinalStr = moment([2014, 0, i]).format('YYYY MM Do');
- testMoment = moment(ordinalStr, 'YYYY MM Do', true);
- assert.ok(testMoment.isValid(), 'strict ordinal parsing ' + i);
- }
- });
-
}));
;(function (global, factory) {
@@ -7650,6 +10604,224 @@
typeof define === 'function' && define.amd ? define(['../../moment'], factory) :
factory(global.moment)
}(this, function (moment) { 'use strict';
+
+ function each(array, callback) {
+ var i;
+ for (i = 0; i < array.length; i++) {
+ callback(array[i], i, array);
+ }
+ }
+
+ function objectKeys(obj) {
+ if (Object.keys) {
+ return Object.keys(obj);
+ } else {
+ // IE8
+ var res = [], i;
+ for (i in obj) {
+ if (obj.hasOwnProperty(i)) {
+ res.push(i);
+ }
+ }
+ return res;
+ }
+ }
+
+ // Pick the first defined of two or three arguments.
+ function defaults(a, b, c) {
+ if (a != null) {
+ return a;
+ }
+ if (b != null) {
+ return b;
+ }
+ return c;
+ }
+
+ function defineCommonLocaleTests(locale, options) {
+ test('lenient ordinal parsing', function (assert) {
+ var i, ordinalStr, testMoment;
+ for (i = 1; i <= 31; ++i) {
+ ordinalStr = moment([2014, 0, i]).format('YYYY MM Do');
+ testMoment = moment(ordinalStr, 'YYYY MM Do');
+ assert.equal(testMoment.year(), 2014,
+ 'lenient ordinal parsing ' + i + ' year check');
+ assert.equal(testMoment.month(), 0,
+ 'lenient ordinal parsing ' + i + ' month check');
+ assert.equal(testMoment.date(), i,
+ 'lenient ordinal parsing ' + i + ' date check');
+ }
+ });
+
+ test('lenient ordinal parsing of number', function (assert) {
+ var i, testMoment;
+ for (i = 1; i <= 31; ++i) {
+ testMoment = moment('2014 01 ' + i, 'YYYY MM Do');
+ assert.equal(testMoment.year(), 2014,
+ 'lenient ordinal parsing of number ' + i + ' year check');
+ assert.equal(testMoment.month(), 0,
+ 'lenient ordinal parsing of number ' + i + ' month check');
+ assert.equal(testMoment.date(), i,
+ 'lenient ordinal parsing of number ' + i + ' date check');
+ }
+ });
+
+ test('strict ordinal parsing', function (assert) {
+ var i, ordinalStr, testMoment;
+ for (i = 1; i <= 31; ++i) {
+ ordinalStr = moment([2014, 0, i]).format('YYYY MM Do');
+ testMoment = moment(ordinalStr, 'YYYY MM Do', true);
+ assert.ok(testMoment.isValid(), 'strict ordinal parsing ' + i);
+ }
+ });
+
+ test('meridiem invariant', function (assert) {
+ var h, m, t1, t2;
+ for (h = 0; h < 24; ++h) {
+ for (m = 0; m < 60; m += 15) {
+ t1 = moment.utc([2000, 0, 1, h, m]);
+ t2 = moment.utc(t1.format('A h:mm'), 'A h:mm');
+ assert.equal(t2.format('HH:mm'), t1.format('HH:mm'),
+ 'meridiem at ' + t1.format('HH:mm'));
+ }
+ }
+ });
+
+ test('date format correctness', function (assert) {
+ var data, tokens;
+ data = moment.localeData()._longDateFormat;
+ tokens = objectKeys(data);
+ each(tokens, function (srchToken) {
+ // Check each format string to make sure it does not contain any
+ // tokens that need to be expanded.
+ each(tokens, function (baseToken) {
+ // strip escaped sequences
+ var format = data[baseToken].replace(/(\[[^\]]*\])/g, '');
+ assert.equal(false, !!~format.indexOf(srchToken),
+ 'contains ' + srchToken + ' in ' + baseToken);
+ });
+ });
+ });
+
+ test('month parsing correctness', function (assert) {
+ var i, m;
+
+ if (locale === 'tr') {
+ // I can't fix it :(
+ expect(0);
+ return;
+ }
+ function tester(format) {
+ var r;
+ r = moment(m.format(format), format);
+ assert.equal(r.month(), m.month(), 'month ' + i + ' fmt ' + format);
+ r = moment(m.format(format).toLocaleUpperCase(), format);
+ assert.equal(r.month(), m.month(), 'month ' + i + ' fmt ' + format + ' upper');
+ r = moment(m.format(format).toLocaleLowerCase(), format);
+ assert.equal(r.month(), m.month(), 'month ' + i + ' fmt ' + format + ' lower');
+
+ r = moment(m.format(format), format, true);
+ assert.equal(r.month(), m.month(), 'month ' + i + ' fmt ' + format + ' strict');
+ r = moment(m.format(format).toLocaleUpperCase(), format, true);
+ assert.equal(r.month(), m.month(), 'month ' + i + ' fmt ' + format + ' upper strict');
+ r = moment(m.format(format).toLocaleLowerCase(), format, true);
+ assert.equal(r.month(), m.month(), 'month ' + i + ' fmt ' + format + ' lower strict');
+ }
+
+ for (i = 0; i < 12; ++i) {
+ m = moment([2015, i, 15, 18]);
+ tester('MMM');
+ tester('MMM.');
+ tester('MMMM');
+ tester('MMMM.');
+ }
+ });
+
+ test('weekday parsing correctness', function (assert) {
+ var i, m;
+
+ if (locale === 'tr' || locale === 'az') {
+ // There is a lower-case letter (ı), that converted to upper then
+ // lower changes to i
+ expect(0);
+ return;
+ }
+ function tester(format) {
+ var r, baseMsg = 'weekday ' + m.weekday() + ' fmt ' + format;
+ r = moment(m.format(format), format);
+ assert.equal(r.weekday(), m.weekday(), baseMsg);
+ r = moment(m.format(format).toLocaleUpperCase(), format);
+ assert.equal(r.weekday(), m.weekday(), baseMsg + ' upper');
+ r = moment(m.format(format).toLocaleLowerCase(), format);
+ assert.equal(r.weekday(), m.weekday(), baseMsg + ' lower');
+
+ r = moment(m.format(format), format, true);
+ assert.equal(r.weekday(), m.weekday(), baseMsg + ' strict');
+ r = moment(m.format(format).toLocaleUpperCase(), format, true);
+ assert.equal(r.weekday(), m.weekday(), baseMsg + ' upper strict');
+ r = moment(m.format(format).toLocaleLowerCase(), format, true);
+ assert.equal(r.weekday(), m.weekday(), baseMsg + ' lower strict');
+ }
+
+ for (i = 0; i < 7; ++i) {
+ m = moment.utc([2015, i, 15, 18]);
+ tester('dd');
+ tester('ddd');
+ tester('dddd');
+ }
+ });
+ }
+
+ function setupDeprecationHandler(test, moment, scope) {
+ test._expectedDeprecations = null;
+ test._observedDeprecations = null;
+ test._oldSupress = moment.suppressDeprecationWarnings;
+ moment.suppressDeprecationWarnings = true;
+ test.expectedDeprecations = function () {
+ test._expectedDeprecations = arguments;
+ test._observedDeprecations = [];
+ };
+ moment.deprecationHandler = function (name, msg) {
+ var deprecationId = matchedDeprecation(name, msg, test._expectedDeprecations);
+ if (deprecationId === -1) {
+ throw new Error('Unexpected deprecation thrown name=' +
+ name + ' msg=' + msg);
+ }
+ test._observedDeprecations[deprecationId] = 1;
+ };
+ }
+
+ function teardownDeprecationHandler(test, moment, scope) {
+ moment.suppressDeprecationWarnings = test._oldSupress;
+
+ if (test._expectedDeprecations != null) {
+ var missedDeprecations = [];
+ each(test._expectedDeprecations, function (deprecationPattern, id) {
+ if (test._observedDeprecations[id] !== 1) {
+ missedDeprecations.push(deprecationPattern);
+ }
+ });
+ if (missedDeprecations.length !== 0) {
+ throw new Error('Expected deprecation warnings did not happen: ' +
+ missedDeprecations.join(' '));
+ }
+ }
+ }
+
+ function matchedDeprecation(name, msg, deprecations) {
+ if (deprecations == null) {
+ return -1;
+ }
+ for (var i = 0; i < deprecations.length; ++i) {
+ if (name != null && name === deprecations[i]) {
+ return i;
+ }
+ if (msg != null && msg.substring(0, deprecations[i].length) === deprecations[i]) {
+ return i;
+ }
+ }
+ return -1;
+ }
/*global QUnit:false*/
@@ -7664,11 +10836,13 @@
moment.createFromInputFallback = function (config) {
throw new Error('input not handled by moment: ' + config._i);
};
+ setupDeprecationHandler(test, moment, 'core');
if (lifecycle && lifecycle.setup) {
lifecycle.setup();
}
},
teardown : function () {
+ teardownDeprecationHandler(test, moment, 'core');
if (lifecycle && lifecycle.teardown) {
lifecycle.teardown();
}
@@ -7683,23 +10857,26 @@
moment.createFromInputFallback = function (config) {
throw new Error('input not handled by moment: ' + config._i);
};
+ setupDeprecationHandler(test, moment, 'locale');
if (lifecycle && lifecycle.setup) {
lifecycle.setup();
}
},
teardown : function () {
moment.locale('en');
+ teardownDeprecationHandler(test, moment, 'locale');
if (lifecycle && lifecycle.teardown) {
lifecycle.teardown();
}
}
});
+ defineCommonLocaleTests(name, -1, -1);
}
localeModule('en-au');
test('parse', function (assert) {
- var tests = 'January Jan_February Feb_March Mar_April Apr_May May_June Jun_July Jul_August Aug_September Sept_October Oct_November Nov_December Dec'.split('_'), i;
+ var tests = '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('_'), i;
function equalTest(input, mmm, i) {
assert.equal(moment(input, mmm).month(), i, input + ' should be month ' + (i + 1));
}
@@ -7787,7 +10964,7 @@
});
test('format month', function (assert) {
- var expected = 'January Jan_February Feb_March Mar_April Apr_May May_June Jun_July Jul_August Aug_September Sept_October Oct_November Nov_December Dec'.split('_'), i;
+ 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('_'), i;
for (i = 0; i < expected.length; i++) {
assert.equal(moment([2011, i, 1]).format('MMMM MMM'), expected[i], expected[i]);
}
@@ -7847,14 +11024,14 @@
});
test('calendar day', function (assert) {
- var a = moment().hours(2).minutes(0).seconds(0);
-
- assert.equal(moment(a).calendar(), 'Today at 2:00 AM', 'today at the same time');
- assert.equal(moment(a).add({m: 25}).calendar(), 'Today at 2:25 AM', 'Now plus 25 min');
- assert.equal(moment(a).add({h: 1}).calendar(), 'Today at 3:00 AM', 'Now plus 1 hour');
- assert.equal(moment(a).add({d: 1}).calendar(), 'Tomorrow at 2:00 AM', 'tomorrow at the same time');
- assert.equal(moment(a).subtract({h: 1}).calendar(), 'Today at 1:00 AM', 'Now minus 1 hour');
- assert.equal(moment(a).subtract({d: 1}).calendar(), 'Yesterday at 2:00 AM', 'yesterday at the same time');
+ var a = moment().hours(12).minutes(0).seconds(0);
+
+ assert.equal(moment(a).calendar(), 'Today at 12:00 PM', 'today at the same time');
+ assert.equal(moment(a).add({m: 25}).calendar(), 'Today at 12:25 PM', 'Now plus 25 min');
+ assert.equal(moment(a).add({h: 1}).calendar(), 'Today at 1:00 PM', 'Now plus 1 hour');
+ assert.equal(moment(a).add({d: 1}).calendar(), 'Tomorrow at 12:00 PM', 'tomorrow at the same time');
+ assert.equal(moment(a).subtract({h: 1}).calendar(), 'Today at 11:00 AM', 'Now minus 1 hour');
+ assert.equal(moment(a).subtract({d: 1}).calendar(), 'Yesterday at 12:00 PM', 'yesterday at the same time');
});
test('calendar next week', function (assert) {
@@ -7896,67 +11073,6 @@
assert.equal(weeksFromNow.calendar(), weeksFromNow.format('L'), 'in 2 weeks');
});
- test('weeks year starting sunday', function (assert) {
- assert.equal(moment([2012, 0, 1]).week(), 52, 'Jan 1 2012 should be week 52');
- assert.equal(moment([2012, 0, 2]).week(), 1, 'Jan 2 2012 should be week 1');
- assert.equal(moment([2012, 0, 8]).week(), 1, 'Jan 8 2012 should be week 1');
- assert.equal(moment([2012, 0, 9]).week(), 2, 'Jan 9 2012 should be week 2');
- assert.equal(moment([2012, 0, 15]).week(), 2, 'Jan 15 2012 should be week 2');
- });
-
- test('weeks year starting monday', function (assert) {
- assert.equal(moment([2007, 0, 1]).week(), 1, 'Jan 1 2007 should be week 1');
- assert.equal(moment([2007, 0, 7]).week(), 1, 'Jan 7 2007 should be week 1');
- assert.equal(moment([2007, 0, 8]).week(), 2, 'Jan 8 2007 should be week 2');
- assert.equal(moment([2007, 0, 14]).week(), 2, 'Jan 14 2007 should be week 2');
- assert.equal(moment([2007, 0, 15]).week(), 3, 'Jan 15 2007 should be week 3');
- });
-
- test('weeks year starting tuesday', function (assert) {
- assert.equal(moment([2007, 11, 31]).week(), 1, 'Dec 31 2007 should be week 1');
- assert.equal(moment([2008, 0, 1]).week(), 1, 'Jan 1 2008 should be week 1');
- assert.equal(moment([2008, 0, 6]).week(), 1, 'Jan 6 2008 should be week 1');
- assert.equal(moment([2008, 0, 7]).week(), 2, 'Jan 7 2008 should be week 2');
- assert.equal(moment([2008, 0, 13]).week(), 2, 'Jan 13 2008 should be week 2');
- assert.equal(moment([2008, 0, 14]).week(), 3, 'Jan 14 2008 should be week 3');
- });
-
- test('weeks year starting wednesday', function (assert) {
- assert.equal(moment([2002, 11, 30]).week(), 1, 'Dec 30 2002 should be week 1');
- assert.equal(moment([2003, 0, 1]).week(), 1, 'Jan 1 2003 should be week 1');
- assert.equal(moment([2003, 0, 5]).week(), 1, 'Jan 5 2003 should be week 1');
- assert.equal(moment([2003, 0, 6]).week(), 2, 'Jan 6 2003 should be week 2');
- assert.equal(moment([2003, 0, 12]).week(), 2, 'Jan 12 2003 should be week 2');
- assert.equal(moment([2003, 0, 13]).week(), 3, 'Jan 13 2003 should be week 3');
- });
-
- test('weeks year starting thursday', function (assert) {
- assert.equal(moment([2008, 11, 29]).week(), 1, 'Dec 29 2008 should be week 1');
- assert.equal(moment([2009, 0, 1]).week(), 1, 'Jan 1 2009 should be week 1');
- assert.equal(moment([2009, 0, 4]).week(), 1, 'Jan 4 2009 should be week 1');
- assert.equal(moment([2009, 0, 5]).week(), 2, 'Jan 5 2009 should be week 2');
- assert.equal(moment([2009, 0, 11]).week(), 2, 'Jan 11 2009 should be week 2');
- assert.equal(moment([2009, 0, 13]).week(), 3, 'Jan 12 2009 should be week 3');
- });
-
- test('weeks year starting friday', function (assert) {
- assert.equal(moment([2009, 11, 28]).week(), 53, 'Dec 28 2009 should be week 53');
- assert.equal(moment([2010, 0, 1]).week(), 53, 'Jan 1 2010 should be week 53');
- assert.equal(moment([2010, 0, 3]).week(), 53, 'Jan 3 2010 should be week 53');
- assert.equal(moment([2010, 0, 4]).week(), 1, 'Jan 4 2010 should be week 1');
- assert.equal(moment([2010, 0, 10]).week(), 1, 'Jan 10 2010 should be week 1');
- assert.equal(moment([2010, 0, 11]).week(), 2, 'Jan 11 2010 should be week 2');
- });
-
- test('weeks year starting saturday', function (assert) {
- assert.equal(moment([2010, 11, 27]).week(), 52, 'Dec 27 2010 should be week 52');
- assert.equal(moment([2011, 0, 1]).week(), 52, 'Jan 1 2011 should be week 52');
- assert.equal(moment([2011, 0, 2]).week(), 52, 'Jan 2 2011 should be week 52');
- assert.equal(moment([2011, 0, 3]).week(), 1, 'Jan 3 2011 should be week 1');
- assert.equal(moment([2011, 0, 9]).week(), 1, 'Jan 9 2011 should be week 1');
- assert.equal(moment([2011, 0, 10]).week(), 2, 'Jan 10 2011 should be week 2');
- });
-
test('weeks year starting sunday formatted', function (assert) {
assert.equal(moment([2012, 0, 1]).format('w ww wo'), '52 52 52nd', 'Jan 1 2012 should be week 52');
assert.equal(moment([2012, 0, 2]).format('w ww wo'), '1 01 1st', 'Jan 2 2012 should be week 1');
@@ -7965,33 +11081,6 @@
assert.equal(moment([2012, 0, 15]).format('w ww wo'), '2 02 2nd', 'Jan 15 2012 should be week 2');
});
- test('lenient ordinal parsing', function (assert) {
- var i, ordinalStr, testStr;
- for (i = 1; i <= 31; ++i) {
- ordinalStr = moment([2014, 0, i]).format('YYYY MM Do');
- testStr = moment(ordinalStr, 'YYYY MM Do').format('YYYY MM D');
- assert.equal(testStr, '2014 01 ' + i, 'lenient ordinal parsing ' + i);
- }
- });
-
- test('lenient ordinal parsing of number', function (assert) {
- var i, testStr;
- for (i = 1; i <= 31; ++i) {
- testStr = moment('2014 01 ' + i, 'YYYY MM Do').format('YYYY MM D');
- assert.equal(testStr, '2014 01 ' + i,
- 'lenient ordinal parsing of number ' + i);
- }
- });
-
- test('strict ordinal parsing', function (assert) {
- var i, ordinalStr, testMoment;
- for (i = 1; i <= 31; ++i) {
- ordinalStr = moment([2014, 0, i]).format('YYYY MMM Do');
- testMoment = moment(ordinalStr, 'YYYY MMM Do', true);
- assert.ok(testMoment.isValid(), 'strict ordinal parsing ' + i);
- }
- });
-
}));
;(function (global, factory) {
@@ -8000,6 +11089,224 @@
typeof define === 'function' && define.amd ? define(['../../moment'], factory) :
factory(global.moment)
}(this, function (moment) { 'use strict';
+
+ function each(array, callback) {
+ var i;
+ for (i = 0; i < array.length; i++) {
+ callback(array[i], i, array);
+ }
+ }
+
+ function objectKeys(obj) {
+ if (Object.keys) {
+ return Object.keys(obj);
+ } else {
+ // IE8
+ var res = [], i;
+ for (i in obj) {
+ if (obj.hasOwnProperty(i)) {
+ res.push(i);
+ }
+ }
+ return res;
+ }
+ }
+
+ // Pick the first defined of two or three arguments.
+ function defaults(a, b, c) {
+ if (a != null) {
+ return a;
+ }
+ if (b != null) {
+ return b;
+ }
+ return c;
+ }
+
+ function defineCommonLocaleTests(locale, options) {
+ test('lenient ordinal parsing', function (assert) {
+ var i, ordinalStr, testMoment;
+ for (i = 1; i <= 31; ++i) {
+ ordinalStr = moment([2014, 0, i]).format('YYYY MM Do');
+ testMoment = moment(ordinalStr, 'YYYY MM Do');
+ assert.equal(testMoment.year(), 2014,
+ 'lenient ordinal parsing ' + i + ' year check');
+ assert.equal(testMoment.month(), 0,
+ 'lenient ordinal parsing ' + i + ' month check');
+ assert.equal(testMoment.date(), i,
+ 'lenient ordinal parsing ' + i + ' date check');
+ }
+ });
+
+ test('lenient ordinal parsing of number', function (assert) {
+ var i, testMoment;
+ for (i = 1; i <= 31; ++i) {
+ testMoment = moment('2014 01 ' + i, 'YYYY MM Do');
+ assert.equal(testMoment.year(), 2014,
+ 'lenient ordinal parsing of number ' + i + ' year check');
+ assert.equal(testMoment.month(), 0,
+ 'lenient ordinal parsing of number ' + i + ' month check');
+ assert.equal(testMoment.date(), i,
+ 'lenient ordinal parsing of number ' + i + ' date check');
+ }
+ });
+
+ test('strict ordinal parsing', function (assert) {
+ var i, ordinalStr, testMoment;
+ for (i = 1; i <= 31; ++i) {
+ ordinalStr = moment([2014, 0, i]).format('YYYY MM Do');
+ testMoment = moment(ordinalStr, 'YYYY MM Do', true);
+ assert.ok(testMoment.isValid(), 'strict ordinal parsing ' + i);
+ }
+ });
+
+ test('meridiem invariant', function (assert) {
+ var h, m, t1, t2;
+ for (h = 0; h < 24; ++h) {
+ for (m = 0; m < 60; m += 15) {
+ t1 = moment.utc([2000, 0, 1, h, m]);
+ t2 = moment.utc(t1.format('A h:mm'), 'A h:mm');
+ assert.equal(t2.format('HH:mm'), t1.format('HH:mm'),
+ 'meridiem at ' + t1.format('HH:mm'));
+ }
+ }
+ });
+
+ test('date format correctness', function (assert) {
+ var data, tokens;
+ data = moment.localeData()._longDateFormat;
+ tokens = objectKeys(data);
+ each(tokens, function (srchToken) {
+ // Check each format string to make sure it does not contain any
+ // tokens that need to be expanded.
+ each(tokens, function (baseToken) {
+ // strip escaped sequences
+ var format = data[baseToken].replace(/(\[[^\]]*\])/g, '');
+ assert.equal(false, !!~format.indexOf(srchToken),
+ 'contains ' + srchToken + ' in ' + baseToken);
+ });
+ });
+ });
+
+ test('month parsing correctness', function (assert) {
+ var i, m;
+
+ if (locale === 'tr') {
+ // I can't fix it :(
+ expect(0);
+ return;
+ }
+ function tester(format) {
+ var r;
+ r = moment(m.format(format), format);
+ assert.equal(r.month(), m.month(), 'month ' + i + ' fmt ' + format);
+ r = moment(m.format(format).toLocaleUpperCase(), format);
+ assert.equal(r.month(), m.month(), 'month ' + i + ' fmt ' + format + ' upper');
+ r = moment(m.format(format).toLocaleLowerCase(), format);
+ assert.equal(r.month(), m.month(), 'month ' + i + ' fmt ' + format + ' lower');
+
+ r = moment(m.format(format), format, true);
+ assert.equal(r.month(), m.month(), 'month ' + i + ' fmt ' + format + ' strict');
+ r = moment(m.format(format).toLocaleUpperCase(), format, true);
+ assert.equal(r.month(), m.month(), 'month ' + i + ' fmt ' + format + ' upper strict');
+ r = moment(m.format(format).toLocaleLowerCase(), format, true);
+ assert.equal(r.month(), m.month(), 'month ' + i + ' fmt ' + format + ' lower strict');
+ }
+
+ for (i = 0; i < 12; ++i) {
+ m = moment([2015, i, 15, 18]);
+ tester('MMM');
+ tester('MMM.');
+ tester('MMMM');
+ tester('MMMM.');
+ }
+ });
+
+ test('weekday parsing correctness', function (assert) {
+ var i, m;
+
+ if (locale === 'tr' || locale === 'az') {
+ // There is a lower-case letter (ı), that converted to upper then
+ // lower changes to i
+ expect(0);
+ return;
+ }
+ function tester(format) {
+ var r, baseMsg = 'weekday ' + m.weekday() + ' fmt ' + format;
+ r = moment(m.format(format), format);
+ assert.equal(r.weekday(), m.weekday(), baseMsg);
+ r = moment(m.format(format).toLocaleUpperCase(), format);
+ assert.equal(r.weekday(), m.weekday(), baseMsg + ' upper');
+ r = moment(m.format(format).toLocaleLowerCase(), format);
+ assert.equal(r.weekday(), m.weekday(), baseMsg + ' lower');
+
+ r = moment(m.format(format), format, true);
+ assert.equal(r.weekday(), m.weekday(), baseMsg + ' strict');
+ r = moment(m.format(format).toLocaleUpperCase(), format, true);
+ assert.equal(r.weekday(), m.weekday(), baseMsg + ' upper strict');
+ r = moment(m.format(format).toLocaleLowerCase(), format, true);
+ assert.equal(r.weekday(), m.weekday(), baseMsg + ' lower strict');
+ }
+
+ for (i = 0; i < 7; ++i) {
+ m = moment.utc([2015, i, 15, 18]);
+ tester('dd');
+ tester('ddd');
+ tester('dddd');
+ }
+ });
+ }
+
+ function setupDeprecationHandler(test, moment, scope) {
+ test._expectedDeprecations = null;
+ test._observedDeprecations = null;
+ test._oldSupress = moment.suppressDeprecationWarnings;
+ moment.suppressDeprecationWarnings = true;
+ test.expectedDeprecations = function () {
+ test._expectedDeprecations = arguments;
+ test._observedDeprecations = [];
+ };
+ moment.deprecationHandler = function (name, msg) {
+ var deprecationId = matchedDeprecation(name, msg, test._expectedDeprecations);
+ if (deprecationId === -1) {
+ throw new Error('Unexpected deprecation thrown name=' +
+ name + ' msg=' + msg);
+ }
+ test._observedDeprecations[deprecationId] = 1;
+ };
+ }
+
+ function teardownDeprecationHandler(test, moment, scope) {
+ moment.suppressDeprecationWarnings = test._oldSupress;
+
+ if (test._expectedDeprecations != null) {
+ var missedDeprecations = [];
+ each(test._expectedDeprecations, function (deprecationPattern, id) {
+ if (test._observedDeprecations[id] !== 1) {
+ missedDeprecations.push(deprecationPattern);
+ }
+ });
+ if (missedDeprecations.length !== 0) {
+ throw new Error('Expected deprecation warnings did not happen: ' +
+ missedDeprecations.join(' '));
+ }
+ }
+ }
+
+ function matchedDeprecation(name, msg, deprecations) {
+ if (deprecations == null) {
+ return -1;
+ }
+ for (var i = 0; i < deprecations.length; ++i) {
+ if (name != null && name === deprecations[i]) {
+ return i;
+ }
+ if (msg != null && msg.substring(0, deprecations[i].length) === deprecations[i]) {
+ return i;
+ }
+ }
+ return -1;
+ }
/*global QUnit:false*/
@@ -8014,11 +11321,13 @@
moment.createFromInputFallback = function (config) {
throw new Error('input not handled by moment: ' + config._i);
};
+ setupDeprecationHandler(test, moment, 'core');
if (lifecycle && lifecycle.setup) {
lifecycle.setup();
}
},
teardown : function () {
+ teardownDeprecationHandler(test, moment, 'core');
if (lifecycle && lifecycle.teardown) {
lifecycle.teardown();
}
@@ -8033,24 +11342,27 @@
moment.createFromInputFallback = function (config) {
throw new Error('input not handled by moment: ' + config._i);
};
+ setupDeprecationHandler(test, moment, 'locale');
if (lifecycle && lifecycle.setup) {
lifecycle.setup();
}
},
teardown : function () {
moment.locale('en');
+ teardownDeprecationHandler(test, moment, 'locale');
if (lifecycle && lifecycle.teardown) {
lifecycle.teardown();
}
}
});
+ defineCommonLocaleTests(name, -1, -1);
}
localeModule('en-ca');
test('parse', function (assert) {
var i,
- tests = 'January Jan_February Feb_March Mar_April Apr_May May_June Jun_July Jul_August Aug_September Sept_October Oct_November Nov_December Dec'.split('_');
+ tests = '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('_');
function equalTest(input, mmm, i) {
assert.equal(moment(input, mmm).month(), i, input + ' should be month ' + (i + 1));
@@ -8087,13 +11399,13 @@
['[the] DDDo [day of the year]', 'the 45th day of the year'],
['L', '2010-02-14'],
['LTS', '3:25:50 PM'],
- ['LL', '14 February, 2010'],
- ['LLL', '14 February, 2010 3:25 PM'],
- ['LLLL', 'Sunday, 14 February, 2010 3:25 PM'],
+ ['LL', 'February 14, 2010'],
+ ['LLL', 'February 14, 2010 3:25 PM'],
+ ['LLLL', 'Sunday, February 14, 2010 3:25 PM'],
['l', '2010-2-14'],
- ['ll', '14 Feb, 2010'],
- ['lll', '14 Feb, 2010 3:25 PM'],
- ['llll', 'Sun, 14 Feb, 2010 3:25 PM']
+ ['ll', 'Feb 14, 2010'],
+ ['lll', 'Feb 14, 2010 3:25 PM'],
+ ['llll', 'Sun, Feb 14, 2010 3:25 PM']
],
b = moment(new Date(2010, 1, 14, 15, 25, 50, 125)),
i;
@@ -8142,7 +11454,7 @@
test('format month', function (assert) {
var i,
- expected = 'January Jan_February Feb_March Mar_April Apr_May May_June Jun_July Jul_August Aug_September Sept_October Oct_November Nov_December Dec'.split('_');
+ 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('_');
for (i = 0; i < expected.length; i++) {
assert.equal(moment([2011, i, 1]).format('MMMM MMM'), expected[i], expected[i]);
@@ -8205,14 +11517,14 @@
});
test('calendar day', function (assert) {
- var a = moment().hours(2).minutes(0).seconds(0);
-
- assert.equal(moment(a).calendar(), 'Today at 2:00 AM', 'today at the same time');
- assert.equal(moment(a).add({m: 25}).calendar(), 'Today at 2:25 AM', 'Now plus 25 min');
- assert.equal(moment(a).add({h: 1}).calendar(), 'Today at 3:00 AM', 'Now plus 1 hour');
- assert.equal(moment(a).add({d: 1}).calendar(), 'Tomorrow at 2:00 AM', 'tomorrow at the same time');
- assert.equal(moment(a).subtract({h: 1}).calendar(), 'Today at 1:00 AM', 'Now minus 1 hour');
- assert.equal(moment(a).subtract({d: 1}).calendar(), 'Yesterday at 2:00 AM', 'yesterday at the same time');
+ var a = moment().hours(12).minutes(0).seconds(0);
+
+ assert.equal(moment(a).calendar(), 'Today at 12:00 PM', 'today at the same time');
+ assert.equal(moment(a).add({m: 25}).calendar(), 'Today at 12:25 PM', 'Now plus 25 min');
+ assert.equal(moment(a).add({h: 1}).calendar(), 'Today at 1:00 PM', 'Now plus 1 hour');
+ assert.equal(moment(a).add({d: 1}).calendar(), 'Tomorrow at 12:00 PM', 'tomorrow at the same time');
+ assert.equal(moment(a).subtract({h: 1}).calendar(), 'Today at 11:00 AM', 'Now minus 1 hour');
+ assert.equal(moment(a).subtract({d: 1}).calendar(), 'Yesterday at 12:00 PM', 'yesterday at the same time');
});
test('calendar next week', function (assert) {
@@ -8255,67 +11567,6 @@
assert.equal(weeksFromNow.calendar(), weeksFromNow.format('L'), 'in 2 weeks');
});
- test('weeks year starting sunday', function (assert) {
- assert.equal(moment([2012, 0, 1]).week(), 1, 'Jan 1 2012 should be week 1');
- assert.equal(moment([2012, 0, 7]).week(), 1, 'Jan 7 2012 should be week 1');
- assert.equal(moment([2012, 0, 8]).week(), 2, 'Jan 8 2012 should be week 2');
- assert.equal(moment([2012, 0, 14]).week(), 2, 'Jan 14 2012 should be week 2');
- assert.equal(moment([2012, 0, 15]).week(), 3, 'Jan 15 2012 should be week 3');
- });
-
- test('weeks year starting monday', function (assert) {
- assert.equal(moment([2006, 11, 31]).week(), 1, 'Dec 31 2006 should be week 1');
- assert.equal(moment([2007, 0, 1]).week(), 1, 'Jan 1 2007 should be week 1');
- assert.equal(moment([2007, 0, 6]).week(), 1, 'Jan 6 2007 should be week 1');
- assert.equal(moment([2007, 0, 7]).week(), 2, 'Jan 7 2007 should be week 2');
- assert.equal(moment([2007, 0, 13]).week(), 2, 'Jan 13 2007 should be week 2');
- assert.equal(moment([2007, 0, 14]).week(), 3, 'Jan 14 2007 should be week 3');
- });
-
- test('weeks year starting tuesday', function (assert) {
- assert.equal(moment([2007, 11, 29]).week(), 52, 'Dec 29 2007 should be week 52');
- assert.equal(moment([2008, 0, 1]).week(), 1, 'Jan 1 2008 should be week 1');
- assert.equal(moment([2008, 0, 5]).week(), 1, 'Jan 5 2008 should be week 1');
- assert.equal(moment([2008, 0, 6]).week(), 2, 'Jan 6 2008 should be week 2');
- assert.equal(moment([2008, 0, 12]).week(), 2, 'Jan 12 2008 should be week 2');
- assert.equal(moment([2008, 0, 13]).week(), 3, 'Jan 13 2008 should be week 3');
- });
-
- test('weeks year starting wednesday', function (assert) {
- assert.equal(moment([2002, 11, 29]).week(), 1, 'Dec 29 2002 should be week 1');
- assert.equal(moment([2003, 0, 1]).week(), 1, 'Jan 1 2003 should be week 1');
- assert.equal(moment([2003, 0, 4]).week(), 1, 'Jan 4 2003 should be week 1');
- assert.equal(moment([2003, 0, 5]).week(), 2, 'Jan 5 2003 should be week 2');
- assert.equal(moment([2003, 0, 11]).week(), 2, 'Jan 11 2003 should be week 2');
- assert.equal(moment([2003, 0, 12]).week(), 3, 'Jan 12 2003 should be week 3');
- });
-
- test('weeks year starting thursday', function (assert) {
- assert.equal(moment([2008, 11, 28]).week(), 1, 'Dec 28 2008 should be week 1');
- assert.equal(moment([2009, 0, 1]).week(), 1, 'Jan 1 2009 should be week 1');
- assert.equal(moment([2009, 0, 3]).week(), 1, 'Jan 3 2009 should be week 1');
- assert.equal(moment([2009, 0, 4]).week(), 2, 'Jan 4 2009 should be week 2');
- assert.equal(moment([2009, 0, 10]).week(), 2, 'Jan 10 2009 should be week 2');
- assert.equal(moment([2009, 0, 11]).week(), 3, 'Jan 11 2009 should be week 3');
- });
-
- test('weeks year starting friday', function (assert) {
- assert.equal(moment([2009, 11, 27]).week(), 1, 'Dec 27 2009 should be week 1');
- assert.equal(moment([2010, 0, 1]).week(), 1, 'Jan 1 2010 should be week 1');
- assert.equal(moment([2010, 0, 2]).week(), 1, 'Jan 2 2010 should be week 1');
- assert.equal(moment([2010, 0, 3]).week(), 2, 'Jan 3 2010 should be week 2');
- assert.equal(moment([2010, 0, 9]).week(), 2, 'Jan 9 2010 should be week 2');
- assert.equal(moment([2010, 0, 10]).week(), 3, 'Jan 10 2010 should be week 3');
- });
-
- test('weeks year starting saturday', function (assert) {
- assert.equal(moment([2010, 11, 26]).week(), 1, 'Dec 26 2010 should be week 1');
- assert.equal(moment([2011, 0, 1]).week(), 1, 'Jan 1 2011 should be week 1');
- assert.equal(moment([2011, 0, 2]).week(), 2, 'Jan 2 2011 should be week 2');
- assert.equal(moment([2011, 0, 8]).week(), 2, 'Jan 8 2011 should be week 2');
- assert.equal(moment([2011, 0, 9]).week(), 3, 'Jan 9 2011 should be week 3');
- });
-
test('weeks year starting sunday format', function (assert) {
assert.equal(moment([2012, 0, 1]).format('w ww wo'), '1 01 1st', 'Jan 1 2012 should be week 1');
assert.equal(moment([2012, 0, 7]).format('w ww wo'), '1 01 1st', 'Jan 7 2012 should be week 1');
@@ -8324,42 +11575,6 @@
assert.equal(moment([2012, 0, 15]).format('w ww wo'), '3 03 3rd', 'Jan 15 2012 should be week 3');
});
- test('lenient ordinal parsing', function (assert) {
- var i, ordinalStr, testMoment;
- for (i = 1; i <= 31; ++i) {
- ordinalStr = moment([2014, 0, i]).format('YYYY MM Do');
- testMoment = moment(ordinalStr, 'YYYY MM Do');
- assert.equal(testMoment.year(), 2014,
- 'lenient ordinal parsing ' + i + ' year check');
- assert.equal(testMoment.month(), 0,
- 'lenient ordinal parsing ' + i + ' month check');
- assert.equal(testMoment.date(), i,
- 'lenient ordinal parsing ' + i + ' date check');
- }
- });
-
- test('lenient ordinal parsing of number', function (assert) {
- var i, testMoment;
- for (i = 1; i <= 31; ++i) {
- testMoment = moment('2014 01 ' + i, 'YYYY MM Do');
- assert.equal(testMoment.year(), 2014,
- 'lenient ordinal parsing of number ' + i + ' year check');
- assert.equal(testMoment.month(), 0,
- 'lenient ordinal parsing of number ' + i + ' month check');
- assert.equal(testMoment.date(), i,
- 'lenient ordinal parsing of number ' + i + ' date check');
- }
- });
-
- test('strict ordinal parsing', function (assert) {
- var i, ordinalStr, testMoment;
- for (i = 1; i <= 31; ++i) {
- ordinalStr = moment([2014, 0, i]).format('YYYY MM Do');
- testMoment = moment(ordinalStr, 'YYYY MM Do', true);
- assert.ok(testMoment.isValid(), 'strict ordinal parsing ' + i);
- }
- });
-
}));
;(function (global, factory) {
@@ -8368,6 +11583,224 @@
typeof define === 'function' && define.amd ? define(['../../moment'], factory) :
factory(global.moment)
}(this, function (moment) { 'use strict';
+
+ function each(array, callback) {
+ var i;
+ for (i = 0; i < array.length; i++) {
+ callback(array[i], i, array);
+ }
+ }
+
+ function objectKeys(obj) {
+ if (Object.keys) {
+ return Object.keys(obj);
+ } else {
+ // IE8
+ var res = [], i;
+ for (i in obj) {
+ if (obj.hasOwnProperty(i)) {
+ res.push(i);
+ }
+ }
+ return res;
+ }
+ }
+
+ // Pick the first defined of two or three arguments.
+ function defaults(a, b, c) {
+ if (a != null) {
+ return a;
+ }
+ if (b != null) {
+ return b;
+ }
+ return c;
+ }
+
+ function defineCommonLocaleTests(locale, options) {
+ test('lenient ordinal parsing', function (assert) {
+ var i, ordinalStr, testMoment;
+ for (i = 1; i <= 31; ++i) {
+ ordinalStr = moment([2014, 0, i]).format('YYYY MM Do');
+ testMoment = moment(ordinalStr, 'YYYY MM Do');
+ assert.equal(testMoment.year(), 2014,
+ 'lenient ordinal parsing ' + i + ' year check');
+ assert.equal(testMoment.month(), 0,
+ 'lenient ordinal parsing ' + i + ' month check');
+ assert.equal(testMoment.date(), i,
+ 'lenient ordinal parsing ' + i + ' date check');
+ }
+ });
+
+ test('lenient ordinal parsing of number', function (assert) {
+ var i, testMoment;
+ for (i = 1; i <= 31; ++i) {
+ testMoment = moment('2014 01 ' + i, 'YYYY MM Do');
+ assert.equal(testMoment.year(), 2014,
+ 'lenient ordinal parsing of number ' + i + ' year check');
+ assert.equal(testMoment.month(), 0,
+ 'lenient ordinal parsing of number ' + i + ' month check');
+ assert.equal(testMoment.date(), i,
+ 'lenient ordinal parsing of number ' + i + ' date check');
+ }
+ });
+
+ test('strict ordinal parsing', function (assert) {
+ var i, ordinalStr, testMoment;
+ for (i = 1; i <= 31; ++i) {
+ ordinalStr = moment([2014, 0, i]).format('YYYY MM Do');
+ testMoment = moment(ordinalStr, 'YYYY MM Do', true);
+ assert.ok(testMoment.isValid(), 'strict ordinal parsing ' + i);
+ }
+ });
+
+ test('meridiem invariant', function (assert) {
+ var h, m, t1, t2;
+ for (h = 0; h < 24; ++h) {
+ for (m = 0; m < 60; m += 15) {
+ t1 = moment.utc([2000, 0, 1, h, m]);
+ t2 = moment.utc(t1.format('A h:mm'), 'A h:mm');
+ assert.equal(t2.format('HH:mm'), t1.format('HH:mm'),
+ 'meridiem at ' + t1.format('HH:mm'));
+ }
+ }
+ });
+
+ test('date format correctness', function (assert) {
+ var data, tokens;
+ data = moment.localeData()._longDateFormat;
+ tokens = objectKeys(data);
+ each(tokens, function (srchToken) {
+ // Check each format string to make sure it does not contain any
+ // tokens that need to be expanded.
+ each(tokens, function (baseToken) {
+ // strip escaped sequences
+ var format = data[baseToken].replace(/(\[[^\]]*\])/g, '');
+ assert.equal(false, !!~format.indexOf(srchToken),
+ 'contains ' + srchToken + ' in ' + baseToken);
+ });
+ });
+ });
+
+ test('month parsing correctness', function (assert) {
+ var i, m;
+
+ if (locale === 'tr') {
+ // I can't fix it :(
+ expect(0);
+ return;
+ }
+ function tester(format) {
+ var r;
+ r = moment(m.format(format), format);
+ assert.equal(r.month(), m.month(), 'month ' + i + ' fmt ' + format);
+ r = moment(m.format(format).toLocaleUpperCase(), format);
+ assert.equal(r.month(), m.month(), 'month ' + i + ' fmt ' + format + ' upper');
+ r = moment(m.format(format).toLocaleLowerCase(), format);
+ assert.equal(r.month(), m.month(), 'month ' + i + ' fmt ' + format + ' lower');
+
+ r = moment(m.format(format), format, true);
+ assert.equal(r.month(), m.month(), 'month ' + i + ' fmt ' + format + ' strict');
+ r = moment(m.format(format).toLocaleUpperCase(), format, true);
+ assert.equal(r.month(), m.month(), 'month ' + i + ' fmt ' + format + ' upper strict');
+ r = moment(m.format(format).toLocaleLowerCase(), format, true);
+ assert.equal(r.month(), m.month(), 'month ' + i + ' fmt ' + format + ' lower strict');
+ }
+
+ for (i = 0; i < 12; ++i) {
+ m = moment([2015, i, 15, 18]);
+ tester('MMM');
+ tester('MMM.');
+ tester('MMMM');
+ tester('MMMM.');
+ }
+ });
+
+ test('weekday parsing correctness', function (assert) {
+ var i, m;
+
+ if (locale === 'tr' || locale === 'az') {
+ // There is a lower-case letter (ı), that converted to upper then
+ // lower changes to i
+ expect(0);
+ return;
+ }
+ function tester(format) {
+ var r, baseMsg = 'weekday ' + m.weekday() + ' fmt ' + format;
+ r = moment(m.format(format), format);
+ assert.equal(r.weekday(), m.weekday(), baseMsg);
+ r = moment(m.format(format).toLocaleUpperCase(), format);
+ assert.equal(r.weekday(), m.weekday(), baseMsg + ' upper');
+ r = moment(m.format(format).toLocaleLowerCase(), format);
+ assert.equal(r.weekday(), m.weekday(), baseMsg + ' lower');
+
+ r = moment(m.format(format), format, true);
+ assert.equal(r.weekday(), m.weekday(), baseMsg + ' strict');
+ r = moment(m.format(format).toLocaleUpperCase(), format, true);
+ assert.equal(r.weekday(), m.weekday(), baseMsg + ' upper strict');
+ r = moment(m.format(format).toLocaleLowerCase(), format, true);
+ assert.equal(r.weekday(), m.weekday(), baseMsg + ' lower strict');
+ }
+
+ for (i = 0; i < 7; ++i) {
+ m = moment.utc([2015, i, 15, 18]);
+ tester('dd');
+ tester('ddd');
+ tester('dddd');
+ }
+ });
+ }
+
+ function setupDeprecationHandler(test, moment, scope) {
+ test._expectedDeprecations = null;
+ test._observedDeprecations = null;
+ test._oldSupress = moment.suppressDeprecationWarnings;
+ moment.suppressDeprecationWarnings = true;
+ test.expectedDeprecations = function () {
+ test._expectedDeprecations = arguments;
+ test._observedDeprecations = [];
+ };
+ moment.deprecationHandler = function (name, msg) {
+ var deprecationId = matchedDeprecation(name, msg, test._expectedDeprecations);
+ if (deprecationId === -1) {
+ throw new Error('Unexpected deprecation thrown name=' +
+ name + ' msg=' + msg);
+ }
+ test._observedDeprecations[deprecationId] = 1;
+ };
+ }
+
+ function teardownDeprecationHandler(test, moment, scope) {
+ moment.suppressDeprecationWarnings = test._oldSupress;
+
+ if (test._expectedDeprecations != null) {
+ var missedDeprecations = [];
+ each(test._expectedDeprecations, function (deprecationPattern, id) {
+ if (test._observedDeprecations[id] !== 1) {
+ missedDeprecations.push(deprecationPattern);
+ }
+ });
+ if (missedDeprecations.length !== 0) {
+ throw new Error('Expected deprecation warnings did not happen: ' +
+ missedDeprecations.join(' '));
+ }
+ }
+ }
+
+ function matchedDeprecation(name, msg, deprecations) {
+ if (deprecations == null) {
+ return -1;
+ }
+ for (var i = 0; i < deprecations.length; ++i) {
+ if (name != null && name === deprecations[i]) {
+ return i;
+ }
+ if (msg != null && msg.substring(0, deprecations[i].length) === deprecations[i]) {
+ return i;
+ }
+ }
+ return -1;
+ }
/*global QUnit:false*/
@@ -8382,11 +11815,13 @@
moment.createFromInputFallback = function (config) {
throw new Error('input not handled by moment: ' + config._i);
};
+ setupDeprecationHandler(test, moment, 'core');
if (lifecycle && lifecycle.setup) {
lifecycle.setup();
}
},
teardown : function () {
+ teardownDeprecationHandler(test, moment, 'core');
if (lifecycle && lifecycle.teardown) {
lifecycle.teardown();
}
@@ -8401,23 +11836,26 @@
moment.createFromInputFallback = function (config) {
throw new Error('input not handled by moment: ' + config._i);
};
+ setupDeprecationHandler(test, moment, 'locale');
if (lifecycle && lifecycle.setup) {
lifecycle.setup();
}
},
teardown : function () {
moment.locale('en');
+ teardownDeprecationHandler(test, moment, 'locale');
if (lifecycle && lifecycle.teardown) {
lifecycle.teardown();
}
}
});
+ defineCommonLocaleTests(name, -1, -1);
}
localeModule('en-gb');
test('parse', function (assert) {
- var tests = 'January Jan_February Feb_March Mar_April Apr_May May_June Jun_July Jul_August Aug_September Sept_October Oct_November Nov_December Dec'.split('_'), i;
+ var tests = '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('_'), i;
function equalTest(input, mmm, i) {
assert.equal(moment(input, mmm).month(), i, input + ' should be month ' + (i + 1));
}
@@ -8505,7 +11943,7 @@
});
test('format month', function (assert) {
- var expected = 'January Jan_February Feb_March Mar_April Apr_May May_June Jun_July Jul_August Aug_September Sept_October Oct_November Nov_December Dec'.split('_'), i;
+ 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('_'), i;
for (i = 0; i < expected.length; i++) {
assert.equal(moment([2011, i, 1]).format('MMMM MMM'), expected[i], expected[i]);
}
@@ -8565,14 +12003,14 @@
});
test('calendar day', function (assert) {
- var a = moment().hours(2).minutes(0).seconds(0);
-
- assert.equal(moment(a).calendar(), 'Today at 02:00', 'today at the same time');
- assert.equal(moment(a).add({m: 25}).calendar(), 'Today at 02:25', 'Now plus 25 min');
- assert.equal(moment(a).add({h: 1}).calendar(), 'Today at 03:00', 'Now plus 1 hour');
- assert.equal(moment(a).add({d: 1}).calendar(), 'Tomorrow at 02:00', 'tomorrow at the same time');
- assert.equal(moment(a).subtract({h: 1}).calendar(), 'Today at 01:00', 'Now minus 1 hour');
- assert.equal(moment(a).subtract({d: 1}).calendar(), 'Yesterday at 02:00', 'yesterday at the same time');
+ var a = moment().hours(12).minutes(0).seconds(0);
+
+ assert.equal(moment(a).calendar(), 'Today at 12:00', 'today at the same time');
+ assert.equal(moment(a).add({m: 25}).calendar(), 'Today at 12:25', 'Now plus 25 min');
+ assert.equal(moment(a).add({h: 1}).calendar(), 'Today at 13:00', 'Now plus 1 hour');
+ assert.equal(moment(a).add({d: 1}).calendar(), 'Tomorrow at 12:00', 'tomorrow at the same time');
+ assert.equal(moment(a).subtract({h: 1}).calendar(), 'Today at 11:00', 'Now minus 1 hour');
+ assert.equal(moment(a).subtract({d: 1}).calendar(), 'Yesterday at 12:00', 'yesterday at the same time');
});
test('calendar next week', function (assert) {
@@ -8614,67 +12052,6 @@
assert.equal(weeksFromNow.calendar(), weeksFromNow.format('L'), 'in 2 weeks');
});
- test('weeks year starting sunday', function (assert) {
- assert.equal(moment([2012, 0, 1]).week(), 52, 'Jan 1 2012 should be week 52');
- assert.equal(moment([2012, 0, 2]).week(), 1, 'Jan 2 2012 should be week 1');
- assert.equal(moment([2012, 0, 8]).week(), 1, 'Jan 8 2012 should be week 1');
- assert.equal(moment([2012, 0, 9]).week(), 2, 'Jan 9 2012 should be week 2');
- assert.equal(moment([2012, 0, 15]).week(), 2, 'Jan 15 2012 should be week 2');
- });
-
- test('weeks year starting monday', function (assert) {
- assert.equal(moment([2007, 0, 1]).week(), 1, 'Jan 1 2007 should be week 1');
- assert.equal(moment([2007, 0, 7]).week(), 1, 'Jan 7 2007 should be week 1');
- assert.equal(moment([2007, 0, 8]).week(), 2, 'Jan 8 2007 should be week 2');
- assert.equal(moment([2007, 0, 14]).week(), 2, 'Jan 14 2007 should be week 2');
- assert.equal(moment([2007, 0, 15]).week(), 3, 'Jan 15 2007 should be week 3');
- });
-
- test('weeks year starting tuesday', function (assert) {
- assert.equal(moment([2007, 11, 31]).week(), 1, 'Dec 31 2007 should be week 1');
- assert.equal(moment([2008, 0, 1]).week(), 1, 'Jan 1 2008 should be week 1');
- assert.equal(moment([2008, 0, 6]).week(), 1, 'Jan 6 2008 should be week 1');
- assert.equal(moment([2008, 0, 7]).week(), 2, 'Jan 7 2008 should be week 2');
- assert.equal(moment([2008, 0, 13]).week(), 2, 'Jan 13 2008 should be week 2');
- assert.equal(moment([2008, 0, 14]).week(), 3, 'Jan 14 2008 should be week 3');
- });
-
- test('weeks year starting wednesday', function (assert) {
- assert.equal(moment([2002, 11, 30]).week(), 1, 'Dec 30 2002 should be week 1');
- assert.equal(moment([2003, 0, 1]).week(), 1, 'Jan 1 2003 should be week 1');
- assert.equal(moment([2003, 0, 5]).week(), 1, 'Jan 5 2003 should be week 1');
- assert.equal(moment([2003, 0, 6]).week(), 2, 'Jan 6 2003 should be week 2');
- assert.equal(moment([2003, 0, 12]).week(), 2, 'Jan 12 2003 should be week 2');
- assert.equal(moment([2003, 0, 13]).week(), 3, 'Jan 13 2003 should be week 3');
- });
-
- test('weeks year starting thursday', function (assert) {
- assert.equal(moment([2008, 11, 29]).week(), 1, 'Dec 29 2008 should be week 1');
- assert.equal(moment([2009, 0, 1]).week(), 1, 'Jan 1 2009 should be week 1');
- assert.equal(moment([2009, 0, 4]).week(), 1, 'Jan 4 2009 should be week 1');
- assert.equal(moment([2009, 0, 5]).week(), 2, 'Jan 5 2009 should be week 2');
- assert.equal(moment([2009, 0, 11]).week(), 2, 'Jan 11 2009 should be week 2');
- assert.equal(moment([2009, 0, 13]).week(), 3, 'Jan 12 2009 should be week 3');
- });
-
- test('weeks year starting friday', function (assert) {
- assert.equal(moment([2009, 11, 28]).week(), 53, 'Dec 28 2009 should be week 53');
- assert.equal(moment([2010, 0, 1]).week(), 53, 'Jan 1 2010 should be week 53');
- assert.equal(moment([2010, 0, 3]).week(), 53, 'Jan 3 2010 should be week 53');
- assert.equal(moment([2010, 0, 4]).week(), 1, 'Jan 4 2010 should be week 1');
- assert.equal(moment([2010, 0, 10]).week(), 1, 'Jan 10 2010 should be week 1');
- assert.equal(moment([2010, 0, 11]).week(), 2, 'Jan 11 2010 should be week 2');
- });
-
- test('weeks year starting saturday', function (assert) {
- assert.equal(moment([2010, 11, 27]).week(), 52, 'Dec 27 2010 should be week 52');
- assert.equal(moment([2011, 0, 1]).week(), 52, 'Jan 1 2011 should be week 52');
- assert.equal(moment([2011, 0, 2]).week(), 52, 'Jan 2 2011 should be week 52');
- assert.equal(moment([2011, 0, 3]).week(), 1, 'Jan 3 2011 should be week 1');
- assert.equal(moment([2011, 0, 9]).week(), 1, 'Jan 9 2011 should be week 1');
- assert.equal(moment([2011, 0, 10]).week(), 2, 'Jan 10 2011 should be week 2');
- });
-
test('weeks year starting sunday formatted', function (assert) {
assert.equal(moment([2012, 0, 1]).format('w ww wo'), '52 52 52nd', 'Jan 1 2012 should be week 52');
assert.equal(moment([2012, 0, 2]).format('w ww wo'), '1 01 1st', 'Jan 2 2012 should be week 1');
@@ -8683,42 +12060,6 @@
assert.equal(moment([2012, 0, 15]).format('w ww wo'), '2 02 2nd', 'Jan 15 2012 should be week 2');
});
- test('lenient ordinal parsing', function (assert) {
- var i, ordinalStr, testMoment;
- for (i = 1; i <= 31; ++i) {
- ordinalStr = moment([2014, 0, i]).format('YYYY MM Do');
- testMoment = moment(ordinalStr, 'YYYY MM Do');
- assert.equal(testMoment.year(), 2014,
- 'lenient ordinal parsing ' + i + ' year check');
- assert.equal(testMoment.month(), 0,
- 'lenient ordinal parsing ' + i + ' month check');
- assert.equal(testMoment.date(), i,
- 'lenient ordinal parsing ' + i + ' date check');
- }
- });
-
- test('lenient ordinal parsing of number', function (assert) {
- var i, testMoment;
- for (i = 1; i <= 31; ++i) {
- testMoment = moment('2014 01 ' + i, 'YYYY MM Do');
- assert.equal(testMoment.year(), 2014,
- 'lenient ordinal parsing of number ' + i + ' year check');
- assert.equal(testMoment.month(), 0,
- 'lenient ordinal parsing of number ' + i + ' month check');
- assert.equal(testMoment.date(), i,
- 'lenient ordinal parsing of number ' + i + ' date check');
- }
- });
-
- test('strict ordinal parsing', function (assert) {
- var i, ordinalStr, testMoment;
- for (i = 1; i <= 31; ++i) {
- ordinalStr = moment([2014, 0, i]).format('YYYY MM Do');
- testMoment = moment(ordinalStr, 'YYYY MM Do', true);
- assert.ok(testMoment.isValid(), 'strict ordinal parsing ' + i);
- }
- });
-
}));
;(function (global, factory) {
@@ -8727,6 +12068,224 @@
typeof define === 'function' && define.amd ? define(['../../moment'], factory) :
factory(global.moment)
}(this, function (moment) { 'use strict';
+
+ function each(array, callback) {
+ var i;
+ for (i = 0; i < array.length; i++) {
+ callback(array[i], i, array);
+ }
+ }
+
+ function objectKeys(obj) {
+ if (Object.keys) {
+ return Object.keys(obj);
+ } else {
+ // IE8
+ var res = [], i;
+ for (i in obj) {
+ if (obj.hasOwnProperty(i)) {
+ res.push(i);
+ }
+ }
+ return res;
+ }
+ }
+
+ // Pick the first defined of two or three arguments.
+ function defaults(a, b, c) {
+ if (a != null) {
+ return a;
+ }
+ if (b != null) {
+ return b;
+ }
+ return c;
+ }
+
+ function defineCommonLocaleTests(locale, options) {
+ test('lenient ordinal parsing', function (assert) {
+ var i, ordinalStr, testMoment;
+ for (i = 1; i <= 31; ++i) {
+ ordinalStr = moment([2014, 0, i]).format('YYYY MM Do');
+ testMoment = moment(ordinalStr, 'YYYY MM Do');
+ assert.equal(testMoment.year(), 2014,
+ 'lenient ordinal parsing ' + i + ' year check');
+ assert.equal(testMoment.month(), 0,
+ 'lenient ordinal parsing ' + i + ' month check');
+ assert.equal(testMoment.date(), i,
+ 'lenient ordinal parsing ' + i + ' date check');
+ }
+ });
+
+ test('lenient ordinal parsing of number', function (assert) {
+ var i, testMoment;
+ for (i = 1; i <= 31; ++i) {
+ testMoment = moment('2014 01 ' + i, 'YYYY MM Do');
+ assert.equal(testMoment.year(), 2014,
+ 'lenient ordinal parsing of number ' + i + ' year check');
+ assert.equal(testMoment.month(), 0,
+ 'lenient ordinal parsing of number ' + i + ' month check');
+ assert.equal(testMoment.date(), i,
+ 'lenient ordinal parsing of number ' + i + ' date check');
+ }
+ });
+
+ test('strict ordinal parsing', function (assert) {
+ var i, ordinalStr, testMoment;
+ for (i = 1; i <= 31; ++i) {
+ ordinalStr = moment([2014, 0, i]).format('YYYY MM Do');
+ testMoment = moment(ordinalStr, 'YYYY MM Do', true);
+ assert.ok(testMoment.isValid(), 'strict ordinal parsing ' + i);
+ }
+ });
+
+ test('meridiem invariant', function (assert) {
+ var h, m, t1, t2;
+ for (h = 0; h < 24; ++h) {
+ for (m = 0; m < 60; m += 15) {
+ t1 = moment.utc([2000, 0, 1, h, m]);
+ t2 = moment.utc(t1.format('A h:mm'), 'A h:mm');
+ assert.equal(t2.format('HH:mm'), t1.format('HH:mm'),
+ 'meridiem at ' + t1.format('HH:mm'));
+ }
+ }
+ });
+
+ test('date format correctness', function (assert) {
+ var data, tokens;
+ data = moment.localeData()._longDateFormat;
+ tokens = objectKeys(data);
+ each(tokens, function (srchToken) {
+ // Check each format string to make sure it does not contain any
+ // tokens that need to be expanded.
+ each(tokens, function (baseToken) {
+ // strip escaped sequences
+ var format = data[baseToken].replace(/(\[[^\]]*\])/g, '');
+ assert.equal(false, !!~format.indexOf(srchToken),
+ 'contains ' + srchToken + ' in ' + baseToken);
+ });
+ });
+ });
+
+ test('month parsing correctness', function (assert) {
+ var i, m;
+
+ if (locale === 'tr') {
+ // I can't fix it :(
+ expect(0);
+ return;
+ }
+ function tester(format) {
+ var r;
+ r = moment(m.format(format), format);
+ assert.equal(r.month(), m.month(), 'month ' + i + ' fmt ' + format);
+ r = moment(m.format(format).toLocaleUpperCase(), format);
+ assert.equal(r.month(), m.month(), 'month ' + i + ' fmt ' + format + ' upper');
+ r = moment(m.format(format).toLocaleLowerCase(), format);
+ assert.equal(r.month(), m.month(), 'month ' + i + ' fmt ' + format + ' lower');
+
+ r = moment(m.format(format), format, true);
+ assert.equal(r.month(), m.month(), 'month ' + i + ' fmt ' + format + ' strict');
+ r = moment(m.format(format).toLocaleUpperCase(), format, true);
+ assert.equal(r.month(), m.month(), 'month ' + i + ' fmt ' + format + ' upper strict');
+ r = moment(m.format(format).toLocaleLowerCase(), format, true);
+ assert.equal(r.month(), m.month(), 'month ' + i + ' fmt ' + format + ' lower strict');
+ }
+
+ for (i = 0; i < 12; ++i) {
+ m = moment([2015, i, 15, 18]);
+ tester('MMM');
+ tester('MMM.');
+ tester('MMMM');
+ tester('MMMM.');
+ }
+ });
+
+ test('weekday parsing correctness', function (assert) {
+ var i, m;
+
+ if (locale === 'tr' || locale === 'az') {
+ // There is a lower-case letter (ı), that converted to upper then
+ // lower changes to i
+ expect(0);
+ return;
+ }
+ function tester(format) {
+ var r, baseMsg = 'weekday ' + m.weekday() + ' fmt ' + format;
+ r = moment(m.format(format), format);
+ assert.equal(r.weekday(), m.weekday(), baseMsg);
+ r = moment(m.format(format).toLocaleUpperCase(), format);
+ assert.equal(r.weekday(), m.weekday(), baseMsg + ' upper');
+ r = moment(m.format(format).toLocaleLowerCase(), format);
+ assert.equal(r.weekday(), m.weekday(), baseMsg + ' lower');
+
+ r = moment(m.format(format), format, true);
+ assert.equal(r.weekday(), m.weekday(), baseMsg + ' strict');
+ r = moment(m.format(format).toLocaleUpperCase(), format, true);
+ assert.equal(r.weekday(), m.weekday(), baseMsg + ' upper strict');
+ r = moment(m.format(format).toLocaleLowerCase(), format, true);
+ assert.equal(r.weekday(), m.weekday(), baseMsg + ' lower strict');
+ }
+
+ for (i = 0; i < 7; ++i) {
+ m = moment.utc([2015, i, 15, 18]);
+ tester('dd');
+ tester('ddd');
+ tester('dddd');
+ }
+ });
+ }
+
+ function setupDeprecationHandler(test, moment, scope) {
+ test._expectedDeprecations = null;
+ test._observedDeprecations = null;
+ test._oldSupress = moment.suppressDeprecationWarnings;
+ moment.suppressDeprecationWarnings = true;
+ test.expectedDeprecations = function () {
+ test._expectedDeprecations = arguments;
+ test._observedDeprecations = [];
+ };
+ moment.deprecationHandler = function (name, msg) {
+ var deprecationId = matchedDeprecation(name, msg, test._expectedDeprecations);
+ if (deprecationId === -1) {
+ throw new Error('Unexpected deprecation thrown name=' +
+ name + ' msg=' + msg);
+ }
+ test._observedDeprecations[deprecationId] = 1;
+ };
+ }
+
+ function teardownDeprecationHandler(test, moment, scope) {
+ moment.suppressDeprecationWarnings = test._oldSupress;
+
+ if (test._expectedDeprecations != null) {
+ var missedDeprecations = [];
+ each(test._expectedDeprecations, function (deprecationPattern, id) {
+ if (test._observedDeprecations[id] !== 1) {
+ missedDeprecations.push(deprecationPattern);
+ }
+ });
+ if (missedDeprecations.length !== 0) {
+ throw new Error('Expected deprecation warnings did not happen: ' +
+ missedDeprecations.join(' '));
+ }
+ }
+ }
+
+ function matchedDeprecation(name, msg, deprecations) {
+ if (deprecations == null) {
+ return -1;
+ }
+ for (var i = 0; i < deprecations.length; ++i) {
+ if (name != null && name === deprecations[i]) {
+ return i;
+ }
+ if (msg != null && msg.substring(0, deprecations[i].length) === deprecations[i]) {
+ return i;
+ }
+ }
+ return -1;
+ }
/*global QUnit:false*/
@@ -8741,11 +12300,13 @@
moment.createFromInputFallback = function (config) {
throw new Error('input not handled by moment: ' + config._i);
};
+ setupDeprecationHandler(test, moment, 'core');
if (lifecycle && lifecycle.setup) {
lifecycle.setup();
}
},
teardown : function () {
+ teardownDeprecationHandler(test, moment, 'core');
if (lifecycle && lifecycle.teardown) {
lifecycle.teardown();
}
@@ -8760,17 +12321,20 @@
moment.createFromInputFallback = function (config) {
throw new Error('input not handled by moment: ' + config._i);
};
+ setupDeprecationHandler(test, moment, 'locale');
if (lifecycle && lifecycle.setup) {
lifecycle.setup();
}
},
teardown : function () {
moment.locale('en');
+ teardownDeprecationHandler(test, moment, 'locale');
if (lifecycle && lifecycle.teardown) {
lifecycle.teardown();
}
}
});
+ defineCommonLocaleTests(name, -1, -1);
}
localeModule('en-ie');
@@ -8924,14 +12488,14 @@
});
test('calendar day', function (assert) {
- var a = moment().hours(2).minutes(0).seconds(0);
-
- assert.equal(moment(a).calendar(), 'Today at 02:00', 'today at the same time');
- assert.equal(moment(a).add({m: 25}).calendar(), 'Today at 02:25', 'Now plus 25 min');
- assert.equal(moment(a).add({h: 1}).calendar(), 'Today at 03:00', 'Now plus 1 hour');
- assert.equal(moment(a).add({d: 1}).calendar(), 'Tomorrow at 02:00', 'tomorrow at the same time');
- assert.equal(moment(a).subtract({h: 1}).calendar(), 'Today at 01:00', 'Now minus 1 hour');
- assert.equal(moment(a).subtract({d: 1}).calendar(), 'Yesterday at 02:00', 'yesterday at the same time');
+ var a = moment().hours(12).minutes(0).seconds(0);
+
+ assert.equal(moment(a).calendar(), 'Today at 12:00', 'today at the same time');
+ assert.equal(moment(a).add({m: 25}).calendar(), 'Today at 12:25', 'Now plus 25 min');
+ assert.equal(moment(a).add({h: 1}).calendar(), 'Today at 13:00', 'Now plus 1 hour');
+ assert.equal(moment(a).add({d: 1}).calendar(), 'Tomorrow at 12:00', 'tomorrow at the same time');
+ assert.equal(moment(a).subtract({h: 1}).calendar(), 'Today at 11:00', 'Now minus 1 hour');
+ assert.equal(moment(a).subtract({d: 1}).calendar(), 'Yesterday at 12:00', 'yesterday at the same time');
});
test('calendar next week', function (assert) {
@@ -8973,67 +12537,6 @@
assert.equal(weeksFromNow.calendar(), weeksFromNow.format('L'), 'in 2 weeks');
});
- test('weeks year starting sunday', function (assert) {
- assert.equal(moment([2012, 0, 1]).week(), 52, 'Jan 1 2012 should be week 52');
- assert.equal(moment([2012, 0, 2]).week(), 1, 'Jan 2 2012 should be week 1');
- assert.equal(moment([2012, 0, 8]).week(), 1, 'Jan 8 2012 should be week 1');
- assert.equal(moment([2012, 0, 9]).week(), 2, 'Jan 9 2012 should be week 2');
- assert.equal(moment([2012, 0, 15]).week(), 2, 'Jan 15 2012 should be week 2');
- });
-
- test('weeks year starting monday', function (assert) {
- assert.equal(moment([2007, 0, 1]).week(), 1, 'Jan 1 2007 should be week 1');
- assert.equal(moment([2007, 0, 7]).week(), 1, 'Jan 7 2007 should be week 1');
- assert.equal(moment([2007, 0, 8]).week(), 2, 'Jan 8 2007 should be week 2');
- assert.equal(moment([2007, 0, 14]).week(), 2, 'Jan 14 2007 should be week 2');
- assert.equal(moment([2007, 0, 15]).week(), 3, 'Jan 15 2007 should be week 3');
- });
-
- test('weeks year starting tuesday', function (assert) {
- assert.equal(moment([2007, 11, 31]).week(), 1, 'Dec 31 2007 should be week 1');
- assert.equal(moment([2008, 0, 1]).week(), 1, 'Jan 1 2008 should be week 1');
- assert.equal(moment([2008, 0, 6]).week(), 1, 'Jan 6 2008 should be week 1');
- assert.equal(moment([2008, 0, 7]).week(), 2, 'Jan 7 2008 should be week 2');
- assert.equal(moment([2008, 0, 13]).week(), 2, 'Jan 13 2008 should be week 2');
- assert.equal(moment([2008, 0, 14]).week(), 3, 'Jan 14 2008 should be week 3');
- });
-
- test('weeks year starting wednesday', function (assert) {
- assert.equal(moment([2002, 11, 30]).week(), 1, 'Dec 30 2002 should be week 1');
- assert.equal(moment([2003, 0, 1]).week(), 1, 'Jan 1 2003 should be week 1');
- assert.equal(moment([2003, 0, 5]).week(), 1, 'Jan 5 2003 should be week 1');
- assert.equal(moment([2003, 0, 6]).week(), 2, 'Jan 6 2003 should be week 2');
- assert.equal(moment([2003, 0, 12]).week(), 2, 'Jan 12 2003 should be week 2');
- assert.equal(moment([2003, 0, 13]).week(), 3, 'Jan 13 2003 should be week 3');
- });
-
- test('weeks year starting thursday', function (assert) {
- assert.equal(moment([2008, 11, 29]).week(), 1, 'Dec 29 2008 should be week 1');
- assert.equal(moment([2009, 0, 1]).week(), 1, 'Jan 1 2009 should be week 1');
- assert.equal(moment([2009, 0, 4]).week(), 1, 'Jan 4 2009 should be week 1');
- assert.equal(moment([2009, 0, 5]).week(), 2, 'Jan 5 2009 should be week 2');
- assert.equal(moment([2009, 0, 11]).week(), 2, 'Jan 11 2009 should be week 2');
- assert.equal(moment([2009, 0, 13]).week(), 3, 'Jan 12 2009 should be week 3');
- });
-
- test('weeks year starting friday', function (assert) {
- assert.equal(moment([2009, 11, 28]).week(), 53, 'Dec 28 2009 should be week 53');
- assert.equal(moment([2010, 0, 1]).week(), 53, 'Jan 1 2010 should be week 53');
- assert.equal(moment([2010, 0, 3]).week(), 53, 'Jan 3 2010 should be week 53');
- assert.equal(moment([2010, 0, 4]).week(), 1, 'Jan 4 2010 should be week 1');
- assert.equal(moment([2010, 0, 10]).week(), 1, 'Jan 10 2010 should be week 1');
- assert.equal(moment([2010, 0, 11]).week(), 2, 'Jan 11 2010 should be week 2');
- });
-
- test('weeks year starting saturday', function (assert) {
- assert.equal(moment([2010, 11, 27]).week(), 52, 'Dec 27 2010 should be week 52');
- assert.equal(moment([2011, 0, 1]).week(), 52, 'Jan 1 2011 should be week 52');
- assert.equal(moment([2011, 0, 2]).week(), 52, 'Jan 2 2011 should be week 52');
- assert.equal(moment([2011, 0, 3]).week(), 1, 'Jan 3 2011 should be week 1');
- assert.equal(moment([2011, 0, 9]).week(), 1, 'Jan 9 2011 should be week 1');
- assert.equal(moment([2011, 0, 10]).week(), 2, 'Jan 10 2011 should be week 2');
- });
-
test('weeks year starting sunday formatted', function (assert) {
assert.equal(moment([2012, 0, 1]).format('w ww wo'), '52 52 52nd', 'Jan 1 2012 should be week 52');
assert.equal(moment([2012, 0, 2]).format('w ww wo'), '1 01 1st', 'Jan 2 2012 should be week 1');
@@ -9042,42 +12545,6 @@
assert.equal(moment([2012, 0, 15]).format('w ww wo'), '2 02 2nd', 'Jan 15 2012 should be week 2');
});
- test('lenient ordinal parsing', function (assert) {
- var i, ordinalStr, testMoment;
- for (i = 1; i <= 31; ++i) {
- ordinalStr = moment([2014, 0, i]).format('YYYY MM Do');
- testMoment = moment(ordinalStr, 'YYYY MM Do');
- assert.equal(testMoment.year(), 2014,
- 'lenient ordinal parsing ' + i + ' year check');
- assert.equal(testMoment.month(), 0,
- 'lenient ordinal parsing ' + i + ' month check');
- assert.equal(testMoment.date(), i,
- 'lenient ordinal parsing ' + i + ' date check');
- }
- });
-
- test('lenient ordinal parsing of number', function (assert) {
- var i, testMoment;
- for (i = 1; i <= 31; ++i) {
- testMoment = moment('2014 01 ' + i, 'YYYY MM Do');
- assert.equal(testMoment.year(), 2014,
- 'lenient ordinal parsing of number ' + i + ' year check');
- assert.equal(testMoment.month(), 0,
- 'lenient ordinal parsing of number ' + i + ' month check');
- assert.equal(testMoment.date(), i,
- 'lenient ordinal parsing of number ' + i + ' date check');
- }
- });
-
- test('strict ordinal parsing', function (assert) {
- var i, ordinalStr, testMoment;
- for (i = 1; i <= 31; ++i) {
- ordinalStr = moment([2014, 0, i]).format('YYYY MM Do');
- testMoment = moment(ordinalStr, 'YYYY MM Do', true);
- assert.ok(testMoment.isValid(), 'strict ordinal parsing ' + i);
- }
- });
-
}));
;(function (global, factory) {
@@ -9086,6 +12553,224 @@
typeof define === 'function' && define.amd ? define(['../../moment'], factory) :
factory(global.moment)
}(this, function (moment) { 'use strict';
+
+ function each(array, callback) {
+ var i;
+ for (i = 0; i < array.length; i++) {
+ callback(array[i], i, array);
+ }
+ }
+
+ function objectKeys(obj) {
+ if (Object.keys) {
+ return Object.keys(obj);
+ } else {
+ // IE8
+ var res = [], i;
+ for (i in obj) {
+ if (obj.hasOwnProperty(i)) {
+ res.push(i);
+ }
+ }
+ return res;
+ }
+ }
+
+ // Pick the first defined of two or three arguments.
+ function defaults(a, b, c) {
+ if (a != null) {
+ return a;
+ }
+ if (b != null) {
+ return b;
+ }
+ return c;
+ }
+
+ function defineCommonLocaleTests(locale, options) {
+ test('lenient ordinal parsing', function (assert) {
+ var i, ordinalStr, testMoment;
+ for (i = 1; i <= 31; ++i) {
+ ordinalStr = moment([2014, 0, i]).format('YYYY MM Do');
+ testMoment = moment(ordinalStr, 'YYYY MM Do');
+ assert.equal(testMoment.year(), 2014,
+ 'lenient ordinal parsing ' + i + ' year check');
+ assert.equal(testMoment.month(), 0,
+ 'lenient ordinal parsing ' + i + ' month check');
+ assert.equal(testMoment.date(), i,
+ 'lenient ordinal parsing ' + i + ' date check');
+ }
+ });
+
+ test('lenient ordinal parsing of number', function (assert) {
+ var i, testMoment;
+ for (i = 1; i <= 31; ++i) {
+ testMoment = moment('2014 01 ' + i, 'YYYY MM Do');
+ assert.equal(testMoment.year(), 2014,
+ 'lenient ordinal parsing of number ' + i + ' year check');
+ assert.equal(testMoment.month(), 0,
+ 'lenient ordinal parsing of number ' + i + ' month check');
+ assert.equal(testMoment.date(), i,
+ 'lenient ordinal parsing of number ' + i + ' date check');
+ }
+ });
+
+ test('strict ordinal parsing', function (assert) {
+ var i, ordinalStr, testMoment;
+ for (i = 1; i <= 31; ++i) {
+ ordinalStr = moment([2014, 0, i]).format('YYYY MM Do');
+ testMoment = moment(ordinalStr, 'YYYY MM Do', true);
+ assert.ok(testMoment.isValid(), 'strict ordinal parsing ' + i);
+ }
+ });
+
+ test('meridiem invariant', function (assert) {
+ var h, m, t1, t2;
+ for (h = 0; h < 24; ++h) {
+ for (m = 0; m < 60; m += 15) {
+ t1 = moment.utc([2000, 0, 1, h, m]);
+ t2 = moment.utc(t1.format('A h:mm'), 'A h:mm');
+ assert.equal(t2.format('HH:mm'), t1.format('HH:mm'),
+ 'meridiem at ' + t1.format('HH:mm'));
+ }
+ }
+ });
+
+ test('date format correctness', function (assert) {
+ var data, tokens;
+ data = moment.localeData()._longDateFormat;
+ tokens = objectKeys(data);
+ each(tokens, function (srchToken) {
+ // Check each format string to make sure it does not contain any
+ // tokens that need to be expanded.
+ each(tokens, function (baseToken) {
+ // strip escaped sequences
+ var format = data[baseToken].replace(/(\[[^\]]*\])/g, '');
+ assert.equal(false, !!~format.indexOf(srchToken),
+ 'contains ' + srchToken + ' in ' + baseToken);
+ });
+ });
+ });
+
+ test('month parsing correctness', function (assert) {
+ var i, m;
+
+ if (locale === 'tr') {
+ // I can't fix it :(
+ expect(0);
+ return;
+ }
+ function tester(format) {
+ var r;
+ r = moment(m.format(format), format);
+ assert.equal(r.month(), m.month(), 'month ' + i + ' fmt ' + format);
+ r = moment(m.format(format).toLocaleUpperCase(), format);
+ assert.equal(r.month(), m.month(), 'month ' + i + ' fmt ' + format + ' upper');
+ r = moment(m.format(format).toLocaleLowerCase(), format);
+ assert.equal(r.month(), m.month(), 'month ' + i + ' fmt ' + format + ' lower');
+
+ r = moment(m.format(format), format, true);
+ assert.equal(r.month(), m.month(), 'month ' + i + ' fmt ' + format + ' strict');
+ r = moment(m.format(format).toLocaleUpperCase(), format, true);
+ assert.equal(r.month(), m.month(), 'month ' + i + ' fmt ' + format + ' upper strict');
+ r = moment(m.format(format).toLocaleLowerCase(), format, true);
+ assert.equal(r.month(), m.month(), 'month ' + i + ' fmt ' + format + ' lower strict');
+ }
+
+ for (i = 0; i < 12; ++i) {
+ m = moment([2015, i, 15, 18]);
+ tester('MMM');
+ tester('MMM.');
+ tester('MMMM');
+ tester('MMMM.');
+ }
+ });
+
+ test('weekday parsing correctness', function (assert) {
+ var i, m;
+
+ if (locale === 'tr' || locale === 'az') {
+ // There is a lower-case letter (ı), that converted to upper then
+ // lower changes to i
+ expect(0);
+ return;
+ }
+ function tester(format) {
+ var r, baseMsg = 'weekday ' + m.weekday() + ' fmt ' + format;
+ r = moment(m.format(format), format);
+ assert.equal(r.weekday(), m.weekday(), baseMsg);
+ r = moment(m.format(format).toLocaleUpperCase(), format);
+ assert.equal(r.weekday(), m.weekday(), baseMsg + ' upper');
+ r = moment(m.format(format).toLocaleLowerCase(), format);
+ assert.equal(r.weekday(), m.weekday(), baseMsg + ' lower');
+
+ r = moment(m.format(format), format, true);
+ assert.equal(r.weekday(), m.weekday(), baseMsg + ' strict');
+ r = moment(m.format(format).toLocaleUpperCase(), format, true);
+ assert.equal(r.weekday(), m.weekday(), baseMsg + ' upper strict');
+ r = moment(m.format(format).toLocaleLowerCase(), format, true);
+ assert.equal(r.weekday(), m.weekday(), baseMsg + ' lower strict');
+ }
+
+ for (i = 0; i < 7; ++i) {
+ m = moment.utc([2015, i, 15, 18]);
+ tester('dd');
+ tester('ddd');
+ tester('dddd');
+ }
+ });
+ }
+
+ function setupDeprecationHandler(test, moment, scope) {
+ test._expectedDeprecations = null;
+ test._observedDeprecations = null;
+ test._oldSupress = moment.suppressDeprecationWarnings;
+ moment.suppressDeprecationWarnings = true;
+ test.expectedDeprecations = function () {
+ test._expectedDeprecations = arguments;
+ test._observedDeprecations = [];
+ };
+ moment.deprecationHandler = function (name, msg) {
+ var deprecationId = matchedDeprecation(name, msg, test._expectedDeprecations);
+ if (deprecationId === -1) {
+ throw new Error('Unexpected deprecation thrown name=' +
+ name + ' msg=' + msg);
+ }
+ test._observedDeprecations[deprecationId] = 1;
+ };
+ }
+
+ function teardownDeprecationHandler(test, moment, scope) {
+ moment.suppressDeprecationWarnings = test._oldSupress;
+
+ if (test._expectedDeprecations != null) {
+ var missedDeprecations = [];
+ each(test._expectedDeprecations, function (deprecationPattern, id) {
+ if (test._observedDeprecations[id] !== 1) {
+ missedDeprecations.push(deprecationPattern);
+ }
+ });
+ if (missedDeprecations.length !== 0) {
+ throw new Error('Expected deprecation warnings did not happen: ' +
+ missedDeprecations.join(' '));
+ }
+ }
+ }
+
+ function matchedDeprecation(name, msg, deprecations) {
+ if (deprecations == null) {
+ return -1;
+ }
+ for (var i = 0; i < deprecations.length; ++i) {
+ if (name != null && name === deprecations[i]) {
+ return i;
+ }
+ if (msg != null && msg.substring(0, deprecations[i].length) === deprecations[i]) {
+ return i;
+ }
+ }
+ return -1;
+ }
/*global QUnit:false*/
@@ -9100,11 +12785,13 @@
moment.createFromInputFallback = function (config) {
throw new Error('input not handled by moment: ' + config._i);
};
+ setupDeprecationHandler(test, moment, 'core');
if (lifecycle && lifecycle.setup) {
lifecycle.setup();
}
},
teardown : function () {
+ teardownDeprecationHandler(test, moment, 'core');
if (lifecycle && lifecycle.teardown) {
lifecycle.teardown();
}
@@ -9119,23 +12806,26 @@
moment.createFromInputFallback = function (config) {
throw new Error('input not handled by moment: ' + config._i);
};
+ setupDeprecationHandler(test, moment, 'locale');
if (lifecycle && lifecycle.setup) {
lifecycle.setup();
}
},
teardown : function () {
moment.locale('en');
+ teardownDeprecationHandler(test, moment, 'locale');
if (lifecycle && lifecycle.teardown) {
lifecycle.teardown();
}
}
});
+ defineCommonLocaleTests(name, -1, -1);
}
localeModule('en-nz');
test('parse', function (assert) {
- var tests = 'January Jan_February Feb_March Mar_April Apr_May May_June Jun_July Jul_August Aug_September Sept_October Oct_November Nov_December Dec'.split('_'), i;
+ var tests = '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('_'), i;
function equalTest(input, mmm, i) {
assert.equal(moment(input, mmm).month(), i, input + ' should be month ' + (i + 1));
}
@@ -9223,7 +12913,7 @@
});
test('format month', function (assert) {
- var expected = 'January Jan_February Feb_March Mar_April Apr_May May_June Jun_July Jul_August Aug_September Sept_October Oct_November Nov_December Dec'.split('_'), i;
+ 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('_'), i;
for (i = 0; i < expected.length; i++) {
assert.equal(moment([2011, i, 1]).format('MMMM MMM'), expected[i], expected[i]);
}
@@ -9283,14 +12973,14 @@
});
test('calendar day', function (assert) {
- var a = moment().hours(2).minutes(0).seconds(0);
-
- assert.equal(moment(a).calendar(), 'Today at 2:00 AM', 'today at the same time');
- assert.equal(moment(a).add({m: 25}).calendar(), 'Today at 2:25 AM', 'Now plus 25 min');
- assert.equal(moment(a).add({h: 1}).calendar(), 'Today at 3:00 AM', 'Now plus 1 hour');
- assert.equal(moment(a).add({d: 1}).calendar(), 'Tomorrow at 2:00 AM', 'tomorrow at the same time');
- assert.equal(moment(a).subtract({h: 1}).calendar(), 'Today at 1:00 AM', 'Now minus 1 hour');
- assert.equal(moment(a).subtract({d: 1}).calendar(), 'Yesterday at 2:00 AM', 'yesterday at the same time');
+ var a = moment().hours(12).minutes(0).seconds(0);
+
+ assert.equal(moment(a).calendar(), 'Today at 12:00 PM', 'today at the same time');
+ assert.equal(moment(a).add({m: 25}).calendar(), 'Today at 12:25 PM', 'Now plus 25 min');
+ assert.equal(moment(a).add({h: 1}).calendar(), 'Today at 1:00 PM', 'Now plus 1 hour');
+ assert.equal(moment(a).add({d: 1}).calendar(), 'Tomorrow at 12:00 PM', 'tomorrow at the same time');
+ assert.equal(moment(a).subtract({h: 1}).calendar(), 'Today at 11:00 AM', 'Now minus 1 hour');
+ assert.equal(moment(a).subtract({d: 1}).calendar(), 'Yesterday at 12:00 PM', 'yesterday at the same time');
});
test('calendar next week', function (assert) {
@@ -9332,67 +13022,6 @@
assert.equal(weeksFromNow.calendar(), weeksFromNow.format('L'), 'in 2 weeks');
});
- test('weeks year starting sunday', function (assert) {
- assert.equal(moment([2012, 0, 1]).week(), 52, 'Jan 1 2012 should be week 52');
- assert.equal(moment([2012, 0, 2]).week(), 1, 'Jan 2 2012 should be week 1');
- assert.equal(moment([2012, 0, 8]).week(), 1, 'Jan 8 2012 should be week 1');
- assert.equal(moment([2012, 0, 9]).week(), 2, 'Jan 9 2012 should be week 2');
- assert.equal(moment([2012, 0, 15]).week(), 2, 'Jan 15 2012 should be week 2');
- });
-
- test('weeks year starting monday', function (assert) {
- assert.equal(moment([2007, 0, 1]).week(), 1, 'Jan 1 2007 should be week 1');
- assert.equal(moment([2007, 0, 7]).week(), 1, 'Jan 7 2007 should be week 1');
- assert.equal(moment([2007, 0, 8]).week(), 2, 'Jan 8 2007 should be week 2');
- assert.equal(moment([2007, 0, 14]).week(), 2, 'Jan 14 2007 should be week 2');
- assert.equal(moment([2007, 0, 15]).week(), 3, 'Jan 15 2007 should be week 3');
- });
-
- test('weeks year starting tuesday', function (assert) {
- assert.equal(moment([2007, 11, 31]).week(), 1, 'Dec 31 2007 should be week 1');
- assert.equal(moment([2008, 0, 1]).week(), 1, 'Jan 1 2008 should be week 1');
- assert.equal(moment([2008, 0, 6]).week(), 1, 'Jan 6 2008 should be week 1');
- assert.equal(moment([2008, 0, 7]).week(), 2, 'Jan 7 2008 should be week 2');
- assert.equal(moment([2008, 0, 13]).week(), 2, 'Jan 13 2008 should be week 2');
- assert.equal(moment([2008, 0, 14]).week(), 3, 'Jan 14 2008 should be week 3');
- });
-
- test('weeks year starting wednesday', function (assert) {
- assert.equal(moment([2002, 11, 30]).week(), 1, 'Dec 30 2002 should be week 1');
- assert.equal(moment([2003, 0, 1]).week(), 1, 'Jan 1 2003 should be week 1');
- assert.equal(moment([2003, 0, 5]).week(), 1, 'Jan 5 2003 should be week 1');
- assert.equal(moment([2003, 0, 6]).week(), 2, 'Jan 6 2003 should be week 2');
- assert.equal(moment([2003, 0, 12]).week(), 2, 'Jan 12 2003 should be week 2');
- assert.equal(moment([2003, 0, 13]).week(), 3, 'Jan 13 2003 should be week 3');
- });
-
- test('weeks year starting thursday', function (assert) {
- assert.equal(moment([2008, 11, 29]).week(), 1, 'Dec 29 2008 should be week 1');
- assert.equal(moment([2009, 0, 1]).week(), 1, 'Jan 1 2009 should be week 1');
- assert.equal(moment([2009, 0, 4]).week(), 1, 'Jan 4 2009 should be week 1');
- assert.equal(moment([2009, 0, 5]).week(), 2, 'Jan 5 2009 should be week 2');
- assert.equal(moment([2009, 0, 11]).week(), 2, 'Jan 11 2009 should be week 2');
- assert.equal(moment([2009, 0, 13]).week(), 3, 'Jan 12 2009 should be week 3');
- });
-
- test('weeks year starting friday', function (assert) {
- assert.equal(moment([2009, 11, 28]).week(), 53, 'Dec 28 2009 should be week 53');
- assert.equal(moment([2010, 0, 1]).week(), 53, 'Jan 1 2010 should be week 53');
- assert.equal(moment([2010, 0, 3]).week(), 53, 'Jan 3 2010 should be week 53');
- assert.equal(moment([2010, 0, 4]).week(), 1, 'Jan 4 2010 should be week 1');
- assert.equal(moment([2010, 0, 10]).week(), 1, 'Jan 10 2010 should be week 1');
- assert.equal(moment([2010, 0, 11]).week(), 2, 'Jan 11 2010 should be week 2');
- });
-
- test('weeks year starting saturday', function (assert) {
- assert.equal(moment([2010, 11, 27]).week(), 52, 'Dec 27 2010 should be week 52');
- assert.equal(moment([2011, 0, 1]).week(), 52, 'Jan 1 2011 should be week 52');
- assert.equal(moment([2011, 0, 2]).week(), 52, 'Jan 2 2011 should be week 52');
- assert.equal(moment([2011, 0, 3]).week(), 1, 'Jan 3 2011 should be week 1');
- assert.equal(moment([2011, 0, 9]).week(), 1, 'Jan 9 2011 should be week 1');
- assert.equal(moment([2011, 0, 10]).week(), 2, 'Jan 10 2011 should be week 2');
- });
-
test('weeks year starting sunday formatted', function (assert) {
assert.equal(moment([2012, 0, 1]).format('w ww wo'), '52 52 52nd', 'Jan 1 2012 should be week 52');
assert.equal(moment([2012, 0, 2]).format('w ww wo'), '1 01 1st', 'Jan 2 2012 should be week 1');
@@ -9401,33 +13030,6 @@
assert.equal(moment([2012, 0, 15]).format('w ww wo'), '2 02 2nd', 'Jan 15 2012 should be week 2');
});
- test('lenient ordinal parsing', function (assert) {
- var i, ordinalStr, testStr;
- for (i = 1; i <= 31; ++i) {
- ordinalStr = moment([2014, 0, i]).format('YYYY MM Do');
- testStr = moment(ordinalStr, 'YYYY MM Do').format('YYYY MM D');
- assert.equal(testStr, '2014 01 ' + i, 'lenient ordinal parsing ' + i);
- }
- });
-
- test('lenient ordinal parsing of number', function (assert) {
- var i, testStr;
- for (i = 1; i <= 31; ++i) {
- testStr = moment('2014 01 ' + i, 'YYYY MM Do').format('YYYY MM D');
- assert.equal(testStr, '2014 01 ' + i,
- 'lenient ordinal parsing of number ' + i);
- }
- });
-
- test('strict ordinal parsing', function (assert) {
- var i, ordinalStr, testMoment;
- for (i = 1; i <= 31; ++i) {
- ordinalStr = moment([2014, 0, i]).format('YYYY MMM Do');
- testMoment = moment(ordinalStr, 'YYYY MMM Do', true);
- assert.ok(testMoment.isValid(), 'strict ordinal parsing ' + i);
- }
- });
-
}));
;(function (global, factory) {
@@ -9436,6 +13038,224 @@
typeof define === 'function' && define.amd ? define(['../../moment'], factory) :
factory(global.moment)
}(this, function (moment) { 'use strict';
+
+ function each(array, callback) {
+ var i;
+ for (i = 0; i < array.length; i++) {
+ callback(array[i], i, array);
+ }
+ }
+
+ function objectKeys(obj) {
+ if (Object.keys) {
+ return Object.keys(obj);
+ } else {
+ // IE8
+ var res = [], i;
+ for (i in obj) {
+ if (obj.hasOwnProperty(i)) {
+ res.push(i);
+ }
+ }
+ return res;
+ }
+ }
+
+ // Pick the first defined of two or three arguments.
+ function defaults(a, b, c) {
+ if (a != null) {
+ return a;
+ }
+ if (b != null) {
+ return b;
+ }
+ return c;
+ }
+
+ function defineCommonLocaleTests(locale, options) {
+ test('lenient ordinal parsing', function (assert) {
+ var i, ordinalStr, testMoment;
+ for (i = 1; i <= 31; ++i) {
+ ordinalStr = moment([2014, 0, i]).format('YYYY MM Do');
+ testMoment = moment(ordinalStr, 'YYYY MM Do');
+ assert.equal(testMoment.year(), 2014,
+ 'lenient ordinal parsing ' + i + ' year check');
+ assert.equal(testMoment.month(), 0,
+ 'lenient ordinal parsing ' + i + ' month check');
+ assert.equal(testMoment.date(), i,
+ 'lenient ordinal parsing ' + i + ' date check');
+ }
+ });
+
+ test('lenient ordinal parsing of number', function (assert) {
+ var i, testMoment;
+ for (i = 1; i <= 31; ++i) {
+ testMoment = moment('2014 01 ' + i, 'YYYY MM Do');
+ assert.equal(testMoment.year(), 2014,
+ 'lenient ordinal parsing of number ' + i + ' year check');
+ assert.equal(testMoment.month(), 0,
+ 'lenient ordinal parsing of number ' + i + ' month check');
+ assert.equal(testMoment.date(), i,
+ 'lenient ordinal parsing of number ' + i + ' date check');
+ }
+ });
+
+ test('strict ordinal parsing', function (assert) {
+ var i, ordinalStr, testMoment;
+ for (i = 1; i <= 31; ++i) {
+ ordinalStr = moment([2014, 0, i]).format('YYYY MM Do');
+ testMoment = moment(ordinalStr, 'YYYY MM Do', true);
+ assert.ok(testMoment.isValid(), 'strict ordinal parsing ' + i);
+ }
+ });
+
+ test('meridiem invariant', function (assert) {
+ var h, m, t1, t2;
+ for (h = 0; h < 24; ++h) {
+ for (m = 0; m < 60; m += 15) {
+ t1 = moment.utc([2000, 0, 1, h, m]);
+ t2 = moment.utc(t1.format('A h:mm'), 'A h:mm');
+ assert.equal(t2.format('HH:mm'), t1.format('HH:mm'),
+ 'meridiem at ' + t1.format('HH:mm'));
+ }
+ }
+ });
+
+ test('date format correctness', function (assert) {
+ var data, tokens;
+ data = moment.localeData()._longDateFormat;
+ tokens = objectKeys(data);
+ each(tokens, function (srchToken) {
+ // Check each format string to make sure it does not contain any
+ // tokens that need to be expanded.
+ each(tokens, function (baseToken) {
+ // strip escaped sequences
+ var format = data[baseToken].replace(/(\[[^\]]*\])/g, '');
+ assert.equal(false, !!~format.indexOf(srchToken),
+ 'contains ' + srchToken + ' in ' + baseToken);
+ });
+ });
+ });
+
+ test('month parsing correctness', function (assert) {
+ var i, m;
+
+ if (locale === 'tr') {
+ // I can't fix it :(
+ expect(0);
+ return;
+ }
+ function tester(format) {
+ var r;
+ r = moment(m.format(format), format);
+ assert.equal(r.month(), m.month(), 'month ' + i + ' fmt ' + format);
+ r = moment(m.format(format).toLocaleUpperCase(), format);
+ assert.equal(r.month(), m.month(), 'month ' + i + ' fmt ' + format + ' upper');
+ r = moment(m.format(format).toLocaleLowerCase(), format);
+ assert.equal(r.month(), m.month(), 'month ' + i + ' fmt ' + format + ' lower');
+
+ r = moment(m.format(format), format, true);
+ assert.equal(r.month(), m.month(), 'month ' + i + ' fmt ' + format + ' strict');
+ r = moment(m.format(format).toLocaleUpperCase(), format, true);
+ assert.equal(r.month(), m.month(), 'month ' + i + ' fmt ' + format + ' upper strict');
+ r = moment(m.format(format).toLocaleLowerCase(), format, true);
+ assert.equal(r.month(), m.month(), 'month ' + i + ' fmt ' + format + ' lower strict');
+ }
+
+ for (i = 0; i < 12; ++i) {
+ m = moment([2015, i, 15, 18]);
+ tester('MMM');
+ tester('MMM.');
+ tester('MMMM');
+ tester('MMMM.');
+ }
+ });
+
+ test('weekday parsing correctness', function (assert) {
+ var i, m;
+
+ if (locale === 'tr' || locale === 'az') {
+ // There is a lower-case letter (ı), that converted to upper then
+ // lower changes to i
+ expect(0);
+ return;
+ }
+ function tester(format) {
+ var r, baseMsg = 'weekday ' + m.weekday() + ' fmt ' + format;
+ r = moment(m.format(format), format);
+ assert.equal(r.weekday(), m.weekday(), baseMsg);
+ r = moment(m.format(format).toLocaleUpperCase(), format);
+ assert.equal(r.weekday(), m.weekday(), baseMsg + ' upper');
+ r = moment(m.format(format).toLocaleLowerCase(), format);
+ assert.equal(r.weekday(), m.weekday(), baseMsg + ' lower');
+
+ r = moment(m.format(format), format, true);
+ assert.equal(r.weekday(), m.weekday(), baseMsg + ' strict');
+ r = moment(m.format(format).toLocaleUpperCase(), format, true);
+ assert.equal(r.weekday(), m.weekday(), baseMsg + ' upper strict');
+ r = moment(m.format(format).toLocaleLowerCase(), format, true);
+ assert.equal(r.weekday(), m.weekday(), baseMsg + ' lower strict');
+ }
+
+ for (i = 0; i < 7; ++i) {
+ m = moment.utc([2015, i, 15, 18]);
+ tester('dd');
+ tester('ddd');
+ tester('dddd');
+ }
+ });
+ }
+
+ function setupDeprecationHandler(test, moment, scope) {
+ test._expectedDeprecations = null;
+ test._observedDeprecations = null;
+ test._oldSupress = moment.suppressDeprecationWarnings;
+ moment.suppressDeprecationWarnings = true;
+ test.expectedDeprecations = function () {
+ test._expectedDeprecations = arguments;
+ test._observedDeprecations = [];
+ };
+ moment.deprecationHandler = function (name, msg) {
+ var deprecationId = matchedDeprecation(name, msg, test._expectedDeprecations);
+ if (deprecationId === -1) {
+ throw new Error('Unexpected deprecation thrown name=' +
+ name + ' msg=' + msg);
+ }
+ test._observedDeprecations[deprecationId] = 1;
+ };
+ }
+
+ function teardownDeprecationHandler(test, moment, scope) {
+ moment.suppressDeprecationWarnings = test._oldSupress;
+
+ if (test._expectedDeprecations != null) {
+ var missedDeprecations = [];
+ each(test._expectedDeprecations, function (deprecationPattern, id) {
+ if (test._observedDeprecations[id] !== 1) {
+ missedDeprecations.push(deprecationPattern);
+ }
+ });
+ if (missedDeprecations.length !== 0) {
+ throw new Error('Expected deprecation warnings did not happen: ' +
+ missedDeprecations.join(' '));
+ }
+ }
+ }
+
+ function matchedDeprecation(name, msg, deprecations) {
+ if (deprecations == null) {
+ return -1;
+ }
+ for (var i = 0; i < deprecations.length; ++i) {
+ if (name != null && name === deprecations[i]) {
+ return i;
+ }
+ if (msg != null && msg.substring(0, deprecations[i].length) === deprecations[i]) {
+ return i;
+ }
+ }
+ return -1;
+ }
/*global QUnit:false*/
@@ -9450,11 +13270,13 @@
moment.createFromInputFallback = function (config) {
throw new Error('input not handled by moment: ' + config._i);
};
+ setupDeprecationHandler(test, moment, 'core');
if (lifecycle && lifecycle.setup) {
lifecycle.setup();
}
},
teardown : function () {
+ teardownDeprecationHandler(test, moment, 'core');
if (lifecycle && lifecycle.teardown) {
lifecycle.teardown();
}
@@ -9469,24 +13291,27 @@
moment.createFromInputFallback = function (config) {
throw new Error('input not handled by moment: ' + config._i);
};
+ setupDeprecationHandler(test, moment, 'locale');
if (lifecycle && lifecycle.setup) {
lifecycle.setup();
}
},
teardown : function () {
moment.locale('en');
+ teardownDeprecationHandler(test, moment, 'locale');
if (lifecycle && lifecycle.teardown) {
lifecycle.teardown();
}
}
});
+ defineCommonLocaleTests(name, -1, -1);
}
localeModule('en');
test('parse', function (assert) {
var i,
- tests = 'January Jan_February Feb_March Mar_April Apr_May May_June Jun_July Jul_August Aug_September Sept_October Oct_November Nov_December Dec'.split('_');
+ tests = '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('_');
function equalTest(input, mmm, i) {
assert.equal(moment(input, mmm).month(), i, input + ' should be month ' + (i + 1));
@@ -9578,7 +13403,7 @@
test('format month', function (assert) {
var i,
- expected = 'January Jan_February Feb_March Mar_April Apr_May May_June Jun_July Jul_August Aug_September Sept_October Oct_November Nov_December Dec'.split('_');
+ 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('_');
for (i = 0; i < expected.length; i++) {
assert.equal(moment([2011, i, 1]).format('MMMM MMM'), expected[i], expected[i]);
@@ -9642,14 +13467,14 @@
});
test('calendar day', function (assert) {
- var a = moment().hours(2).minutes(0).seconds(0);
-
- assert.equal(moment(a).calendar(), 'Today at 2:00 AM', 'today at the same time');
- assert.equal(moment(a).add({m: 25}).calendar(), 'Today at 2:25 AM', 'Now plus 25 min');
- assert.equal(moment(a).add({h: 1}).calendar(), 'Today at 3:00 AM', 'Now plus 1 hour');
- assert.equal(moment(a).add({d: 1}).calendar(), 'Tomorrow at 2:00 AM', 'tomorrow at the same time');
- assert.equal(moment(a).subtract({h: 1}).calendar(), 'Today at 1:00 AM', 'Now minus 1 hour');
- assert.equal(moment(a).subtract({d: 1}).calendar(), 'Yesterday at 2:00 AM', 'yesterday at the same time');
+ var a = moment().hours(12).minutes(0).seconds(0);
+
+ assert.equal(moment(a).calendar(), 'Today at 12:00 PM', 'today at the same time');
+ assert.equal(moment(a).add({m: 25}).calendar(), 'Today at 12:25 PM', 'Now plus 25 min');
+ assert.equal(moment(a).add({h: 1}).calendar(), 'Today at 1:00 PM', 'Now plus 1 hour');
+ assert.equal(moment(a).add({d: 1}).calendar(), 'Tomorrow at 12:00 PM', 'tomorrow at the same time');
+ assert.equal(moment(a).subtract({h: 1}).calendar(), 'Today at 11:00 AM', 'Now minus 1 hour');
+ assert.equal(moment(a).subtract({d: 1}).calendar(), 'Yesterday at 12:00 PM', 'yesterday at the same time');
});
test('calendar next week', function (assert) {
@@ -9692,67 +13517,6 @@
assert.equal(weeksFromNow.calendar(), weeksFromNow.format('L'), 'in 2 weeks');
});
- test('weeks year starting sunday', function (assert) {
- assert.equal(moment([2012, 0, 1]).week(), 1, 'Jan 1 2012 should be week 1');
- assert.equal(moment([2012, 0, 7]).week(), 1, 'Jan 7 2012 should be week 1');
- assert.equal(moment([2012, 0, 8]).week(), 2, 'Jan 8 2012 should be week 2');
- assert.equal(moment([2012, 0, 14]).week(), 2, 'Jan 14 2012 should be week 2');
- assert.equal(moment([2012, 0, 15]).week(), 3, 'Jan 15 2012 should be week 3');
- });
-
- test('weeks year starting monday', function (assert) {
- assert.equal(moment([2006, 11, 31]).week(), 1, 'Dec 31 2006 should be week 1');
- assert.equal(moment([2007, 0, 1]).week(), 1, 'Jan 1 2007 should be week 1');
- assert.equal(moment([2007, 0, 6]).week(), 1, 'Jan 6 2007 should be week 1');
- assert.equal(moment([2007, 0, 7]).week(), 2, 'Jan 7 2007 should be week 2');
- assert.equal(moment([2007, 0, 13]).week(), 2, 'Jan 13 2007 should be week 2');
- assert.equal(moment([2007, 0, 14]).week(), 3, 'Jan 14 2007 should be week 3');
- });
-
- test('weeks year starting tuesday', function (assert) {
- assert.equal(moment([2007, 11, 29]).week(), 52, 'Dec 29 2007 should be week 52');
- assert.equal(moment([2008, 0, 1]).week(), 1, 'Jan 1 2008 should be week 1');
- assert.equal(moment([2008, 0, 5]).week(), 1, 'Jan 5 2008 should be week 1');
- assert.equal(moment([2008, 0, 6]).week(), 2, 'Jan 6 2008 should be week 2');
- assert.equal(moment([2008, 0, 12]).week(), 2, 'Jan 12 2008 should be week 2');
- assert.equal(moment([2008, 0, 13]).week(), 3, 'Jan 13 2008 should be week 3');
- });
-
- test('weeks year starting wednesday', function (assert) {
- assert.equal(moment([2002, 11, 29]).week(), 1, 'Dec 29 2002 should be week 1');
- assert.equal(moment([2003, 0, 1]).week(), 1, 'Jan 1 2003 should be week 1');
- assert.equal(moment([2003, 0, 4]).week(), 1, 'Jan 4 2003 should be week 1');
- assert.equal(moment([2003, 0, 5]).week(), 2, 'Jan 5 2003 should be week 2');
- assert.equal(moment([2003, 0, 11]).week(), 2, 'Jan 11 2003 should be week 2');
- assert.equal(moment([2003, 0, 12]).week(), 3, 'Jan 12 2003 should be week 3');
- });
-
- test('weeks year starting thursday', function (assert) {
- assert.equal(moment([2008, 11, 28]).week(), 1, 'Dec 28 2008 should be week 1');
- assert.equal(moment([2009, 0, 1]).week(), 1, 'Jan 1 2009 should be week 1');
- assert.equal(moment([2009, 0, 3]).week(), 1, 'Jan 3 2009 should be week 1');
- assert.equal(moment([2009, 0, 4]).week(), 2, 'Jan 4 2009 should be week 2');
- assert.equal(moment([2009, 0, 10]).week(), 2, 'Jan 10 2009 should be week 2');
- assert.equal(moment([2009, 0, 11]).week(), 3, 'Jan 11 2009 should be week 3');
- });
-
- test('weeks year starting friday', function (assert) {
- assert.equal(moment([2009, 11, 27]).week(), 1, 'Dec 27 2009 should be week 1');
- assert.equal(moment([2010, 0, 1]).week(), 1, 'Jan 1 2010 should be week 1');
- assert.equal(moment([2010, 0, 2]).week(), 1, 'Jan 2 2010 should be week 1');
- assert.equal(moment([2010, 0, 3]).week(), 2, 'Jan 3 2010 should be week 2');
- assert.equal(moment([2010, 0, 9]).week(), 2, 'Jan 9 2010 should be week 2');
- assert.equal(moment([2010, 0, 10]).week(), 3, 'Jan 10 2010 should be week 3');
- });
-
- test('weeks year starting saturday', function (assert) {
- assert.equal(moment([2010, 11, 26]).week(), 1, 'Dec 26 2010 should be week 1');
- assert.equal(moment([2011, 0, 1]).week(), 1, 'Jan 1 2011 should be week 1');
- assert.equal(moment([2011, 0, 2]).week(), 2, 'Jan 2 2011 should be week 2');
- assert.equal(moment([2011, 0, 8]).week(), 2, 'Jan 8 2011 should be week 2');
- assert.equal(moment([2011, 0, 9]).week(), 3, 'Jan 9 2011 should be week 3');
- });
-
test('weeks year starting sunday format', function (assert) {
assert.equal(moment([2012, 0, 1]).format('w ww wo'), '1 01 1st', 'Jan 1 2012 should be week 1');
assert.equal(moment([2012, 0, 7]).format('w ww wo'), '1 01 1st', 'Jan 7 2012 should be week 1');
@@ -9761,20 +13525,6 @@
assert.equal(moment([2012, 0, 15]).format('w ww wo'), '3 03 3rd', 'Jan 15 2012 should be week 3');
});
- test('lenient ordinal parsing', function (assert) {
- var i, ordinalStr, testMoment;
- for (i = 1; i <= 31; ++i) {
- ordinalStr = moment([2014, 0, i]).format('YYYY MM Do');
- testMoment = moment(ordinalStr, 'YYYY MM Do');
- assert.equal(testMoment.year(), 2014,
- 'lenient ordinal parsing ' + i + ' year check');
- assert.equal(testMoment.month(), 0,
- 'lenient ordinal parsing ' + i + ' month check');
- assert.equal(testMoment.date(), i,
- 'lenient ordinal parsing ' + i + ' date check');
- }
- });
-
test('weekdays strict parsing', function (assert) {
var m = moment('2015-01-01T12', moment.ISO_8601, true),
enLocale = moment.localeData('en');
@@ -9787,28 +13537,6 @@
// negative tests
assert.equal(moment(enLocale.weekdaysMin(m.day(i), ''), 'ddd', true).isValid(), false, 'parse short weekday ' + i);
assert.equal(moment(enLocale.weekdaysShort(m.day(i), ''), 'dd', true).isValid(), false, 'parse min weekday ' + i);
- }
- });
-
- test('lenient ordinal parsing of number', function (assert) {
- var i, testMoment;
- for (i = 1; i <= 31; ++i) {
- testMoment = moment('2014 01 ' + i, 'YYYY MM Do');
- assert.equal(testMoment.year(), 2014,
- 'lenient ordinal parsing of number ' + i + ' year check');
- assert.equal(testMoment.month(), 0,
- 'lenient ordinal parsing of number ' + i + ' month check');
- assert.equal(testMoment.date(), i,
- 'lenient ordinal parsing of number ' + i + ' date check');
- }
- });
-
- test('strict ordinal parsing', function (assert) {
- var i, ordinalStr, testMoment;
- for (i = 1; i <= 31; ++i) {
- ordinalStr = moment([2014, 0, i]).format('YYYY MM Do');
- testMoment = moment(ordinalStr, 'YYYY MM Do', true);
- assert.ok(testMoment.isValid(), 'strict ordinal parsing ' + i);
}
});
@@ -9820,6 +13548,224 @@
typeof define === 'function' && define.amd ? define(['../../moment'], factory) :
factory(global.moment)
}(this, function (moment) { 'use strict';
+
+ function each(array, callback) {
+ var i;
+ for (i = 0; i < array.length; i++) {
+ callback(array[i], i, array);
+ }
+ }
+
+ function objectKeys(obj) {
+ if (Object.keys) {
+ return Object.keys(obj);
+ } else {
+ // IE8
+ var res = [], i;
+ for (i in obj) {
+ if (obj.hasOwnProperty(i)) {
+ res.push(i);
+ }
+ }
+ return res;
+ }
+ }
+
+ // Pick the first defined of two or three arguments.
+ function defaults(a, b, c) {
+ if (a != null) {
+ return a;
+ }
+ if (b != null) {
+ return b;
+ }
+ return c;
+ }
+
+ function defineCommonLocaleTests(locale, options) {
+ test('lenient ordinal parsing', function (assert) {
+ var i, ordinalStr, testMoment;
+ for (i = 1; i <= 31; ++i) {
+ ordinalStr = moment([2014, 0, i]).format('YYYY MM Do');
+ testMoment = moment(ordinalStr, 'YYYY MM Do');
+ assert.equal(testMoment.year(), 2014,
+ 'lenient ordinal parsing ' + i + ' year check');
+ assert.equal(testMoment.month(), 0,
+ 'lenient ordinal parsing ' + i + ' month check');
+ assert.equal(testMoment.date(), i,
+ 'lenient ordinal parsing ' + i + ' date check');
+ }
+ });
+
+ test('lenient ordinal parsing of number', function (assert) {
+ var i, testMoment;
+ for (i = 1; i <= 31; ++i) {
+ testMoment = moment('2014 01 ' + i, 'YYYY MM Do');
+ assert.equal(testMoment.year(), 2014,
+ 'lenient ordinal parsing of number ' + i + ' year check');
+ assert.equal(testMoment.month(), 0,
+ 'lenient ordinal parsing of number ' + i + ' month check');
+ assert.equal(testMoment.date(), i,
+ 'lenient ordinal parsing of number ' + i + ' date check');
+ }
+ });
+
+ test('strict ordinal parsing', function (assert) {
+ var i, ordinalStr, testMoment;
+ for (i = 1; i <= 31; ++i) {
+ ordinalStr = moment([2014, 0, i]).format('YYYY MM Do');
+ testMoment = moment(ordinalStr, 'YYYY MM Do', true);
+ assert.ok(testMoment.isValid(), 'strict ordinal parsing ' + i);
+ }
+ });
+
+ test('meridiem invariant', function (assert) {
+ var h, m, t1, t2;
+ for (h = 0; h < 24; ++h) {
+ for (m = 0; m < 60; m += 15) {
+ t1 = moment.utc([2000, 0, 1, h, m]);
+ t2 = moment.utc(t1.format('A h:mm'), 'A h:mm');
+ assert.equal(t2.format('HH:mm'), t1.format('HH:mm'),
+ 'meridiem at ' + t1.format('HH:mm'));
+ }
+ }
+ });
+
+ test('date format correctness', function (assert) {
+ var data, tokens;
+ data = moment.localeData()._longDateFormat;
+ tokens = objectKeys(data);
+ each(tokens, function (srchToken) {
+ // Check each format string to make sure it does not contain any
+ // tokens that need to be expanded.
+ each(tokens, function (baseToken) {
+ // strip escaped sequences
+ var format = data[baseToken].replace(/(\[[^\]]*\])/g, '');
+ assert.equal(false, !!~format.indexOf(srchToken),
+ 'contains ' + srchToken + ' in ' + baseToken);
+ });
+ });
+ });
+
+ test('month parsing correctness', function (assert) {
+ var i, m;
+
+ if (locale === 'tr') {
+ // I can't fix it :(
+ expect(0);
+ return;
+ }
+ function tester(format) {
+ var r;
+ r = moment(m.format(format), format);
+ assert.equal(r.month(), m.month(), 'month ' + i + ' fmt ' + format);
+ r = moment(m.format(format).toLocaleUpperCase(), format);
+ assert.equal(r.month(), m.month(), 'month ' + i + ' fmt ' + format + ' upper');
+ r = moment(m.format(format).toLocaleLowerCase(), format);
+ assert.equal(r.month(), m.month(), 'month ' + i + ' fmt ' + format + ' lower');
+
+ r = moment(m.format(format), format, true);
+ assert.equal(r.month(), m.month(), 'month ' + i + ' fmt ' + format + ' strict');
+ r = moment(m.format(format).toLocaleUpperCase(), format, true);
+ assert.equal(r.month(), m.month(), 'month ' + i + ' fmt ' + format + ' upper strict');
+ r = moment(m.format(format).toLocaleLowerCase(), format, true);
+ assert.equal(r.month(), m.month(), 'month ' + i + ' fmt ' + format + ' lower strict');
+ }
+
+ for (i = 0; i < 12; ++i) {
+ m = moment([2015, i, 15, 18]);
+ tester('MMM');
+ tester('MMM.');
+ tester('MMMM');
+ tester('MMMM.');
+ }
+ });
+
+ test('weekday parsing correctness', function (assert) {
+ var i, m;
+
+ if (locale === 'tr' || locale === 'az') {
+ // There is a lower-case letter (ı), that converted to upper then
+ // lower changes to i
+ expect(0);
+ return;
+ }
+ function tester(format) {
+ var r, baseMsg = 'weekday ' + m.weekday() + ' fmt ' + format;
+ r = moment(m.format(format), format);
+ assert.equal(r.weekday(), m.weekday(), baseMsg);
+ r = moment(m.format(format).toLocaleUpperCase(), format);
+ assert.equal(r.weekday(), m.weekday(), baseMsg + ' upper');
+ r = moment(m.format(format).toLocaleLowerCase(), format);
+ assert.equal(r.weekday(), m.weekday(), baseMsg + ' lower');
+
+ r = moment(m.format(format), format, true);
+ assert.equal(r.weekday(), m.weekday(), baseMsg + ' strict');
+ r = moment(m.format(format).toLocaleUpperCase(), format, true);
+ assert.equal(r.weekday(), m.weekday(), baseMsg + ' upper strict');
+ r = moment(m.format(format).toLocaleLowerCase(), format, true);
+ assert.equal(r.weekday(), m.weekday(), baseMsg + ' lower strict');
+ }
+
+ for (i = 0; i < 7; ++i) {
+ m = moment.utc([2015, i, 15, 18]);
+ tester('dd');
+ tester('ddd');
+ tester('dddd');
+ }
+ });
+ }
+
+ function setupDeprecationHandler(test, moment, scope) {
+ test._expectedDeprecations = null;
+ test._observedDeprecations = null;
+ test._oldSupress = moment.suppressDeprecationWarnings;
+ moment.suppressDeprecationWarnings = true;
+ test.expectedDeprecations = function () {
+ test._expectedDeprecations = arguments;
+ test._observedDeprecations = [];
+ };
+ moment.deprecationHandler = function (name, msg) {
+ var deprecationId = matchedDeprecation(name, msg, test._expectedDeprecations);
+ if (deprecationId === -1) {
+ throw new Error('Unexpected deprecation thrown name=' +
+ name + ' msg=' + msg);
+ }
+ test._observedDeprecations[deprecationId] = 1;
+ };
+ }
+
+ function teardownDeprecationHandler(test, moment, scope) {
+ moment.suppressDeprecationWarnings = test._oldSupress;
+
+ if (test._expectedDeprecations != null) {
+ var missedDeprecations = [];
+ each(test._expectedDeprecations, function (deprecationPattern, id) {
+ if (test._observedDeprecations[id] !== 1) {
+ missedDeprecations.push(deprecationPattern);
+ }
+ });
+ if (missedDeprecations.length !== 0) {
+ throw new Error('Expected deprecation warnings did not happen: ' +
+ missedDeprecations.join(' '));
+ }
+ }
+ }
+
+ function matchedDeprecation(name, msg, deprecations) {
+ if (deprecations == null) {
+ return -1;
+ }
+ for (var i = 0; i < deprecations.length; ++i) {
+ if (name != null && name === deprecations[i]) {
+ return i;
+ }
+ if (msg != null && msg.substring(0, deprecations[i].length) === deprecations[i]) {
+ return i;
+ }
+ }
+ return -1;
+ }
/*global QUnit:false*/
@@ -9834,11 +13780,13 @@
moment.createFromInputFallback = function (config) {
throw new Error('input not handled by moment: ' + config._i);
};
+ setupDeprecationHandler(test, moment, 'core');
if (lifecycle && lifecycle.setup) {
lifecycle.setup();
}
},
teardown : function () {
+ teardownDeprecationHandler(test, moment, 'core');
if (lifecycle && lifecycle.teardown) {
lifecycle.teardown();
}
@@ -9853,17 +13801,20 @@
moment.createFromInputFallback = function (config) {
throw new Error('input not handled by moment: ' + config._i);
};
+ setupDeprecationHandler(test, moment, 'locale');
if (lifecycle && lifecycle.setup) {
lifecycle.setup();
}
},
teardown : function () {
moment.locale('en');
+ teardownDeprecationHandler(test, moment, 'locale');
if (lifecycle && lifecycle.teardown) {
lifecycle.teardown();
}
}
});
+ defineCommonLocaleTests(name, -1, -1);
}
localeModule('eo');
@@ -10017,14 +13968,14 @@
});
test('calendar day', function (assert) {
- var a = moment().hours(2).minutes(0).seconds(0);
-
- assert.equal(moment(a).calendar(), 'Hodiaŭ je 02:00', 'today at the same time');
- assert.equal(moment(a).add({m: 25}).calendar(), 'Hodiaŭ je 02:25', 'Now plus 25 min');
- assert.equal(moment(a).add({h: 1}).calendar(), 'Hodiaŭ je 03:00', 'Now plus 1 hour');
- assert.equal(moment(a).add({d: 1}).calendar(), 'Morgaŭ je 02:00', 'tomorrow at the same time');
- assert.equal(moment(a).subtract({h: 1}).calendar(), 'Hodiaŭ je 01:00', 'Now minus 1 hour');
- assert.equal(moment(a).subtract({d: 1}).calendar(), 'Hieraŭ je 02:00', 'yesterday at the same time');
+ var a = moment().hours(12).minutes(0).seconds(0);
+
+ assert.equal(moment(a).calendar(), 'Hodiaŭ je 12:00', 'today at the same time');
+ assert.equal(moment(a).add({m: 25}).calendar(), 'Hodiaŭ je 12:25', 'Now plus 25 min');
+ assert.equal(moment(a).add({h: 1}).calendar(), 'Hodiaŭ je 13:00', 'Now plus 1 hour');
+ assert.equal(moment(a).add({d: 1}).calendar(), 'Morgaŭ je 12:00', 'tomorrow at the same time');
+ assert.equal(moment(a).subtract({h: 1}).calendar(), 'Hodiaŭ je 11:00', 'Now minus 1 hour');
+ assert.equal(moment(a).subtract({d: 1}).calendar(), 'Hieraŭ je 12:00', 'yesterday at the same time');
});
test('calendar next week', function (assert) {
@@ -10067,67 +14018,6 @@
assert.equal(weeksFromNow.calendar(), weeksFromNow.format('L'), 'in 2 weeks');
});
- test('weeks year starting sunday', function (assert) {
- assert.equal(moment([2011, 11, 26]).week(), 1, 'Dec 26 2011 should be week 1');
- assert.equal(moment([2012, 0, 1]).week(), 1, 'Jan 1 2012 should be week 1');
- assert.equal(moment([2012, 0, 2]).week(), 2, 'Jan 2 2012 should be week 2');
- assert.equal(moment([2012, 0, 8]).week(), 2, 'Jan 8 2012 should be week 2');
- assert.equal(moment([2012, 0, 9]).week(), 3, 'Jan 9 2012 should be week 3');
- });
-
- test('weeks year starting monday', function (assert) {
- assert.equal(moment([2007, 0, 1]).week(), 1, 'Jan 1 2007 should be week 1');
- assert.equal(moment([2007, 0, 7]).week(), 1, 'Jan 7 2007 should be week 1');
- assert.equal(moment([2007, 0, 8]).week(), 2, 'Jan 8 2007 should be week 2');
- assert.equal(moment([2007, 0, 14]).week(), 2, 'Jan 14 2007 should be week 2');
- assert.equal(moment([2007, 0, 15]).week(), 3, 'Jan 15 2007 should be week 3');
- });
-
- test('weeks year starting tuesday', function (assert) {
- assert.equal(moment([2007, 11, 31]).week(), 1, 'Dec 31 2007 should be week 1');
- assert.equal(moment([2008, 0, 1]).week(), 1, 'Jan 1 2008 should be week 1');
- assert.equal(moment([2008, 0, 6]).week(), 1, 'Jan 6 2008 should be week 1');
- assert.equal(moment([2008, 0, 7]).week(), 2, 'Jan 7 2008 should be week 2');
- assert.equal(moment([2008, 0, 13]).week(), 2, 'Jan 13 2008 should be week 2');
- assert.equal(moment([2008, 0, 14]).week(), 3, 'Jan 14 2008 should be week 3');
- });
-
- test('weeks year starting wednesday', function (assert) {
- assert.equal(moment([2002, 11, 30]).week(), 1, 'Dec 30 2002 should be week 1');
- assert.equal(moment([2003, 0, 1]).week(), 1, 'Jan 1 2003 should be week 1');
- assert.equal(moment([2003, 0, 5]).week(), 1, 'Jan 5 2003 should be week 1');
- assert.equal(moment([2003, 0, 6]).week(), 2, 'Jan 6 2003 should be week 2');
- assert.equal(moment([2003, 0, 12]).week(), 2, 'Jan 12 2003 should be week 2');
- assert.equal(moment([2003, 0, 13]).week(), 3, 'Jan 13 2003 should be week 3');
- });
-
- test('weeks year starting thursday', function (assert) {
- assert.equal(moment([2008, 11, 29]).week(), 1, 'Dec 29 2008 should be week 1');
- assert.equal(moment([2009, 0, 1]).week(), 1, 'Jan 1 2009 should be week 1');
- assert.equal(moment([2009, 0, 4]).week(), 1, 'Jan 4 2009 should be week 1');
- assert.equal(moment([2009, 0, 5]).week(), 2, 'Jan 5 2009 should be week 2');
- assert.equal(moment([2009, 0, 11]).week(), 2, 'Jan 11 2009 should be week 2');
- assert.equal(moment([2009, 0, 12]).week(), 3, 'Jan 12 2009 should be week 3');
- });
-
- test('weeks year starting friday', function (assert) {
- assert.equal(moment([2009, 11, 28]).week(), 1, 'Dec 28 2009 should be week 1');
- assert.equal(moment([2010, 0, 1]).week(), 1, 'Jan 1 2010 should be week 1');
- assert.equal(moment([2010, 0, 3]).week(), 1, 'Jan 3 2010 should be week 1');
- assert.equal(moment([2010, 0, 4]).week(), 2, 'Jan 4 2010 should be week 2');
- assert.equal(moment([2010, 0, 10]).week(), 2, 'Jan 10 2010 should be week 2');
- assert.equal(moment([2010, 0, 11]).week(), 3, 'Jan 11 2010 should be week 3');
- });
-
- test('weeks year starting saturday', function (assert) {
- assert.equal(moment([2010, 11, 27]).week(), 1, 'Dec 27 2010 should be week 1');
- assert.equal(moment([2011, 0, 1]).week(), 1, 'Jan 1 2011 should be week 1');
- assert.equal(moment([2011, 0, 2]).week(), 1, 'Jan 2 2011 should be week 1');
- assert.equal(moment([2011, 0, 3]).week(), 2, 'Jan 3 2011 should be week 2');
- assert.equal(moment([2011, 0, 9]).week(), 2, 'Jan 9 2011 should be week 2');
- assert.equal(moment([2011, 0, 10]).week(), 3, 'Jan 10 2011 should be week 3');
- });
-
test('weeks year starting sunday formatted', function (assert) {
assert.equal(moment([2011, 11, 26]).format('w ww wo'), '1 01 1a', 'Dec 26 2011 should be week 1');
assert.equal(moment([2012, 0, 1]).format('w ww wo'), '1 01 1a', 'Jan 1 2012 should be week 1');
@@ -10136,42 +14026,6 @@
assert.equal(moment([2012, 0, 9]).format('w ww wo'), '3 03 3a', 'Jan 9 2012 should be week 3');
});
- test('lenient ordinal parsing', function (assert) {
- var i, ordinalStr, testMoment;
- for (i = 1; i <= 31; ++i) {
- ordinalStr = moment([2014, 0, i]).format('YYYY MM Do');
- testMoment = moment(ordinalStr, 'YYYY MM Do');
- assert.equal(testMoment.year(), 2014,
- 'lenient ordinal parsing ' + i + ' year check');
- assert.equal(testMoment.month(), 0,
- 'lenient ordinal parsing ' + i + ' month check');
- assert.equal(testMoment.date(), i,
- 'lenient ordinal parsing ' + i + ' date check');
- }
- });
-
- test('lenient ordinal parsing of number', function (assert) {
- var i, testMoment;
- for (i = 1; i <= 31; ++i) {
- testMoment = moment('2014 01 ' + i, 'YYYY MM Do');
- assert.equal(testMoment.year(), 2014,
- 'lenient ordinal parsing of number ' + i + ' year check');
- assert.equal(testMoment.month(), 0,
- 'lenient ordinal parsing of number ' + i + ' month check');
- assert.equal(testMoment.date(), i,
- 'lenient ordinal parsing of number ' + i + ' date check');
- }
- });
-
- test('strict ordinal parsing', function (assert) {
- var i, ordinalStr, testMoment;
- for (i = 1; i <= 31; ++i) {
- ordinalStr = moment([2014, 0, i]).format('YYYY MM Do');
- testMoment = moment(ordinalStr, 'YYYY MM Do', true);
- assert.ok(testMoment.isValid(), 'strict ordinal parsing ' + i);
- }
- });
-
}));
;(function (global, factory) {
@@ -10180,6 +14034,224 @@
typeof define === 'function' && define.amd ? define(['../../moment'], factory) :
factory(global.moment)
}(this, function (moment) { 'use strict';
+
+ function each(array, callback) {
+ var i;
+ for (i = 0; i < array.length; i++) {
+ callback(array[i], i, array);
+ }
+ }
+
+ function objectKeys(obj) {
+ if (Object.keys) {
+ return Object.keys(obj);
+ } else {
+ // IE8
+ var res = [], i;
+ for (i in obj) {
+ if (obj.hasOwnProperty(i)) {
+ res.push(i);
+ }
+ }
+ return res;
+ }
+ }
+
+ // Pick the first defined of two or three arguments.
+ function defaults(a, b, c) {
+ if (a != null) {
+ return a;
+ }
+ if (b != null) {
+ return b;
+ }
+ return c;
+ }
+
+ function defineCommonLocaleTests(locale, options) {
+ test('lenient ordinal parsing', function (assert) {
+ var i, ordinalStr, testMoment;
+ for (i = 1; i <= 31; ++i) {
+ ordinalStr = moment([2014, 0, i]).format('YYYY MM Do');
+ testMoment = moment(ordinalStr, 'YYYY MM Do');
+ assert.equal(testMoment.year(), 2014,
+ 'lenient ordinal parsing ' + i + ' year check');
+ assert.equal(testMoment.month(), 0,
+ 'lenient ordinal parsing ' + i + ' month check');
+ assert.equal(testMoment.date(), i,
+ 'lenient ordinal parsing ' + i + ' date check');
+ }
+ });
+
+ test('lenient ordinal parsing of number', function (assert) {
+ var i, testMoment;
+ for (i = 1; i <= 31; ++i) {
+ testMoment = moment('2014 01 ' + i, 'YYYY MM Do');
+ assert.equal(testMoment.year(), 2014,
+ 'lenient ordinal parsing of number ' + i + ' year check');
+ assert.equal(testMoment.month(), 0,
+ 'lenient ordinal parsing of number ' + i + ' month check');
+ assert.equal(testMoment.date(), i,
+ 'lenient ordinal parsing of number ' + i + ' date check');
+ }
+ });
+
+ test('strict ordinal parsing', function (assert) {
+ var i, ordinalStr, testMoment;
+ for (i = 1; i <= 31; ++i) {
+ ordinalStr = moment([2014, 0, i]).format('YYYY MM Do');
+ testMoment = moment(ordinalStr, 'YYYY MM Do', true);
+ assert.ok(testMoment.isValid(), 'strict ordinal parsing ' + i);
+ }
+ });
+
+ test('meridiem invariant', function (assert) {
+ var h, m, t1, t2;
+ for (h = 0; h < 24; ++h) {
+ for (m = 0; m < 60; m += 15) {
+ t1 = moment.utc([2000, 0, 1, h, m]);
+ t2 = moment.utc(t1.format('A h:mm'), 'A h:mm');
+ assert.equal(t2.format('HH:mm'), t1.format('HH:mm'),
+ 'meridiem at ' + t1.format('HH:mm'));
+ }
+ }
+ });
+
+ test('date format correctness', function (assert) {
+ var data, tokens;
+ data = moment.localeData()._longDateFormat;
+ tokens = objectKeys(data);
+ each(tokens, function (srchToken) {
+ // Check each format string to make sure it does not contain any
+ // tokens that need to be expanded.
+ each(tokens, function (baseToken) {
+ // strip escaped sequences
+ var format = data[baseToken].replace(/(\[[^\]]*\])/g, '');
+ assert.equal(false, !!~format.indexOf(srchToken),
+ 'contains ' + srchToken + ' in ' + baseToken);
+ });
+ });
+ });
+
+ test('month parsing correctness', function (assert) {
+ var i, m;
+
+ if (locale === 'tr') {
+ // I can't fix it :(
+ expect(0);
+ return;
+ }
+ function tester(format) {
+ var r;
+ r = moment(m.format(format), format);
+ assert.equal(r.month(), m.month(), 'month ' + i + ' fmt ' + format);
+ r = moment(m.format(format).toLocaleUpperCase(), format);
+ assert.equal(r.month(), m.month(), 'month ' + i + ' fmt ' + format + ' upper');
+ r = moment(m.format(format).toLocaleLowerCase(), format);
+ assert.equal(r.month(), m.month(), 'month ' + i + ' fmt ' + format + ' lower');
+
+ r = moment(m.format(format), format, true);
+ assert.equal(r.month(), m.month(), 'month ' + i + ' fmt ' + format + ' strict');
+ r = moment(m.format(format).toLocaleUpperCase(), format, true);
+ assert.equal(r.month(), m.month(), 'month ' + i + ' fmt ' + format + ' upper strict');
+ r = moment(m.format(format).toLocaleLowerCase(), format, true);
+ assert.equal(r.month(), m.month(), 'month ' + i + ' fmt ' + format + ' lower strict');
+ }
+
+ for (i = 0; i < 12; ++i) {
+ m = moment([2015, i, 15, 18]);
+ tester('MMM');
+ tester('MMM.');
+ tester('MMMM');
+ tester('MMMM.');
+ }
+ });
+
+ test('weekday parsing correctness', function (assert) {
+ var i, m;
+
+ if (locale === 'tr' || locale === 'az') {
+ // There is a lower-case letter (ı), that converted to upper then
+ // lower changes to i
+ expect(0);
+ return;
+ }
+ function tester(format) {
+ var r, baseMsg = 'weekday ' + m.weekday() + ' fmt ' + format;
+ r = moment(m.format(format), format);
+ assert.equal(r.weekday(), m.weekday(), baseMsg);
+ r = moment(m.format(format).toLocaleUpperCase(), format);
+ assert.equal(r.weekday(), m.weekday(), baseMsg + ' upper');
+ r = moment(m.format(format).toLocaleLowerCase(), format);
+ assert.equal(r.weekday(), m.weekday(), baseMsg + ' lower');
+
+ r = moment(m.format(format), format, true);
+ assert.equal(r.weekday(), m.weekday(), baseMsg + ' strict');
+ r = moment(m.format(format).toLocaleUpperCase(), format, true);
+ assert.equal(r.weekday(), m.weekday(), baseMsg + ' upper strict');
+ r = moment(m.format(format).toLocaleLowerCase(), format, true);
+ assert.equal(r.weekday(), m.weekday(), baseMsg + ' lower strict');
+ }
+
+ for (i = 0; i < 7; ++i) {
+ m = moment.utc([2015, i, 15, 18]);
+ tester('dd');
+ tester('ddd');
+ tester('dddd');
+ }
+ });
+ }
+
+ function setupDeprecationHandler(test, moment, scope) {
+ test._expectedDeprecations = null;
+ test._observedDeprecations = null;
+ test._oldSupress = moment.suppressDeprecationWarnings;
+ moment.suppressDeprecationWarnings = true;
+ test.expectedDeprecations = function () {
+ test._expectedDeprecations = arguments;
+ test._observedDeprecations = [];
+ };
+ moment.deprecationHandler = function (name, msg) {
+ var deprecationId = matchedDeprecation(name, msg, test._expectedDeprecations);
+ if (deprecationId === -1) {
+ throw new Error('Unexpected deprecation thrown name=' +
+ name + ' msg=' + msg);
+ }
+ test._observedDeprecations[deprecationId] = 1;
+ };
+ }
+
+ function teardownDeprecationHandler(test, moment, scope) {
+ moment.suppressDeprecationWarnings = test._oldSupress;
+
+ if (test._expectedDeprecations != null) {
+ var missedDeprecations = [];
+ each(test._expectedDeprecations, function (deprecationPattern, id) {
+ if (test._observedDeprecations[id] !== 1) {
+ missedDeprecations.push(deprecationPattern);
+ }
+ });
+ if (missedDeprecations.length !== 0) {
+ throw new Error('Expected deprecation warnings did not happen: ' +
+ missedDeprecations.join(' '));
+ }
+ }
+ }
+
+ function matchedDeprecation(name, msg, deprecations) {
+ if (deprecations == null) {
+ return -1;
+ }
+ for (var i = 0; i < deprecations.length; ++i) {
+ if (name != null && name === deprecations[i]) {
+ return i;
+ }
+ if (msg != null && msg.substring(0, deprecations[i].length) === deprecations[i]) {
+ return i;
+ }
+ }
+ return -1;
+ }
/*global QUnit:false*/
@@ -10194,11 +14266,13 @@
moment.createFromInputFallback = function (config) {
throw new Error('input not handled by moment: ' + config._i);
};
+ setupDeprecationHandler(test, moment, 'core');
if (lifecycle && lifecycle.setup) {
lifecycle.setup();
}
},
teardown : function () {
+ teardownDeprecationHandler(test, moment, 'core');
if (lifecycle && lifecycle.teardown) {
lifecycle.teardown();
}
@@ -10213,17 +14287,20 @@
moment.createFromInputFallback = function (config) {
throw new Error('input not handled by moment: ' + config._i);
};
+ setupDeprecationHandler(test, moment, 'locale');
if (lifecycle && lifecycle.setup) {
lifecycle.setup();
}
},
teardown : function () {
moment.locale('en');
+ teardownDeprecationHandler(test, moment, 'locale');
if (lifecycle && lifecycle.teardown) {
lifecycle.teardown();
}
}
});
+ defineCommonLocaleTests(name, -1, -1);
}
localeModule('es');
@@ -10378,15 +14455,15 @@
});
test('calendar day', function (assert) {
- var a = moment().hours(2).minutes(0).seconds(0);
-
- assert.equal(moment(a).calendar(), 'hoy a las 2:00', 'today at the same time');
- assert.equal(moment(a).add({m: 25}).calendar(), 'hoy a las 2:25', 'Now plus 25 min');
- assert.equal(moment(a).add({h: 1}).calendar(), 'hoy a las 3:00', 'Now plus 1 hour');
- assert.equal(moment(a).add({d: 1}).calendar(), 'mañana a las 2:00', 'tomorrow at the same time');
- assert.equal(moment(a).add({d: 1, h : -1}).calendar(), 'mañana a la 1:00', 'tomorrow minus 1 hour');
- assert.equal(moment(a).subtract({h: 1}).calendar(), 'hoy a la 1:00', 'Now minus 1 hour');
- assert.equal(moment(a).subtract({d: 1}).calendar(), 'ayer a las 2:00', 'yesterday at the same time');
+ var a = moment().hours(12).minutes(0).seconds(0);
+
+ assert.equal(moment(a).calendar(), 'hoy a las 12:00', 'today at the same time');
+ assert.equal(moment(a).add({m: 25}).calendar(), 'hoy a las 12:25', 'Now plus 25 min');
+ assert.equal(moment(a).add({h: 1}).calendar(), 'hoy a las 13:00', 'Now plus 1 hour');
+ assert.equal(moment(a).add({d: 1}).calendar(), 'mañana a las 12:00', 'tomorrow at the same time');
+ assert.equal(moment(a).add({d: 1, h : -1}).calendar(), 'mañana a las 11:00', 'tomorrow minus 1 hour');
+ assert.equal(moment(a).subtract({h: 1}).calendar(), 'hoy a las 11:00', 'Now minus 1 hour');
+ assert.equal(moment(a).subtract({d: 1}).calendar(), 'ayer a las 12:00', 'yesterday at the same time');
});
test('calendar next week', function (assert) {
@@ -10429,67 +14506,6 @@
assert.equal(weeksFromNow.calendar(), weeksFromNow.format('L'), 'in 2 weeks');
});
- test('weeks year starting sunday', function (assert) {
- assert.equal(moment([2012, 0, 1]).week(), 52, 'Jan 1 2012 should be week 52');
- assert.equal(moment([2012, 0, 2]).week(), 1, 'Jan 2 2012 should be week 1');
- assert.equal(moment([2012, 0, 8]).week(), 1, 'Jan 8 2012 should be week 1');
- assert.equal(moment([2012, 0, 9]).week(), 2, 'Jan 9 2012 should be week 2');
- assert.equal(moment([2012, 0, 15]).week(), 2, 'Jan 15 2012 should be week 2');
- });
-
- test('weeks year starting monday', function (assert) {
- assert.equal(moment([2007, 0, 1]).week(), 1, 'Jan 1 2007 should be week 1');
- assert.equal(moment([2007, 0, 7]).week(), 1, 'Jan 7 2007 should be week 1');
- assert.equal(moment([2007, 0, 8]).week(), 2, 'Jan 8 2007 should be week 2');
- assert.equal(moment([2007, 0, 14]).week(), 2, 'Jan 14 2007 should be week 2');
- assert.equal(moment([2007, 0, 15]).week(), 3, 'Jan 15 2007 should be week 3');
- });
-
- test('weeks year starting tuesday', function (assert) {
- assert.equal(moment([2007, 11, 31]).week(), 1, 'Dec 31 2007 should be week 1');
- assert.equal(moment([2008, 0, 1]).week(), 1, 'Jan 1 2008 should be week 1');
- assert.equal(moment([2008, 0, 6]).week(), 1, 'Jan 6 2008 should be week 1');
- assert.equal(moment([2008, 0, 7]).week(), 2, 'Jan 7 2008 should be week 2');
- assert.equal(moment([2008, 0, 13]).week(), 2, 'Jan 13 2008 should be week 2');
- assert.equal(moment([2008, 0, 14]).week(), 3, 'Jan 14 2008 should be week 3');
- });
-
- test('weeks year starting wednesday', function (assert) {
- assert.equal(moment([2002, 11, 30]).week(), 1, 'Dec 30 2002 should be week 1');
- assert.equal(moment([2003, 0, 1]).week(), 1, 'Jan 1 2003 should be week 1');
- assert.equal(moment([2003, 0, 5]).week(), 1, 'Jan 5 2003 should be week 1');
- assert.equal(moment([2003, 0, 6]).week(), 2, 'Jan 6 2003 should be week 2');
- assert.equal(moment([2003, 0, 12]).week(), 2, 'Jan 12 2003 should be week 2');
- assert.equal(moment([2003, 0, 13]).week(), 3, 'Jan 13 2003 should be week 3');
- });
-
- test('weeks year starting thursday', function (assert) {
- assert.equal(moment([2008, 11, 29]).week(), 1, 'Dec 29 2008 should be week 1');
- assert.equal(moment([2009, 0, 1]).week(), 1, 'Jan 1 2009 should be week 1');
- assert.equal(moment([2009, 0, 4]).week(), 1, 'Jan 4 2009 should be week 1');
- assert.equal(moment([2009, 0, 5]).week(), 2, 'Jan 5 2009 should be week 2');
- assert.equal(moment([2009, 0, 11]).week(), 2, 'Jan 11 2009 should be week 2');
- assert.equal(moment([2009, 0, 13]).week(), 3, 'Jan 12 2009 should be week 3');
- });
-
- test('weeks year starting friday', function (assert) {
- assert.equal(moment([2009, 11, 28]).week(), 53, 'Dec 28 2009 should be week 53');
- assert.equal(moment([2010, 0, 1]).week(), 53, 'Jan 1 2010 should be week 53');
- assert.equal(moment([2010, 0, 3]).week(), 53, 'Jan 3 2010 should be week 53');
- assert.equal(moment([2010, 0, 4]).week(), 1, 'Jan 4 2010 should be week 1');
- assert.equal(moment([2010, 0, 10]).week(), 1, 'Jan 10 2010 should be week 1');
- assert.equal(moment([2010, 0, 11]).week(), 2, 'Jan 11 2010 should be week 2');
- });
-
- test('weeks year starting saturday', function (assert) {
- assert.equal(moment([2010, 11, 27]).week(), 52, 'Dec 27 2010 should be week 52');
- assert.equal(moment([2011, 0, 1]).week(), 52, 'Jan 1 2011 should be week 52');
- assert.equal(moment([2011, 0, 2]).week(), 52, 'Jan 2 2011 should be week 52');
- assert.equal(moment([2011, 0, 3]).week(), 1, 'Jan 3 2011 should be week 1');
- assert.equal(moment([2011, 0, 9]).week(), 1, 'Jan 9 2011 should be week 1');
- assert.equal(moment([2011, 0, 10]).week(), 2, 'Jan 10 2011 should be week 2');
- });
-
test('weeks year starting sunday formatted', function (assert) {
assert.equal(moment([2012, 0, 1]).format('w ww wo'), '52 52 52º', 'Jan 1 2012 should be week 52');
assert.equal(moment([2012, 0, 2]).format('w ww wo'), '1 01 1º', 'Jan 2 2012 should be week 1');
@@ -10498,42 +14514,6 @@
assert.equal(moment([2012, 0, 15]).format('w ww wo'), '2 02 2º', 'Jan 15 2012 should be week 2');
});
- test('lenient ordinal parsing', function (assert) {
- var i, ordinalStr, testMoment;
- for (i = 1; i <= 31; ++i) {
- ordinalStr = moment([2014, 0, i]).format('YYYY MM Do');
- testMoment = moment(ordinalStr, 'YYYY MM Do');
- assert.equal(testMoment.year(), 2014,
- 'lenient ordinal parsing ' + i + ' year check');
- assert.equal(testMoment.month(), 0,
- 'lenient ordinal parsing ' + i + ' month check');
- assert.equal(testMoment.date(), i,
- 'lenient ordinal parsing ' + i + ' date check');
- }
- });
-
- test('lenient ordinal parsing of number', function (assert) {
- var i, testMoment;
- for (i = 1; i <= 31; ++i) {
- testMoment = moment('2014 01 ' + i, 'YYYY MM Do');
- assert.equal(testMoment.year(), 2014,
- 'lenient ordinal parsing of number ' + i + ' year check');
- assert.equal(testMoment.month(), 0,
- 'lenient ordinal parsing of number ' + i + ' month check');
- assert.equal(testMoment.date(), i,
- 'lenient ordinal parsing of number ' + i + ' date check');
- }
- });
-
- test('strict ordinal parsing', function (assert) {
- var i, ordinalStr, testMoment;
- for (i = 1; i <= 31; ++i) {
- ordinalStr = moment([2014, 0, i]).format('YYYY MM Do');
- testMoment = moment(ordinalStr, 'YYYY MM Do', true);
- assert.ok(testMoment.isValid(), 'strict ordinal parsing ' + i);
- }
- });
-
}));
;(function (global, factory) {
@@ -10542,6 +14522,224 @@
typeof define === 'function' && define.amd ? define(['../../moment'], factory) :
factory(global.moment)
}(this, function (moment) { 'use strict';
+
+ function each(array, callback) {
+ var i;
+ for (i = 0; i < array.length; i++) {
+ callback(array[i], i, array);
+ }
+ }
+
+ function objectKeys(obj) {
+ if (Object.keys) {
+ return Object.keys(obj);
+ } else {
+ // IE8
+ var res = [], i;
+ for (i in obj) {
+ if (obj.hasOwnProperty(i)) {
+ res.push(i);
+ }
+ }
+ return res;
+ }
+ }
+
+ // Pick the first defined of two or three arguments.
+ function defaults(a, b, c) {
+ if (a != null) {
+ return a;
+ }
+ if (b != null) {
+ return b;
+ }
+ return c;
+ }
+
+ function defineCommonLocaleTests(locale, options) {
+ test('lenient ordinal parsing', function (assert) {
+ var i, ordinalStr, testMoment;
+ for (i = 1; i <= 31; ++i) {
+ ordinalStr = moment([2014, 0, i]).format('YYYY MM Do');
+ testMoment = moment(ordinalStr, 'YYYY MM Do');
+ assert.equal(testMoment.year(), 2014,
+ 'lenient ordinal parsing ' + i + ' year check');
+ assert.equal(testMoment.month(), 0,
+ 'lenient ordinal parsing ' + i + ' month check');
+ assert.equal(testMoment.date(), i,
+ 'lenient ordinal parsing ' + i + ' date check');
+ }
+ });
+
+ test('lenient ordinal parsing of number', function (assert) {
+ var i, testMoment;
+ for (i = 1; i <= 31; ++i) {
+ testMoment = moment('2014 01 ' + i, 'YYYY MM Do');
+ assert.equal(testMoment.year(), 2014,
+ 'lenient ordinal parsing of number ' + i + ' year check');
+ assert.equal(testMoment.month(), 0,
+ 'lenient ordinal parsing of number ' + i + ' month check');
+ assert.equal(testMoment.date(), i,
+ 'lenient ordinal parsing of number ' + i + ' date check');
+ }
+ });
+
+ test('strict ordinal parsing', function (assert) {
+ var i, ordinalStr, testMoment;
+ for (i = 1; i <= 31; ++i) {
+ ordinalStr = moment([2014, 0, i]).format('YYYY MM Do');
+ testMoment = moment(ordinalStr, 'YYYY MM Do', true);
+ assert.ok(testMoment.isValid(), 'strict ordinal parsing ' + i);
+ }
+ });
+
+ test('meridiem invariant', function (assert) {
+ var h, m, t1, t2;
+ for (h = 0; h < 24; ++h) {
+ for (m = 0; m < 60; m += 15) {
+ t1 = moment.utc([2000, 0, 1, h, m]);
+ t2 = moment.utc(t1.format('A h:mm'), 'A h:mm');
+ assert.equal(t2.format('HH:mm'), t1.format('HH:mm'),
+ 'meridiem at ' + t1.format('HH:mm'));
+ }
+ }
+ });
+
+ test('date format correctness', function (assert) {
+ var data, tokens;
+ data = moment.localeData()._longDateFormat;
+ tokens = objectKeys(data);
+ each(tokens, function (srchToken) {
+ // Check each format string to make sure it does not contain any
+ // tokens that need to be expanded.
+ each(tokens, function (baseToken) {
+ // strip escaped sequences
+ var format = data[baseToken].replace(/(\[[^\]]*\])/g, '');
+ assert.equal(false, !!~format.indexOf(srchToken),
+ 'contains ' + srchToken + ' in ' + baseToken);
+ });
+ });
+ });
+
+ test('month parsing correctness', function (assert) {
+ var i, m;
+
+ if (locale === 'tr') {
+ // I can't fix it :(
+ expect(0);
+ return;
+ }
+ function tester(format) {
+ var r;
+ r = moment(m.format(format), format);
+ assert.equal(r.month(), m.month(), 'month ' + i + ' fmt ' + format);
+ r = moment(m.format(format).toLocaleUpperCase(), format);
+ assert.equal(r.month(), m.month(), 'month ' + i + ' fmt ' + format + ' upper');
+ r = moment(m.format(format).toLocaleLowerCase(), format);
+ assert.equal(r.month(), m.month(), 'month ' + i + ' fmt ' + format + ' lower');
+
+ r = moment(m.format(format), format, true);
+ assert.equal(r.month(), m.month(), 'month ' + i + ' fmt ' + format + ' strict');
+ r = moment(m.format(format).toLocaleUpperCase(), format, true);
+ assert.equal(r.month(), m.month(), 'month ' + i + ' fmt ' + format + ' upper strict');
+ r = moment(m.format(format).toLocaleLowerCase(), format, true);
+ assert.equal(r.month(), m.month(), 'month ' + i + ' fmt ' + format + ' lower strict');
+ }
+
+ for (i = 0; i < 12; ++i) {
+ m = moment([2015, i, 15, 18]);
+ tester('MMM');
+ tester('MMM.');
+ tester('MMMM');
+ tester('MMMM.');
+ }
+ });
+
+ test('weekday parsing correctness', function (assert) {
+ var i, m;
+
+ if (locale === 'tr' || locale === 'az') {
+ // There is a lower-case letter (ı), that converted to upper then
+ // lower changes to i
+ expect(0);
+ return;
+ }
+ function tester(format) {
+ var r, baseMsg = 'weekday ' + m.weekday() + ' fmt ' + format;
+ r = moment(m.format(format), format);
+ assert.equal(r.weekday(), m.weekday(), baseMsg);
+ r = moment(m.format(format).toLocaleUpperCase(), format);
+ assert.equal(r.weekday(), m.weekday(), baseMsg + ' upper');
+ r = moment(m.format(format).toLocaleLowerCase(), format);
+ assert.equal(r.weekday(), m.weekday(), baseMsg + ' lower');
+
+ r = moment(m.format(format), format, true);
+ assert.equal(r.weekday(), m.weekday(), baseMsg + ' strict');
+ r = moment(m.format(format).toLocaleUpperCase(), format, true);
+ assert.equal(r.weekday(), m.weekday(), baseMsg + ' upper strict');
+ r = moment(m.format(format).toLocaleLowerCase(), format, true);
+ assert.equal(r.weekday(), m.weekday(), baseMsg + ' lower strict');
+ }
+
+ for (i = 0; i < 7; ++i) {
+ m = moment.utc([2015, i, 15, 18]);
+ tester('dd');
+ tester('ddd');
+ tester('dddd');
+ }
+ });
+ }
+
+ function setupDeprecationHandler(test, moment, scope) {
+ test._expectedDeprecations = null;
+ test._observedDeprecations = null;
+ test._oldSupress = moment.suppressDeprecationWarnings;
+ moment.suppressDeprecationWarnings = true;
+ test.expectedDeprecations = function () {
+ test._expectedDeprecations = arguments;
+ test._observedDeprecations = [];
+ };
+ moment.deprecationHandler = function (name, msg) {
+ var deprecationId = matchedDeprecation(name, msg, test._expectedDeprecations);
+ if (deprecationId === -1) {
+ throw new Error('Unexpected deprecation thrown name=' +
+ name + ' msg=' + msg);
+ }
+ test._observedDeprecations[deprecationId] = 1;
+ };
+ }
+
+ function teardownDeprecationHandler(test, moment, scope) {
+ moment.suppressDeprecationWarnings = test._oldSupress;
+
+ if (test._expectedDeprecations != null) {
+ var missedDeprecations = [];
+ each(test._expectedDeprecations, function (deprecationPattern, id) {
+ if (test._observedDeprecations[id] !== 1) {
+ missedDeprecations.push(deprecationPattern);
+ }
+ });
+ if (missedDeprecations.length !== 0) {
+ throw new Error('Expected deprecation warnings did not happen: ' +
+ missedDeprecations.join(' '));
+ }
+ }
+ }
+
+ function matchedDeprecation(name, msg, deprecations) {
+ if (deprecations == null) {
+ return -1;
+ }
+ for (var i = 0; i < deprecations.length; ++i) {
+ if (name != null && name === deprecations[i]) {
+ return i;
+ }
+ if (msg != null && msg.substring(0, deprecations[i].length) === deprecations[i]) {
+ return i;
+ }
+ }
+ return -1;
+ }
/*global QUnit:false*/
@@ -10556,11 +14754,13 @@
moment.createFromInputFallback = function (config) {
throw new Error('input not handled by moment: ' + config._i);
};
+ setupDeprecationHandler(test, moment, 'core');
if (lifecycle && lifecycle.setup) {
lifecycle.setup();
}
},
teardown : function () {
+ teardownDeprecationHandler(test, moment, 'core');
if (lifecycle && lifecycle.teardown) {
lifecycle.teardown();
}
@@ -10575,17 +14775,20 @@
moment.createFromInputFallback = function (config) {
throw new Error('input not handled by moment: ' + config._i);
};
+ setupDeprecationHandler(test, moment, 'locale');
if (lifecycle && lifecycle.setup) {
lifecycle.setup();
}
},
teardown : function () {
moment.locale('en');
+ teardownDeprecationHandler(test, moment, 'locale');
if (lifecycle && lifecycle.teardown) {
lifecycle.teardown();
}
}
});
+ defineCommonLocaleTests(name, -1, -1);
}
localeModule('et');
@@ -10763,14 +14966,14 @@
});
test('calendar day', function (assert) {
- var a = moment().hours(2).minutes(0).seconds(0);
-
- assert.equal(moment(a).calendar(), 'Täna, 2:00', 'today at the same time');
- assert.equal(moment(a).add({m: 25}).calendar(), 'Täna, 2:25', 'Now plus 25 min');
- assert.equal(moment(a).add({h: 1}).calendar(), 'Täna, 3:00', 'Now plus 1 hour');
- assert.equal(moment(a).add({d: 1}).calendar(), 'Homme, 2:00', 'tomorrow at the same time');
- assert.equal(moment(a).subtract({h: 1}).calendar(), 'Täna, 1:00', 'Now minus 1 hour');
- assert.equal(moment(a).subtract({d: 1}).calendar(), 'Eile, 2:00', 'yesterday at the same time');
+ var a = moment().hours(12).minutes(0).seconds(0);
+
+ assert.equal(moment(a).calendar(), 'Täna, 12:00', 'today at the same time');
+ assert.equal(moment(a).add({m: 25}).calendar(), 'Täna, 12:25', 'Now plus 25 min');
+ assert.equal(moment(a).add({h: 1}).calendar(), 'Täna, 13:00', 'Now plus 1 hour');
+ assert.equal(moment(a).add({d: 1}).calendar(), 'Homme, 12:00', 'tomorrow at the same time');
+ assert.equal(moment(a).subtract({h: 1}).calendar(), 'Täna, 11:00', 'Now minus 1 hour');
+ assert.equal(moment(a).subtract({d: 1}).calendar(), 'Eile, 12:00', 'yesterday at the same time');
});
test('calendar next week', function (assert) {
@@ -10811,67 +15014,6 @@
assert.equal(weeksFromNow.calendar(), weeksFromNow.format('L'), '2 nädala pärast');
});
- test('weeks year starting sunday', function (assert) {
- assert.equal(moment([2012, 0, 1]).week(), 52, 'Jan 1 2012 should be week 52');
- assert.equal(moment([2012, 0, 2]).week(), 1, 'Jan 2 2012 should be week 1');
- assert.equal(moment([2012, 0, 8]).week(), 1, 'Jan 8 2012 should be week 1');
- assert.equal(moment([2012, 0, 9]).week(), 2, 'Jan 9 2012 should be week 2');
- assert.equal(moment([2012, 0, 15]).week(), 2, 'Jan 15 2012 should be week 2');
- });
-
- test('weeks year starting monday', function (assert) {
- assert.equal(moment([2007, 0, 1]).week(), 1, 'Jan 1 2007 should be week 1');
- assert.equal(moment([2007, 0, 7]).week(), 1, 'Jan 7 2007 should be week 1');
- assert.equal(moment([2007, 0, 8]).week(), 2, 'Jan 8 2007 should be week 2');
- assert.equal(moment([2007, 0, 14]).week(), 2, 'Jan 14 2007 should be week 2');
- assert.equal(moment([2007, 0, 15]).week(), 3, 'Jan 15 2007 should be week 3');
- });
-
- test('weeks year starting tuesday', function (assert) {
- assert.equal(moment([2007, 11, 31]).week(), 1, 'Dec 31 2007 should be week 1');
- assert.equal(moment([2008, 0, 1]).week(), 1, 'Jan 1 2008 should be week 1');
- assert.equal(moment([2008, 0, 6]).week(), 1, 'Jan 6 2008 should be week 1');
- assert.equal(moment([2008, 0, 7]).week(), 2, 'Jan 7 2008 should be week 2');
- assert.equal(moment([2008, 0, 13]).week(), 2, 'Jan 13 2008 should be week 2');
- assert.equal(moment([2008, 0, 14]).week(), 3, 'Jan 14 2008 should be week 3');
- });
-
- test('weeks year starting wednesday', function (assert) {
- assert.equal(moment([2002, 11, 30]).week(), 1, 'Dec 30 2002 should be week 1');
- assert.equal(moment([2003, 0, 1]).week(), 1, 'Jan 1 2003 should be week 1');
- assert.equal(moment([2003, 0, 5]).week(), 1, 'Jan 5 2003 should be week 1');
- assert.equal(moment([2003, 0, 6]).week(), 2, 'Jan 6 2003 should be week 2');
- assert.equal(moment([2003, 0, 12]).week(), 2, 'Jan 12 2003 should be week 2');
- assert.equal(moment([2003, 0, 13]).week(), 3, 'Jan 13 2003 should be week 3');
- });
-
- test('weeks year starting thursday', function (assert) {
- assert.equal(moment([2008, 11, 29]).week(), 1, 'Dec 29 2008 should be week 1');
- assert.equal(moment([2009, 0, 1]).week(), 1, 'Jan 1 2009 should be week 1');
- assert.equal(moment([2009, 0, 4]).week(), 1, 'Jan 4 2009 should be week 1');
- assert.equal(moment([2009, 0, 5]).week(), 2, 'Jan 5 2009 should be week 2');
- assert.equal(moment([2009, 0, 11]).week(), 2, 'Jan 11 2009 should be week 2');
- assert.equal(moment([2009, 0, 13]).week(), 3, 'Jan 12 2009 should be week 3');
- });
-
- test('weeks year starting friday', function (assert) {
- assert.equal(moment([2009, 11, 28]).week(), 53, 'Dec 28 2009 should be week 53');
- assert.equal(moment([2010, 0, 1]).week(), 53, 'Jan 1 2010 should be week 53');
- assert.equal(moment([2010, 0, 3]).week(), 53, 'Jan 3 2010 should be week 53');
- assert.equal(moment([2010, 0, 4]).week(), 1, 'Jan 4 2010 should be week 1');
- assert.equal(moment([2010, 0, 10]).week(), 1, 'Jan 10 2010 should be week 1');
- assert.equal(moment([2010, 0, 11]).week(), 2, 'Jan 11 2010 should be week 2');
- });
-
- test('weeks year starting saturday', function (assert) {
- assert.equal(moment([2010, 11, 27]).week(), 52, 'Dec 27 2010 should be week 52');
- assert.equal(moment([2011, 0, 1]).week(), 52, 'Jan 1 2011 should be week 52');
- assert.equal(moment([2011, 0, 2]).week(), 52, 'Jan 2 2011 should be week 52');
- assert.equal(moment([2011, 0, 3]).week(), 1, 'Jan 3 2011 should be week 1');
- assert.equal(moment([2011, 0, 9]).week(), 1, 'Jan 9 2011 should be week 1');
- assert.equal(moment([2011, 0, 10]).week(), 2, 'Jan 10 2011 should be week 2');
- });
-
test('weeks year starting sunday formatted', function (assert) {
assert.equal(moment([2012, 0, 1]).format('w ww wo'), '52 52 52.', 'Jan 1 2012 should be week 52');
assert.equal(moment([2012, 0, 2]).format('w ww wo'), '1 01 1.', 'Jan 2 2012 should be week 1');
@@ -10880,42 +15022,6 @@
assert.equal(moment([2012, 0, 15]).format('w ww wo'), '2 02 2.', 'Jan 15 2012 should be week 2');
});
- test('lenient ordinal parsing', function (assert) {
- var i, ordinalStr, testMoment;
- for (i = 1; i <= 31; ++i) {
- ordinalStr = moment([2014, 0, i]).format('YYYY MM Do');
- testMoment = moment(ordinalStr, 'YYYY MM Do');
- assert.equal(testMoment.year(), 2014,
- 'lenient ordinal parsing ' + i + ' year check');
- assert.equal(testMoment.month(), 0,
- 'lenient ordinal parsing ' + i + ' month check');
- assert.equal(testMoment.date(), i,
- 'lenient ordinal parsing ' + i + ' date check');
- }
- });
-
- test('lenient ordinal parsing of number', function (assert) {
- var i, testMoment;
- for (i = 1; i <= 31; ++i) {
- testMoment = moment('2014 01 ' + i, 'YYYY MM Do');
- assert.equal(testMoment.year(), 2014,
- 'lenient ordinal parsing of number ' + i + ' year check');
- assert.equal(testMoment.month(), 0,
- 'lenient ordinal parsing of number ' + i + ' month check');
- assert.equal(testMoment.date(), i,
- 'lenient ordinal parsing of number ' + i + ' date check');
- }
- });
-
- test('strict ordinal parsing', function (assert) {
- var i, ordinalStr, testMoment;
- for (i = 1; i <= 31; ++i) {
- ordinalStr = moment([2014, 0, i]).format('YYYY MM Do');
- testMoment = moment(ordinalStr, 'YYYY MM Do', true);
- assert.ok(testMoment.isValid(), 'strict ordinal parsing ' + i);
- }
- });
-
}));
;(function (global, factory) {
@@ -10924,6 +15030,224 @@
typeof define === 'function' && define.amd ? define(['../../moment'], factory) :
factory(global.moment)
}(this, function (moment) { 'use strict';
+
+ function each(array, callback) {
+ var i;
+ for (i = 0; i < array.length; i++) {
+ callback(array[i], i, array);
+ }
+ }
+
+ function objectKeys(obj) {
+ if (Object.keys) {
+ return Object.keys(obj);
+ } else {
+ // IE8
+ var res = [], i;
+ for (i in obj) {
+ if (obj.hasOwnProperty(i)) {
+ res.push(i);
+ }
+ }
+ return res;
+ }
+ }
+
+ // Pick the first defined of two or three arguments.
+ function defaults(a, b, c) {
+ if (a != null) {
+ return a;
+ }
+ if (b != null) {
+ return b;
+ }
+ return c;
+ }
+
+ function defineCommonLocaleTests(locale, options) {
+ test('lenient ordinal parsing', function (assert) {
+ var i, ordinalStr, testMoment;
+ for (i = 1; i <= 31; ++i) {
+ ordinalStr = moment([2014, 0, i]).format('YYYY MM Do');
+ testMoment = moment(ordinalStr, 'YYYY MM Do');
+ assert.equal(testMoment.year(), 2014,
+ 'lenient ordinal parsing ' + i + ' year check');
+ assert.equal(testMoment.month(), 0,
+ 'lenient ordinal parsing ' + i + ' month check');
+ assert.equal(testMoment.date(), i,
+ 'lenient ordinal parsing ' + i + ' date check');
+ }
+ });
+
+ test('lenient ordinal parsing of number', function (assert) {
+ var i, testMoment;
+ for (i = 1; i <= 31; ++i) {
+ testMoment = moment('2014 01 ' + i, 'YYYY MM Do');
+ assert.equal(testMoment.year(), 2014,
+ 'lenient ordinal parsing of number ' + i + ' year check');
+ assert.equal(testMoment.month(), 0,
+ 'lenient ordinal parsing of number ' + i + ' month check');
+ assert.equal(testMoment.date(), i,
+ 'lenient ordinal parsing of number ' + i + ' date check');
+ }
+ });
+
+ test('strict ordinal parsing', function (assert) {
+ var i, ordinalStr, testMoment;
+ for (i = 1; i <= 31; ++i) {
+ ordinalStr = moment([2014, 0, i]).format('YYYY MM Do');
+ testMoment = moment(ordinalStr, 'YYYY MM Do', true);
+ assert.ok(testMoment.isValid(), 'strict ordinal parsing ' + i);
+ }
+ });
+
+ test('meridiem invariant', function (assert) {
+ var h, m, t1, t2;
+ for (h = 0; h < 24; ++h) {
+ for (m = 0; m < 60; m += 15) {
+ t1 = moment.utc([2000, 0, 1, h, m]);
+ t2 = moment.utc(t1.format('A h:mm'), 'A h:mm');
+ assert.equal(t2.format('HH:mm'), t1.format('HH:mm'),
+ 'meridiem at ' + t1.format('HH:mm'));
+ }
+ }
+ });
+
+ test('date format correctness', function (assert) {
+ var data, tokens;
+ data = moment.localeData()._longDateFormat;
+ tokens = objectKeys(data);
+ each(tokens, function (srchToken) {
+ // Check each format string to make sure it does not contain any
+ // tokens that need to be expanded.
+ each(tokens, function (baseToken) {
+ // strip escaped sequences
+ var format = data[baseToken].replace(/(\[[^\]]*\])/g, '');
+ assert.equal(false, !!~format.indexOf(srchToken),
+ 'contains ' + srchToken + ' in ' + baseToken);
+ });
+ });
+ });
+
+ test('month parsing correctness', function (assert) {
+ var i, m;
+
+ if (locale === 'tr') {
+ // I can't fix it :(
+ expect(0);
+ return;
+ }
+ function tester(format) {
+ var r;
+ r = moment(m.format(format), format);
+ assert.equal(r.month(), m.month(), 'month ' + i + ' fmt ' + format);
+ r = moment(m.format(format).toLocaleUpperCase(), format);
+ assert.equal(r.month(), m.month(), 'month ' + i + ' fmt ' + format + ' upper');
+ r = moment(m.format(format).toLocaleLowerCase(), format);
+ assert.equal(r.month(), m.month(), 'month ' + i + ' fmt ' + format + ' lower');
+
+ r = moment(m.format(format), format, true);
+ assert.equal(r.month(), m.month(), 'month ' + i + ' fmt ' + format + ' strict');
+ r = moment(m.format(format).toLocaleUpperCase(), format, true);
+ assert.equal(r.month(), m.month(), 'month ' + i + ' fmt ' + format + ' upper strict');
+ r = moment(m.format(format).toLocaleLowerCase(), format, true);
+ assert.equal(r.month(), m.month(), 'month ' + i + ' fmt ' + format + ' lower strict');
+ }
+
+ for (i = 0; i < 12; ++i) {
+ m = moment([2015, i, 15, 18]);
+ tester('MMM');
+ tester('MMM.');
+ tester('MMMM');
+ tester('MMMM.');
+ }
+ });
+
+ test('weekday parsing correctness', function (assert) {
+ var i, m;
+
+ if (locale === 'tr' || locale === 'az') {
+ // There is a lower-case letter (ı), that converted to upper then
+ // lower changes to i
+ expect(0);
+ return;
+ }
+ function tester(format) {
+ var r, baseMsg = 'weekday ' + m.weekday() + ' fmt ' + format;
+ r = moment(m.format(format), format);
+ assert.equal(r.weekday(), m.weekday(), baseMsg);
+ r = moment(m.format(format).toLocaleUpperCase(), format);
+ assert.equal(r.weekday(), m.weekday(), baseMsg + ' upper');
+ r = moment(m.format(format).toLocaleLowerCase(), format);
+ assert.equal(r.weekday(), m.weekday(), baseMsg + ' lower');
+
+ r = moment(m.format(format), format, true);
+ assert.equal(r.weekday(), m.weekday(), baseMsg + ' strict');
+ r = moment(m.format(format).toLocaleUpperCase(), format, true);
+ assert.equal(r.weekday(), m.weekday(), baseMsg + ' upper strict');
+ r = moment(m.format(format).toLocaleLowerCase(), format, true);
+ assert.equal(r.weekday(), m.weekday(), baseMsg + ' lower strict');
+ }
+
+ for (i = 0; i < 7; ++i) {
+ m = moment.utc([2015, i, 15, 18]);
+ tester('dd');
+ tester('ddd');
+ tester('dddd');
+ }
+ });
+ }
+
+ function setupDeprecationHandler(test, moment, scope) {
+ test._expectedDeprecations = null;
+ test._observedDeprecations = null;
+ test._oldSupress = moment.suppressDeprecationWarnings;
+ moment.suppressDeprecationWarnings = true;
+ test.expectedDeprecations = function () {
+ test._expectedDeprecations = arguments;
+ test._observedDeprecations = [];
+ };
+ moment.deprecationHandler = function (name, msg) {
+ var deprecationId = matchedDeprecation(name, msg, test._expectedDeprecations);
+ if (deprecationId === -1) {
+ throw new Error('Unexpected deprecation thrown name=' +
+ name + ' msg=' + msg);
+ }
+ test._observedDeprecations[deprecationId] = 1;
+ };
+ }
+
+ function teardownDeprecationHandler(test, moment, scope) {
+ moment.suppressDeprecationWarnings = test._oldSupress;
+
+ if (test._expectedDeprecations != null) {
+ var missedDeprecations = [];
+ each(test._expectedDeprecations, function (deprecationPattern, id) {
+ if (test._observedDeprecations[id] !== 1) {
+ missedDeprecations.push(deprecationPattern);
+ }
+ });
+ if (missedDeprecations.length !== 0) {
+ throw new Error('Expected deprecation warnings did not happen: ' +
+ missedDeprecations.join(' '));
+ }
+ }
+ }
+
+ function matchedDeprecation(name, msg, deprecations) {
+ if (deprecations == null) {
+ return -1;
+ }
+ for (var i = 0; i < deprecations.length; ++i) {
+ if (name != null && name === deprecations[i]) {
+ return i;
+ }
+ if (msg != null && msg.substring(0, deprecations[i].length) === deprecations[i]) {
+ return i;
+ }
+ }
+ return -1;
+ }
/*global QUnit:false*/
@@ -10938,11 +15262,13 @@
moment.createFromInputFallback = function (config) {
throw new Error('input not handled by moment: ' + config._i);
};
+ setupDeprecationHandler(test, moment, 'core');
if (lifecycle && lifecycle.setup) {
lifecycle.setup();
}
},
teardown : function () {
+ teardownDeprecationHandler(test, moment, 'core');
if (lifecycle && lifecycle.teardown) {
lifecycle.teardown();
}
@@ -10957,17 +15283,20 @@
moment.createFromInputFallback = function (config) {
throw new Error('input not handled by moment: ' + config._i);
};
+ setupDeprecationHandler(test, moment, 'locale');
if (lifecycle && lifecycle.setup) {
lifecycle.setup();
}
},
teardown : function () {
moment.locale('en');
+ teardownDeprecationHandler(test, moment, 'locale');
if (lifecycle && lifecycle.teardown) {
lifecycle.teardown();
}
}
});
+ defineCommonLocaleTests(name, -1, -1);
}
localeModule('eu');
@@ -11121,14 +15450,14 @@
});
test('calendar day', function (assert) {
- var a = moment().hours(2).minutes(0).seconds(0);
-
- assert.equal(moment(a).calendar(), 'gaur 02:00etan', 'today at the same time');
- assert.equal(moment(a).add({m: 25}).calendar(), 'gaur 02:25etan', 'now plus 25 min');
- assert.equal(moment(a).add({h: 1}).calendar(), 'gaur 03:00etan', 'now plus 1 hour');
- assert.equal(moment(a).add({d: 1}).calendar(), 'bihar 02:00etan', 'tomorrow at the same time');
- assert.equal(moment(a).subtract({h: 1}).calendar(), 'gaur 01:00etan', 'now minus 1 hour');
- assert.equal(moment(a).subtract({d: 1}).calendar(), 'atzo 02:00etan', 'yesterday at the same time');
+ var a = moment().hours(12).minutes(0).seconds(0);
+
+ assert.equal(moment(a).calendar(), 'gaur 12:00etan', 'today at the same time');
+ assert.equal(moment(a).add({m: 25}).calendar(), 'gaur 12:25etan', 'now plus 25 min');
+ assert.equal(moment(a).add({h: 1}).calendar(), 'gaur 13:00etan', 'now plus 1 hour');
+ assert.equal(moment(a).add({d: 1}).calendar(), 'bihar 12:00etan', 'tomorrow at the same time');
+ assert.equal(moment(a).subtract({h: 1}).calendar(), 'gaur 11:00etan', 'now minus 1 hour');
+ assert.equal(moment(a).subtract({d: 1}).calendar(), 'atzo 12:00etan', 'yesterday at the same time');
});
test('calendar next week', function (assert) {
@@ -11169,67 +15498,6 @@
assert.equal(weeksFromNow.calendar(), weeksFromNow.format('L'), 'in 2 weeks');
});
- test('weeks year starting sunday', function (assert) {
- assert.equal(moment([2011, 11, 26]).week(), 1, 'Dec 26 2011 should be week 1');
- assert.equal(moment([2012, 0, 1]).week(), 1, 'Jan 1 2012 should be week 1');
- assert.equal(moment([2012, 0, 2]).week(), 2, 'Jan 2 2012 should be week 2');
- assert.equal(moment([2012, 0, 8]).week(), 2, 'Jan 8 2012 should be week 2');
- assert.equal(moment([2012, 0, 9]).week(), 3, 'Jan 9 2012 should be week 3');
- });
-
- test('weeks year starting monday', function (assert) {
- assert.equal(moment([2007, 0, 1]).week(), 1, 'Jan 1 2007 should be week 1');
- assert.equal(moment([2007, 0, 7]).week(), 1, 'Jan 7 2007 should be week 1');
- assert.equal(moment([2007, 0, 8]).week(), 2, 'Jan 8 2007 should be week 2');
- assert.equal(moment([2007, 0, 14]).week(), 2, 'Jan 14 2007 should be week 2');
- assert.equal(moment([2007, 0, 15]).week(), 3, 'Jan 15 2007 should be week 3');
- });
-
- test('weeks year starting tuesday', function (assert) {
- assert.equal(moment([2007, 11, 31]).week(), 1, 'Dec 31 2007 should be week 1');
- assert.equal(moment([2008, 0, 1]).week(), 1, 'Jan 1 2008 should be week 1');
- assert.equal(moment([2008, 0, 6]).week(), 1, 'Jan 6 2008 should be week 1');
- assert.equal(moment([2008, 0, 7]).week(), 2, 'Jan 7 2008 should be week 2');
- assert.equal(moment([2008, 0, 13]).week(), 2, 'Jan 13 2008 should be week 2');
- assert.equal(moment([2008, 0, 14]).week(), 3, 'Jan 14 2008 should be week 3');
- });
-
- test('weeks year starting wednesday', function (assert) {
- assert.equal(moment([2002, 11, 30]).week(), 1, 'Dec 30 2002 should be week 1');
- assert.equal(moment([2003, 0, 1]).week(), 1, 'Jan 1 2003 should be week 1');
- assert.equal(moment([2003, 0, 5]).week(), 1, 'Jan 5 2003 should be week 1');
- assert.equal(moment([2003, 0, 6]).week(), 2, 'Jan 6 2003 should be week 2');
- assert.equal(moment([2003, 0, 12]).week(), 2, 'Jan 12 2003 should be week 2');
- assert.equal(moment([2003, 0, 13]).week(), 3, 'Jan 13 2003 should be week 3');
- });
-
- test('weeks year starting thursday', function (assert) {
- assert.equal(moment([2008, 11, 29]).week(), 1, 'Dec 29 2008 should be week 1');
- assert.equal(moment([2009, 0, 1]).week(), 1, 'Jan 1 2009 should be week 1');
- assert.equal(moment([2009, 0, 4]).week(), 1, 'Jan 4 2009 should be week 1');
- assert.equal(moment([2009, 0, 5]).week(), 2, 'Jan 5 2009 should be week 2');
- assert.equal(moment([2009, 0, 11]).week(), 2, 'Jan 11 2009 should be week 2');
- assert.equal(moment([2009, 0, 12]).week(), 3, 'Jan 12 2009 should be week 3');
- });
-
- test('weeks year starting friday', function (assert) {
- assert.equal(moment([2009, 11, 28]).week(), 1, 'Dec 28 2009 should be week 1');
- assert.equal(moment([2010, 0, 1]).week(), 1, 'Jan 1 2010 should be week 1');
- assert.equal(moment([2010, 0, 3]).week(), 1, 'Jan 3 2010 should be week 1');
- assert.equal(moment([2010, 0, 4]).week(), 2, 'Jan 4 2010 should be week 2');
- assert.equal(moment([2010, 0, 10]).week(), 2, 'Jan 10 2010 should be week 2');
- assert.equal(moment([2010, 0, 11]).week(), 3, 'Jan 11 2010 should be week 3');
- });
-
- test('weeks year starting saturday', function (assert) {
- assert.equal(moment([2010, 11, 27]).week(), 1, 'Dec 27 2010 should be week 1');
- assert.equal(moment([2011, 0, 1]).week(), 1, 'Jan 1 2011 should be week 1');
- assert.equal(moment([2011, 0, 2]).week(), 1, 'Jan 2 2011 should be week 1');
- assert.equal(moment([2011, 0, 3]).week(), 2, 'Jan 3 2011 should be week 2');
- assert.equal(moment([2011, 0, 9]).week(), 2, 'Jan 9 2011 should be week 2');
- assert.equal(moment([2011, 0, 10]).week(), 3, 'Jan 10 2011 should be week 3');
- });
-
test('weeks year starting sunday formatted', function (assert) {
assert.equal(moment([2011, 11, 26]).format('w ww wo'), '1 01 1.', 'Dec 26 2011 should be week 1');
assert.equal(moment([2012, 0, 1]).format('w ww wo'), '1 01 1.', 'Jan 1 2012 should be week 1');
@@ -11238,42 +15506,6 @@
assert.equal(moment([2012, 0, 9]).format('w ww wo'), '3 03 3.', 'Jan 9 2012 should be week 3');
});
- test('lenient ordinal parsing', function (assert) {
- var i, ordinalStr, testMoment;
- for (i = 1; i <= 31; ++i) {
- ordinalStr = moment([2014, 0, i]).format('YYYY MM Do');
- testMoment = moment(ordinalStr, 'YYYY MM Do');
- assert.equal(testMoment.year(), 2014,
- 'lenient ordinal parsing ' + i + ' year check');
- assert.equal(testMoment.month(), 0,
- 'lenient ordinal parsing ' + i + ' month check');
- assert.equal(testMoment.date(), i,
- 'lenient ordinal parsing ' + i + ' date check');
- }
- });
-
- test('lenient ordinal parsing of number', function (assert) {
- var i, testMoment;
- for (i = 1; i <= 31; ++i) {
- testMoment = moment('2014 01 ' + i, 'YYYY MM Do');
- assert.equal(testMoment.year(), 2014,
- 'lenient ordinal parsing of number ' + i + ' year check');
- assert.equal(testMoment.month(), 0,
- 'lenient ordinal parsing of number ' + i + ' month check');
- assert.equal(testMoment.date(), i,
- 'lenient ordinal parsing of number ' + i + ' date check');
- }
- });
-
- test('strict ordinal parsing', function (assert) {
- var i, ordinalStr, testMoment;
- for (i = 1; i <= 31; ++i) {
- ordinalStr = moment([2014, 0, i]).format('YYYY MM Do');
- testMoment = moment(ordinalStr, 'YYYY MM Do', true);
- assert.ok(testMoment.isValid(), 'strict ordinal parsing ' + i);
- }
- });
-
}));
;(function (global, factory) {
@@ -11282,6 +15514,224 @@
typeof define === 'function' && define.amd ? define(['../../moment'], factory) :
factory(global.moment)
}(this, function (moment) { 'use strict';
+
+ function each(array, callback) {
+ var i;
+ for (i = 0; i < array.length; i++) {
+ callback(array[i], i, array);
+ }
+ }
+
+ function objectKeys(obj) {
+ if (Object.keys) {
+ return Object.keys(obj);
+ } else {
+ // IE8
+ var res = [], i;
+ for (i in obj) {
+ if (obj.hasOwnProperty(i)) {
+ res.push(i);
+ }
+ }
+ return res;
+ }
+ }
+
+ // Pick the first defined of two or three arguments.
+ function defaults(a, b, c) {
+ if (a != null) {
+ return a;
+ }
+ if (b != null) {
+ return b;
+ }
+ return c;
+ }
+
+ function defineCommonLocaleTests(locale, options) {
+ test('lenient ordinal parsing', function (assert) {
+ var i, ordinalStr, testMoment;
+ for (i = 1; i <= 31; ++i) {
+ ordinalStr = moment([2014, 0, i]).format('YYYY MM Do');
+ testMoment = moment(ordinalStr, 'YYYY MM Do');
+ assert.equal(testMoment.year(), 2014,
+ 'lenient ordinal parsing ' + i + ' year check');
+ assert.equal(testMoment.month(), 0,
+ 'lenient ordinal parsing ' + i + ' month check');
+ assert.equal(testMoment.date(), i,
+ 'lenient ordinal parsing ' + i + ' date check');
+ }
+ });
+
+ test('lenient ordinal parsing of number', function (assert) {
+ var i, testMoment;
+ for (i = 1; i <= 31; ++i) {
+ testMoment = moment('2014 01 ' + i, 'YYYY MM Do');
+ assert.equal(testMoment.year(), 2014,
+ 'lenient ordinal parsing of number ' + i + ' year check');
+ assert.equal(testMoment.month(), 0,
+ 'lenient ordinal parsing of number ' + i + ' month check');
+ assert.equal(testMoment.date(), i,
+ 'lenient ordinal parsing of number ' + i + ' date check');
+ }
+ });
+
+ test('strict ordinal parsing', function (assert) {
+ var i, ordinalStr, testMoment;
+ for (i = 1; i <= 31; ++i) {
+ ordinalStr = moment([2014, 0, i]).format('YYYY MM Do');
+ testMoment = moment(ordinalStr, 'YYYY MM Do', true);
+ assert.ok(testMoment.isValid(), 'strict ordinal parsing ' + i);
+ }
+ });
+
+ test('meridiem invariant', function (assert) {
+ var h, m, t1, t2;
+ for (h = 0; h < 24; ++h) {
+ for (m = 0; m < 60; m += 15) {
+ t1 = moment.utc([2000, 0, 1, h, m]);
+ t2 = moment.utc(t1.format('A h:mm'), 'A h:mm');
+ assert.equal(t2.format('HH:mm'), t1.format('HH:mm'),
+ 'meridiem at ' + t1.format('HH:mm'));
+ }
+ }
+ });
+
+ test('date format correctness', function (assert) {
+ var data, tokens;
+ data = moment.localeData()._longDateFormat;
+ tokens = objectKeys(data);
+ each(tokens, function (srchToken) {
+ // Check each format string to make sure it does not contain any
+ // tokens that need to be expanded.
+ each(tokens, function (baseToken) {
+ // strip escaped sequences
+ var format = data[baseToken].replace(/(\[[^\]]*\])/g, '');
+ assert.equal(false, !!~format.indexOf(srchToken),
+ 'contains ' + srchToken + ' in ' + baseToken);
+ });
+ });
+ });
+
+ test('month parsing correctness', function (assert) {
+ var i, m;
+
+ if (locale === 'tr') {
+ // I can't fix it :(
+ expect(0);
+ return;
+ }
+ function tester(format) {
+ var r;
+ r = moment(m.format(format), format);
+ assert.equal(r.month(), m.month(), 'month ' + i + ' fmt ' + format);
+ r = moment(m.format(format).toLocaleUpperCase(), format);
+ assert.equal(r.month(), m.month(), 'month ' + i + ' fmt ' + format + ' upper');
+ r = moment(m.format(format).toLocaleLowerCase(), format);
+ assert.equal(r.month(), m.month(), 'month ' + i + ' fmt ' + format + ' lower');
+
+ r = moment(m.format(format), format, true);
+ assert.equal(r.month(), m.month(), 'month ' + i + ' fmt ' + format + ' strict');
+ r = moment(m.format(format).toLocaleUpperCase(), format, true);
+ assert.equal(r.month(), m.month(), 'month ' + i + ' fmt ' + format + ' upper strict');
+ r = moment(m.format(format).toLocaleLowerCase(), format, true);
+ assert.equal(r.month(), m.month(), 'month ' + i + ' fmt ' + format + ' lower strict');
+ }
+
+ for (i = 0; i < 12; ++i) {
+ m = moment([2015, i, 15, 18]);
+ tester('MMM');
+ tester('MMM.');
+ tester('MMMM');
+ tester('MMMM.');
+ }
+ });
+
+ test('weekday parsing correctness', function (assert) {
+ var i, m;
+
+ if (locale === 'tr' || locale === 'az') {
+ // There is a lower-case letter (ı), that converted to upper then
+ // lower changes to i
+ expect(0);
+ return;
+ }
+ function tester(format) {
+ var r, baseMsg = 'weekday ' + m.weekday() + ' fmt ' + format;
+ r = moment(m.format(format), format);
+ assert.equal(r.weekday(), m.weekday(), baseMsg);
+ r = moment(m.format(format).toLocaleUpperCase(), format);
+ assert.equal(r.weekday(), m.weekday(), baseMsg + ' upper');
+ r = moment(m.format(format).toLocaleLowerCase(), format);
+ assert.equal(r.weekday(), m.weekday(), baseMsg + ' lower');
+
+ r = moment(m.format(format), format, true);
+ assert.equal(r.weekday(), m.weekday(), baseMsg + ' strict');
+ r = moment(m.format(format).toLocaleUpperCase(), format, true);
+ assert.equal(r.weekday(), m.weekday(), baseMsg + ' upper strict');
+ r = moment(m.format(format).toLocaleLowerCase(), format, true);
+ assert.equal(r.weekday(), m.weekday(), baseMsg + ' lower strict');
+ }
+
+ for (i = 0; i < 7; ++i) {
+ m = moment.utc([2015, i, 15, 18]);
+ tester('dd');
+ tester('ddd');
+ tester('dddd');
+ }
+ });
+ }
+
+ function setupDeprecationHandler(test, moment, scope) {
+ test._expectedDeprecations = null;
+ test._observedDeprecations = null;
+ test._oldSupress = moment.suppressDeprecationWarnings;
+ moment.suppressDeprecationWarnings = true;
+ test.expectedDeprecations = function () {
+ test._expectedDeprecations = arguments;
+ test._observedDeprecations = [];
+ };
+ moment.deprecationHandler = function (name, msg) {
+ var deprecationId = matchedDeprecation(name, msg, test._expectedDeprecations);
+ if (deprecationId === -1) {
+ throw new Error('Unexpected deprecation thrown name=' +
+ name + ' msg=' + msg);
+ }
+ test._observedDeprecations[deprecationId] = 1;
+ };
+ }
+
+ function teardownDeprecationHandler(test, moment, scope) {
+ moment.suppressDeprecationWarnings = test._oldSupress;
+
+ if (test._expectedDeprecations != null) {
+ var missedDeprecations = [];
+ each(test._expectedDeprecations, function (deprecationPattern, id) {
+ if (test._observedDeprecations[id] !== 1) {
+ missedDeprecations.push(deprecationPattern);
+ }
+ });
+ if (missedDeprecations.length !== 0) {
+ throw new Error('Expected deprecation warnings did not happen: ' +
+ missedDeprecations.join(' '));
+ }
+ }
+ }
+
+ function matchedDeprecation(name, msg, deprecations) {
+ if (deprecations == null) {
+ return -1;
+ }
+ for (var i = 0; i < deprecations.length; ++i) {
+ if (name != null && name === deprecations[i]) {
+ return i;
+ }
+ if (msg != null && msg.substring(0, deprecations[i].length) === deprecations[i]) {
+ return i;
+ }
+ }
+ return -1;
+ }
/*global QUnit:false*/
@@ -11296,11 +15746,13 @@
moment.createFromInputFallback = function (config) {
throw new Error('input not handled by moment: ' + config._i);
};
+ setupDeprecationHandler(test, moment, 'core');
if (lifecycle && lifecycle.setup) {
lifecycle.setup();
}
},
teardown : function () {
+ teardownDeprecationHandler(test, moment, 'core');
if (lifecycle && lifecycle.teardown) {
lifecycle.teardown();
}
@@ -11315,17 +15767,20 @@
moment.createFromInputFallback = function (config) {
throw new Error('input not handled by moment: ' + config._i);
};
+ setupDeprecationHandler(test, moment, 'locale');
if (lifecycle && lifecycle.setup) {
lifecycle.setup();
}
},
teardown : function () {
moment.locale('en');
+ teardownDeprecationHandler(test, moment, 'locale');
if (lifecycle && lifecycle.teardown) {
lifecycle.teardown();
}
}
});
+ defineCommonLocaleTests(name, -1, -1);
}
localeModule('fa');
@@ -11472,14 +15927,14 @@
});
test('calendar day', function (assert) {
- var a = moment().hours(2).minutes(0).seconds(0);
-
- assert.equal(moment(a).calendar(), 'امروز ساعت ۰۲:۰۰', 'today at the same time');
- assert.equal(moment(a).add({m: 25}).calendar(), 'امروز ساعت ۰۲:۲۵', 'Now plus 25 min');
- assert.equal(moment(a).add({h: 1}).calendar(), 'امروز ساعت ۰۳:۰۰', 'Now plus 1 hour');
- assert.equal(moment(a).add({d: 1}).calendar(), 'فردا ساعت ۰۲:۰۰', 'tomorrow at the same time');
- assert.equal(moment(a).subtract({h: 1}).calendar(), 'امروز ساعت ۰۱:۰۰', 'Now minus 1 hour');
- assert.equal(moment(a).subtract({d: 1}).calendar(), 'دیروز ساعت ۰۲:۰۰', 'yesterday at the same time');
+ var a = moment().hours(12).minutes(0).seconds(0);
+
+ assert.equal(moment(a).calendar(), 'امروز ساعت ۱۲:۰۰', 'today at the same time');
+ assert.equal(moment(a).add({m: 25}).calendar(), 'امروز ساعت ۱۲:۲۵', 'Now plus 25 min');
+ assert.equal(moment(a).add({h: 1}).calendar(), 'امروز ساعت ۱۳:۰۰', 'Now plus 1 hour');
+ assert.equal(moment(a).add({d: 1}).calendar(), 'فردا ساعت ۱۲:۰۰', 'tomorrow at the same time');
+ assert.equal(moment(a).subtract({h: 1}).calendar(), 'امروز ساعت ۱۱:۰۰', 'Now minus 1 hour');
+ assert.equal(moment(a).subtract({d: 1}).calendar(), 'دیروز ساعت ۱۲:۰۰', 'yesterday at the same time');
});
test('calendar next week', function (assert) {
@@ -11520,65 +15975,6 @@
assert.equal(weeksFromNow.calendar(), weeksFromNow.format('L'), 'in 2 weeks');
});
- test('weeks year starting sunday', function (assert) {
- assert.equal(moment([2011, 11, 31]).week(), 1, 'Dec 31 2011 should be week 1');
- assert.equal(moment([2012, 0, 6]).week(), 1, 'Jan 6 2012 should be week 1');
- assert.equal(moment([2012, 0, 7]).week(), 2, 'Jan 7 2012 should be week 2');
- assert.equal(moment([2012, 0, 13]).week(), 2, 'Jan 13 2012 should be week 2');
- assert.equal(moment([2012, 0, 14]).week(), 3, 'Jan 14 2012 should be week 3');
- });
-
- test('weeks year starting monday', function (assert) {
- assert.equal(moment([2006, 11, 30]).week(), 1, 'Dec 30 2006 should be week 1');
- assert.equal(moment([2007, 0, 5]).week(), 1, 'Jan 5 2007 should be week 1');
- assert.equal(moment([2007, 0, 6]).week(), 2, 'Jan 6 2007 should be week 2');
- assert.equal(moment([2007, 0, 12]).week(), 2, 'Jan 12 2007 should be week 2');
- assert.equal(moment([2007, 0, 13]).week(), 3, 'Jan 13 2007 should be week 3');
- });
-
- test('weeks year starting tuesday', function (assert) {
- assert.equal(moment([2007, 11, 29]).week(), 1, 'Dec 29 2007 should be week 1');
- assert.equal(moment([2008, 0, 1]).week(), 1, 'Jan 1 2008 should be week 1');
- assert.equal(moment([2008, 0, 4]).week(), 1, 'Jan 4 2008 should be week 1');
- assert.equal(moment([2008, 0, 5]).week(), 2, 'Jan 5 2008 should be week 2');
- assert.equal(moment([2008, 0, 11]).week(), 2, 'Jan 11 2008 should be week 2');
- assert.equal(moment([2008, 0, 12]).week(), 3, 'Jan 12 2008 should be week 3');
- });
-
- test('weeks year starting wednesday', function (assert) {
- assert.equal(moment([2002, 11, 28]).week(), 1, 'Dec 28 2002 should be week 1');
- assert.equal(moment([2003, 0, 1]).week(), 1, 'Jan 1 2003 should be week 1');
- assert.equal(moment([2003, 0, 3]).week(), 1, 'Jan 3 2003 should be week 1');
- assert.equal(moment([2003, 0, 4]).week(), 2, 'Jan 4 2003 should be week 2');
- assert.equal(moment([2003, 0, 10]).week(), 2, 'Jan 10 2003 should be week 2');
- assert.equal(moment([2003, 0, 11]).week(), 3, 'Jan 11 2003 should be week 3');
- });
-
- test('weeks year starting thursday', function (assert) {
- assert.equal(moment([2008, 11, 27]).week(), 1, 'Dec 27 2008 should be week 1');
- assert.equal(moment([2009, 0, 1]).week(), 1, 'Jan 1 2009 should be week 1');
- assert.equal(moment([2009, 0, 2]).week(), 1, 'Jan 2 2009 should be week 1');
- assert.equal(moment([2009, 0, 3]).week(), 2, 'Jan 3 2009 should be week 2');
- assert.equal(moment([2009, 0, 9]).week(), 2, 'Jan 9 2009 should be week 2');
- assert.equal(moment([2009, 0, 10]).week(), 3, 'Jan 10 2009 should be week 3');
- });
-
- test('weeks year starting friday', function (assert) {
- assert.equal(moment([2009, 11, 26]).week(), 1, 'Dec 26 2009 should be week 1');
- assert.equal(moment([2010, 0, 1]).week(), 1, 'Jan 1 2010 should be week 1');
- assert.equal(moment([2010, 0, 2]).week(), 2, 'Jan 2 2010 should be week 2');
- assert.equal(moment([2010, 0, 8]).week(), 2, 'Jan 8 2010 should be week 2');
- assert.equal(moment([2010, 0, 9]).week(), 3, 'Jan 9 2010 should be week 3');
- });
-
- test('weeks year starting saturday', function (assert) {
- assert.equal(moment([2011, 0, 1]).week(), 1, 'Jan 1 2011 should be week 1');
- assert.equal(moment([2011, 0, 7]).week(), 1, 'Jan 7 2011 should be week 1');
- assert.equal(moment([2011, 0, 8]).week(), 2, 'Jan 8 2011 should be week 2');
- assert.equal(moment([2011, 0, 14]).week(), 2, 'Jan 14 2011 should be week 2');
- assert.equal(moment([2011, 0, 15]).week(), 3, 'Jan 15 2011 should be week 3');
- });
-
test('weeks year starting sunday formatted', function (assert) {
assert.equal(moment([2011, 11, 31]).format('w ww wo'), '۱ ۰۱ ۱م', 'Dec 31 2011 should be week 1');
assert.equal(moment([2012, 0, 6]).format('w ww wo'), '۱ ۰۱ ۱م', 'Jan 6 2012 should be week 1');
@@ -11587,42 +15983,6 @@
assert.equal(moment([2012, 0, 14]).format('w ww wo'), '۳ ۰۳ ۳م', 'Jan 14 2012 should be week 3');
});
- test('lenient ordinal parsing', function (assert) {
- var i, ordinalStr, testMoment;
- for (i = 1; i <= 31; ++i) {
- ordinalStr = moment([2014, 0, i]).format('YYYY MM Do');
- testMoment = moment(ordinalStr, 'YYYY MM Do');
- assert.equal(testMoment.year(), 2014,
- 'lenient ordinal parsing ' + i + ' year check');
- assert.equal(testMoment.month(), 0,
- 'lenient ordinal parsing ' + i + ' month check');
- assert.equal(testMoment.date(), i,
- 'lenient ordinal parsing ' + i + ' date check');
- }
- });
-
- test('lenient ordinal parsing of number', function (assert) {
- var i, testMoment;
- for (i = 1; i <= 31; ++i) {
- testMoment = moment('2014 01 ' + i, 'YYYY MM Do');
- assert.equal(testMoment.year(), 2014,
- 'lenient ordinal parsing of number ' + i + ' year check');
- assert.equal(testMoment.month(), 0,
- 'lenient ordinal parsing of number ' + i + ' month check');
- assert.equal(testMoment.date(), i,
- 'lenient ordinal parsing of number ' + i + ' date check');
- }
- });
-
- test('strict ordinal parsing', function (assert) {
- var i, ordinalStr, testMoment;
- for (i = 1; i <= 31; ++i) {
- ordinalStr = moment([2014, 0, i]).format('YYYY MM Do');
- testMoment = moment(ordinalStr, 'YYYY MM Do', true);
- assert.ok(testMoment.isValid(), 'strict ordinal parsing ' + i);
- }
- });
-
}));
;(function (global, factory) {
@@ -11631,6 +15991,224 @@
typeof define === 'function' && define.amd ? define(['../../moment'], factory) :
factory(global.moment)
}(this, function (moment) { 'use strict';
+
+ function each(array, callback) {
+ var i;
+ for (i = 0; i < array.length; i++) {
+ callback(array[i], i, array);
+ }
+ }
+
+ function objectKeys(obj) {
+ if (Object.keys) {
+ return Object.keys(obj);
+ } else {
+ // IE8
+ var res = [], i;
+ for (i in obj) {
+ if (obj.hasOwnProperty(i)) {
+ res.push(i);
+ }
+ }
+ return res;
+ }
+ }
+
+ // Pick the first defined of two or three arguments.
+ function defaults(a, b, c) {
+ if (a != null) {
+ return a;
+ }
+ if (b != null) {
+ return b;
+ }
+ return c;
+ }
+
+ function defineCommonLocaleTests(locale, options) {
+ test('lenient ordinal parsing', function (assert) {
+ var i, ordinalStr, testMoment;
+ for (i = 1; i <= 31; ++i) {
+ ordinalStr = moment([2014, 0, i]).format('YYYY MM Do');
+ testMoment = moment(ordinalStr, 'YYYY MM Do');
+ assert.equal(testMoment.year(), 2014,
+ 'lenient ordinal parsing ' + i + ' year check');
+ assert.equal(testMoment.month(), 0,
+ 'lenient ordinal parsing ' + i + ' month check');
+ assert.equal(testMoment.date(), i,
+ 'lenient ordinal parsing ' + i + ' date check');
+ }
+ });
+
+ test('lenient ordinal parsing of number', function (assert) {
+ var i, testMoment;
+ for (i = 1; i <= 31; ++i) {
+ testMoment = moment('2014 01 ' + i, 'YYYY MM Do');
+ assert.equal(testMoment.year(), 2014,
+ 'lenient ordinal parsing of number ' + i + ' year check');
+ assert.equal(testMoment.month(), 0,
+ 'lenient ordinal parsing of number ' + i + ' month check');
+ assert.equal(testMoment.date(), i,
+ 'lenient ordinal parsing of number ' + i + ' date check');
+ }
+ });
+
+ test('strict ordinal parsing', function (assert) {
+ var i, ordinalStr, testMoment;
+ for (i = 1; i <= 31; ++i) {
+ ordinalStr = moment([2014, 0, i]).format('YYYY MM Do');
+ testMoment = moment(ordinalStr, 'YYYY MM Do', true);
+ assert.ok(testMoment.isValid(), 'strict ordinal parsing ' + i);
+ }
+ });
+
+ test('meridiem invariant', function (assert) {
+ var h, m, t1, t2;
+ for (h = 0; h < 24; ++h) {
+ for (m = 0; m < 60; m += 15) {
+ t1 = moment.utc([2000, 0, 1, h, m]);
+ t2 = moment.utc(t1.format('A h:mm'), 'A h:mm');
+ assert.equal(t2.format('HH:mm'), t1.format('HH:mm'),
+ 'meridiem at ' + t1.format('HH:mm'));
+ }
+ }
+ });
+
+ test('date format correctness', function (assert) {
+ var data, tokens;
+ data = moment.localeData()._longDateFormat;
+ tokens = objectKeys(data);
+ each(tokens, function (srchToken) {
+ // Check each format string to make sure it does not contain any
+ // tokens that need to be expanded.
+ each(tokens, function (baseToken) {
+ // strip escaped sequences
+ var format = data[baseToken].replace(/(\[[^\]]*\])/g, '');
+ assert.equal(false, !!~format.indexOf(srchToken),
+ 'contains ' + srchToken + ' in ' + baseToken);
+ });
+ });
+ });
+
+ test('month parsing correctness', function (assert) {
+ var i, m;
+
+ if (locale === 'tr') {
+ // I can't fix it :(
+ expect(0);
+ return;
+ }
+ function tester(format) {
+ var r;
+ r = moment(m.format(format), format);
+ assert.equal(r.month(), m.month(), 'month ' + i + ' fmt ' + format);
+ r = moment(m.format(format).toLocaleUpperCase(), format);
+ assert.equal(r.month(), m.month(), 'month ' + i + ' fmt ' + format + ' upper');
+ r = moment(m.format(format).toLocaleLowerCase(), format);
+ assert.equal(r.month(), m.month(), 'month ' + i + ' fmt ' + format + ' lower');
+
+ r = moment(m.format(format), format, true);
+ assert.equal(r.month(), m.month(), 'month ' + i + ' fmt ' + format + ' strict');
+ r = moment(m.format(format).toLocaleUpperCase(), format, true);
+ assert.equal(r.month(), m.month(), 'month ' + i + ' fmt ' + format + ' upper strict');
+ r = moment(m.format(format).toLocaleLowerCase(), format, true);
+ assert.equal(r.month(), m.month(), 'month ' + i + ' fmt ' + format + ' lower strict');
+ }
+
+ for (i = 0; i < 12; ++i) {
+ m = moment([2015, i, 15, 18]);
+ tester('MMM');
+ tester('MMM.');
+ tester('MMMM');
+ tester('MMMM.');
+ }
+ });
+
+ test('weekday parsing correctness', function (assert) {
+ var i, m;
+
+ if (locale === 'tr' || locale === 'az') {
+ // There is a lower-case letter (ı), that converted to upper then
+ // lower changes to i
+ expect(0);
+ return;
+ }
+ function tester(format) {
+ var r, baseMsg = 'weekday ' + m.weekday() + ' fmt ' + format;
+ r = moment(m.format(format), format);
+ assert.equal(r.weekday(), m.weekday(), baseMsg);
+ r = moment(m.format(format).toLocaleUpperCase(), format);
+ assert.equal(r.weekday(), m.weekday(), baseMsg + ' upper');
+ r = moment(m.format(format).toLocaleLowerCase(), format);
+ assert.equal(r.weekday(), m.weekday(), baseMsg + ' lower');
+
+ r = moment(m.format(format), format, true);
+ assert.equal(r.weekday(), m.weekday(), baseMsg + ' strict');
+ r = moment(m.format(format).toLocaleUpperCase(), format, true);
+ assert.equal(r.weekday(), m.weekday(), baseMsg + ' upper strict');
+ r = moment(m.format(format).toLocaleLowerCase(), format, true);
+ assert.equal(r.weekday(), m.weekday(), baseMsg + ' lower strict');
+ }
+
+ for (i = 0; i < 7; ++i) {
+ m = moment.utc([2015, i, 15, 18]);
+ tester('dd');
+ tester('ddd');
+ tester('dddd');
+ }
+ });
+ }
+
+ function setupDeprecationHandler(test, moment, scope) {
+ test._expectedDeprecations = null;
+ test._observedDeprecations = null;
+ test._oldSupress = moment.suppressDeprecationWarnings;
+ moment.suppressDeprecationWarnings = true;
+ test.expectedDeprecations = function () {
+ test._expectedDeprecations = arguments;
+ test._observedDeprecations = [];
+ };
+ moment.deprecationHandler = function (name, msg) {
+ var deprecationId = matchedDeprecation(name, msg, test._expectedDeprecations);
+ if (deprecationId === -1) {
+ throw new Error('Unexpected deprecation thrown name=' +
+ name + ' msg=' + msg);
+ }
+ test._observedDeprecations[deprecationId] = 1;
+ };
+ }
+
+ function teardownDeprecationHandler(test, moment, scope) {
+ moment.suppressDeprecationWarnings = test._oldSupress;
+
+ if (test._expectedDeprecations != null) {
+ var missedDeprecations = [];
+ each(test._expectedDeprecations, function (deprecationPattern, id) {
+ if (test._observedDeprecations[id] !== 1) {
+ missedDeprecations.push(deprecationPattern);
+ }
+ });
+ if (missedDeprecations.length !== 0) {
+ throw new Error('Expected deprecation warnings did not happen: ' +
+ missedDeprecations.join(' '));
+ }
+ }
+ }
+
+ function matchedDeprecation(name, msg, deprecations) {
+ if (deprecations == null) {
+ return -1;
+ }
+ for (var i = 0; i < deprecations.length; ++i) {
+ if (name != null && name === deprecations[i]) {
+ return i;
+ }
+ if (msg != null && msg.substring(0, deprecations[i].length) === deprecations[i]) {
+ return i;
+ }
+ }
+ return -1;
+ }
/*global QUnit:false*/
@@ -11645,11 +16223,13 @@
moment.createFromInputFallback = function (config) {
throw new Error('input not handled by moment: ' + config._i);
};
+ setupDeprecationHandler(test, moment, 'core');
if (lifecycle && lifecycle.setup) {
lifecycle.setup();
}
},
teardown : function () {
+ teardownDeprecationHandler(test, moment, 'core');
if (lifecycle && lifecycle.teardown) {
lifecycle.teardown();
}
@@ -11664,17 +16244,20 @@
moment.createFromInputFallback = function (config) {
throw new Error('input not handled by moment: ' + config._i);
};
+ setupDeprecationHandler(test, moment, 'locale');
if (lifecycle && lifecycle.setup) {
lifecycle.setup();
}
},
teardown : function () {
moment.locale('en');
+ teardownDeprecationHandler(test, moment, 'locale');
if (lifecycle && lifecycle.teardown) {
lifecycle.teardown();
}
}
});
+ defineCommonLocaleTests(name, -1, -1);
}
localeModule('fi');
@@ -11828,14 +16411,14 @@
});
test('calendar day', function (assert) {
- var a = moment().hours(2).minutes(0).seconds(0);
-
- assert.equal(moment(a).calendar(), 'tänään klo 02.00', 'today at the same time');
- assert.equal(moment(a).add({m: 25}).calendar(), 'tänään klo 02.25', 'Now plus 25 min');
- assert.equal(moment(a).add({h: 1}).calendar(), 'tänään klo 03.00', 'Now plus 1 hour');
- assert.equal(moment(a).add({d: 1}).calendar(), 'huomenna klo 02.00', 'tomorrow at the same time');
- assert.equal(moment(a).subtract({h: 1}).calendar(), 'tänään klo 01.00', 'Now minus 1 hour');
- assert.equal(moment(a).subtract({d: 1}).calendar(), 'eilen klo 02.00', 'yesterday at the same time');
+ var a = moment().hours(12).minutes(0).seconds(0);
+
+ assert.equal(moment(a).calendar(), 'tänään klo 12.00', 'today at the same time');
+ assert.equal(moment(a).add({m: 25}).calendar(), 'tänään klo 12.25', 'Now plus 25 min');
+ assert.equal(moment(a).add({h: 1}).calendar(), 'tänään klo 13.00', 'Now plus 1 hour');
+ assert.equal(moment(a).add({d: 1}).calendar(), 'huomenna klo 12.00', 'tomorrow at the same time');
+ assert.equal(moment(a).subtract({h: 1}).calendar(), 'tänään klo 11.00', 'Now minus 1 hour');
+ assert.equal(moment(a).subtract({d: 1}).calendar(), 'eilen klo 12.00', 'yesterday at the same time');
});
test('calendar next week', function (assert) {
@@ -11877,67 +16460,6 @@
assert.equal(weeksFromNow.calendar(), weeksFromNow.format('L'), 'kaden viikon päästä');
});
- test('weeks year starting sunday', function (assert) {
- assert.equal(moment([2012, 0, 1]).week(), 52, 'Jan 1 2012 should be week 52');
- assert.equal(moment([2012, 0, 2]).week(), 1, 'Jan 2 2012 should be week 1');
- assert.equal(moment([2012, 0, 8]).week(), 1, 'Jan 8 2012 should be week 1');
- assert.equal(moment([2012, 0, 9]).week(), 2, 'Jan 9 2012 should be week 2');
- assert.equal(moment([2012, 0, 15]).week(), 2, 'Jan 15 2012 should be week 2');
- });
-
- test('weeks year starting monday', function (assert) {
- assert.equal(moment([2007, 0, 1]).week(), 1, 'Jan 1 2007 should be week 1');
- assert.equal(moment([2007, 0, 7]).week(), 1, 'Jan 7 2007 should be week 1');
- assert.equal(moment([2007, 0, 8]).week(), 2, 'Jan 8 2007 should be week 2');
- assert.equal(moment([2007, 0, 14]).week(), 2, 'Jan 14 2007 should be week 2');
- assert.equal(moment([2007, 0, 15]).week(), 3, 'Jan 15 2007 should be week 3');
- });
-
- test('weeks year starting tuesday', function (assert) {
- assert.equal(moment([2007, 11, 31]).week(), 1, 'Dec 31 2007 should be week 1');
- assert.equal(moment([2008, 0, 1]).week(), 1, 'Jan 1 2008 should be week 1');
- assert.equal(moment([2008, 0, 6]).week(), 1, 'Jan 6 2008 should be week 1');
- assert.equal(moment([2008, 0, 7]).week(), 2, 'Jan 7 2008 should be week 2');
- assert.equal(moment([2008, 0, 13]).week(), 2, 'Jan 13 2008 should be week 2');
- assert.equal(moment([2008, 0, 14]).week(), 3, 'Jan 14 2008 should be week 3');
- });
-
- test('weeks year starting wednesday', function (assert) {
- assert.equal(moment([2002, 11, 30]).week(), 1, 'Dec 30 2002 should be week 1');
- assert.equal(moment([2003, 0, 1]).week(), 1, 'Jan 1 2003 should be week 1');
- assert.equal(moment([2003, 0, 5]).week(), 1, 'Jan 5 2003 should be week 1');
- assert.equal(moment([2003, 0, 6]).week(), 2, 'Jan 6 2003 should be week 2');
- assert.equal(moment([2003, 0, 12]).week(), 2, 'Jan 12 2003 should be week 2');
- assert.equal(moment([2003, 0, 13]).week(), 3, 'Jan 13 2003 should be week 3');
- });
-
- test('weeks year starting thursday', function (assert) {
- assert.equal(moment([2008, 11, 29]).week(), 1, 'Dec 29 2008 should be week 1');
- assert.equal(moment([2009, 0, 1]).week(), 1, 'Jan 1 2009 should be week 1');
- assert.equal(moment([2009, 0, 4]).week(), 1, 'Jan 4 2009 should be week 1');
- assert.equal(moment([2009, 0, 5]).week(), 2, 'Jan 5 2009 should be week 2');
- assert.equal(moment([2009, 0, 11]).week(), 2, 'Jan 11 2009 should be week 2');
- assert.equal(moment([2009, 0, 13]).week(), 3, 'Jan 12 2009 should be week 3');
- });
-
- test('weeks year starting friday', function (assert) {
- assert.equal(moment([2009, 11, 28]).week(), 53, 'Dec 28 2009 should be week 53');
- assert.equal(moment([2010, 0, 1]).week(), 53, 'Jan 1 2010 should be week 53');
- assert.equal(moment([2010, 0, 3]).week(), 53, 'Jan 3 2010 should be week 53');
- assert.equal(moment([2010, 0, 4]).week(), 1, 'Jan 4 2010 should be week 1');
- assert.equal(moment([2010, 0, 10]).week(), 1, 'Jan 10 2010 should be week 1');
- assert.equal(moment([2010, 0, 11]).week(), 2, 'Jan 11 2010 should be week 2');
- });
-
- test('weeks year starting saturday', function (assert) {
- assert.equal(moment([2010, 11, 27]).week(), 52, 'Dec 27 2010 should be week 52');
- assert.equal(moment([2011, 0, 1]).week(), 52, 'Jan 1 2011 should be week 52');
- assert.equal(moment([2011, 0, 2]).week(), 52, 'Jan 2 2011 should be week 52');
- assert.equal(moment([2011, 0, 3]).week(), 1, 'Jan 3 2011 should be week 1');
- assert.equal(moment([2011, 0, 9]).week(), 1, 'Jan 9 2011 should be week 1');
- assert.equal(moment([2011, 0, 10]).week(), 2, 'Jan 10 2011 should be week 2');
- });
-
test('weeks year starting sunday formatted', function (assert) {
assert.equal(moment([2012, 0, 1]).format('w ww wo'), '52 52 52.', 'Jan 1 2012 should be week 52');
assert.equal(moment([2012, 0, 2]).format('w ww wo'), '1 01 1.', 'Jan 2 2012 should be week 1');
@@ -11946,42 +16468,6 @@
assert.equal(moment([2012, 0, 15]).format('w ww wo'), '2 02 2.', 'Jan 15 2012 should be week 2');
});
- test('lenient ordinal parsing', function (assert) {
- var i, ordinalStr, testMoment;
- for (i = 1; i <= 31; ++i) {
- ordinalStr = moment([2014, 0, i]).format('YYYY MM Do');
- testMoment = moment(ordinalStr, 'YYYY MM Do');
- assert.equal(testMoment.year(), 2014,
- 'lenient ordinal parsing ' + i + ' year check');
- assert.equal(testMoment.month(), 0,
- 'lenient ordinal parsing ' + i + ' month check');
- assert.equal(testMoment.date(), i,
- 'lenient ordinal parsing ' + i + ' date check');
- }
- });
-
- test('lenient ordinal parsing of number', function (assert) {
- var i, testMoment;
- for (i = 1; i <= 31; ++i) {
- testMoment = moment('2014 01 ' + i, 'YYYY MM Do');
- assert.equal(testMoment.year(), 2014,
- 'lenient ordinal parsing of number ' + i + ' year check');
- assert.equal(testMoment.month(), 0,
- 'lenient ordinal parsing of number ' + i + ' month check');
- assert.equal(testMoment.date(), i,
- 'lenient ordinal parsing of number ' + i + ' date check');
- }
- });
-
- test('strict ordinal parsing', function (assert) {
- var i, ordinalStr, testMoment;
- for (i = 1; i <= 31; ++i) {
- ordinalStr = moment([2014, 0, i]).format('YYYY MM Do');
- testMoment = moment(ordinalStr, 'YYYY MM Do', true);
- assert.ok(testMoment.isValid(), 'strict ordinal parsing ' + i);
- }
- });
-
}));
;(function (global, factory) {
@@ -11990,6 +16476,224 @@
typeof define === 'function' && define.amd ? define(['../../moment'], factory) :
factory(global.moment)
}(this, function (moment) { 'use strict';
+
+ function each(array, callback) {
+ var i;
+ for (i = 0; i < array.length; i++) {
+ callback(array[i], i, array);
+ }
+ }
+
+ function objectKeys(obj) {
+ if (Object.keys) {
+ return Object.keys(obj);
+ } else {
+ // IE8
+ var res = [], i;
+ for (i in obj) {
+ if (obj.hasOwnProperty(i)) {
+ res.push(i);
+ }
+ }
+ return res;
+ }
+ }
+
+ // Pick the first defined of two or three arguments.
+ function defaults(a, b, c) {
+ if (a != null) {
+ return a;
+ }
+ if (b != null) {
+ return b;
+ }
+ return c;
+ }
+
+ function defineCommonLocaleTests(locale, options) {
+ test('lenient ordinal parsing', function (assert) {
+ var i, ordinalStr, testMoment;
+ for (i = 1; i <= 31; ++i) {
+ ordinalStr = moment([2014, 0, i]).format('YYYY MM Do');
+ testMoment = moment(ordinalStr, 'YYYY MM Do');
+ assert.equal(testMoment.year(), 2014,
+ 'lenient ordinal parsing ' + i + ' year check');
+ assert.equal(testMoment.month(), 0,
+ 'lenient ordinal parsing ' + i + ' month check');
+ assert.equal(testMoment.date(), i,
+ 'lenient ordinal parsing ' + i + ' date check');
+ }
+ });
+
+ test('lenient ordinal parsing of number', function (assert) {
+ var i, testMoment;
+ for (i = 1; i <= 31; ++i) {
+ testMoment = moment('2014 01 ' + i, 'YYYY MM Do');
+ assert.equal(testMoment.year(), 2014,
+ 'lenient ordinal parsing of number ' + i + ' year check');
+ assert.equal(testMoment.month(), 0,
+ 'lenient ordinal parsing of number ' + i + ' month check');
+ assert.equal(testMoment.date(), i,
+ 'lenient ordinal parsing of number ' + i + ' date check');
+ }
+ });
+
+ test('strict ordinal parsing', function (assert) {
+ var i, ordinalStr, testMoment;
+ for (i = 1; i <= 31; ++i) {
+ ordinalStr = moment([2014, 0, i]).format('YYYY MM Do');
+ testMoment = moment(ordinalStr, 'YYYY MM Do', true);
+ assert.ok(testMoment.isValid(), 'strict ordinal parsing ' + i);
+ }
+ });
+
+ test('meridiem invariant', function (assert) {
+ var h, m, t1, t2;
+ for (h = 0; h < 24; ++h) {
+ for (m = 0; m < 60; m += 15) {
+ t1 = moment.utc([2000, 0, 1, h, m]);
+ t2 = moment.utc(t1.format('A h:mm'), 'A h:mm');
+ assert.equal(t2.format('HH:mm'), t1.format('HH:mm'),
+ 'meridiem at ' + t1.format('HH:mm'));
+ }
+ }
+ });
+
+ test('date format correctness', function (assert) {
+ var data, tokens;
+ data = moment.localeData()._longDateFormat;
+ tokens = objectKeys(data);
+ each(tokens, function (srchToken) {
+ // Check each format string to make sure it does not contain any
+ // tokens that need to be expanded.
+ each(tokens, function (baseToken) {
+ // strip escaped sequences
+ var format = data[baseToken].replace(/(\[[^\]]*\])/g, '');
+ assert.equal(false, !!~format.indexOf(srchToken),
+ 'contains ' + srchToken + ' in ' + baseToken);
+ });
+ });
+ });
+
+ test('month parsing correctness', function (assert) {
+ var i, m;
+
+ if (locale === 'tr') {
+ // I can't fix it :(
+ expect(0);
+ return;
+ }
+ function tester(format) {
+ var r;
+ r = moment(m.format(format), format);
+ assert.equal(r.month(), m.month(), 'month ' + i + ' fmt ' + format);
+ r = moment(m.format(format).toLocaleUpperCase(), format);
+ assert.equal(r.month(), m.month(), 'month ' + i + ' fmt ' + format + ' upper');
+ r = moment(m.format(format).toLocaleLowerCase(), format);
+ assert.equal(r.month(), m.month(), 'month ' + i + ' fmt ' + format + ' lower');
+
+ r = moment(m.format(format), format, true);
+ assert.equal(r.month(), m.month(), 'month ' + i + ' fmt ' + format + ' strict');
+ r = moment(m.format(format).toLocaleUpperCase(), format, true);
+ assert.equal(r.month(), m.month(), 'month ' + i + ' fmt ' + format + ' upper strict');
+ r = moment(m.format(format).toLocaleLowerCase(), format, true);
+ assert.equal(r.month(), m.month(), 'month ' + i + ' fmt ' + format + ' lower strict');
+ }
+
+ for (i = 0; i < 12; ++i) {
+ m = moment([2015, i, 15, 18]);
+ tester('MMM');
+ tester('MMM.');
+ tester('MMMM');
+ tester('MMMM.');
+ }
+ });
+
+ test('weekday parsing correctness', function (assert) {
+ var i, m;
+
+ if (locale === 'tr' || locale === 'az') {
+ // There is a lower-case letter (ı), that converted to upper then
+ // lower changes to i
+ expect(0);
+ return;
+ }
+ function tester(format) {
+ var r, baseMsg = 'weekday ' + m.weekday() + ' fmt ' + format;
+ r = moment(m.format(format), format);
+ assert.equal(r.weekday(), m.weekday(), baseMsg);
+ r = moment(m.format(format).toLocaleUpperCase(), format);
+ assert.equal(r.weekday(), m.weekday(), baseMsg + ' upper');
+ r = moment(m.format(format).toLocaleLowerCase(), format);
+ assert.equal(r.weekday(), m.weekday(), baseMsg + ' lower');
+
+ r = moment(m.format(format), format, true);
+ assert.equal(r.weekday(), m.weekday(), baseMsg + ' strict');
+ r = moment(m.format(format).toLocaleUpperCase(), format, true);
+ assert.equal(r.weekday(), m.weekday(), baseMsg + ' upper strict');
+ r = moment(m.format(format).toLocaleLowerCase(), format, true);
+ assert.equal(r.weekday(), m.weekday(), baseMsg + ' lower strict');
+ }
+
+ for (i = 0; i < 7; ++i) {
+ m = moment.utc([2015, i, 15, 18]);
+ tester('dd');
+ tester('ddd');
+ tester('dddd');
+ }
+ });
+ }
+
+ function setupDeprecationHandler(test, moment, scope) {
+ test._expectedDeprecations = null;
+ test._observedDeprecations = null;
+ test._oldSupress = moment.suppressDeprecationWarnings;
+ moment.suppressDeprecationWarnings = true;
+ test.expectedDeprecations = function () {
+ test._expectedDeprecations = arguments;
+ test._observedDeprecations = [];
+ };
+ moment.deprecationHandler = function (name, msg) {
+ var deprecationId = matchedDeprecation(name, msg, test._expectedDeprecations);
+ if (deprecationId === -1) {
+ throw new Error('Unexpected deprecation thrown name=' +
+ name + ' msg=' + msg);
+ }
+ test._observedDeprecations[deprecationId] = 1;
+ };
+ }
+
+ function teardownDeprecationHandler(test, moment, scope) {
+ moment.suppressDeprecationWarnings = test._oldSupress;
+
+ if (test._expectedDeprecations != null) {
+ var missedDeprecations = [];
+ each(test._expectedDeprecations, function (deprecationPattern, id) {
+ if (test._observedDeprecations[id] !== 1) {
+ missedDeprecations.push(deprecationPattern);
+ }
+ });
+ if (missedDeprecations.length !== 0) {
+ throw new Error('Expected deprecation warnings did not happen: ' +
+ missedDeprecations.join(' '));
+ }
+ }
+ }
+
+ function matchedDeprecation(name, msg, deprecations) {
+ if (deprecations == null) {
+ return -1;
+ }
+ for (var i = 0; i < deprecations.length; ++i) {
+ if (name != null && name === deprecations[i]) {
+ return i;
+ }
+ if (msg != null && msg.substring(0, deprecations[i].length) === deprecations[i]) {
+ return i;
+ }
+ }
+ return -1;
+ }
/*global QUnit:false*/
@@ -12004,11 +16708,13 @@
moment.createFromInputFallback = function (config) {
throw new Error('input not handled by moment: ' + config._i);
};
+ setupDeprecationHandler(test, moment, 'core');
if (lifecycle && lifecycle.setup) {
lifecycle.setup();
}
},
teardown : function () {
+ teardownDeprecationHandler(test, moment, 'core');
if (lifecycle && lifecycle.teardown) {
lifecycle.teardown();
}
@@ -12023,17 +16729,20 @@
moment.createFromInputFallback = function (config) {
throw new Error('input not handled by moment: ' + config._i);
};
+ setupDeprecationHandler(test, moment, 'locale');
if (lifecycle && lifecycle.setup) {
lifecycle.setup();
}
},
teardown : function () {
moment.locale('en');
+ teardownDeprecationHandler(test, moment, 'locale');
if (lifecycle && lifecycle.teardown) {
lifecycle.teardown();
}
}
});
+ defineCommonLocaleTests(name, -1, -1);
}
localeModule('fo');
@@ -12186,65 +16895,55 @@
assert.equal(moment().add({d: 5}).fromNow(), 'um 5 dagar', 'in 5 days');
});
- test('weeks year starting sunday', function (assert) {
- assert.equal(moment([2012, 0, 1]).week(), 52, 'Jan 1 2012 should be week 52');
- assert.equal(moment([2012, 0, 2]).week(), 1, 'Jan 2 2012 should be week 1');
- assert.equal(moment([2012, 0, 8]).week(), 1, 'Jan 8 2012 should be week 1');
- assert.equal(moment([2012, 0, 9]).week(), 2, 'Jan 9 2012 should be week 2');
- assert.equal(moment([2012, 0, 15]).week(), 2, 'Jan 15 2012 should be week 2');
- });
-
- test('weeks year starting monday', function (assert) {
- assert.equal(moment([2007, 0, 1]).week(), 1, 'Jan 1 2007 should be week 1');
- assert.equal(moment([2007, 0, 7]).week(), 1, 'Jan 7 2007 should be week 1');
- assert.equal(moment([2007, 0, 8]).week(), 2, 'Jan 8 2007 should be week 2');
- assert.equal(moment([2007, 0, 14]).week(), 2, 'Jan 14 2007 should be week 2');
- assert.equal(moment([2007, 0, 15]).week(), 3, 'Jan 15 2007 should be week 3');
- });
-
- test('weeks year starting tuesday', function (assert) {
- assert.equal(moment([2007, 11, 31]).week(), 1, 'Dec 31 2007 should be week 1');
- assert.equal(moment([2008, 0, 1]).week(), 1, 'Jan 1 2008 should be week 1');
- assert.equal(moment([2008, 0, 6]).week(), 1, 'Jan 6 2008 should be week 1');
- assert.equal(moment([2008, 0, 7]).week(), 2, 'Jan 7 2008 should be week 2');
- assert.equal(moment([2008, 0, 13]).week(), 2, 'Jan 13 2008 should be week 2');
- assert.equal(moment([2008, 0, 14]).week(), 3, 'Jan 14 2008 should be week 3');
- });
-
- test('weeks year starting wednesday', function (assert) {
- assert.equal(moment([2002, 11, 30]).week(), 1, 'Dec 30 2002 should be week 1');
- assert.equal(moment([2003, 0, 1]).week(), 1, 'Jan 1 2003 should be week 1');
- assert.equal(moment([2003, 0, 5]).week(), 1, 'Jan 5 2003 should be week 1');
- assert.equal(moment([2003, 0, 6]).week(), 2, 'Jan 6 2003 should be week 2');
- assert.equal(moment([2003, 0, 12]).week(), 2, 'Jan 12 2003 should be week 2');
- assert.equal(moment([2003, 0, 13]).week(), 3, 'Jan 13 2003 should be week 3');
- });
-
- test('weeks year starting thursday', function (assert) {
- assert.equal(moment([2008, 11, 29]).week(), 1, 'Dec 29 2008 should be week 1');
- assert.equal(moment([2009, 0, 1]).week(), 1, 'Jan 1 2009 should be week 1');
- assert.equal(moment([2009, 0, 4]).week(), 1, 'Jan 4 2009 should be week 1');
- assert.equal(moment([2009, 0, 5]).week(), 2, 'Jan 5 2009 should be week 2');
- assert.equal(moment([2009, 0, 11]).week(), 2, 'Jan 11 2009 should be week 2');
- assert.equal(moment([2009, 0, 13]).week(), 3, 'Jan 12 2009 should be week 3');
- });
-
- test('weeks year starting friday', function (assert) {
- assert.equal(moment([2009, 11, 28]).week(), 53, 'Dec 28 2009 should be week 53');
- assert.equal(moment([2010, 0, 1]).week(), 53, 'Jan 1 2010 should be week 53');
- assert.equal(moment([2010, 0, 3]).week(), 53, 'Jan 3 2010 should be week 53');
- assert.equal(moment([2010, 0, 4]).week(), 1, 'Jan 4 2010 should be week 1');
- assert.equal(moment([2010, 0, 10]).week(), 1, 'Jan 10 2010 should be week 1');
- assert.equal(moment([2010, 0, 11]).week(), 2, 'Jan 11 2010 should be week 2');
- });
-
- test('weeks year starting saturday', function (assert) {
- assert.equal(moment([2010, 11, 27]).week(), 52, 'Dec 27 2010 should be week 52');
- assert.equal(moment([2011, 0, 1]).week(), 52, 'Jan 1 2011 should be week 52');
- assert.equal(moment([2011, 0, 2]).week(), 52, 'Jan 2 2011 should be week 52');
- assert.equal(moment([2011, 0, 3]).week(), 1, 'Jan 3 2011 should be week 1');
- assert.equal(moment([2011, 0, 9]).week(), 1, 'Jan 9 2011 should be week 1');
- assert.equal(moment([2011, 0, 10]).week(), 2, 'Jan 10 2011 should be week 2');
+
+ test('calendar day', function (assert) {
+ var a = moment().hours(12).minutes(0).seconds(0);
+
+ assert.equal(moment(a).calendar(), 'Í dag kl. 12:00', 'today at the same time');
+ assert.equal(moment(a).add({m: 25}).calendar(), 'Í dag kl. 12:25', 'Now plus 25 min');
+ assert.equal(moment(a).add({h: 1}).calendar(), 'Í dag kl. 13:00', 'Now plus 1 hour');
+ assert.equal(moment(a).add({d: 1}).calendar(), 'Í morgin kl. 12:00', 'tomorrow at the same time');
+ assert.equal(moment(a).subtract({h: 1}).calendar(), 'Í dag kl. 11:00', 'Now minus 1 hour');
+ assert.equal(moment(a).subtract({d: 1}).calendar(), 'Í gjár kl. 12:00', 'yesterday at the same time');
+ });
+
+ test('calendar next week', function (assert) {
+ var i, m;
+
+ for (i = 2; i < 7; i++) {
+ m = moment().add({d: i});
+ assert.equal(m.calendar(), m.format('dddd [kl.] LT'), 'today + ' + i + ' days current time');
+ m.hours(0).minutes(0).seconds(0).milliseconds(0);
+ assert.equal(m.calendar(), m.format('dddd [kl.] LT'), 'today + ' + i + ' days beginning of day');
+ m.hours(23).minutes(59).seconds(59).milliseconds(999);
+ assert.equal(m.calendar(), m.format('dddd [kl.] LT'), 'today + ' + i + ' days end of day');
+ }
+ });
+
+ test('calendar last week', function (assert) {
+ var i, m;
+ for (i = 2; i < 7; i++) {
+ m = moment().subtract({d: i});
+ assert.equal(m.calendar(), m.format('[síðstu] dddd [kl] LT'), 'today - ' + i + ' days current time');
+ m.hours(0).minutes(0).seconds(0).milliseconds(0);
+ assert.equal(m.calendar(), m.format('[síðstu] dddd [kl] LT'), 'today - ' + i + ' days beginning of day');
+ m.hours(23).minutes(59).seconds(59).milliseconds(999);
+ assert.equal(m.calendar(), m.format('[síðstu] dddd [kl] LT'), 'today - ' + i + ' days end of day');
+ }
+ });
+
+ test('calendar all else', function (assert) {
+ var weeksAgo = moment().subtract({w: 1}),
+ weeksFromNow = moment().add({w: 1});
+
+ assert.equal(weeksAgo.calendar(), weeksAgo.format('L'), 'yksi viikko sitten');
+ assert.equal(weeksFromNow.calendar(), weeksFromNow.format('L'), 'yhden viikon päästä');
+
+ weeksAgo = moment().subtract({w: 2});
+ weeksFromNow = moment().add({w: 2});
+
+ assert.equal(weeksAgo.calendar(), weeksAgo.format('L'), 'kaksi viikkoa sitten');
+ assert.equal(weeksFromNow.calendar(), weeksFromNow.format('L'), 'kaden viikon päästä');
});
test('weeks year starting sunday formatted', function (assert) {
@@ -12255,42 +16954,6 @@
assert.equal(moment([2012, 0, 15]).format('w ww wo'), '2 02 2.', 'Jan 15 2012 should be week 2');
});
- test('lenient ordinal parsing', function (assert) {
- var i, ordinalStr, testMoment;
- for (i = 1; i <= 31; ++i) {
- ordinalStr = moment([2014, 0, i]).format('YYYY MM Do');
- testMoment = moment(ordinalStr, 'YYYY MM Do');
- assert.equal(testMoment.year(), 2014,
- 'lenient ordinal parsing ' + i + ' year check');
- assert.equal(testMoment.month(), 0,
- 'lenient ordinal parsing ' + i + ' month check');
- assert.equal(testMoment.date(), i,
- 'lenient ordinal parsing ' + i + ' date check');
- }
- });
-
- test('lenient ordinal parsing of number', function (assert) {
- var i, testMoment;
- for (i = 1; i <= 31; ++i) {
- testMoment = moment('2014 01 ' + i, 'YYYY MM Do');
- assert.equal(testMoment.year(), 2014,
- 'lenient ordinal parsing of number ' + i + ' year check');
- assert.equal(testMoment.month(), 0,
- 'lenient ordinal parsing of number ' + i + ' month check');
- assert.equal(testMoment.date(), i,
- 'lenient ordinal parsing of number ' + i + ' date check');
- }
- });
-
- test('strict ordinal parsing', function (assert) {
- var i, ordinalStr, testMoment;
- for (i = 1; i <= 31; ++i) {
- ordinalStr = moment([2014, 0, i]).format('YYYY MM Do');
- testMoment = moment(ordinalStr, 'YYYY MM Do', true);
- assert.ok(testMoment.isValid(), 'strict ordinal parsing ' + i);
- }
- });
-
}));
;(function (global, factory) {
@@ -12299,6 +16962,224 @@
typeof define === 'function' && define.amd ? define(['../../moment'], factory) :
factory(global.moment)
}(this, function (moment) { 'use strict';
+
+ function each(array, callback) {
+ var i;
+ for (i = 0; i < array.length; i++) {
+ callback(array[i], i, array);
+ }
+ }
+
+ function objectKeys(obj) {
+ if (Object.keys) {
+ return Object.keys(obj);
+ } else {
+ // IE8
+ var res = [], i;
+ for (i in obj) {
+ if (obj.hasOwnProperty(i)) {
+ res.push(i);
+ }
+ }
+ return res;
+ }
+ }
+
+ // Pick the first defined of two or three arguments.
+ function defaults(a, b, c) {
+ if (a != null) {
+ return a;
+ }
+ if (b != null) {
+ return b;
+ }
+ return c;
+ }
+
+ function defineCommonLocaleTests(locale, options) {
+ test('lenient ordinal parsing', function (assert) {
+ var i, ordinalStr, testMoment;
+ for (i = 1; i <= 31; ++i) {
+ ordinalStr = moment([2014, 0, i]).format('YYYY MM Do');
+ testMoment = moment(ordinalStr, 'YYYY MM Do');
+ assert.equal(testMoment.year(), 2014,
+ 'lenient ordinal parsing ' + i + ' year check');
+ assert.equal(testMoment.month(), 0,
+ 'lenient ordinal parsing ' + i + ' month check');
+ assert.equal(testMoment.date(), i,
+ 'lenient ordinal parsing ' + i + ' date check');
+ }
+ });
+
+ test('lenient ordinal parsing of number', function (assert) {
+ var i, testMoment;
+ for (i = 1; i <= 31; ++i) {
+ testMoment = moment('2014 01 ' + i, 'YYYY MM Do');
+ assert.equal(testMoment.year(), 2014,
+ 'lenient ordinal parsing of number ' + i + ' year check');
+ assert.equal(testMoment.month(), 0,
+ 'lenient ordinal parsing of number ' + i + ' month check');
+ assert.equal(testMoment.date(), i,
+ 'lenient ordinal parsing of number ' + i + ' date check');
+ }
+ });
+
+ test('strict ordinal parsing', function (assert) {
+ var i, ordinalStr, testMoment;
+ for (i = 1; i <= 31; ++i) {
+ ordinalStr = moment([2014, 0, i]).format('YYYY MM Do');
+ testMoment = moment(ordinalStr, 'YYYY MM Do', true);
+ assert.ok(testMoment.isValid(), 'strict ordinal parsing ' + i);
+ }
+ });
+
+ test('meridiem invariant', function (assert) {
+ var h, m, t1, t2;
+ for (h = 0; h < 24; ++h) {
+ for (m = 0; m < 60; m += 15) {
+ t1 = moment.utc([2000, 0, 1, h, m]);
+ t2 = moment.utc(t1.format('A h:mm'), 'A h:mm');
+ assert.equal(t2.format('HH:mm'), t1.format('HH:mm'),
+ 'meridiem at ' + t1.format('HH:mm'));
+ }
+ }
+ });
+
+ test('date format correctness', function (assert) {
+ var data, tokens;
+ data = moment.localeData()._longDateFormat;
+ tokens = objectKeys(data);
+ each(tokens, function (srchToken) {
+ // Check each format string to make sure it does not contain any
+ // tokens that need to be expanded.
+ each(tokens, function (baseToken) {
+ // strip escaped sequences
+ var format = data[baseToken].replace(/(\[[^\]]*\])/g, '');
+ assert.equal(false, !!~format.indexOf(srchToken),
+ 'contains ' + srchToken + ' in ' + baseToken);
+ });
+ });
+ });
+
+ test('month parsing correctness', function (assert) {
+ var i, m;
+
+ if (locale === 'tr') {
+ // I can't fix it :(
+ expect(0);
+ return;
+ }
+ function tester(format) {
+ var r;
+ r = moment(m.format(format), format);
+ assert.equal(r.month(), m.month(), 'month ' + i + ' fmt ' + format);
+ r = moment(m.format(format).toLocaleUpperCase(), format);
+ assert.equal(r.month(), m.month(), 'month ' + i + ' fmt ' + format + ' upper');
+ r = moment(m.format(format).toLocaleLowerCase(), format);
+ assert.equal(r.month(), m.month(), 'month ' + i + ' fmt ' + format + ' lower');
+
+ r = moment(m.format(format), format, true);
+ assert.equal(r.month(), m.month(), 'month ' + i + ' fmt ' + format + ' strict');
+ r = moment(m.format(format).toLocaleUpperCase(), format, true);
+ assert.equal(r.month(), m.month(), 'month ' + i + ' fmt ' + format + ' upper strict');
+ r = moment(m.format(format).toLocaleLowerCase(), format, true);
+ assert.equal(r.month(), m.month(), 'month ' + i + ' fmt ' + format + ' lower strict');
+ }
+
+ for (i = 0; i < 12; ++i) {
+ m = moment([2015, i, 15, 18]);
+ tester('MMM');
+ tester('MMM.');
+ tester('MMMM');
+ tester('MMMM.');
+ }
+ });
+
+ test('weekday parsing correctness', function (assert) {
+ var i, m;
+
+ if (locale === 'tr' || locale === 'az') {
+ // There is a lower-case letter (ı), that converted to upper then
+ // lower changes to i
+ expect(0);
+ return;
+ }
+ function tester(format) {
+ var r, baseMsg = 'weekday ' + m.weekday() + ' fmt ' + format;
+ r = moment(m.format(format), format);
+ assert.equal(r.weekday(), m.weekday(), baseMsg);
+ r = moment(m.format(format).toLocaleUpperCase(), format);
+ assert.equal(r.weekday(), m.weekday(), baseMsg + ' upper');
+ r = moment(m.format(format).toLocaleLowerCase(), format);
+ assert.equal(r.weekday(), m.weekday(), baseMsg + ' lower');
+
+ r = moment(m.format(format), format, true);
+ assert.equal(r.weekday(), m.weekday(), baseMsg + ' strict');
+ r = moment(m.format(format).toLocaleUpperCase(), format, true);
+ assert.equal(r.weekday(), m.weekday(), baseMsg + ' upper strict');
+ r = moment(m.format(format).toLocaleLowerCase(), format, true);
+ assert.equal(r.weekday(), m.weekday(), baseMsg + ' lower strict');
+ }
+
+ for (i = 0; i < 7; ++i) {
+ m = moment.utc([2015, i, 15, 18]);
+ tester('dd');
+ tester('ddd');
+ tester('dddd');
+ }
+ });
+ }
+
+ function setupDeprecationHandler(test, moment, scope) {
+ test._expectedDeprecations = null;
+ test._observedDeprecations = null;
+ test._oldSupress = moment.suppressDeprecationWarnings;
+ moment.suppressDeprecationWarnings = true;
+ test.expectedDeprecations = function () {
+ test._expectedDeprecations = arguments;
+ test._observedDeprecations = [];
+ };
+ moment.deprecationHandler = function (name, msg) {
+ var deprecationId = matchedDeprecation(name, msg, test._expectedDeprecations);
+ if (deprecationId === -1) {
+ throw new Error('Unexpected deprecation thrown name=' +
+ name + ' msg=' + msg);
+ }
+ test._observedDeprecations[deprecationId] = 1;
+ };
+ }
+
+ function teardownDeprecationHandler(test, moment, scope) {
+ moment.suppressDeprecationWarnings = test._oldSupress;
+
+ if (test._expectedDeprecations != null) {
+ var missedDeprecations = [];
+ each(test._expectedDeprecations, function (deprecationPattern, id) {
+ if (test._observedDeprecations[id] !== 1) {
+ missedDeprecations.push(deprecationPattern);
+ }
+ });
+ if (missedDeprecations.length !== 0) {
+ throw new Error('Expected deprecation warnings did not happen: ' +
+ missedDeprecations.join(' '));
+ }
+ }
+ }
+
+ function matchedDeprecation(name, msg, deprecations) {
+ if (deprecations == null) {
+ return -1;
+ }
+ for (var i = 0; i < deprecations.length; ++i) {
+ if (name != null && name === deprecations[i]) {
+ return i;
+ }
+ if (msg != null && msg.substring(0, deprecations[i].length) === deprecations[i]) {
+ return i;
+ }
+ }
+ return -1;
+ }
/*global QUnit:false*/
@@ -12313,11 +17194,13 @@
moment.createFromInputFallback = function (config) {
throw new Error('input not handled by moment: ' + config._i);
};
+ setupDeprecationHandler(test, moment, 'core');
if (lifecycle && lifecycle.setup) {
lifecycle.setup();
}
},
teardown : function () {
+ teardownDeprecationHandler(test, moment, 'core');
if (lifecycle && lifecycle.teardown) {
lifecycle.teardown();
}
@@ -12332,17 +17215,20 @@
moment.createFromInputFallback = function (config) {
throw new Error('input not handled by moment: ' + config._i);
};
+ setupDeprecationHandler(test, moment, 'locale');
if (lifecycle && lifecycle.setup) {
lifecycle.setup();
}
},
teardown : function () {
moment.locale('en');
+ teardownDeprecationHandler(test, moment, 'locale');
if (lifecycle && lifecycle.teardown) {
lifecycle.teardown();
}
}
});
+ defineCommonLocaleTests(name, -1, -1);
}
localeModule('fr-ca');
@@ -12501,14 +17387,14 @@
});
test('same day', function (assert) {
- var a = moment().hours(2).minutes(0).seconds(0);
-
- assert.equal(moment(a).calendar(), 'Aujourd\'hui à 02:00', 'today at the same time');
- assert.equal(moment(a).add({m: 25}).calendar(), 'Aujourd\'hui à 02:25', 'Now plus 25 min');
- assert.equal(moment(a).add({h: 1}).calendar(), 'Aujourd\'hui à 03:00', 'Now plus 1 hour');
- assert.equal(moment(a).add({d: 1}).calendar(), 'Demain à 02:00', 'tomorrow at the same time');
- assert.equal(moment(a).subtract({h: 1}).calendar(), 'Aujourd\'hui à 01:00', 'Now minus 1 hour');
- assert.equal(moment(a).subtract({d: 1}).calendar(), 'Hier à 02:00', 'yesterday at the same time');
+ var a = moment().hours(12).minutes(0).seconds(0);
+
+ assert.equal(moment(a).calendar(), 'Aujourd\'hui à 12:00', 'today at the same time');
+ assert.equal(moment(a).add({m: 25}).calendar(), 'Aujourd\'hui à 12:25', 'Now plus 25 min');
+ assert.equal(moment(a).add({h: 1}).calendar(), 'Aujourd\'hui à 13:00', 'Now plus 1 hour');
+ assert.equal(moment(a).add({d: 1}).calendar(), 'Demain à 12:00', 'tomorrow at the same time');
+ assert.equal(moment(a).subtract({h: 1}).calendar(), 'Aujourd\'hui à 11:00', 'Now minus 1 hour');
+ assert.equal(moment(a).subtract({d: 1}).calendar(), 'Hier à 12:00', 'yesterday at the same time');
});
test('same next week', function (assert) {
@@ -12551,67 +17437,6 @@
assert.equal(weeksFromNow.calendar(), weeksFromNow.format('L'), 'in 2 weeks');
});
- test('weeks year starting sunday', function (assert) {
- assert.equal(moment([2012, 0, 1]).week(), 1, 'Jan 1 2012 should be week 1');
- assert.equal(moment([2012, 0, 7]).week(), 1, 'Jan 7 2012 should be week 1');
- assert.equal(moment([2012, 0, 8]).week(), 2, 'Jan 8 2012 should be week 2');
- assert.equal(moment([2012, 0, 14]).week(), 2, 'Jan 14 2012 should be week 2');
- assert.equal(moment([2012, 0, 15]).week(), 3, 'Jan 15 2012 should be week 3');
- });
-
- test('weeks year starting monday', function (assert) {
- assert.equal(moment([2006, 11, 31]).week(), 1, 'Dec 31 2006 should be week 1');
- assert.equal(moment([2007, 0, 1]).week(), 1, 'Jan 1 2007 should be week 1');
- assert.equal(moment([2007, 0, 6]).week(), 1, 'Jan 6 2007 should be week 1');
- assert.equal(moment([2007, 0, 7]).week(), 2, 'Jan 7 2007 should be week 2');
- assert.equal(moment([2007, 0, 13]).week(), 2, 'Jan 13 2007 should be week 2');
- assert.equal(moment([2007, 0, 14]).week(), 3, 'Jan 14 2007 should be week 3');
- });
-
- test('weeks year starting tuesday', function (assert) {
- assert.equal(moment([2007, 11, 29]).week(), 52, 'Dec 29 2007 should be week 52');
- assert.equal(moment([2008, 0, 1]).week(), 1, 'Jan 1 2008 should be week 1');
- assert.equal(moment([2008, 0, 5]).week(), 1, 'Jan 5 2008 should be week 1');
- assert.equal(moment([2008, 0, 6]).week(), 2, 'Jan 6 2008 should be week 2');
- assert.equal(moment([2008, 0, 12]).week(), 2, 'Jan 12 2008 should be week 2');
- assert.equal(moment([2008, 0, 13]).week(), 3, 'Jan 13 2008 should be week 3');
- });
-
- test('weeks year starting wednesday', function (assert) {
- assert.equal(moment([2002, 11, 29]).week(), 1, 'Dec 29 2002 should be week 1');
- assert.equal(moment([2003, 0, 1]).week(), 1, 'Jan 1 2003 should be week 1');
- assert.equal(moment([2003, 0, 4]).week(), 1, 'Jan 4 2003 should be week 1');
- assert.equal(moment([2003, 0, 5]).week(), 2, 'Jan 5 2003 should be week 2');
- assert.equal(moment([2003, 0, 11]).week(), 2, 'Jan 11 2003 should be week 2');
- assert.equal(moment([2003, 0, 12]).week(), 3, 'Jan 12 2003 should be week 3');
- });
-
- test('weeks year starting thursday', function (assert) {
- assert.equal(moment([2008, 11, 28]).week(), 1, 'Dec 28 2008 should be week 1');
- assert.equal(moment([2009, 0, 1]).week(), 1, 'Jan 1 2009 should be week 1');
- assert.equal(moment([2009, 0, 3]).week(), 1, 'Jan 3 2009 should be week 1');
- assert.equal(moment([2009, 0, 4]).week(), 2, 'Jan 4 2009 should be week 2');
- assert.equal(moment([2009, 0, 10]).week(), 2, 'Jan 10 2009 should be week 2');
- assert.equal(moment([2009, 0, 11]).week(), 3, 'Jan 11 2009 should be week 3');
- });
-
- test('weeks year starting friday', function (assert) {
- assert.equal(moment([2009, 11, 27]).week(), 1, 'Dec 27 2009 should be week 1');
- assert.equal(moment([2010, 0, 1]).week(), 1, 'Jan 1 2010 should be week 1');
- assert.equal(moment([2010, 0, 2]).week(), 1, 'Jan 2 2010 should be week 1');
- assert.equal(moment([2010, 0, 3]).week(), 2, 'Jan 3 2010 should be week 2');
- assert.equal(moment([2010, 0, 9]).week(), 2, 'Jan 9 2010 should be week 2');
- assert.equal(moment([2010, 0, 10]).week(), 3, 'Jan 10 2010 should be week 3');
- });
-
- test('weeks year starting saturday', function (assert) {
- assert.equal(moment([2010, 11, 26]).week(), 1, 'Dec 26 2010 should be week 1');
- assert.equal(moment([2011, 0, 1]).week(), 1, 'Jan 1 2011 should be week 1');
- assert.equal(moment([2011, 0, 2]).week(), 2, 'Jan 2 2011 should be week 2');
- assert.equal(moment([2011, 0, 8]).week(), 2, 'Jan 8 2011 should be week 2');
- assert.equal(moment([2011, 0, 9]).week(), 3, 'Jan 9 2011 should be week 3');
- });
-
test('weeks year starting sunday format', function (assert) {
assert.equal(moment([2012, 0, 1]).format('w ww wo'), '1 01 1er', 'Jan 1 2012 should be week 1');
assert.equal(moment([2012, 0, 7]).format('w ww wo'), '1 01 1er', 'Jan 7 2012 should be week 1');
@@ -12620,42 +17445,6 @@
assert.equal(moment([2012, 0, 15]).format('w ww wo'), '3 03 3e', 'Jan 15 2012 should be week 3');
});
- test('lenient ordinal parsing', function (assert) {
- var i, ordinalStr, testMoment;
- for (i = 1; i <= 31; ++i) {
- ordinalStr = moment([2014, 0, i]).format('YYYY MM Do');
- testMoment = moment(ordinalStr, 'YYYY MM Do');
- assert.equal(testMoment.year(), 2014,
- 'lenient ordinal parsing ' + i + ' year check');
- assert.equal(testMoment.month(), 0,
- 'lenient ordinal parsing ' + i + ' month check');
- assert.equal(testMoment.date(), i,
- 'lenient ordinal parsing ' + i + ' date check');
- }
- });
-
- test('lenient ordinal parsing of number', function (assert) {
- var i, testMoment;
- for (i = 1; i <= 31; ++i) {
- testMoment = moment('2014 01 ' + i, 'YYYY MM Do');
- assert.equal(testMoment.year(), 2014,
- 'lenient ordinal parsing of number ' + i + ' year check');
- assert.equal(testMoment.month(), 0,
- 'lenient ordinal parsing of number ' + i + ' month check');
- assert.equal(testMoment.date(), i,
- 'lenient ordinal parsing of number ' + i + ' date check');
- }
- });
-
- test('strict ordinal parsing', function (assert) {
- var i, ordinalStr, testMoment;
- for (i = 1; i <= 31; ++i) {
- ordinalStr = moment([2014, 0, i]).format('YYYY MM Do');
- testMoment = moment(ordinalStr, 'YYYY MM Do', true);
- assert.ok(testMoment.isValid(), 'strict ordinal parsing ' + i);
- }
- });
-
}));
;(function (global, factory) {
@@ -12664,6 +17453,224 @@
typeof define === 'function' && define.amd ? define(['../../moment'], factory) :
factory(global.moment)
}(this, function (moment) { 'use strict';
+
+ function each(array, callback) {
+ var i;
+ for (i = 0; i < array.length; i++) {
+ callback(array[i], i, array);
+ }
+ }
+
+ function objectKeys(obj) {
+ if (Object.keys) {
+ return Object.keys(obj);
+ } else {
+ // IE8
+ var res = [], i;
+ for (i in obj) {
+ if (obj.hasOwnProperty(i)) {
+ res.push(i);
+ }
+ }
+ return res;
+ }
+ }
+
+ // Pick the first defined of two or three arguments.
+ function defaults(a, b, c) {
+ if (a != null) {
+ return a;
+ }
+ if (b != null) {
+ return b;
+ }
+ return c;
+ }
+
+ function defineCommonLocaleTests(locale, options) {
+ test('lenient ordinal parsing', function (assert) {
+ var i, ordinalStr, testMoment;
+ for (i = 1; i <= 31; ++i) {
+ ordinalStr = moment([2014, 0, i]).format('YYYY MM Do');
+ testMoment = moment(ordinalStr, 'YYYY MM Do');
+ assert.equal(testMoment.year(), 2014,
+ 'lenient ordinal parsing ' + i + ' year check');
+ assert.equal(testMoment.month(), 0,
+ 'lenient ordinal parsing ' + i + ' month check');
+ assert.equal(testMoment.date(), i,
+ 'lenient ordinal parsing ' + i + ' date check');
+ }
+ });
+
+ test('lenient ordinal parsing of number', function (assert) {
+ var i, testMoment;
+ for (i = 1; i <= 31; ++i) {
+ testMoment = moment('2014 01 ' + i, 'YYYY MM Do');
+ assert.equal(testMoment.year(), 2014,
+ 'lenient ordinal parsing of number ' + i + ' year check');
+ assert.equal(testMoment.month(), 0,
+ 'lenient ordinal parsing of number ' + i + ' month check');
+ assert.equal(testMoment.date(), i,
+ 'lenient ordinal parsing of number ' + i + ' date check');
+ }
+ });
+
+ test('strict ordinal parsing', function (assert) {
+ var i, ordinalStr, testMoment;
+ for (i = 1; i <= 31; ++i) {
+ ordinalStr = moment([2014, 0, i]).format('YYYY MM Do');
+ testMoment = moment(ordinalStr, 'YYYY MM Do', true);
+ assert.ok(testMoment.isValid(), 'strict ordinal parsing ' + i);
+ }
+ });
+
+ test('meridiem invariant', function (assert) {
+ var h, m, t1, t2;
+ for (h = 0; h < 24; ++h) {
+ for (m = 0; m < 60; m += 15) {
+ t1 = moment.utc([2000, 0, 1, h, m]);
+ t2 = moment.utc(t1.format('A h:mm'), 'A h:mm');
+ assert.equal(t2.format('HH:mm'), t1.format('HH:mm'),
+ 'meridiem at ' + t1.format('HH:mm'));
+ }
+ }
+ });
+
+ test('date format correctness', function (assert) {
+ var data, tokens;
+ data = moment.localeData()._longDateFormat;
+ tokens = objectKeys(data);
+ each(tokens, function (srchToken) {
+ // Check each format string to make sure it does not contain any
+ // tokens that need to be expanded.
+ each(tokens, function (baseToken) {
+ // strip escaped sequences
+ var format = data[baseToken].replace(/(\[[^\]]*\])/g, '');
+ assert.equal(false, !!~format.indexOf(srchToken),
+ 'contains ' + srchToken + ' in ' + baseToken);
+ });
+ });
+ });
+
+ test('month parsing correctness', function (assert) {
+ var i, m;
+
+ if (locale === 'tr') {
+ // I can't fix it :(
+ expect(0);
+ return;
+ }
+ function tester(format) {
+ var r;
+ r = moment(m.format(format), format);
+ assert.equal(r.month(), m.month(), 'month ' + i + ' fmt ' + format);
+ r = moment(m.format(format).toLocaleUpperCase(), format);
+ assert.equal(r.month(), m.month(), 'month ' + i + ' fmt ' + format + ' upper');
+ r = moment(m.format(format).toLocaleLowerCase(), format);
+ assert.equal(r.month(), m.month(), 'month ' + i + ' fmt ' + format + ' lower');
+
+ r = moment(m.format(format), format, true);
+ assert.equal(r.month(), m.month(), 'month ' + i + ' fmt ' + format + ' strict');
+ r = moment(m.format(format).toLocaleUpperCase(), format, true);
+ assert.equal(r.month(), m.month(), 'month ' + i + ' fmt ' + format + ' upper strict');
+ r = moment(m.format(format).toLocaleLowerCase(), format, true);
+ assert.equal(r.month(), m.month(), 'month ' + i + ' fmt ' + format + ' lower strict');
+ }
+
+ for (i = 0; i < 12; ++i) {
+ m = moment([2015, i, 15, 18]);
+ tester('MMM');
+ tester('MMM.');
+ tester('MMMM');
+ tester('MMMM.');
+ }
+ });
+
+ test('weekday parsing correctness', function (assert) {
+ var i, m;
+
+ if (locale === 'tr' || locale === 'az') {
+ // There is a lower-case letter (ı), that converted to upper then
+ // lower changes to i
+ expect(0);
+ return;
+ }
+ function tester(format) {
+ var r, baseMsg = 'weekday ' + m.weekday() + ' fmt ' + format;
+ r = moment(m.format(format), format);
+ assert.equal(r.weekday(), m.weekday(), baseMsg);
+ r = moment(m.format(format).toLocaleUpperCase(), format);
+ assert.equal(r.weekday(), m.weekday(), baseMsg + ' upper');
+ r = moment(m.format(format).toLocaleLowerCase(), format);
+ assert.equal(r.weekday(), m.weekday(), baseMsg + ' lower');
+
+ r = moment(m.format(format), format, true);
+ assert.equal(r.weekday(), m.weekday(), baseMsg + ' strict');
+ r = moment(m.format(format).toLocaleUpperCase(), format, true);
+ assert.equal(r.weekday(), m.weekday(), baseMsg + ' upper strict');
+ r = moment(m.format(format).toLocaleLowerCase(), format, true);
+ assert.equal(r.weekday(), m.weekday(), baseMsg + ' lower strict');
+ }
+
+ for (i = 0; i < 7; ++i) {
+ m = moment.utc([2015, i, 15, 18]);
+ tester('dd');
+ tester('ddd');
+ tester('dddd');
+ }
+ });
+ }
+
+ function setupDeprecationHandler(test, moment, scope) {
+ test._expectedDeprecations = null;
+ test._observedDeprecations = null;
+ test._oldSupress = moment.suppressDeprecationWarnings;
+ moment.suppressDeprecationWarnings = true;
+ test.expectedDeprecations = function () {
+ test._expectedDeprecations = arguments;
+ test._observedDeprecations = [];
+ };
+ moment.deprecationHandler = function (name, msg) {
+ var deprecationId = matchedDeprecation(name, msg, test._expectedDeprecations);
+ if (deprecationId === -1) {
+ throw new Error('Unexpected deprecation thrown name=' +
+ name + ' msg=' + msg);
+ }
+ test._observedDeprecations[deprecationId] = 1;
+ };
+ }
+
+ function teardownDeprecationHandler(test, moment, scope) {
+ moment.suppressDeprecationWarnings = test._oldSupress;
+
+ if (test._expectedDeprecations != null) {
+ var missedDeprecations = [];
+ each(test._expectedDeprecations, function (deprecationPattern, id) {
+ if (test._observedDeprecations[id] !== 1) {
+ missedDeprecations.push(deprecationPattern);
+ }
+ });
+ if (missedDeprecations.length !== 0) {
+ throw new Error('Expected deprecation warnings did not happen: ' +
+ missedDeprecations.join(' '));
+ }
+ }
+ }
+
+ function matchedDeprecation(name, msg, deprecations) {
+ if (deprecations == null) {
+ return -1;
+ }
+ for (var i = 0; i < deprecations.length; ++i) {
+ if (name != null && name === deprecations[i]) {
+ return i;
+ }
+ if (msg != null && msg.substring(0, deprecations[i].length) === deprecations[i]) {
+ return i;
+ }
+ }
+ return -1;
+ }
/*global QUnit:false*/
@@ -12678,11 +17685,13 @@
moment.createFromInputFallback = function (config) {
throw new Error('input not handled by moment: ' + config._i);
};
+ setupDeprecationHandler(test, moment, 'core');
if (lifecycle && lifecycle.setup) {
lifecycle.setup();
}
},
teardown : function () {
+ teardownDeprecationHandler(test, moment, 'core');
if (lifecycle && lifecycle.teardown) {
lifecycle.teardown();
}
@@ -12697,17 +17706,20 @@
moment.createFromInputFallback = function (config) {
throw new Error('input not handled by moment: ' + config._i);
};
+ setupDeprecationHandler(test, moment, 'locale');
if (lifecycle && lifecycle.setup) {
lifecycle.setup();
}
},
teardown : function () {
moment.locale('en');
+ teardownDeprecationHandler(test, moment, 'locale');
if (lifecycle && lifecycle.teardown) {
lifecycle.teardown();
}
}
});
+ defineCommonLocaleTests(name, -1, -1);
}
localeModule('fr-ch');
@@ -12866,14 +17878,14 @@
});
test('same day', function (assert) {
- var a = moment().hours(2).minutes(0).seconds(0);
-
- assert.equal(moment(a).calendar(), 'Aujourd\'hui à 02:00', 'today at the same time');
- assert.equal(moment(a).add({m: 25}).calendar(), 'Aujourd\'hui à 02:25', 'Now plus 25 min');
- assert.equal(moment(a).add({h: 1}).calendar(), 'Aujourd\'hui à 03:00', 'Now plus 1 hour');
- assert.equal(moment(a).add({d: 1}).calendar(), 'Demain à 02:00', 'tomorrow at the same time');
- assert.equal(moment(a).subtract({h: 1}).calendar(), 'Aujourd\'hui à 01:00', 'Now minus 1 hour');
- assert.equal(moment(a).subtract({d: 1}).calendar(), 'Hier à 02:00', 'yesterday at the same time');
+ var a = moment().hours(12).minutes(0).seconds(0);
+
+ assert.equal(moment(a).calendar(), 'Aujourd\'hui à 12:00', 'today at the same time');
+ assert.equal(moment(a).add({m: 25}).calendar(), 'Aujourd\'hui à 12:25', 'Now plus 25 min');
+ assert.equal(moment(a).add({h: 1}).calendar(), 'Aujourd\'hui à 13:00', 'Now plus 1 hour');
+ assert.equal(moment(a).add({d: 1}).calendar(), 'Demain à 12:00', 'tomorrow at the same time');
+ assert.equal(moment(a).subtract({h: 1}).calendar(), 'Aujourd\'hui à 11:00', 'Now minus 1 hour');
+ assert.equal(moment(a).subtract({d: 1}).calendar(), 'Hier à 12:00', 'yesterday at the same time');
});
test('same next week', function (assert) {
@@ -12916,67 +17928,6 @@
assert.equal(weeksFromNow.calendar(), weeksFromNow.format('L'), 'in 2 weeks');
});
- test('weeks year starting sunday', function (assert) {
- assert.equal(moment([2012, 0, 1]).week(), 52, 'Jan 1 2012 should be week 52');
- assert.equal(moment([2012, 0, 2]).week(), 1, 'Jan 2 2012 should be week 1');
- assert.equal(moment([2012, 0, 8]).week(), 1, 'Jan 8 2012 should be week 1');
- assert.equal(moment([2012, 0, 9]).week(), 2, 'Jan 9 2012 should be week 2');
- assert.equal(moment([2012, 0, 15]).week(), 2, 'Jan 15 2012 should be week 2');
- });
-
- test('weeks year starting monday', function (assert) {
- assert.equal(moment([2007, 0, 1]).week(), 1, 'Jan 1 2007 should be week 1');
- assert.equal(moment([2007, 0, 7]).week(), 1, 'Jan 7 2007 should be week 1');
- assert.equal(moment([2007, 0, 8]).week(), 2, 'Jan 8 2007 should be week 2');
- assert.equal(moment([2007, 0, 14]).week(), 2, 'Jan 14 2007 should be week 2');
- assert.equal(moment([2007, 0, 15]).week(), 3, 'Jan 15 2007 should be week 3');
- });
-
- test('weeks year starting tuesday', function (assert) {
- assert.equal(moment([2007, 11, 31]).week(), 1, 'Dec 31 2007 should be week 1');
- assert.equal(moment([2008, 0, 1]).week(), 1, 'Jan 1 2008 should be week 1');
- assert.equal(moment([2008, 0, 6]).week(), 1, 'Jan 6 2008 should be week 1');
- assert.equal(moment([2008, 0, 7]).week(), 2, 'Jan 7 2008 should be week 2');
- assert.equal(moment([2008, 0, 13]).week(), 2, 'Jan 13 2008 should be week 2');
- assert.equal(moment([2008, 0, 14]).week(), 3, 'Jan 14 2008 should be week 3');
- });
-
- test('weeks year starting wednesday', function (assert) {
- assert.equal(moment([2002, 11, 30]).week(), 1, 'Dec 30 2002 should be week 1');
- assert.equal(moment([2003, 0, 1]).week(), 1, 'Jan 1 2003 should be week 1');
- assert.equal(moment([2003, 0, 5]).week(), 1, 'Jan 5 2003 should be week 1');
- assert.equal(moment([2003, 0, 6]).week(), 2, 'Jan 6 2003 should be week 2');
- assert.equal(moment([2003, 0, 12]).week(), 2, 'Jan 12 2003 should be week 2');
- assert.equal(moment([2003, 0, 13]).week(), 3, 'Jan 13 2003 should be week 3');
- });
-
- test('weeks year starting thursday', function (assert) {
- assert.equal(moment([2008, 11, 29]).week(), 1, 'Dec 29 2008 should be week 1');
- assert.equal(moment([2009, 0, 1]).week(), 1, 'Jan 1 2009 should be week 1');
- assert.equal(moment([2009, 0, 4]).week(), 1, 'Jan 4 2009 should be week 1');
- assert.equal(moment([2009, 0, 5]).week(), 2, 'Jan 5 2009 should be week 2');
- assert.equal(moment([2009, 0, 11]).week(), 2, 'Jan 11 2009 should be week 2');
- assert.equal(moment([2009, 0, 13]).week(), 3, 'Jan 12 2009 should be week 3');
- });
-
- test('weeks year starting friday', function (assert) {
- assert.equal(moment([2009, 11, 28]).week(), 53, 'Dec 28 2009 should be week 53');
- assert.equal(moment([2010, 0, 1]).week(), 53, 'Jan 1 2010 should be week 53');
- assert.equal(moment([2010, 0, 3]).week(), 53, 'Jan 3 2010 should be week 53');
- assert.equal(moment([2010, 0, 4]).week(), 1, 'Jan 4 2010 should be week 1');
- assert.equal(moment([2010, 0, 10]).week(), 1, 'Jan 10 2010 should be week 1');
- assert.equal(moment([2010, 0, 11]).week(), 2, 'Jan 11 2010 should be week 2');
- });
-
- test('weeks year starting saturday', function (assert) {
- assert.equal(moment([2010, 11, 27]).week(), 52, 'Dec 27 2010 should be week 52');
- assert.equal(moment([2011, 0, 1]).week(), 52, 'Jan 1 2011 should be week 52');
- assert.equal(moment([2011, 0, 2]).week(), 52, 'Jan 2 2011 should be week 52');
- assert.equal(moment([2011, 0, 3]).week(), 1, 'Jan 3 2011 should be week 1');
- assert.equal(moment([2011, 0, 9]).week(), 1, 'Jan 9 2011 should be week 1');
- assert.equal(moment([2011, 0, 10]).week(), 2, 'Jan 10 2011 should be week 2');
- });
-
test('weeks year starting sunday formatted', function (assert) {
assert.equal(moment([2012, 0, 1]).format('w ww wo'), '52 52 52e', 'Jan 1 2012 should be week 52');
assert.equal(moment([2012, 0, 2]).format('w ww wo'), '1 01 1er', 'Jan 2 2012 should be week 1');
@@ -12985,42 +17936,6 @@
assert.equal(moment([2012, 0, 15]).format('w ww wo'), '2 02 2e', 'Jan 15 2012 should be week 2');
});
- test('lenient ordinal parsing', function (assert) {
- var i, ordinalStr, testMoment;
- for (i = 1; i <= 31; ++i) {
- ordinalStr = moment([2014, 0, i]).format('YYYY MM Do');
- testMoment = moment(ordinalStr, 'YYYY MM Do');
- assert.equal(testMoment.year(), 2014,
- 'lenient ordinal parsing ' + i + ' year check');
- assert.equal(testMoment.month(), 0,
- 'lenient ordinal parsing ' + i + ' month check');
- assert.equal(testMoment.date(), i,
- 'lenient ordinal parsing ' + i + ' date check');
- }
- });
-
- test('lenient ordinal parsing of number', function (assert) {
- var i, testMoment;
- for (i = 1; i <= 31; ++i) {
- testMoment = moment('2014 01 ' + i, 'YYYY MM Do');
- assert.equal(testMoment.year(), 2014,
- 'lenient ordinal parsing of number ' + i + ' year check');
- assert.equal(testMoment.month(), 0,
- 'lenient ordinal parsing of number ' + i + ' month check');
- assert.equal(testMoment.date(), i,
- 'lenient ordinal parsing of number ' + i + ' date check');
- }
- });
-
- test('strict ordinal parsing', function (assert) {
- var i, ordinalStr, testMoment;
- for (i = 1; i <= 31; ++i) {
- ordinalStr = moment([2014, 0, i]).format('YYYY MM Do');
- testMoment = moment(ordinalStr, 'YYYY MM Do', true);
- assert.ok(testMoment.isValid(), 'strict ordinal parsing ' + i);
- }
- });
-
}));
;(function (global, factory) {
@@ -13029,6 +17944,224 @@
typeof define === 'function' && define.amd ? define(['../../moment'], factory) :
factory(global.moment)
}(this, function (moment) { 'use strict';
+
+ function each(array, callback) {
+ var i;
+ for (i = 0; i < array.length; i++) {
+ callback(array[i], i, array);
+ }
+ }
+
+ function objectKeys(obj) {
+ if (Object.keys) {
+ return Object.keys(obj);
+ } else {
+ // IE8
+ var res = [], i;
+ for (i in obj) {
+ if (obj.hasOwnProperty(i)) {
+ res.push(i);
+ }
+ }
+ return res;
+ }
+ }
+
+ // Pick the first defined of two or three arguments.
+ function defaults(a, b, c) {
+ if (a != null) {
+ return a;
+ }
+ if (b != null) {
+ return b;
+ }
+ return c;
+ }
+
+ function defineCommonLocaleTests(locale, options) {
+ test('lenient ordinal parsing', function (assert) {
+ var i, ordinalStr, testMoment;
+ for (i = 1; i <= 31; ++i) {
+ ordinalStr = moment([2014, 0, i]).format('YYYY MM Do');
+ testMoment = moment(ordinalStr, 'YYYY MM Do');
+ assert.equal(testMoment.year(), 2014,
+ 'lenient ordinal parsing ' + i + ' year check');
+ assert.equal(testMoment.month(), 0,
+ 'lenient ordinal parsing ' + i + ' month check');
+ assert.equal(testMoment.date(), i,
+ 'lenient ordinal parsing ' + i + ' date check');
+ }
+ });
+
+ test('lenient ordinal parsing of number', function (assert) {
+ var i, testMoment;
+ for (i = 1; i <= 31; ++i) {
+ testMoment = moment('2014 01 ' + i, 'YYYY MM Do');
+ assert.equal(testMoment.year(), 2014,
+ 'lenient ordinal parsing of number ' + i + ' year check');
+ assert.equal(testMoment.month(), 0,
+ 'lenient ordinal parsing of number ' + i + ' month check');
+ assert.equal(testMoment.date(), i,
+ 'lenient ordinal parsing of number ' + i + ' date check');
+ }
+ });
+
+ test('strict ordinal parsing', function (assert) {
+ var i, ordinalStr, testMoment;
+ for (i = 1; i <= 31; ++i) {
+ ordinalStr = moment([2014, 0, i]).format('YYYY MM Do');
+ testMoment = moment(ordinalStr, 'YYYY MM Do', true);
+ assert.ok(testMoment.isValid(), 'strict ordinal parsing ' + i);
+ }
+ });
+
+ test('meridiem invariant', function (assert) {
+ var h, m, t1, t2;
+ for (h = 0; h < 24; ++h) {
+ for (m = 0; m < 60; m += 15) {
+ t1 = moment.utc([2000, 0, 1, h, m]);
+ t2 = moment.utc(t1.format('A h:mm'), 'A h:mm');
+ assert.equal(t2.format('HH:mm'), t1.format('HH:mm'),
+ 'meridiem at ' + t1.format('HH:mm'));
+ }
+ }
+ });
+
+ test('date format correctness', function (assert) {
+ var data, tokens;
+ data = moment.localeData()._longDateFormat;
+ tokens = objectKeys(data);
+ each(tokens, function (srchToken) {
+ // Check each format string to make sure it does not contain any
+ // tokens that need to be expanded.
+ each(tokens, function (baseToken) {
+ // strip escaped sequences
+ var format = data[baseToken].replace(/(\[[^\]]*\])/g, '');
+ assert.equal(false, !!~format.indexOf(srchToken),
+ 'contains ' + srchToken + ' in ' + baseToken);
+ });
+ });
+ });
+
+ test('month parsing correctness', function (assert) {
+ var i, m;
+
+ if (locale === 'tr') {
+ // I can't fix it :(
+ expect(0);
+ return;
+ }
+ function tester(format) {
+ var r;
+ r = moment(m.format(format), format);
+ assert.equal(r.month(), m.month(), 'month ' + i + ' fmt ' + format);
+ r = moment(m.format(format).toLocaleUpperCase(), format);
+ assert.equal(r.month(), m.month(), 'month ' + i + ' fmt ' + format + ' upper');
+ r = moment(m.format(format).toLocaleLowerCase(), format);
+ assert.equal(r.month(), m.month(), 'month ' + i + ' fmt ' + format + ' lower');
+
+ r = moment(m.format(format), format, true);
+ assert.equal(r.month(), m.month(), 'month ' + i + ' fmt ' + format + ' strict');
+ r = moment(m.format(format).toLocaleUpperCase(), format, true);
+ assert.equal(r.month(), m.month(), 'month ' + i + ' fmt ' + format + ' upper strict');
+ r = moment(m.format(format).toLocaleLowerCase(), format, true);
+ assert.equal(r.month(), m.month(), 'month ' + i + ' fmt ' + format + ' lower strict');
+ }
+
+ for (i = 0; i < 12; ++i) {
+ m = moment([2015, i, 15, 18]);
+ tester('MMM');
+ tester('MMM.');
+ tester('MMMM');
+ tester('MMMM.');
+ }
+ });
+
+ test('weekday parsing correctness', function (assert) {
+ var i, m;
+
+ if (locale === 'tr' || locale === 'az') {
+ // There is a lower-case letter (ı), that converted to upper then
+ // lower changes to i
+ expect(0);
+ return;
+ }
+ function tester(format) {
+ var r, baseMsg = 'weekday ' + m.weekday() + ' fmt ' + format;
+ r = moment(m.format(format), format);
+ assert.equal(r.weekday(), m.weekday(), baseMsg);
+ r = moment(m.format(format).toLocaleUpperCase(), format);
+ assert.equal(r.weekday(), m.weekday(), baseMsg + ' upper');
+ r = moment(m.format(format).toLocaleLowerCase(), format);
+ assert.equal(r.weekday(), m.weekday(), baseMsg + ' lower');
+
+ r = moment(m.format(format), format, true);
+ assert.equal(r.weekday(), m.weekday(), baseMsg + ' strict');
+ r = moment(m.format(format).toLocaleUpperCase(), format, true);
+ assert.equal(r.weekday(), m.weekday(), baseMsg + ' upper strict');
+ r = moment(m.format(format).toLocaleLowerCase(), format, true);
+ assert.equal(r.weekday(), m.weekday(), baseMsg + ' lower strict');
+ }
+
+ for (i = 0; i < 7; ++i) {
+ m = moment.utc([2015, i, 15, 18]);
+ tester('dd');
+ tester('ddd');
+ tester('dddd');
+ }
+ });
+ }
+
+ function setupDeprecationHandler(test, moment, scope) {
+ test._expectedDeprecations = null;
+ test._observedDeprecations = null;
+ test._oldSupress = moment.suppressDeprecationWarnings;
+ moment.suppressDeprecationWarnings = true;
+ test.expectedDeprecations = function () {
+ test._expectedDeprecations = arguments;
+ test._observedDeprecations = [];
+ };
+ moment.deprecationHandler = function (name, msg) {
+ var deprecationId = matchedDeprecation(name, msg, test._expectedDeprecations);
+ if (deprecationId === -1) {
+ throw new Error('Unexpected deprecation thrown name=' +
+ name + ' msg=' + msg);
+ }
+ test._observedDeprecations[deprecationId] = 1;
+ };
+ }
+
+ function teardownDeprecationHandler(test, moment, scope) {
+ moment.suppressDeprecationWarnings = test._oldSupress;
+
+ if (test._expectedDeprecations != null) {
+ var missedDeprecations = [];
+ each(test._expectedDeprecations, function (deprecationPattern, id) {
+ if (test._observedDeprecations[id] !== 1) {
+ missedDeprecations.push(deprecationPattern);
+ }
+ });
+ if (missedDeprecations.length !== 0) {
+ throw new Error('Expected deprecation warnings did not happen: ' +
+ missedDeprecations.join(' '));
+ }
+ }
+ }
+
+ function matchedDeprecation(name, msg, deprecations) {
+ if (deprecations == null) {
+ return -1;
+ }
+ for (var i = 0; i < deprecations.length; ++i) {
+ if (name != null && name === deprecations[i]) {
+ return i;
+ }
+ if (msg != null && msg.substring(0, deprecations[i].length) === deprecations[i]) {
+ return i;
+ }
+ }
+ return -1;
+ }
/*global QUnit:false*/
@@ -13043,11 +18176,13 @@
moment.createFromInputFallback = function (config) {
throw new Error('input not handled by moment: ' + config._i);
};
+ setupDeprecationHandler(test, moment, 'core');
if (lifecycle && lifecycle.setup) {
lifecycle.setup();
}
},
teardown : function () {
+ teardownDeprecationHandler(test, moment, 'core');
if (lifecycle && lifecycle.teardown) {
lifecycle.teardown();
}
@@ -13062,17 +18197,20 @@
moment.createFromInputFallback = function (config) {
throw new Error('input not handled by moment: ' + config._i);
};
+ setupDeprecationHandler(test, moment, 'locale');
if (lifecycle && lifecycle.setup) {
lifecycle.setup();
}
},
teardown : function () {
moment.locale('en');
+ teardownDeprecationHandler(test, moment, 'locale');
if (lifecycle && lifecycle.teardown) {
lifecycle.teardown();
}
}
});
+ defineCommonLocaleTests(name, -1, -1);
}
localeModule('fr');
@@ -13223,14 +18361,14 @@
});
test('same day', function (assert) {
- var a = moment().hours(2).minutes(0).seconds(0);
-
- assert.equal(moment(a).calendar(), 'Aujourd\'hui à 02:00', 'today at the same time');
- assert.equal(moment(a).add({m: 25}).calendar(), 'Aujourd\'hui à 02:25', 'Now plus 25 min');
- assert.equal(moment(a).add({h: 1}).calendar(), 'Aujourd\'hui à 03:00', 'Now plus 1 hour');
- assert.equal(moment(a).add({d: 1}).calendar(), 'Demain à 02:00', 'tomorrow at the same time');
- assert.equal(moment(a).subtract({h: 1}).calendar(), 'Aujourd\'hui à 01:00', 'Now minus 1 hour');
- assert.equal(moment(a).subtract({d: 1}).calendar(), 'Hier à 02:00', 'yesterday at the same time');
+ var a = moment().hours(12).minutes(0).seconds(0);
+
+ assert.equal(moment(a).calendar(), 'Aujourd\'hui à 12:00', 'today at the same time');
+ assert.equal(moment(a).add({m: 25}).calendar(), 'Aujourd\'hui à 12:25', 'Now plus 25 min');
+ assert.equal(moment(a).add({h: 1}).calendar(), 'Aujourd\'hui à 13:00', 'Now plus 1 hour');
+ assert.equal(moment(a).add({d: 1}).calendar(), 'Demain à 12:00', 'tomorrow at the same time');
+ assert.equal(moment(a).subtract({h: 1}).calendar(), 'Aujourd\'hui à 11:00', 'Now minus 1 hour');
+ assert.equal(moment(a).subtract({d: 1}).calendar(), 'Hier à 12:00', 'yesterday at the same time');
});
test('same next week', function (assert) {
@@ -13273,67 +18411,6 @@
assert.equal(weeksFromNow.calendar(), weeksFromNow.format('L'), 'in 2 weeks');
});
- test('weeks year starting sunday', function (assert) {
- assert.equal(moment([2012, 0, 1]).week(), 52, 'Jan 1 2012 should be week 52');
- assert.equal(moment([2012, 0, 2]).week(), 1, 'Jan 2 2012 should be week 1');
- assert.equal(moment([2012, 0, 8]).week(), 1, 'Jan 8 2012 should be week 1');
- assert.equal(moment([2012, 0, 9]).week(), 2, 'Jan 9 2012 should be week 2');
- assert.equal(moment([2012, 0, 15]).week(), 2, 'Jan 15 2012 should be week 2');
- });
-
- test('weeks year starting monday', function (assert) {
- assert.equal(moment([2007, 0, 1]).week(), 1, 'Jan 1 2007 should be week 1');
- assert.equal(moment([2007, 0, 7]).week(), 1, 'Jan 7 2007 should be week 1');
- assert.equal(moment([2007, 0, 8]).week(), 2, 'Jan 8 2007 should be week 2');
- assert.equal(moment([2007, 0, 14]).week(), 2, 'Jan 14 2007 should be week 2');
- assert.equal(moment([2007, 0, 15]).week(), 3, 'Jan 15 2007 should be week 3');
- });
-
- test('weeks year starting tuesday', function (assert) {
- assert.equal(moment([2007, 11, 31]).week(), 1, 'Dec 31 2007 should be week 1');
- assert.equal(moment([2008, 0, 1]).week(), 1, 'Jan 1 2008 should be week 1');
- assert.equal(moment([2008, 0, 6]).week(), 1, 'Jan 6 2008 should be week 1');
- assert.equal(moment([2008, 0, 7]).week(), 2, 'Jan 7 2008 should be week 2');
- assert.equal(moment([2008, 0, 13]).week(), 2, 'Jan 13 2008 should be week 2');
- assert.equal(moment([2008, 0, 14]).week(), 3, 'Jan 14 2008 should be week 3');
- });
-
- test('weeks year starting wednesday', function (assert) {
- assert.equal(moment([2002, 11, 30]).week(), 1, 'Dec 30 2002 should be week 1');
- assert.equal(moment([2003, 0, 1]).week(), 1, 'Jan 1 2003 should be week 1');
- assert.equal(moment([2003, 0, 5]).week(), 1, 'Jan 5 2003 should be week 1');
- assert.equal(moment([2003, 0, 6]).week(), 2, 'Jan 6 2003 should be week 2');
- assert.equal(moment([2003, 0, 12]).week(), 2, 'Jan 12 2003 should be week 2');
- assert.equal(moment([2003, 0, 13]).week(), 3, 'Jan 13 2003 should be week 3');
- });
-
- test('weeks year starting thursday', function (assert) {
- assert.equal(moment([2008, 11, 29]).week(), 1, 'Dec 29 2008 should be week 1');
- assert.equal(moment([2009, 0, 1]).week(), 1, 'Jan 1 2009 should be week 1');
- assert.equal(moment([2009, 0, 4]).week(), 1, 'Jan 4 2009 should be week 1');
- assert.equal(moment([2009, 0, 5]).week(), 2, 'Jan 5 2009 should be week 2');
- assert.equal(moment([2009, 0, 11]).week(), 2, 'Jan 11 2009 should be week 2');
- assert.equal(moment([2009, 0, 13]).week(), 3, 'Jan 12 2009 should be week 3');
- });
-
- test('weeks year starting friday', function (assert) {
- assert.equal(moment([2009, 11, 28]).week(), 53, 'Dec 28 2009 should be week 53');
- assert.equal(moment([2010, 0, 1]).week(), 53, 'Jan 1 2010 should be week 53');
- assert.equal(moment([2010, 0, 3]).week(), 53, 'Jan 3 2010 should be week 53');
- assert.equal(moment([2010, 0, 4]).week(), 1, 'Jan 4 2010 should be week 1');
- assert.equal(moment([2010, 0, 10]).week(), 1, 'Jan 10 2010 should be week 1');
- assert.equal(moment([2010, 0, 11]).week(), 2, 'Jan 11 2010 should be week 2');
- });
-
- test('weeks year starting saturday', function (assert) {
- assert.equal(moment([2010, 11, 27]).week(), 52, 'Dec 27 2010 should be week 52');
- assert.equal(moment([2011, 0, 1]).week(), 52, 'Jan 1 2011 should be week 52');
- assert.equal(moment([2011, 0, 2]).week(), 52, 'Jan 2 2011 should be week 52');
- assert.equal(moment([2011, 0, 3]).week(), 1, 'Jan 3 2011 should be week 1');
- assert.equal(moment([2011, 0, 9]).week(), 1, 'Jan 9 2011 should be week 1');
- assert.equal(moment([2011, 0, 10]).week(), 2, 'Jan 10 2011 should be week 2');
- });
-
test('weeks year starting sunday formatted', function (assert) {
assert.equal(moment([2012, 0, 1]).format('w ww wo'), '52 52 52', 'Jan 1 2012 should be week 52');
assert.equal(moment([2012, 0, 2]).format('w ww wo'), '1 01 1er', 'Jan 2 2012 should be week 1');
@@ -13342,42 +18419,6 @@
assert.equal(moment([2012, 0, 15]).format('w ww wo'), '2 02 2', 'Jan 15 2012 should be week 2');
});
- test('lenient ordinal parsing', function (assert) {
- var i, ordinalStr, testMoment;
- for (i = 1; i <= 31; ++i) {
- ordinalStr = moment([2014, 0, i]).format('YYYY MM Do');
- testMoment = moment(ordinalStr, 'YYYY MM Do');
- assert.equal(testMoment.year(), 2014,
- 'lenient ordinal parsing ' + i + ' year check');
- assert.equal(testMoment.month(), 0,
- 'lenient ordinal parsing ' + i + ' month check');
- assert.equal(testMoment.date(), i,
- 'lenient ordinal parsing ' + i + ' date check');
- }
- });
-
- test('lenient ordinal parsing of number', function (assert) {
- var i, testMoment;
- for (i = 1; i <= 31; ++i) {
- testMoment = moment('2014 01 ' + i, 'YYYY MM Do');
- assert.equal(testMoment.year(), 2014,
- 'lenient ordinal parsing of number ' + i + ' year check');
- assert.equal(testMoment.month(), 0,
- 'lenient ordinal parsing of number ' + i + ' month check');
- assert.equal(testMoment.date(), i,
- 'lenient ordinal parsing of number ' + i + ' date check');
- }
- });
-
- test('strict ordinal parsing', function (assert) {
- var i, ordinalStr, testMoment;
- for (i = 1; i <= 31; ++i) {
- ordinalStr = moment([2014, 0, i]).format('YYYY MM Do');
- testMoment = moment(ordinalStr, 'YYYY MM Do', true);
- assert.ok(testMoment.isValid(), 'strict ordinal parsing ' + i);
- }
- });
-
}));
;(function (global, factory) {
@@ -13386,6 +18427,224 @@
typeof define === 'function' && define.amd ? define(['../../moment'], factory) :
factory(global.moment)
}(this, function (moment) { 'use strict';
+
+ function each(array, callback) {
+ var i;
+ for (i = 0; i < array.length; i++) {
+ callback(array[i], i, array);
+ }
+ }
+
+ function objectKeys(obj) {
+ if (Object.keys) {
+ return Object.keys(obj);
+ } else {
+ // IE8
+ var res = [], i;
+ for (i in obj) {
+ if (obj.hasOwnProperty(i)) {
+ res.push(i);
+ }
+ }
+ return res;
+ }
+ }
+
+ // Pick the first defined of two or three arguments.
+ function defaults(a, b, c) {
+ if (a != null) {
+ return a;
+ }
+ if (b != null) {
+ return b;
+ }
+ return c;
+ }
+
+ function defineCommonLocaleTests(locale, options) {
+ test('lenient ordinal parsing', function (assert) {
+ var i, ordinalStr, testMoment;
+ for (i = 1; i <= 31; ++i) {
+ ordinalStr = moment([2014, 0, i]).format('YYYY MM Do');
+ testMoment = moment(ordinalStr, 'YYYY MM Do');
+ assert.equal(testMoment.year(), 2014,
+ 'lenient ordinal parsing ' + i + ' year check');
+ assert.equal(testMoment.month(), 0,
+ 'lenient ordinal parsing ' + i + ' month check');
+ assert.equal(testMoment.date(), i,
+ 'lenient ordinal parsing ' + i + ' date check');
+ }
+ });
+
+ test('lenient ordinal parsing of number', function (assert) {
+ var i, testMoment;
+ for (i = 1; i <= 31; ++i) {
+ testMoment = moment('2014 01 ' + i, 'YYYY MM Do');
+ assert.equal(testMoment.year(), 2014,
+ 'lenient ordinal parsing of number ' + i + ' year check');
+ assert.equal(testMoment.month(), 0,
+ 'lenient ordinal parsing of number ' + i + ' month check');
+ assert.equal(testMoment.date(), i,
+ 'lenient ordinal parsing of number ' + i + ' date check');
+ }
+ });
+
+ test('strict ordinal parsing', function (assert) {
+ var i, ordinalStr, testMoment;
+ for (i = 1; i <= 31; ++i) {
+ ordinalStr = moment([2014, 0, i]).format('YYYY MM Do');
+ testMoment = moment(ordinalStr, 'YYYY MM Do', true);
+ assert.ok(testMoment.isValid(), 'strict ordinal parsing ' + i);
+ }
+ });
+
+ test('meridiem invariant', function (assert) {
+ var h, m, t1, t2;
+ for (h = 0; h < 24; ++h) {
+ for (m = 0; m < 60; m += 15) {
+ t1 = moment.utc([2000, 0, 1, h, m]);
+ t2 = moment.utc(t1.format('A h:mm'), 'A h:mm');
+ assert.equal(t2.format('HH:mm'), t1.format('HH:mm'),
+ 'meridiem at ' + t1.format('HH:mm'));
+ }
+ }
+ });
+
+ test('date format correctness', function (assert) {
+ var data, tokens;
+ data = moment.localeData()._longDateFormat;
+ tokens = objectKeys(data);
+ each(tokens, function (srchToken) {
+ // Check each format string to make sure it does not contain any
+ // tokens that need to be expanded.
+ each(tokens, function (baseToken) {
+ // strip escaped sequences
+ var format = data[baseToken].replace(/(\[[^\]]*\])/g, '');
+ assert.equal(false, !!~format.indexOf(srchToken),
+ 'contains ' + srchToken + ' in ' + baseToken);
+ });
+ });
+ });
+
+ test('month parsing correctness', function (assert) {
+ var i, m;
+
+ if (locale === 'tr') {
+ // I can't fix it :(
+ expect(0);
+ return;
+ }
+ function tester(format) {
+ var r;
+ r = moment(m.format(format), format);
+ assert.equal(r.month(), m.month(), 'month ' + i + ' fmt ' + format);
+ r = moment(m.format(format).toLocaleUpperCase(), format);
+ assert.equal(r.month(), m.month(), 'month ' + i + ' fmt ' + format + ' upper');
+ r = moment(m.format(format).toLocaleLowerCase(), format);
+ assert.equal(r.month(), m.month(), 'month ' + i + ' fmt ' + format + ' lower');
+
+ r = moment(m.format(format), format, true);
+ assert.equal(r.month(), m.month(), 'month ' + i + ' fmt ' + format + ' strict');
+ r = moment(m.format(format).toLocaleUpperCase(), format, true);
+ assert.equal(r.month(), m.month(), 'month ' + i + ' fmt ' + format + ' upper strict');
+ r = moment(m.format(format).toLocaleLowerCase(), format, true);
+ assert.equal(r.month(), m.month(), 'month ' + i + ' fmt ' + format + ' lower strict');
+ }
+
+ for (i = 0; i < 12; ++i) {
+ m = moment([2015, i, 15, 18]);
+ tester('MMM');
+ tester('MMM.');
+ tester('MMMM');
+ tester('MMMM.');
+ }
+ });
+
+ test('weekday parsing correctness', function (assert) {
+ var i, m;
+
+ if (locale === 'tr' || locale === 'az') {
+ // There is a lower-case letter (ı), that converted to upper then
+ // lower changes to i
+ expect(0);
+ return;
+ }
+ function tester(format) {
+ var r, baseMsg = 'weekday ' + m.weekday() + ' fmt ' + format;
+ r = moment(m.format(format), format);
+ assert.equal(r.weekday(), m.weekday(), baseMsg);
+ r = moment(m.format(format).toLocaleUpperCase(), format);
+ assert.equal(r.weekday(), m.weekday(), baseMsg + ' upper');
+ r = moment(m.format(format).toLocaleLowerCase(), format);
+ assert.equal(r.weekday(), m.weekday(), baseMsg + ' lower');
+
+ r = moment(m.format(format), format, true);
+ assert.equal(r.weekday(), m.weekday(), baseMsg + ' strict');
+ r = moment(m.format(format).toLocaleUpperCase(), format, true);
+ assert.equal(r.weekday(), m.weekday(), baseMsg + ' upper strict');
+ r = moment(m.format(format).toLocaleLowerCase(), format, true);
+ assert.equal(r.weekday(), m.weekday(), baseMsg + ' lower strict');
+ }
+
+ for (i = 0; i < 7; ++i) {
+ m = moment.utc([2015, i, 15, 18]);
+ tester('dd');
+ tester('ddd');
+ tester('dddd');
+ }
+ });
+ }
+
+ function setupDeprecationHandler(test, moment, scope) {
+ test._expectedDeprecations = null;
+ test._observedDeprecations = null;
+ test._oldSupress = moment.suppressDeprecationWarnings;
+ moment.suppressDeprecationWarnings = true;
+ test.expectedDeprecations = function () {
+ test._expectedDeprecations = arguments;
+ test._observedDeprecations = [];
+ };
+ moment.deprecationHandler = function (name, msg) {
+ var deprecationId = matchedDeprecation(name, msg, test._expectedDeprecations);
+ if (deprecationId === -1) {
+ throw new Error('Unexpected deprecation thrown name=' +
+ name + ' msg=' + msg);
+ }
+ test._observedDeprecations[deprecationId] = 1;
+ };
+ }
+
+ function teardownDeprecationHandler(test, moment, scope) {
+ moment.suppressDeprecationWarnings = test._oldSupress;
+
+ if (test._expectedDeprecations != null) {
+ var missedDeprecations = [];
+ each(test._expectedDeprecations, function (deprecationPattern, id) {
+ if (test._observedDeprecations[id] !== 1) {
+ missedDeprecations.push(deprecationPattern);
+ }
+ });
+ if (missedDeprecations.length !== 0) {
+ throw new Error('Expected deprecation warnings did not happen: ' +
+ missedDeprecations.join(' '));
+ }
+ }
+ }
+
+ function matchedDeprecation(name, msg, deprecations) {
+ if (deprecations == null) {
+ return -1;
+ }
+ for (var i = 0; i < deprecations.length; ++i) {
+ if (name != null && name === deprecations[i]) {
+ return i;
+ }
+ if (msg != null && msg.substring(0, deprecations[i].length) === deprecations[i]) {
+ return i;
+ }
+ }
+ return -1;
+ }
/*global QUnit:false*/
@@ -13400,11 +18659,13 @@
moment.createFromInputFallback = function (config) {
throw new Error('input not handled by moment: ' + config._i);
};
+ setupDeprecationHandler(test, moment, 'core');
if (lifecycle && lifecycle.setup) {
lifecycle.setup();
}
},
teardown : function () {
+ teardownDeprecationHandler(test, moment, 'core');
if (lifecycle && lifecycle.teardown) {
lifecycle.teardown();
}
@@ -13419,17 +18680,20 @@
moment.createFromInputFallback = function (config) {
throw new Error('input not handled by moment: ' + config._i);
};
+ setupDeprecationHandler(test, moment, 'locale');
if (lifecycle && lifecycle.setup) {
lifecycle.setup();
}
},
teardown : function () {
moment.locale('en');
+ teardownDeprecationHandler(test, moment, 'locale');
if (lifecycle && lifecycle.teardown) {
lifecycle.teardown();
}
}
});
+ defineCommonLocaleTests(name, -1, -1);
}
localeModule('fy');
@@ -13583,14 +18847,14 @@
});
test('calendar day', function (assert) {
- var a = moment().hours(2).minutes(0).seconds(0);
-
- assert.equal(moment(a).calendar(), 'hjoed om 02:00', 'today at the same time');
- assert.equal(moment(a).add({m: 25}).calendar(), 'hjoed om 02:25', 'Now plus 25 min');
- assert.equal(moment(a).add({h: 1}).calendar(), 'hjoed om 03:00', 'Now plus 1 hour');
- assert.equal(moment(a).add({d: 1}).calendar(), 'moarn om 02:00', 'tomorrow at the same time');
- assert.equal(moment(a).subtract({h: 1}).calendar(), 'hjoed om 01:00', 'Now minus 1 hour');
- assert.equal(moment(a).subtract({d: 1}).calendar(), 'juster om 02:00', 'yesterday at the same time');
+ var a = moment().hours(12).minutes(0).seconds(0);
+
+ assert.equal(moment(a).calendar(), 'hjoed om 12:00', 'today at the same time');
+ assert.equal(moment(a).add({m: 25}).calendar(), 'hjoed om 12:25', 'Now plus 25 min');
+ assert.equal(moment(a).add({h: 1}).calendar(), 'hjoed om 13:00', 'Now plus 1 hour');
+ assert.equal(moment(a).add({d: 1}).calendar(), 'moarn om 12:00', 'tomorrow at the same time');
+ assert.equal(moment(a).subtract({h: 1}).calendar(), 'hjoed om 11:00', 'Now minus 1 hour');
+ assert.equal(moment(a).subtract({d: 1}).calendar(), 'juster om 12:00', 'yesterday at the same time');
});
test('calendar next week', function (assert) {
@@ -13636,67 +18900,6 @@
assert.equal(moment([2012, 5, 23]).format('D MMM YYYY'), '23 jun. 2012', 'format month abbreviation not surrounded by dashes should include a dot');
});
- test('weeks year starting sunday', function (assert) {
- assert.equal(moment([2012, 0, 1]).week(), 52, 'Jan 1 2012 should be week 52');
- assert.equal(moment([2012, 0, 2]).week(), 1, 'Jan 2 2012 should be week 1');
- assert.equal(moment([2012, 0, 8]).week(), 1, 'Jan 8 2012 should be week 1');
- assert.equal(moment([2012, 0, 9]).week(), 2, 'Jan 9 2012 should be week 2');
- assert.equal(moment([2012, 0, 15]).week(), 2, 'Jan 15 2012 should be week 2');
- });
-
- test('weeks year starting monday', function (assert) {
- assert.equal(moment([2007, 0, 1]).week(), 1, 'Jan 1 2007 should be week 1');
- assert.equal(moment([2007, 0, 7]).week(), 1, 'Jan 7 2007 should be week 1');
- assert.equal(moment([2007, 0, 8]).week(), 2, 'Jan 8 2007 should be week 2');
- assert.equal(moment([2007, 0, 14]).week(), 2, 'Jan 14 2007 should be week 2');
- assert.equal(moment([2007, 0, 15]).week(), 3, 'Jan 15 2007 should be week 3');
- });
-
- test('weeks year starting tuesday', function (assert) {
- assert.equal(moment([2007, 11, 31]).week(), 1, 'Dec 31 2007 should be week 1');
- assert.equal(moment([2008, 0, 1]).week(), 1, 'Jan 1 2008 should be week 1');
- assert.equal(moment([2008, 0, 6]).week(), 1, 'Jan 6 2008 should be week 1');
- assert.equal(moment([2008, 0, 7]).week(), 2, 'Jan 7 2008 should be week 2');
- assert.equal(moment([2008, 0, 13]).week(), 2, 'Jan 13 2008 should be week 2');
- assert.equal(moment([2008, 0, 14]).week(), 3, 'Jan 14 2008 should be week 3');
- });
-
- test('weeks year starting wednesday', function (assert) {
- assert.equal(moment([2002, 11, 30]).week(), 1, 'Dec 30 2002 should be week 1');
- assert.equal(moment([2003, 0, 1]).week(), 1, 'Jan 1 2003 should be week 1');
- assert.equal(moment([2003, 0, 5]).week(), 1, 'Jan 5 2003 should be week 1');
- assert.equal(moment([2003, 0, 6]).week(), 2, 'Jan 6 2003 should be week 2');
- assert.equal(moment([2003, 0, 12]).week(), 2, 'Jan 12 2003 should be week 2');
- assert.equal(moment([2003, 0, 13]).week(), 3, 'Jan 13 2003 should be week 3');
- });
-
- test('weeks year starting thursday', function (assert) {
- assert.equal(moment([2008, 11, 29]).week(), 1, 'Dec 29 2008 should be week 1');
- assert.equal(moment([2009, 0, 1]).week(), 1, 'Jan 1 2009 should be week 1');
- assert.equal(moment([2009, 0, 4]).week(), 1, 'Jan 4 2009 should be week 1');
- assert.equal(moment([2009, 0, 5]).week(), 2, 'Jan 5 2009 should be week 2');
- assert.equal(moment([2009, 0, 11]).week(), 2, 'Jan 11 2009 should be week 2');
- assert.equal(moment([2009, 0, 13]).week(), 3, 'Jan 12 2009 should be week 3');
- });
-
- test('weeks year starting friday', function (assert) {
- assert.equal(moment([2009, 11, 28]).week(), 53, 'Dec 28 2009 should be week 53');
- assert.equal(moment([2010, 0, 1]).week(), 53, 'Jan 1 2010 should be week 53');
- assert.equal(moment([2010, 0, 3]).week(), 53, 'Jan 3 2010 should be week 53');
- assert.equal(moment([2010, 0, 4]).week(), 1, 'Jan 4 2010 should be week 1');
- assert.equal(moment([2010, 0, 10]).week(), 1, 'Jan 10 2010 should be week 1');
- assert.equal(moment([2010, 0, 11]).week(), 2, 'Jan 11 2010 should be week 2');
- });
-
- test('weeks year starting saturday', function (assert) {
- assert.equal(moment([2010, 11, 27]).week(), 52, 'Dec 27 2010 should be week 52');
- assert.equal(moment([2011, 0, 1]).week(), 52, 'Jan 1 2011 should be week 52');
- assert.equal(moment([2011, 0, 2]).week(), 52, 'Jan 2 2011 should be week 52');
- assert.equal(moment([2011, 0, 3]).week(), 1, 'Jan 3 2011 should be week 1');
- assert.equal(moment([2011, 0, 9]).week(), 1, 'Jan 9 2011 should be week 1');
- assert.equal(moment([2011, 0, 10]).week(), 2, 'Jan 10 2011 should be week 2');
- });
-
test('weeks year starting sunday formatted', function (assert) {
assert.equal(moment([2012, 0, 1]).format('w ww wo'), '52 52 52ste', 'Jan 1 2012 should be week 52');
assert.equal(moment([2012, 0, 2]).format('w ww wo'), '1 01 1ste', 'Jan 2 2012 should be week 1');
@@ -13705,42 +18908,6 @@
assert.equal(moment([2012, 0, 15]).format('w ww wo'), '2 02 2de', 'Jan 15 2012 should be week 2');
});
- test('lenient ordinal parsing', function (assert) {
- var i, ordinalStr, testMoment;
- for (i = 1; i <= 31; ++i) {
- ordinalStr = moment([2014, 0, i]).format('YYYY MM Do');
- testMoment = moment(ordinalStr, 'YYYY MM Do');
- assert.equal(testMoment.year(), 2014,
- 'lenient ordinal parsing ' + i + ' year check');
- assert.equal(testMoment.month(), 0,
- 'lenient ordinal parsing ' + i + ' month check');
- assert.equal(testMoment.date(), i,
- 'lenient ordinal parsing ' + i + ' date check');
- }
- });
-
- test('lenient ordinal parsing of number', function (assert) {
- var i, testMoment;
- for (i = 1; i <= 31; ++i) {
- testMoment = moment('2014 01 ' + i, 'YYYY MM Do');
- assert.equal(testMoment.year(), 2014,
- 'lenient ordinal parsing of number ' + i + ' year check');
- assert.equal(testMoment.month(), 0,
- 'lenient ordinal parsing of number ' + i + ' month check');
- assert.equal(testMoment.date(), i,
- 'lenient ordinal parsing of number ' + i + ' date check');
- }
- });
-
- test('strict ordinal parsing', function (assert) {
- var i, ordinalStr, testMoment;
- for (i = 1; i <= 31; ++i) {
- ordinalStr = moment([2014, 0, i]).format('YYYY MM Do');
- testMoment = moment(ordinalStr, 'YYYY MM Do', true);
- assert.ok(testMoment.isValid(), 'strict ordinal parsing ' + i);
- }
- });
-
}));
;(function (global, factory) {
@@ -13749,6 +18916,224 @@
typeof define === 'function' && define.amd ? define(['../../moment'], factory) :
factory(global.moment)
}(this, function (moment) { 'use strict';
+
+ function each(array, callback) {
+ var i;
+ for (i = 0; i < array.length; i++) {
+ callback(array[i], i, array);
+ }
+ }
+
+ function objectKeys(obj) {
+ if (Object.keys) {
+ return Object.keys(obj);
+ } else {
+ // IE8
+ var res = [], i;
+ for (i in obj) {
+ if (obj.hasOwnProperty(i)) {
+ res.push(i);
+ }
+ }
+ return res;
+ }
+ }
+
+ // Pick the first defined of two or three arguments.
+ function defaults(a, b, c) {
+ if (a != null) {
+ return a;
+ }
+ if (b != null) {
+ return b;
+ }
+ return c;
+ }
+
+ function defineCommonLocaleTests(locale, options) {
+ test('lenient ordinal parsing', function (assert) {
+ var i, ordinalStr, testMoment;
+ for (i = 1; i <= 31; ++i) {
+ ordinalStr = moment([2014, 0, i]).format('YYYY MM Do');
+ testMoment = moment(ordinalStr, 'YYYY MM Do');
+ assert.equal(testMoment.year(), 2014,
+ 'lenient ordinal parsing ' + i + ' year check');
+ assert.equal(testMoment.month(), 0,
+ 'lenient ordinal parsing ' + i + ' month check');
+ assert.equal(testMoment.date(), i,
+ 'lenient ordinal parsing ' + i + ' date check');
+ }
+ });
+
+ test('lenient ordinal parsing of number', function (assert) {
+ var i, testMoment;
+ for (i = 1; i <= 31; ++i) {
+ testMoment = moment('2014 01 ' + i, 'YYYY MM Do');
+ assert.equal(testMoment.year(), 2014,
+ 'lenient ordinal parsing of number ' + i + ' year check');
+ assert.equal(testMoment.month(), 0,
+ 'lenient ordinal parsing of number ' + i + ' month check');
+ assert.equal(testMoment.date(), i,
+ 'lenient ordinal parsing of number ' + i + ' date check');
+ }
+ });
+
+ test('strict ordinal parsing', function (assert) {
+ var i, ordinalStr, testMoment;
+ for (i = 1; i <= 31; ++i) {
+ ordinalStr = moment([2014, 0, i]).format('YYYY MM Do');
+ testMoment = moment(ordinalStr, 'YYYY MM Do', true);
+ assert.ok(testMoment.isValid(), 'strict ordinal parsing ' + i);
+ }
+ });
+
+ test('meridiem invariant', function (assert) {
+ var h, m, t1, t2;
+ for (h = 0; h < 24; ++h) {
+ for (m = 0; m < 60; m += 15) {
+ t1 = moment.utc([2000, 0, 1, h, m]);
+ t2 = moment.utc(t1.format('A h:mm'), 'A h:mm');
+ assert.equal(t2.format('HH:mm'), t1.format('HH:mm'),
+ 'meridiem at ' + t1.format('HH:mm'));
+ }
+ }
+ });
+
+ test('date format correctness', function (assert) {
+ var data, tokens;
+ data = moment.localeData()._longDateFormat;
+ tokens = objectKeys(data);
+ each(tokens, function (srchToken) {
+ // Check each format string to make sure it does not contain any
+ // tokens that need to be expanded.
+ each(tokens, function (baseToken) {
+ // strip escaped sequences
+ var format = data[baseToken].replace(/(\[[^\]]*\])/g, '');
+ assert.equal(false, !!~format.indexOf(srchToken),
+ 'contains ' + srchToken + ' in ' + baseToken);
+ });
+ });
+ });
+
+ test('month parsing correctness', function (assert) {
+ var i, m;
+
+ if (locale === 'tr') {
+ // I can't fix it :(
+ expect(0);
+ return;
+ }
+ function tester(format) {
+ var r;
+ r = moment(m.format(format), format);
+ assert.equal(r.month(), m.month(), 'month ' + i + ' fmt ' + format);
+ r = moment(m.format(format).toLocaleUpperCase(), format);
+ assert.equal(r.month(), m.month(), 'month ' + i + ' fmt ' + format + ' upper');
+ r = moment(m.format(format).toLocaleLowerCase(), format);
+ assert.equal(r.month(), m.month(), 'month ' + i + ' fmt ' + format + ' lower');
+
+ r = moment(m.format(format), format, true);
+ assert.equal(r.month(), m.month(), 'month ' + i + ' fmt ' + format + ' strict');
+ r = moment(m.format(format).toLocaleUpperCase(), format, true);
+ assert.equal(r.month(), m.month(), 'month ' + i + ' fmt ' + format + ' upper strict');
+ r = moment(m.format(format).toLocaleLowerCase(), format, true);
+ assert.equal(r.month(), m.month(), 'month ' + i + ' fmt ' + format + ' lower strict');
+ }
+
+ for (i = 0; i < 12; ++i) {
+ m = moment([2015, i, 15, 18]);
+ tester('MMM');
+ tester('MMM.');
+ tester('MMMM');
+ tester('MMMM.');
+ }
+ });
+
+ test('weekday parsing correctness', function (assert) {
+ var i, m;
+
+ if (locale === 'tr' || locale === 'az') {
+ // There is a lower-case letter (ı), that converted to upper then
+ // lower changes to i
+ expect(0);
+ return;
+ }
+ function tester(format) {
+ var r, baseMsg = 'weekday ' + m.weekday() + ' fmt ' + format;
+ r = moment(m.format(format), format);
+ assert.equal(r.weekday(), m.weekday(), baseMsg);
+ r = moment(m.format(format).toLocaleUpperCase(), format);
+ assert.equal(r.weekday(), m.weekday(), baseMsg + ' upper');
+ r = moment(m.format(format).toLocaleLowerCase(), format);
+ assert.equal(r.weekday(), m.weekday(), baseMsg + ' lower');
+
+ r = moment(m.format(format), format, true);
+ assert.equal(r.weekday(), m.weekday(), baseMsg + ' strict');
+ r = moment(m.format(format).toLocaleUpperCase(), format, true);
+ assert.equal(r.weekday(), m.weekday(), baseMsg + ' upper strict');
+ r = moment(m.format(format).toLocaleLowerCase(), format, true);
+ assert.equal(r.weekday(), m.weekday(), baseMsg + ' lower strict');
+ }
+
+ for (i = 0; i < 7; ++i) {
+ m = moment.utc([2015, i, 15, 18]);
+ tester('dd');
+ tester('ddd');
+ tester('dddd');
+ }
+ });
+ }
+
+ function setupDeprecationHandler(test, moment, scope) {
+ test._expectedDeprecations = null;
+ test._observedDeprecations = null;
+ test._oldSupress = moment.suppressDeprecationWarnings;
+ moment.suppressDeprecationWarnings = true;
+ test.expectedDeprecations = function () {
+ test._expectedDeprecations = arguments;
+ test._observedDeprecations = [];
+ };
+ moment.deprecationHandler = function (name, msg) {
+ var deprecationId = matchedDeprecation(name, msg, test._expectedDeprecations);
+ if (deprecationId === -1) {
+ throw new Error('Unexpected deprecation thrown name=' +
+ name + ' msg=' + msg);
+ }
+ test._observedDeprecations[deprecationId] = 1;
+ };
+ }
+
+ function teardownDeprecationHandler(test, moment, scope) {
+ moment.suppressDeprecationWarnings = test._oldSupress;
+
+ if (test._expectedDeprecations != null) {
+ var missedDeprecations = [];
+ each(test._expectedDeprecations, function (deprecationPattern, id) {
+ if (test._observedDeprecations[id] !== 1) {
+ missedDeprecations.push(deprecationPattern);
+ }
+ });
+ if (missedDeprecations.length !== 0) {
+ throw new Error('Expected deprecation warnings did not happen: ' +
+ missedDeprecations.join(' '));
+ }
+ }
+ }
+
+ function matchedDeprecation(name, msg, deprecations) {
+ if (deprecations == null) {
+ return -1;
+ }
+ for (var i = 0; i < deprecations.length; ++i) {
+ if (name != null && name === deprecations[i]) {
+ return i;
+ }
+ if (msg != null && msg.substring(0, deprecations[i].length) === deprecations[i]) {
+ return i;
+ }
+ }
+ return -1;
+ }
/*global QUnit:false*/
@@ -13763,11 +19148,13 @@
moment.createFromInputFallback = function (config) {
throw new Error('input not handled by moment: ' + config._i);
};
+ setupDeprecationHandler(test, moment, 'core');
if (lifecycle && lifecycle.setup) {
lifecycle.setup();
}
},
teardown : function () {
+ teardownDeprecationHandler(test, moment, 'core');
if (lifecycle && lifecycle.teardown) {
lifecycle.teardown();
}
@@ -13782,17 +19169,20 @@
moment.createFromInputFallback = function (config) {
throw new Error('input not handled by moment: ' + config._i);
};
+ setupDeprecationHandler(test, moment, 'locale');
if (lifecycle && lifecycle.setup) {
lifecycle.setup();
}
},
teardown : function () {
moment.locale('en');
+ teardownDeprecationHandler(test, moment, 'locale');
if (lifecycle && lifecycle.teardown) {
lifecycle.teardown();
}
}
});
+ defineCommonLocaleTests(name, -1, -1);
}
localeModule('gd');
@@ -13814,7 +19204,7 @@
test('parse', function (assert) {
function equalTest(monthName, monthFormat, monthNum) {
- assert.equal(moment(monthName, monthFormat).month(), monthNum, monthName + ' should be month ' + monthNum + 1);
+ assert.equal(moment(monthName, monthFormat).month(), monthNum, monthName + ' should be month ' + (monthNum + 1));
}
for (var i = 0; i < 12; i++) {
@@ -13958,14 +19348,14 @@
});
test('calendar day', function (assert) {
- var a = moment().hours(2).minutes(0).seconds(0);
-
- assert.equal(moment(a).calendar(), 'An-diugh aig 02:00', 'today at the same time');
- assert.equal(moment(a).add({m: 25}).calendar(), 'An-diugh aig 02:25', 'Now plus 25 min');
- assert.equal(moment(a).add({h: 1}).calendar(), 'An-diugh aig 03:00', 'Now plus 1 hour');
- assert.equal(moment(a).add({d: 1}).calendar(), 'A-màireach aig 02:00', 'tomorrow at the same time');
- assert.equal(moment(a).subtract({h: 1}).calendar(), 'An-diugh aig 01:00', 'Now minus 1 hour');
- assert.equal(moment(a).subtract({d: 1}).calendar(), 'An-dè aig 02:00', 'yesterday at the same time');
+ var a = moment().hours(12).minutes(0).seconds(0);
+
+ assert.equal(moment(a).calendar(), 'An-diugh aig 12:00', 'today at the same time');
+ assert.equal(moment(a).add({m: 25}).calendar(), 'An-diugh aig 12:25', 'Now plus 25 min');
+ assert.equal(moment(a).add({h: 1}).calendar(), 'An-diugh aig 13:00', 'Now plus 1 hour');
+ assert.equal(moment(a).add({d: 1}).calendar(), 'A-màireach aig 12:00', 'tomorrow at the same time');
+ assert.equal(moment(a).subtract({h: 1}).calendar(), 'An-diugh aig 11:00', 'Now minus 1 hour');
+ assert.equal(moment(a).subtract({d: 1}).calendar(), 'An-dè aig 12:00', 'yesterday at the same time');
});
test('calendar next week', function (assert) {
@@ -14007,67 +19397,6 @@
assert.equal(weeksFromNow.calendar(), weeksFromNow.format('L'), 'in 2 weeks');
});
- test('weeks year starting sunday', function (assert) {
- assert.equal(moment([2012, 0, 1]).week(), 52, 'Faoi 1 2012 should be week 52');
- assert.equal(moment([2012, 0, 2]).week(), 1, 'Faoi 2 2012 should be week 1');
- assert.equal(moment([2012, 0, 8]).week(), 1, 'Faoi 8 2012 should be week 1');
- assert.equal(moment([2012, 0, 9]).week(), 2, 'Faoi 9 2012 should be week 2');
- assert.equal(moment([2012, 0, 15]).week(), 2, 'Faoi 15 2012 should be week 2');
- });
-
- test('weeks year starting monday', function (assert) {
- assert.equal(moment([2007, 0, 1]).week(), 1, 'Faoi 1 2007 should be week 1');
- assert.equal(moment([2007, 0, 7]).week(), 1, 'Faoi 7 2007 should be week 1');
- assert.equal(moment([2007, 0, 8]).week(), 2, 'Faoi 8 2007 should be week 2');
- assert.equal(moment([2007, 0, 14]).week(), 2, 'Faoi 14 2007 should be week 2');
- assert.equal(moment([2007, 0, 15]).week(), 3, 'Faoi 15 2007 should be week 3');
- });
-
- test('weeks year starting tuesday', function (assert) {
- assert.equal(moment([2007, 11, 31]).week(), 1, 'Dùbh 31 2007 should be week 1');
- assert.equal(moment([2008, 0, 1]).week(), 1, 'Faoi 1 2008 should be week 1');
- assert.equal(moment([2008, 0, 6]).week(), 1, 'Faoi 6 2008 should be week 1');
- assert.equal(moment([2008, 0, 7]).week(), 2, 'Faoi 7 2008 should be week 2');
- assert.equal(moment([2008, 0, 13]).week(), 2, 'Faoi 13 2008 should be week 2');
- assert.equal(moment([2008, 0, 14]).week(), 3, 'Faoi 14 2008 should be week 3');
- });
-
- test('weeks year starting wednesday', function (assert) {
- assert.equal(moment([2002, 11, 30]).week(), 1, 'Dùbh 30 2002 should be week 1');
- assert.equal(moment([2003, 0, 1]).week(), 1, 'Faoi 1 2003 should be week 1');
- assert.equal(moment([2003, 0, 5]).week(), 1, 'Faoi 5 2003 should be week 1');
- assert.equal(moment([2003, 0, 6]).week(), 2, 'Faoi 6 2003 should be week 2');
- assert.equal(moment([2003, 0, 12]).week(), 2, 'Faoi 12 2003 should be week 2');
- assert.equal(moment([2003, 0, 13]).week(), 3, 'Faoi 13 2003 should be week 3');
- });
-
- test('weeks year starting thursday', function (assert) {
- assert.equal(moment([2008, 11, 29]).week(), 1, 'Dùbh 29 2008 should be week 1');
- assert.equal(moment([2009, 0, 1]).week(), 1, 'Faoi 1 2009 should be week 1');
- assert.equal(moment([2009, 0, 4]).week(), 1, 'Faoi 4 2009 should be week 1');
- assert.equal(moment([2009, 0, 5]).week(), 2, 'Faoi 5 2009 should be week 2');
- assert.equal(moment([2009, 0, 11]).week(), 2, 'Faoi 11 2009 should be week 2');
- assert.equal(moment([2009, 0, 13]).week(), 3, 'Faoi 12 2009 should be week 3');
- });
-
- test('weeks year starting friday', function (assert) {
- assert.equal(moment([2009, 11, 28]).week(), 53, 'Dùbh 28 2009 should be week 53');
- assert.equal(moment([2010, 0, 1]).week(), 53, 'Faoi 1 2010 should be week 53');
- assert.equal(moment([2010, 0, 3]).week(), 53, 'Faoi 3 2010 should be week 53');
- assert.equal(moment([2010, 0, 4]).week(), 1, 'Faoi 4 2010 should be week 1');
- assert.equal(moment([2010, 0, 10]).week(), 1, 'Faoi 10 2010 should be week 1');
- assert.equal(moment([2010, 0, 11]).week(), 2, 'Faoi 11 2010 should be week 2');
- });
-
- test('weeks year starting saturday', function (assert) {
- assert.equal(moment([2010, 11, 27]).week(), 52, 'Dùbh 27 2010 should be week 52');
- assert.equal(moment([2011, 0, 1]).week(), 52, 'Faoi 1 2011 should be week 52');
- assert.equal(moment([2011, 0, 2]).week(), 52, 'Faoi 2 2011 should be week 52');
- assert.equal(moment([2011, 0, 3]).week(), 1, 'Faoi 3 2011 should be week 1');
- assert.equal(moment([2011, 0, 9]).week(), 1, 'Faoi 9 2011 should be week 1');
- assert.equal(moment([2011, 0, 10]).week(), 2, 'Faoi 10 2011 should be week 2');
- });
-
test('weeks year starting sunday formatted', function (assert) {
assert.equal(moment([2012, 0, 1]).format('w ww wo'), '52 52 52na', 'Faoi 1 2012 should be week 52');
assert.equal(moment([2012, 0, 2]).format('w ww wo'), '1 01 1d', 'Faoi 2 2012 should be week 1');
@@ -14076,42 +19405,6 @@
assert.equal(moment([2012, 0, 15]).format('w ww wo'), '2 02 2na', 'Faoi 15 2012 should be week 2');
});
- test('lenient ordinal parsing', function (assert) {
- var i, ordinalStr, testMoment;
- for (i = 1; i <= 31; ++i) {
- ordinalStr = moment([2014, 0, i]).format('YYYY MM Do');
- testMoment = moment(ordinalStr, 'YYYY MM Do');
- assert.equal(testMoment.year(), 2014,
- 'lenient ordinal parsing ' + i + ' year check');
- assert.equal(testMoment.month(), 0,
- 'lenient ordinal parsing ' + i + ' month check');
- assert.equal(testMoment.date(), i,
- 'lenient ordinal parsing ' + i + ' date check');
- }
- });
-
- test('lenient ordinal parsing of number', function (assert) {
- var i, testMoment;
- for (i = 1; i <= 31; ++i) {
- testMoment = moment('2014 01 ' + i, 'YYYY MM Do');
- assert.equal(testMoment.year(), 2014,
- 'lenient ordinal parsing of number ' + i + ' year check');
- assert.equal(testMoment.month(), 0,
- 'lenient ordinal parsing of number ' + i + ' month check');
- assert.equal(testMoment.date(), i,
- 'lenient ordinal parsing of number ' + i + ' date check');
- }
- });
-
- test('strict ordinal parsing', function (assert) {
- var i, ordinalStr, testMoment;
- for (i = 1; i <= 31; ++i) {
- ordinalStr = moment([2014, 0, i]).format('YYYY MM Do');
- testMoment = moment(ordinalStr, 'YYYY MM Do', true);
- assert.ok(testMoment.isValid(), 'strict ordinal parsing ' + i);
- }
- });
-
}));
;(function (global, factory) {
@@ -14120,6 +19413,224 @@
typeof define === 'function' && define.amd ? define(['../../moment'], factory) :
factory(global.moment)
}(this, function (moment) { 'use strict';
+
+ function each(array, callback) {
+ var i;
+ for (i = 0; i < array.length; i++) {
+ callback(array[i], i, array);
+ }
+ }
+
+ function objectKeys(obj) {
+ if (Object.keys) {
+ return Object.keys(obj);
+ } else {
+ // IE8
+ var res = [], i;
+ for (i in obj) {
+ if (obj.hasOwnProperty(i)) {
+ res.push(i);
+ }
+ }
+ return res;
+ }
+ }
+
+ // Pick the first defined of two or three arguments.
+ function defaults(a, b, c) {
+ if (a != null) {
+ return a;
+ }
+ if (b != null) {
+ return b;
+ }
+ return c;
+ }
+
+ function defineCommonLocaleTests(locale, options) {
+ test('lenient ordinal parsing', function (assert) {
+ var i, ordinalStr, testMoment;
+ for (i = 1; i <= 31; ++i) {
+ ordinalStr = moment([2014, 0, i]).format('YYYY MM Do');
+ testMoment = moment(ordinalStr, 'YYYY MM Do');
+ assert.equal(testMoment.year(), 2014,
+ 'lenient ordinal parsing ' + i + ' year check');
+ assert.equal(testMoment.month(), 0,
+ 'lenient ordinal parsing ' + i + ' month check');
+ assert.equal(testMoment.date(), i,
+ 'lenient ordinal parsing ' + i + ' date check');
+ }
+ });
+
+ test('lenient ordinal parsing of number', function (assert) {
+ var i, testMoment;
+ for (i = 1; i <= 31; ++i) {
+ testMoment = moment('2014 01 ' + i, 'YYYY MM Do');
+ assert.equal(testMoment.year(), 2014,
+ 'lenient ordinal parsing of number ' + i + ' year check');
+ assert.equal(testMoment.month(), 0,
+ 'lenient ordinal parsing of number ' + i + ' month check');
+ assert.equal(testMoment.date(), i,
+ 'lenient ordinal parsing of number ' + i + ' date check');
+ }
+ });
+
+ test('strict ordinal parsing', function (assert) {
+ var i, ordinalStr, testMoment;
+ for (i = 1; i <= 31; ++i) {
+ ordinalStr = moment([2014, 0, i]).format('YYYY MM Do');
+ testMoment = moment(ordinalStr, 'YYYY MM Do', true);
+ assert.ok(testMoment.isValid(), 'strict ordinal parsing ' + i);
+ }
+ });
+
+ test('meridiem invariant', function (assert) {
+ var h, m, t1, t2;
+ for (h = 0; h < 24; ++h) {
+ for (m = 0; m < 60; m += 15) {
+ t1 = moment.utc([2000, 0, 1, h, m]);
+ t2 = moment.utc(t1.format('A h:mm'), 'A h:mm');
+ assert.equal(t2.format('HH:mm'), t1.format('HH:mm'),
+ 'meridiem at ' + t1.format('HH:mm'));
+ }
+ }
+ });
+
+ test('date format correctness', function (assert) {
+ var data, tokens;
+ data = moment.localeData()._longDateFormat;
+ tokens = objectKeys(data);
+ each(tokens, function (srchToken) {
+ // Check each format string to make sure it does not contain any
+ // tokens that need to be expanded.
+ each(tokens, function (baseToken) {
+ // strip escaped sequences
+ var format = data[baseToken].replace(/(\[[^\]]*\])/g, '');
+ assert.equal(false, !!~format.indexOf(srchToken),
+ 'contains ' + srchToken + ' in ' + baseToken);
+ });
+ });
+ });
+
+ test('month parsing correctness', function (assert) {
+ var i, m;
+
+ if (locale === 'tr') {
+ // I can't fix it :(
+ expect(0);
+ return;
+ }
+ function tester(format) {
+ var r;
+ r = moment(m.format(format), format);
+ assert.equal(r.month(), m.month(), 'month ' + i + ' fmt ' + format);
+ r = moment(m.format(format).toLocaleUpperCase(), format);
+ assert.equal(r.month(), m.month(), 'month ' + i + ' fmt ' + format + ' upper');
+ r = moment(m.format(format).toLocaleLowerCase(), format);
+ assert.equal(r.month(), m.month(), 'month ' + i + ' fmt ' + format + ' lower');
+
+ r = moment(m.format(format), format, true);
+ assert.equal(r.month(), m.month(), 'month ' + i + ' fmt ' + format + ' strict');
+ r = moment(m.format(format).toLocaleUpperCase(), format, true);
+ assert.equal(r.month(), m.month(), 'month ' + i + ' fmt ' + format + ' upper strict');
+ r = moment(m.format(format).toLocaleLowerCase(), format, true);
+ assert.equal(r.month(), m.month(), 'month ' + i + ' fmt ' + format + ' lower strict');
+ }
+
+ for (i = 0; i < 12; ++i) {
+ m = moment([2015, i, 15, 18]);
+ tester('MMM');
+ tester('MMM.');
+ tester('MMMM');
+ tester('MMMM.');
+ }
+ });
+
+ test('weekday parsing correctness', function (assert) {
+ var i, m;
+
+ if (locale === 'tr' || locale === 'az') {
+ // There is a lower-case letter (ı), that converted to upper then
+ // lower changes to i
+ expect(0);
+ return;
+ }
+ function tester(format) {
+ var r, baseMsg = 'weekday ' + m.weekday() + ' fmt ' + format;
+ r = moment(m.format(format), format);
+ assert.equal(r.weekday(), m.weekday(), baseMsg);
+ r = moment(m.format(format).toLocaleUpperCase(), format);
+ assert.equal(r.weekday(), m.weekday(), baseMsg + ' upper');
+ r = moment(m.format(format).toLocaleLowerCase(), format);
+ assert.equal(r.weekday(), m.weekday(), baseMsg + ' lower');
+
+ r = moment(m.format(format), format, true);
+ assert.equal(r.weekday(), m.weekday(), baseMsg + ' strict');
+ r = moment(m.format(format).toLocaleUpperCase(), format, true);
+ assert.equal(r.weekday(), m.weekday(), baseMsg + ' upper strict');
+ r = moment(m.format(format).toLocaleLowerCase(), format, true);
+ assert.equal(r.weekday(), m.weekday(), baseMsg + ' lower strict');
+ }
+
+ for (i = 0; i < 7; ++i) {
+ m = moment.utc([2015, i, 15, 18]);
+ tester('dd');
+ tester('ddd');
+ tester('dddd');
+ }
+ });
+ }
+
+ function setupDeprecationHandler(test, moment, scope) {
+ test._expectedDeprecations = null;
+ test._observedDeprecations = null;
+ test._oldSupress = moment.suppressDeprecationWarnings;
+ moment.suppressDeprecationWarnings = true;
+ test.expectedDeprecations = function () {
+ test._expectedDeprecations = arguments;
+ test._observedDeprecations = [];
+ };
+ moment.deprecationHandler = function (name, msg) {
+ var deprecationId = matchedDeprecation(name, msg, test._expectedDeprecations);
+ if (deprecationId === -1) {
+ throw new Error('Unexpected deprecation thrown name=' +
+ name + ' msg=' + msg);
+ }
+ test._observedDeprecations[deprecationId] = 1;
+ };
+ }
+
+ function teardownDeprecationHandler(test, moment, scope) {
+ moment.suppressDeprecationWarnings = test._oldSupress;
+
+ if (test._expectedDeprecations != null) {
+ var missedDeprecations = [];
+ each(test._expectedDeprecations, function (deprecationPattern, id) {
+ if (test._observedDeprecations[id] !== 1) {
+ missedDeprecations.push(deprecationPattern);
+ }
+ });
+ if (missedDeprecations.length !== 0) {
+ throw new Error('Expected deprecation warnings did not happen: ' +
+ missedDeprecations.join(' '));
+ }
+ }
+ }
+
+ function matchedDeprecation(name, msg, deprecations) {
+ if (deprecations == null) {
+ return -1;
+ }
+ for (var i = 0; i < deprecations.length; ++i) {
+ if (name != null && name === deprecations[i]) {
+ return i;
+ }
+ if (msg != null && msg.substring(0, deprecations[i].length) === deprecations[i]) {
+ return i;
+ }
+ }
+ return -1;
+ }
/*global QUnit:false*/
@@ -14134,11 +19645,13 @@
moment.createFromInputFallback = function (config) {
throw new Error('input not handled by moment: ' + config._i);
};
+ setupDeprecationHandler(test, moment, 'core');
if (lifecycle && lifecycle.setup) {
lifecycle.setup();
}
},
teardown : function () {
+ teardownDeprecationHandler(test, moment, 'core');
if (lifecycle && lifecycle.teardown) {
lifecycle.teardown();
}
@@ -14153,17 +19666,20 @@
moment.createFromInputFallback = function (config) {
throw new Error('input not handled by moment: ' + config._i);
};
+ setupDeprecationHandler(test, moment, 'locale');
if (lifecycle && lifecycle.setup) {
lifecycle.setup();
}
},
teardown : function () {
moment.locale('en');
+ teardownDeprecationHandler(test, moment, 'locale');
if (lifecycle && lifecycle.teardown) {
lifecycle.teardown();
}
}
});
+ defineCommonLocaleTests(name, -1, -1);
}
localeModule('gl');
@@ -14319,15 +19835,15 @@
});
test('calendar day', function (assert) {
- var a = moment().hours(2).minutes(0).seconds(0);
-
- assert.equal(moment(a).calendar(), 'hoxe ás 2:00', 'today at the same time');
- assert.equal(moment(a).add({m: 25}).calendar(), 'hoxe ás 2:25', 'Now plus 25 min');
- assert.equal(moment(a).add({h: 1}).calendar(), 'hoxe ás 3:00', 'Now plus 1 hour');
- assert.equal(moment(a).add({d: 1}).calendar(), 'mañá ás 2:00', 'tomorrow at the same time');
- assert.equal(moment(a).add({d: 1, h : -1}).calendar(), 'mañá á 1:00', 'tomorrow minus 1 hour');
- assert.equal(moment(a).subtract({h: 1}).calendar(), 'hoxe á 1:00', 'Now minus 1 hour');
- assert.equal(moment(a).subtract({d: 1}).calendar(), 'onte á 2:00', 'yesterday at the same time');
+ var a = moment().hours(12).minutes(0).seconds(0);
+
+ assert.equal(moment(a).calendar(), 'hoxe ás 12:00', 'today at the same time');
+ assert.equal(moment(a).add({m: 25}).calendar(), 'hoxe ás 12:25', 'Now plus 25 min');
+ assert.equal(moment(a).add({h: 1}).calendar(), 'hoxe ás 13:00', 'Now plus 1 hour');
+ assert.equal(moment(a).add({d: 1}).calendar(), 'mañá ás 12:00', 'tomorrow at the same time');
+ assert.equal(moment(a).add({d: 1, h : -1}).calendar(), 'mañá ás 11:00', 'tomorrow minus 1 hour');
+ assert.equal(moment(a).subtract({h: 1}).calendar(), 'hoxe ás 11:00', 'Now minus 1 hour');
+ assert.equal(moment(a).subtract({d: 1}).calendar(), 'onte á 12:00', 'yesterday at the same time');
});
test('calendar next week', function (assert) {
@@ -14374,67 +19890,6 @@
assert.equal(lastWeek.calendar(), lastWeek.format('[o] dddd [pasado a] LT'), '1 o\'clock bug');
});
- test('weeks year starting sunday', function (assert) {
- assert.equal(moment([2011, 11, 26]).week(), 1, 'Dec 26 2011 should be week 1');
- assert.equal(moment([2012, 0, 1]).week(), 1, 'Jan 1 2012 should be week 1');
- assert.equal(moment([2012, 0, 2]).week(), 2, 'Jan 2 2012 should be week 2');
- assert.equal(moment([2012, 0, 8]).week(), 2, 'Jan 8 2012 should be week 2');
- assert.equal(moment([2012, 0, 9]).week(), 3, 'Jan 9 2012 should be week 3');
- });
-
- test('weeks year starting monday', function (assert) {
- assert.equal(moment([2007, 0, 1]).week(), 1, 'Jan 1 2007 should be week 1');
- assert.equal(moment([2007, 0, 7]).week(), 1, 'Jan 7 2007 should be week 1');
- assert.equal(moment([2007, 0, 8]).week(), 2, 'Jan 8 2007 should be week 2');
- assert.equal(moment([2007, 0, 14]).week(), 2, 'Jan 14 2007 should be week 2');
- assert.equal(moment([2007, 0, 15]).week(), 3, 'Jan 15 2007 should be week 3');
- });
-
- test('weeks year starting tuesday', function (assert) {
- assert.equal(moment([2007, 11, 31]).week(), 1, 'Dec 31 2007 should be week 1');
- assert.equal(moment([2008, 0, 1]).week(), 1, 'Jan 1 2008 should be week 1');
- assert.equal(moment([2008, 0, 6]).week(), 1, 'Jan 6 2008 should be week 1');
- assert.equal(moment([2008, 0, 7]).week(), 2, 'Jan 7 2008 should be week 2');
- assert.equal(moment([2008, 0, 13]).week(), 2, 'Jan 13 2008 should be week 2');
- assert.equal(moment([2008, 0, 14]).week(), 3, 'Jan 14 2008 should be week 3');
- });
-
- test('weeks year starting wednesday', function (assert) {
- assert.equal(moment([2002, 11, 30]).week(), 1, 'Dec 30 2002 should be week 1');
- assert.equal(moment([2003, 0, 1]).week(), 1, 'Jan 1 2003 should be week 1');
- assert.equal(moment([2003, 0, 5]).week(), 1, 'Jan 5 2003 should be week 1');
- assert.equal(moment([2003, 0, 6]).week(), 2, 'Jan 6 2003 should be week 2');
- assert.equal(moment([2003, 0, 12]).week(), 2, 'Jan 12 2003 should be week 2');
- assert.equal(moment([2003, 0, 13]).week(), 3, 'Jan 13 2003 should be week 3');
- });
-
- test('weeks year starting thursday', function (assert) {
- assert.equal(moment([2008, 11, 29]).week(), 1, 'Dec 29 2008 should be week 1');
- assert.equal(moment([2009, 0, 1]).week(), 1, 'Jan 1 2009 should be week 1');
- assert.equal(moment([2009, 0, 4]).week(), 1, 'Jan 4 2009 should be week 1');
- assert.equal(moment([2009, 0, 5]).week(), 2, 'Jan 5 2009 should be week 2');
- assert.equal(moment([2009, 0, 11]).week(), 2, 'Jan 11 2009 should be week 2');
- assert.equal(moment([2009, 0, 12]).week(), 3, 'Jan 12 2009 should be week 3');
- });
-
- test('weeks year starting friday', function (assert) {
- assert.equal(moment([2009, 11, 28]).week(), 1, 'Dec 28 2009 should be week 1');
- assert.equal(moment([2010, 0, 1]).week(), 1, 'Jan 1 2010 should be week 1');
- assert.equal(moment([2010, 0, 3]).week(), 1, 'Jan 3 2010 should be week 1');
- assert.equal(moment([2010, 0, 4]).week(), 2, 'Jan 4 2010 should be week 2');
- assert.equal(moment([2010, 0, 10]).week(), 2, 'Jan 10 2010 should be week 2');
- assert.equal(moment([2010, 0, 11]).week(), 3, 'Jan 11 2010 should be week 3');
- });
-
- test('weeks year starting saturday', function (assert) {
- assert.equal(moment([2010, 11, 27]).week(), 1, 'Dec 27 2010 should be week 1');
- assert.equal(moment([2011, 0, 1]).week(), 1, 'Jan 1 2011 should be week 1');
- assert.equal(moment([2011, 0, 2]).week(), 1, 'Jan 2 2011 should be week 1');
- assert.equal(moment([2011, 0, 3]).week(), 2, 'Jan 3 2011 should be week 2');
- assert.equal(moment([2011, 0, 9]).week(), 2, 'Jan 9 2011 should be week 2');
- assert.equal(moment([2011, 0, 10]).week(), 3, 'Jan 10 2011 should be week 3');
- });
-
test('weeks year starting sunday formatted', function (assert) {
assert.equal(moment([2011, 11, 26]).format('w ww wo'), '1 01 1º', 'Dec 26 2011 should be week 1');
assert.equal(moment([2012, 0, 1]).format('w ww wo'), '1 01 1º', 'Jan 1 2012 should be week 1');
@@ -14443,42 +19898,6 @@
assert.equal(moment([2012, 0, 9]).format('w ww wo'), '3 03 3º', 'Jan 9 2012 should be week 3');
});
- test('lenient ordinal parsing', function (assert) {
- var i, ordinalStr, testMoment;
- for (i = 1; i <= 31; ++i) {
- ordinalStr = moment([2014, 0, i]).format('YYYY MM Do');
- testMoment = moment(ordinalStr, 'YYYY MM Do');
- assert.equal(testMoment.year(), 2014,
- 'lenient ordinal parsing ' + i + ' year check');
- assert.equal(testMoment.month(), 0,
- 'lenient ordinal parsing ' + i + ' month check');
- assert.equal(testMoment.date(), i,
- 'lenient ordinal parsing ' + i + ' date check');
- }
- });
-
- test('lenient ordinal parsing of number', function (assert) {
- var i, testMoment;
- for (i = 1; i <= 31; ++i) {
- testMoment = moment('2014 01 ' + i, 'YYYY MM Do');
- assert.equal(testMoment.year(), 2014,
- 'lenient ordinal parsing of number ' + i + ' year check');
- assert.equal(testMoment.month(), 0,
- 'lenient ordinal parsing of number ' + i + ' month check');
- assert.equal(testMoment.date(), i,
- 'lenient ordinal parsing of number ' + i + ' date check');
- }
- });
-
- test('strict ordinal parsing', function (assert) {
- var i, ordinalStr, testMoment;
- for (i = 1; i <= 31; ++i) {
- ordinalStr = moment([2014, 0, i]).format('YYYY MM Do');
- testMoment = moment(ordinalStr, 'YYYY MM Do', true);
- assert.ok(testMoment.isValid(), 'strict ordinal parsing ' + i);
- }
- });
-
}));
;(function (global, factory) {
@@ -14487,6 +19906,224 @@
typeof define === 'function' && define.amd ? define(['../../moment'], factory) :
factory(global.moment)
}(this, function (moment) { 'use strict';
+
+ function each(array, callback) {
+ var i;
+ for (i = 0; i < array.length; i++) {
+ callback(array[i], i, array);
+ }
+ }
+
+ function objectKeys(obj) {
+ if (Object.keys) {
+ return Object.keys(obj);
+ } else {
+ // IE8
+ var res = [], i;
+ for (i in obj) {
+ if (obj.hasOwnProperty(i)) {
+ res.push(i);
+ }
+ }
+ return res;
+ }
+ }
+
+ // Pick the first defined of two or three arguments.
+ function defaults(a, b, c) {
+ if (a != null) {
+ return a;
+ }
+ if (b != null) {
+ return b;
+ }
+ return c;
+ }
+
+ function defineCommonLocaleTests(locale, options) {
+ test('lenient ordinal parsing', function (assert) {
+ var i, ordinalStr, testMoment;
+ for (i = 1; i <= 31; ++i) {
+ ordinalStr = moment([2014, 0, i]).format('YYYY MM Do');
+ testMoment = moment(ordinalStr, 'YYYY MM Do');
+ assert.equal(testMoment.year(), 2014,
+ 'lenient ordinal parsing ' + i + ' year check');
+ assert.equal(testMoment.month(), 0,
+ 'lenient ordinal parsing ' + i + ' month check');
+ assert.equal(testMoment.date(), i,
+ 'lenient ordinal parsing ' + i + ' date check');
+ }
+ });
+
+ test('lenient ordinal parsing of number', function (assert) {
+ var i, testMoment;
+ for (i = 1; i <= 31; ++i) {
+ testMoment = moment('2014 01 ' + i, 'YYYY MM Do');
+ assert.equal(testMoment.year(), 2014,
+ 'lenient ordinal parsing of number ' + i + ' year check');
+ assert.equal(testMoment.month(), 0,
+ 'lenient ordinal parsing of number ' + i + ' month check');
+ assert.equal(testMoment.date(), i,
+ 'lenient ordinal parsing of number ' + i + ' date check');
+ }
+ });
+
+ test('strict ordinal parsing', function (assert) {
+ var i, ordinalStr, testMoment;
+ for (i = 1; i <= 31; ++i) {
+ ordinalStr = moment([2014, 0, i]).format('YYYY MM Do');
+ testMoment = moment(ordinalStr, 'YYYY MM Do', true);
+ assert.ok(testMoment.isValid(), 'strict ordinal parsing ' + i);
+ }
+ });
+
+ test('meridiem invariant', function (assert) {
+ var h, m, t1, t2;
+ for (h = 0; h < 24; ++h) {
+ for (m = 0; m < 60; m += 15) {
+ t1 = moment.utc([2000, 0, 1, h, m]);
+ t2 = moment.utc(t1.format('A h:mm'), 'A h:mm');
+ assert.equal(t2.format('HH:mm'), t1.format('HH:mm'),
+ 'meridiem at ' + t1.format('HH:mm'));
+ }
+ }
+ });
+
+ test('date format correctness', function (assert) {
+ var data, tokens;
+ data = moment.localeData()._longDateFormat;
+ tokens = objectKeys(data);
+ each(tokens, function (srchToken) {
+ // Check each format string to make sure it does not contain any
+ // tokens that need to be expanded.
+ each(tokens, function (baseToken) {
+ // strip escaped sequences
+ var format = data[baseToken].replace(/(\[[^\]]*\])/g, '');
+ assert.equal(false, !!~format.indexOf(srchToken),
+ 'contains ' + srchToken + ' in ' + baseToken);
+ });
+ });
+ });
+
+ test('month parsing correctness', function (assert) {
+ var i, m;
+
+ if (locale === 'tr') {
+ // I can't fix it :(
+ expect(0);
+ return;
+ }
+ function tester(format) {
+ var r;
+ r = moment(m.format(format), format);
+ assert.equal(r.month(), m.month(), 'month ' + i + ' fmt ' + format);
+ r = moment(m.format(format).toLocaleUpperCase(), format);
+ assert.equal(r.month(), m.month(), 'month ' + i + ' fmt ' + format + ' upper');
+ r = moment(m.format(format).toLocaleLowerCase(), format);
+ assert.equal(r.month(), m.month(), 'month ' + i + ' fmt ' + format + ' lower');
+
+ r = moment(m.format(format), format, true);
+ assert.equal(r.month(), m.month(), 'month ' + i + ' fmt ' + format + ' strict');
+ r = moment(m.format(format).toLocaleUpperCase(), format, true);
+ assert.equal(r.month(), m.month(), 'month ' + i + ' fmt ' + format + ' upper strict');
+ r = moment(m.format(format).toLocaleLowerCase(), format, true);
+ assert.equal(r.month(), m.month(), 'month ' + i + ' fmt ' + format + ' lower strict');
+ }
+
+ for (i = 0; i < 12; ++i) {
+ m = moment([2015, i, 15, 18]);
+ tester('MMM');
+ tester('MMM.');
+ tester('MMMM');
+ tester('MMMM.');
+ }
+ });
+
+ test('weekday parsing correctness', function (assert) {
+ var i, m;
+
+ if (locale === 'tr' || locale === 'az') {
+ // There is a lower-case letter (ı), that converted to upper then
+ // lower changes to i
+ expect(0);
+ return;
+ }
+ function tester(format) {
+ var r, baseMsg = 'weekday ' + m.weekday() + ' fmt ' + format;
+ r = moment(m.format(format), format);
+ assert.equal(r.weekday(), m.weekday(), baseMsg);
+ r = moment(m.format(format).toLocaleUpperCase(), format);
+ assert.equal(r.weekday(), m.weekday(), baseMsg + ' upper');
+ r = moment(m.format(format).toLocaleLowerCase(), format);
+ assert.equal(r.weekday(), m.weekday(), baseMsg + ' lower');
+
+ r = moment(m.format(format), format, true);
+ assert.equal(r.weekday(), m.weekday(), baseMsg + ' strict');
+ r = moment(m.format(format).toLocaleUpperCase(), format, true);
+ assert.equal(r.weekday(), m.weekday(), baseMsg + ' upper strict');
+ r = moment(m.format(format).toLocaleLowerCase(), format, true);
+ assert.equal(r.weekday(), m.weekday(), baseMsg + ' lower strict');
+ }
+
+ for (i = 0; i < 7; ++i) {
+ m = moment.utc([2015, i, 15, 18]);
+ tester('dd');
+ tester('ddd');
+ tester('dddd');
+ }
+ });
+ }
+
+ function setupDeprecationHandler(test, moment, scope) {
+ test._expectedDeprecations = null;
+ test._observedDeprecations = null;
+ test._oldSupress = moment.suppressDeprecationWarnings;
+ moment.suppressDeprecationWarnings = true;
+ test.expectedDeprecations = function () {
+ test._expectedDeprecations = arguments;
+ test._observedDeprecations = [];
+ };
+ moment.deprecationHandler = function (name, msg) {
+ var deprecationId = matchedDeprecation(name, msg, test._expectedDeprecations);
+ if (deprecationId === -1) {
+ throw new Error('Unexpected deprecation thrown name=' +
+ name + ' msg=' + msg);
+ }
+ test._observedDeprecations[deprecationId] = 1;
+ };
+ }
+
+ function teardownDeprecationHandler(test, moment, scope) {
+ moment.suppressDeprecationWarnings = test._oldSupress;
+
+ if (test._expectedDeprecations != null) {
+ var missedDeprecations = [];
+ each(test._expectedDeprecations, function (deprecationPattern, id) {
+ if (test._observedDeprecations[id] !== 1) {
+ missedDeprecations.push(deprecationPattern);
+ }
+ });
+ if (missedDeprecations.length !== 0) {
+ throw new Error('Expected deprecation warnings did not happen: ' +
+ missedDeprecations.join(' '));
+ }
+ }
+ }
+
+ function matchedDeprecation(name, msg, deprecations) {
+ if (deprecations == null) {
+ return -1;
+ }
+ for (var i = 0; i < deprecations.length; ++i) {
+ if (name != null && name === deprecations[i]) {
+ return i;
+ }
+ if (msg != null && msg.substring(0, deprecations[i].length) === deprecations[i]) {
+ return i;
+ }
+ }
+ return -1;
+ }
/*global QUnit:false*/
@@ -14501,11 +20138,13 @@
moment.createFromInputFallback = function (config) {
throw new Error('input not handled by moment: ' + config._i);
};
+ setupDeprecationHandler(test, moment, 'core');
if (lifecycle && lifecycle.setup) {
lifecycle.setup();
}
},
teardown : function () {
+ teardownDeprecationHandler(test, moment, 'core');
if (lifecycle && lifecycle.teardown) {
lifecycle.teardown();
}
@@ -14520,17 +20159,20 @@
moment.createFromInputFallback = function (config) {
throw new Error('input not handled by moment: ' + config._i);
};
+ setupDeprecationHandler(test, moment, 'locale');
if (lifecycle && lifecycle.setup) {
lifecycle.setup();
}
},
teardown : function () {
moment.locale('en');
+ teardownDeprecationHandler(test, moment, 'locale');
if (lifecycle && lifecycle.teardown) {
lifecycle.teardown();
}
}
});
+ defineCommonLocaleTests(name, -1, -1);
}
localeModule('he');
@@ -14555,8 +20197,8 @@
test('format', function (assert) {
var a = [
- ['dddd, MMMM Do YYYY, h:mm:ss a', 'ראשון, פברואר 14 2010, 3:25:50 pm'],
- ['ddd, hA', 'א׳, 3PM'],
+ ['dddd, MMMM Do YYYY, h:mm:ss a', 'ראשון, פברואר 14 2010, 3:25:50 אחה"צ'],
+ ['ddd, h A', 'א׳, 3 אחרי הצהריים'],
['M Mo MM MMMM MMM', '2 2 02 פברואר פבר׳'],
['YYYY YY', '2010 10'],
['D Do DD', '14 14 14'],
@@ -14567,7 +20209,7 @@
['H HH', '15 15'],
['m mm', '25 25'],
['s ss', '50 50'],
- ['a A', 'pm PM'],
+ ['a A', 'אחה"צ אחרי הצהריים'],
['[the] DDDo [day of the year]', 'the 45 day of the year'],
['LTS', '15:25:50'],
['L', '14/02/2010'],
@@ -14649,14 +20291,14 @@
});
test('calendar day', function (assert) {
- var a = moment().hours(2).minutes(0).seconds(0);
-
- assert.equal(moment(a).calendar(), 'היום ב־02:00', 'today at the same time');
- assert.equal(moment(a).add({m: 25}).calendar(), 'היום ב־02:25', 'Now plus 25 min');
- assert.equal(moment(a).add({h: 1}).calendar(), 'היום ב־03:00', 'Now plus 1 hour');
- assert.equal(moment(a).add({d: 1}).calendar(), 'מחר ב־02:00', 'tomorrow at the same time');
- assert.equal(moment(a).subtract({h: 1}).calendar(), 'היום ב־01:00', 'Now minus 1 hour');
- assert.equal(moment(a).subtract({d: 1}).calendar(), 'אתמול ב־02:00', 'yesterday at the same time');
+ var a = moment().hours(12).minutes(0).seconds(0);
+
+ assert.equal(moment(a).calendar(), 'היום ב־12:00', 'today at the same time');
+ assert.equal(moment(a).add({m: 25}).calendar(), 'היום ב־12:25', 'Now plus 25 min');
+ assert.equal(moment(a).add({h: 1}).calendar(), 'היום ב־13:00', 'Now plus 1 hour');
+ assert.equal(moment(a).add({d: 1}).calendar(), 'מחר ב־12:00', 'tomorrow at the same time');
+ assert.equal(moment(a).subtract({h: 1}).calendar(), 'היום ב־11:00', 'Now minus 1 hour');
+ assert.equal(moment(a).subtract({d: 1}).calendar(), 'אתמול ב־12:00', 'yesterday at the same time');
});
test('calendar next week', function (assert) {
@@ -14697,67 +20339,6 @@
assert.equal(weeksFromNow.calendar(), weeksFromNow.format('L'), 'in 2 weeks');
});
- test('weeks year starting sunday', function (assert) {
- assert.equal(moment([2012, 0, 1]).week(), 1, 'Jan 1 2012 should be week 1');
- assert.equal(moment([2012, 0, 7]).week(), 1, 'Jan 7 2012 should be week 1');
- assert.equal(moment([2012, 0, 8]).week(), 2, 'Jan 8 2012 should be week 2');
- assert.equal(moment([2012, 0, 14]).week(), 2, 'Jan 14 2012 should be week 2');
- assert.equal(moment([2012, 0, 15]).week(), 3, 'Jan 15 2012 should be week 3');
- });
-
- test('weeks year starting monday', function (assert) {
- assert.equal(moment([2006, 11, 31]).week(), 1, 'Dec 31 2006 should be week 1');
- assert.equal(moment([2007, 0, 1]).week(), 1, 'Jan 1 2007 should be week 1');
- assert.equal(moment([2007, 0, 6]).week(), 1, 'Jan 6 2007 should be week 1');
- assert.equal(moment([2007, 0, 7]).week(), 2, 'Jan 7 2007 should be week 2');
- assert.equal(moment([2007, 0, 13]).week(), 2, 'Jan 13 2007 should be week 2');
- assert.equal(moment([2007, 0, 14]).week(), 3, 'Jan 14 2007 should be week 3');
- });
-
- test('weeks year starting tuesday', function (assert) {
- assert.equal(moment([2007, 11, 29]).week(), 52, 'Dec 29 2007 should be week 52');
- assert.equal(moment([2008, 0, 1]).week(), 1, 'Jan 1 2008 should be week 1');
- assert.equal(moment([2008, 0, 5]).week(), 1, 'Jan 5 2008 should be week 1');
- assert.equal(moment([2008, 0, 6]).week(), 2, 'Jan 6 2008 should be week 2');
- assert.equal(moment([2008, 0, 12]).week(), 2, 'Jan 12 2008 should be week 2');
- assert.equal(moment([2008, 0, 13]).week(), 3, 'Jan 13 2008 should be week 3');
- });
-
- test('weeks year starting wednesday', function (assert) {
- assert.equal(moment([2002, 11, 29]).week(), 1, 'Dec 29 2002 should be week 1');
- assert.equal(moment([2003, 0, 1]).week(), 1, 'Jan 1 2003 should be week 1');
- assert.equal(moment([2003, 0, 4]).week(), 1, 'Jan 4 2003 should be week 1');
- assert.equal(moment([2003, 0, 5]).week(), 2, 'Jan 5 2003 should be week 2');
- assert.equal(moment([2003, 0, 11]).week(), 2, 'Jan 11 2003 should be week 2');
- assert.equal(moment([2003, 0, 12]).week(), 3, 'Jan 12 2003 should be week 3');
- });
-
- test('weeks year starting thursday', function (assert) {
- assert.equal(moment([2008, 11, 28]).week(), 1, 'Dec 28 2008 should be week 1');
- assert.equal(moment([2009, 0, 1]).week(), 1, 'Jan 1 2009 should be week 1');
- assert.equal(moment([2009, 0, 3]).week(), 1, 'Jan 3 2009 should be week 1');
- assert.equal(moment([2009, 0, 4]).week(), 2, 'Jan 4 2009 should be week 2');
- assert.equal(moment([2009, 0, 10]).week(), 2, 'Jan 10 2009 should be week 2');
- assert.equal(moment([2009, 0, 11]).week(), 3, 'Jan 11 2009 should be week 3');
- });
-
- test('weeks year starting friday', function (assert) {
- assert.equal(moment([2009, 11, 27]).week(), 1, 'Dec 27 2009 should be week 1');
- assert.equal(moment([2010, 0, 1]).week(), 1, 'Jan 1 2010 should be week 1');
- assert.equal(moment([2010, 0, 2]).week(), 1, 'Jan 2 2010 should be week 1');
- assert.equal(moment([2010, 0, 3]).week(), 2, 'Jan 3 2010 should be week 2');
- assert.equal(moment([2010, 0, 9]).week(), 2, 'Jan 9 2010 should be week 2');
- assert.equal(moment([2010, 0, 10]).week(), 3, 'Jan 10 2010 should be week 3');
- });
-
- test('weeks year starting saturday', function (assert) {
- assert.equal(moment([2010, 11, 26]).week(), 1, 'Dec 26 2010 should be week 1');
- assert.equal(moment([2011, 0, 1]).week(), 1, 'Jan 1 2011 should be week 1');
- assert.equal(moment([2011, 0, 2]).week(), 2, 'Jan 2 2011 should be week 2');
- assert.equal(moment([2011, 0, 8]).week(), 2, 'Jan 8 2011 should be week 2');
- assert.equal(moment([2011, 0, 9]).week(), 3, 'Jan 9 2011 should be week 3');
- });
-
test('weeks year starting sunday format', function (assert) {
assert.equal(moment([2012, 0, 1]).format('w ww wo'), '1 01 1', 'Jan 1 2012 should be week 1');
assert.equal(moment([2012, 0, 7]).format('w ww wo'), '1 01 1', 'Jan 7 2012 should be week 1');
@@ -14766,42 +20347,6 @@
assert.equal(moment([2012, 0, 15]).format('w ww wo'), '3 03 3', 'Jan 15 2012 should be week 3');
});
- test('lenient ordinal parsing', function (assert) {
- var i, ordinalStr, testMoment;
- for (i = 1; i <= 31; ++i) {
- ordinalStr = moment([2014, 0, i]).format('YYYY MM Do');
- testMoment = moment(ordinalStr, 'YYYY MM Do');
- assert.equal(testMoment.year(), 2014,
- 'lenient ordinal parsing ' + i + ' year check');
- assert.equal(testMoment.month(), 0,
- 'lenient ordinal parsing ' + i + ' month check');
- assert.equal(testMoment.date(), i,
- 'lenient ordinal parsing ' + i + ' date check');
- }
- });
-
- test('lenient ordinal parsing of number', function (assert) {
- var i, testMoment;
- for (i = 1; i <= 31; ++i) {
- testMoment = moment('2014 01 ' + i, 'YYYY MM Do');
- assert.equal(testMoment.year(), 2014,
- 'lenient ordinal parsing of number ' + i + ' year check');
- assert.equal(testMoment.month(), 0,
- 'lenient ordinal parsing of number ' + i + ' month check');
- assert.equal(testMoment.date(), i,
- 'lenient ordinal parsing of number ' + i + ' date check');
- }
- });
-
- test('strict ordinal parsing', function (assert) {
- var i, ordinalStr, testMoment;
- for (i = 1; i <= 31; ++i) {
- ordinalStr = moment([2014, 0, i]).format('YYYY MM Do');
- testMoment = moment(ordinalStr, 'YYYY MM Do', true);
- assert.ok(testMoment.isValid(), 'strict ordinal parsing ' + i);
- }
- });
-
}));
;(function (global, factory) {
@@ -14810,6 +20355,224 @@
typeof define === 'function' && define.amd ? define(['../../moment'], factory) :
factory(global.moment)
}(this, function (moment) { 'use strict';
+
+ function each(array, callback) {
+ var i;
+ for (i = 0; i < array.length; i++) {
+ callback(array[i], i, array);
+ }
+ }
+
+ function objectKeys(obj) {
+ if (Object.keys) {
+ return Object.keys(obj);
+ } else {
+ // IE8
+ var res = [], i;
+ for (i in obj) {
+ if (obj.hasOwnProperty(i)) {
+ res.push(i);
+ }
+ }
+ return res;
+ }
+ }
+
+ // Pick the first defined of two or three arguments.
+ function defaults(a, b, c) {
+ if (a != null) {
+ return a;
+ }
+ if (b != null) {
+ return b;
+ }
+ return c;
+ }
+
+ function defineCommonLocaleTests(locale, options) {
+ test('lenient ordinal parsing', function (assert) {
+ var i, ordinalStr, testMoment;
+ for (i = 1; i <= 31; ++i) {
+ ordinalStr = moment([2014, 0, i]).format('YYYY MM Do');
+ testMoment = moment(ordinalStr, 'YYYY MM Do');
+ assert.equal(testMoment.year(), 2014,
+ 'lenient ordinal parsing ' + i + ' year check');
+ assert.equal(testMoment.month(), 0,
+ 'lenient ordinal parsing ' + i + ' month check');
+ assert.equal(testMoment.date(), i,
+ 'lenient ordinal parsing ' + i + ' date check');
+ }
+ });
+
+ test('lenient ordinal parsing of number', function (assert) {
+ var i, testMoment;
+ for (i = 1; i <= 31; ++i) {
+ testMoment = moment('2014 01 ' + i, 'YYYY MM Do');
+ assert.equal(testMoment.year(), 2014,
+ 'lenient ordinal parsing of number ' + i + ' year check');
+ assert.equal(testMoment.month(), 0,
+ 'lenient ordinal parsing of number ' + i + ' month check');
+ assert.equal(testMoment.date(), i,
+ 'lenient ordinal parsing of number ' + i + ' date check');
+ }
+ });
+
+ test('strict ordinal parsing', function (assert) {
+ var i, ordinalStr, testMoment;
+ for (i = 1; i <= 31; ++i) {
+ ordinalStr = moment([2014, 0, i]).format('YYYY MM Do');
+ testMoment = moment(ordinalStr, 'YYYY MM Do', true);
+ assert.ok(testMoment.isValid(), 'strict ordinal parsing ' + i);
+ }
+ });
+
+ test('meridiem invariant', function (assert) {
+ var h, m, t1, t2;
+ for (h = 0; h < 24; ++h) {
+ for (m = 0; m < 60; m += 15) {
+ t1 = moment.utc([2000, 0, 1, h, m]);
+ t2 = moment.utc(t1.format('A h:mm'), 'A h:mm');
+ assert.equal(t2.format('HH:mm'), t1.format('HH:mm'),
+ 'meridiem at ' + t1.format('HH:mm'));
+ }
+ }
+ });
+
+ test('date format correctness', function (assert) {
+ var data, tokens;
+ data = moment.localeData()._longDateFormat;
+ tokens = objectKeys(data);
+ each(tokens, function (srchToken) {
+ // Check each format string to make sure it does not contain any
+ // tokens that need to be expanded.
+ each(tokens, function (baseToken) {
+ // strip escaped sequences
+ var format = data[baseToken].replace(/(\[[^\]]*\])/g, '');
+ assert.equal(false, !!~format.indexOf(srchToken),
+ 'contains ' + srchToken + ' in ' + baseToken);
+ });
+ });
+ });
+
+ test('month parsing correctness', function (assert) {
+ var i, m;
+
+ if (locale === 'tr') {
+ // I can't fix it :(
+ expect(0);
+ return;
+ }
+ function tester(format) {
+ var r;
+ r = moment(m.format(format), format);
+ assert.equal(r.month(), m.month(), 'month ' + i + ' fmt ' + format);
+ r = moment(m.format(format).toLocaleUpperCase(), format);
+ assert.equal(r.month(), m.month(), 'month ' + i + ' fmt ' + format + ' upper');
+ r = moment(m.format(format).toLocaleLowerCase(), format);
+ assert.equal(r.month(), m.month(), 'month ' + i + ' fmt ' + format + ' lower');
+
+ r = moment(m.format(format), format, true);
+ assert.equal(r.month(), m.month(), 'month ' + i + ' fmt ' + format + ' strict');
+ r = moment(m.format(format).toLocaleUpperCase(), format, true);
+ assert.equal(r.month(), m.month(), 'month ' + i + ' fmt ' + format + ' upper strict');
+ r = moment(m.format(format).toLocaleLowerCase(), format, true);
+ assert.equal(r.month(), m.month(), 'month ' + i + ' fmt ' + format + ' lower strict');
+ }
+
+ for (i = 0; i < 12; ++i) {
+ m = moment([2015, i, 15, 18]);
+ tester('MMM');
+ tester('MMM.');
+ tester('MMMM');
+ tester('MMMM.');
+ }
+ });
+
+ test('weekday parsing correctness', function (assert) {
+ var i, m;
+
+ if (locale === 'tr' || locale === 'az') {
+ // There is a lower-case letter (ı), that converted to upper then
+ // lower changes to i
+ expect(0);
+ return;
+ }
+ function tester(format) {
+ var r, baseMsg = 'weekday ' + m.weekday() + ' fmt ' + format;
+ r = moment(m.format(format), format);
+ assert.equal(r.weekday(), m.weekday(), baseMsg);
+ r = moment(m.format(format).toLocaleUpperCase(), format);
+ assert.equal(r.weekday(), m.weekday(), baseMsg + ' upper');
+ r = moment(m.format(format).toLocaleLowerCase(), format);
+ assert.equal(r.weekday(), m.weekday(), baseMsg + ' lower');
+
+ r = moment(m.format(format), format, true);
+ assert.equal(r.weekday(), m.weekday(), baseMsg + ' strict');
+ r = moment(m.format(format).toLocaleUpperCase(), format, true);
+ assert.equal(r.weekday(), m.weekday(), baseMsg + ' upper strict');
+ r = moment(m.format(format).toLocaleLowerCase(), format, true);
+ assert.equal(r.weekday(), m.weekday(), baseMsg + ' lower strict');
+ }
+
+ for (i = 0; i < 7; ++i) {
+ m = moment.utc([2015, i, 15, 18]);
+ tester('dd');
+ tester('ddd');
+ tester('dddd');
+ }
+ });
+ }
+
+ function setupDeprecationHandler(test, moment, scope) {
+ test._expectedDeprecations = null;
+ test._observedDeprecations = null;
+ test._oldSupress = moment.suppressDeprecationWarnings;
+ moment.suppressDeprecationWarnings = true;
+ test.expectedDeprecations = function () {
+ test._expectedDeprecations = arguments;
+ test._observedDeprecations = [];
+ };
+ moment.deprecationHandler = function (name, msg) {
+ var deprecationId = matchedDeprecation(name, msg, test._expectedDeprecations);
+ if (deprecationId === -1) {
+ throw new Error('Unexpected deprecation thrown name=' +
+ name + ' msg=' + msg);
+ }
+ test._observedDeprecations[deprecationId] = 1;
+ };
+ }
+
+ function teardownDeprecationHandler(test, moment, scope) {
+ moment.suppressDeprecationWarnings = test._oldSupress;
+
+ if (test._expectedDeprecations != null) {
+ var missedDeprecations = [];
+ each(test._expectedDeprecations, function (deprecationPattern, id) {
+ if (test._observedDeprecations[id] !== 1) {
+ missedDeprecations.push(deprecationPattern);
+ }
+ });
+ if (missedDeprecations.length !== 0) {
+ throw new Error('Expected deprecation warnings did not happen: ' +
+ missedDeprecations.join(' '));
+ }
+ }
+ }
+
+ function matchedDeprecation(name, msg, deprecations) {
+ if (deprecations == null) {
+ return -1;
+ }
+ for (var i = 0; i < deprecations.length; ++i) {
+ if (name != null && name === deprecations[i]) {
+ return i;
+ }
+ if (msg != null && msg.substring(0, deprecations[i].length) === deprecations[i]) {
+ return i;
+ }
+ }
+ return -1;
+ }
/*global QUnit:false*/
@@ -14824,11 +20587,13 @@
moment.createFromInputFallback = function (config) {
throw new Error('input not handled by moment: ' + config._i);
};
+ setupDeprecationHandler(test, moment, 'core');
if (lifecycle && lifecycle.setup) {
lifecycle.setup();
}
},
teardown : function () {
+ teardownDeprecationHandler(test, moment, 'core');
if (lifecycle && lifecycle.teardown) {
lifecycle.teardown();
}
@@ -14843,17 +20608,20 @@
moment.createFromInputFallback = function (config) {
throw new Error('input not handled by moment: ' + config._i);
};
+ setupDeprecationHandler(test, moment, 'locale');
if (lifecycle && lifecycle.setup) {
lifecycle.setup();
}
},
teardown : function () {
moment.locale('en');
+ teardownDeprecationHandler(test, moment, 'locale');
if (lifecycle && lifecycle.teardown) {
lifecycle.teardown();
}
}
});
+ defineCommonLocaleTests(name, -1, -1);
}
localeModule('hi');
@@ -15006,14 +20774,14 @@
});
test('calendar day', function (assert) {
- var a = moment().hours(2).minutes(0).seconds(0);
-
- assert.equal(moment(a).calendar(), 'आज रात २:०० बजे', 'today at the same time');
- assert.equal(moment(a).add({m: 25}).calendar(), 'आज रात २:२५ बजे', 'Now plus 25 min');
- assert.equal(moment(a).add({h: 3}).calendar(), 'आज सुबह ५:०० बजे', 'Now plus 3 hour');
- assert.equal(moment(a).add({d: 1}).calendar(), 'कल रात २:०० बजे', 'tomorrow at the same time');
- assert.equal(moment(a).subtract({h: 1}).calendar(), 'आज रात १:०० बजे', 'Now minus 1 hour');
- assert.equal(moment(a).subtract({d: 1}).calendar(), 'कल रात २:०० बजे', 'yesterday at the same time');
+ var a = moment().hours(12).minutes(0).seconds(0);
+
+ assert.equal(moment(a).calendar(), 'आज दोपहर १२:०० बजे', 'today at the same time');
+ assert.equal(moment(a).add({m: 25}).calendar(), 'आज दोपहर १२:२५ बजे', 'Now plus 25 min');
+ assert.equal(moment(a).add({h: 3}).calendar(), 'आज दोपहर ३:०० बजे', 'Now plus 3 hours');
+ assert.equal(moment(a).add({d: 1}).calendar(), 'कल दोपहर १२:०० बजे', 'tomorrow at the same time');
+ assert.equal(moment(a).subtract({h: 1}).calendar(), 'आज दोपहर ११:०० बजे', 'Now minus 1 hour');
+ assert.equal(moment(a).subtract({d: 1}).calendar(), 'कल दोपहर १२:०० बजे', 'yesterday at the same time');
});
test('calendar next week', function (assert) {
@@ -15055,7 +20823,7 @@
assert.equal(weeksFromNow.calendar(), weeksFromNow.format('L'), 'in 2 weeks');
});
- test('meridiem invariant', function (assert) {
+ test('meridiem', function (assert) {
assert.equal(moment([2011, 2, 23, 2, 30]).format('a'), 'रात', 'before dawn');
assert.equal(moment([2011, 2, 23, 9, 30]).format('a'), 'सुबह', 'morning');
assert.equal(moment([2011, 2, 23, 14, 30]).format('a'), 'दोपहर', 'during day');
@@ -15071,67 +20839,6 @@
assert.equal(moment([2011, 2, 23, 21, 20]).format('A'), 'रात', 'night');
});
- test('weeks year starting sunday', function (assert) {
- assert.equal(moment([2012, 0, 1]).week(), 1, 'Jan 1 2012 should be week 1');
- assert.equal(moment([2012, 0, 7]).week(), 1, 'Jan 7 2012 should be week 1');
- assert.equal(moment([2012, 0, 8]).week(), 2, 'Jan 8 2012 should be week 2');
- assert.equal(moment([2012, 0, 14]).week(), 2, 'Jan 14 2012 should be week 2');
- assert.equal(moment([2012, 0, 15]).week(), 3, 'Jan 15 2012 should be week 3');
- });
-
- test('weeks year starting monday', function (assert) {
- assert.equal(moment([2006, 11, 31]).week(), 1, 'Dec 31 2006 should be week 1');
- assert.equal(moment([2007, 0, 1]).week(), 1, 'Jan 1 2007 should be week 1');
- assert.equal(moment([2007, 0, 6]).week(), 1, 'Jan 6 2007 should be week 1');
- assert.equal(moment([2007, 0, 7]).week(), 2, 'Jan 7 2007 should be week 2');
- assert.equal(moment([2007, 0, 13]).week(), 2, 'Jan 13 2007 should be week 2');
- assert.equal(moment([2007, 0, 14]).week(), 3, 'Jan 14 2007 should be week 3');
- });
-
- test('weeks year starting tuesday', function (assert) {
- assert.equal(moment([2007, 11, 29]).week(), 52, 'Dec 29 2007 should be week 52');
- assert.equal(moment([2008, 0, 1]).week(), 1, 'Jan 1 2008 should be week 1');
- assert.equal(moment([2008, 0, 5]).week(), 1, 'Jan 5 2008 should be week 1');
- assert.equal(moment([2008, 0, 6]).week(), 2, 'Jan 6 2008 should be week 2');
- assert.equal(moment([2008, 0, 12]).week(), 2, 'Jan 12 2008 should be week 2');
- assert.equal(moment([2008, 0, 13]).week(), 3, 'Jan 13 2008 should be week 3');
- });
-
- test('weeks year starting wednesday', function (assert) {
- assert.equal(moment([2002, 11, 29]).week(), 1, 'Dec 29 2002 should be week 1');
- assert.equal(moment([2003, 0, 1]).week(), 1, 'Jan 1 2003 should be week 1');
- assert.equal(moment([2003, 0, 4]).week(), 1, 'Jan 4 2003 should be week 1');
- assert.equal(moment([2003, 0, 5]).week(), 2, 'Jan 5 2003 should be week 2');
- assert.equal(moment([2003, 0, 11]).week(), 2, 'Jan 11 2003 should be week 2');
- assert.equal(moment([2003, 0, 12]).week(), 3, 'Jan 12 2003 should be week 3');
- });
-
- test('weeks year starting thursday', function (assert) {
- assert.equal(moment([2008, 11, 28]).week(), 1, 'Dec 28 2008 should be week 1');
- assert.equal(moment([2009, 0, 1]).week(), 1, 'Jan 1 2009 should be week 1');
- assert.equal(moment([2009, 0, 3]).week(), 1, 'Jan 3 2009 should be week 1');
- assert.equal(moment([2009, 0, 4]).week(), 2, 'Jan 4 2009 should be week 2');
- assert.equal(moment([2009, 0, 10]).week(), 2, 'Jan 10 2009 should be week 2');
- assert.equal(moment([2009, 0, 11]).week(), 3, 'Jan 11 2009 should be week 3');
- });
-
- test('weeks year starting friday', function (assert) {
- assert.equal(moment([2009, 11, 27]).week(), 1, 'Dec 27 2009 should be week 1');
- assert.equal(moment([2010, 0, 1]).week(), 1, 'Jan 1 2010 should be week 1');
- assert.equal(moment([2010, 0, 2]).week(), 1, 'Jan 2 2010 should be week 1');
- assert.equal(moment([2010, 0, 3]).week(), 2, 'Jan 3 2010 should be week 2');
- assert.equal(moment([2010, 0, 9]).week(), 2, 'Jan 9 2010 should be week 2');
- assert.equal(moment([2010, 0, 10]).week(), 3, 'Jan 10 2010 should be week 3');
- });
-
- test('weeks year starting saturday', function (assert) {
- assert.equal(moment([2010, 11, 26]).week(), 1, 'Dec 26 2010 should be week 1');
- assert.equal(moment([2011, 0, 1]).week(), 1, 'Jan 1 2011 should be week 1');
- assert.equal(moment([2011, 0, 2]).week(), 2, 'Jan 2 2011 should be week 2');
- assert.equal(moment([2011, 0, 8]).week(), 2, 'Jan 8 2011 should be week 2');
- assert.equal(moment([2011, 0, 9]).week(), 3, 'Jan 9 2011 should be week 3');
- });
-
test('weeks year starting sunday formatted', function (assert) {
assert.equal(moment([2012, 0, 1]).format('w ww wo'), '१ ०१ १', 'Jan 1 2012 should be week 1');
assert.equal(moment([2012, 0, 7]).format('w ww wo'), '१ ०१ १', 'Jan 7 2012 should be week 1');
@@ -15140,54 +20847,6 @@
assert.equal(moment([2012, 0, 15]).format('w ww wo'), '३ ०३ ३', 'Jan 15 2012 should be week 3');
});
- test('lenient ordinal parsing', function (assert) {
- var i, ordinalStr, testMoment;
- for (i = 1; i <= 31; ++i) {
- ordinalStr = moment([2014, 0, i]).format('YYYY MM Do');
- testMoment = moment(ordinalStr, 'YYYY MM Do');
- assert.equal(testMoment.year(), 2014,
- 'lenient ordinal parsing ' + i + ' year check');
- assert.equal(testMoment.month(), 0,
- 'lenient ordinal parsing ' + i + ' month check');
- assert.equal(testMoment.date(), i,
- 'lenient ordinal parsing ' + i + ' date check');
- }
- });
-
- test('lenient ordinal parsing of number', function (assert) {
- var i, testMoment;
- for (i = 1; i <= 31; ++i) {
- testMoment = moment('2014 01 ' + i, 'YYYY MM Do');
- assert.equal(testMoment.year(), 2014,
- 'lenient ordinal parsing of number ' + i + ' year check');
- assert.equal(testMoment.month(), 0,
- 'lenient ordinal parsing of number ' + i + ' month check');
- assert.equal(testMoment.date(), i,
- 'lenient ordinal parsing of number ' + i + ' date check');
- }
- });
-
- test('meridiem', function (assert) {
- var h, m, t1, t2;
- for (h = 0; h < 24; ++h) {
- for (m = 0; m < 60; m += 15) {
- t1 = moment.utc([2000, 0, 1, h, m]);
- t2 = moment(t1.format('A h:mm'), 'A h:mm');
- assert.equal(t2.format('HH:mm'), t1.format('HH:mm'),
- 'meridiem at ' + t1.format('HH:mm'));
- }
- }
- });
-
- test('strict ordinal parsing', function (assert) {
- var i, ordinalStr, testMoment;
- for (i = 1; i <= 31; ++i) {
- ordinalStr = moment([2014, 0, i]).format('YYYY MM Do');
- testMoment = moment(ordinalStr, 'YYYY MM Do', true);
- assert.ok(testMoment.isValid(), 'strict ordinal parsing ' + i);
- }
- });
-
}));
;(function (global, factory) {
@@ -15196,6 +20855,224 @@
typeof define === 'function' && define.amd ? define(['../../moment'], factory) :
factory(global.moment)
}(this, function (moment) { 'use strict';
+
+ function each(array, callback) {
+ var i;
+ for (i = 0; i < array.length; i++) {
+ callback(array[i], i, array);
+ }
+ }
+
+ function objectKeys(obj) {
+ if (Object.keys) {
+ return Object.keys(obj);
+ } else {
+ // IE8
+ var res = [], i;
+ for (i in obj) {
+ if (obj.hasOwnProperty(i)) {
+ res.push(i);
+ }
+ }
+ return res;
+ }
+ }
+
+ // Pick the first defined of two or three arguments.
+ function defaults(a, b, c) {
+ if (a != null) {
+ return a;
+ }
+ if (b != null) {
+ return b;
+ }
+ return c;
+ }
+
+ function defineCommonLocaleTests(locale, options) {
+ test('lenient ordinal parsing', function (assert) {
+ var i, ordinalStr, testMoment;
+ for (i = 1; i <= 31; ++i) {
+ ordinalStr = moment([2014, 0, i]).format('YYYY MM Do');
+ testMoment = moment(ordinalStr, 'YYYY MM Do');
+ assert.equal(testMoment.year(), 2014,
+ 'lenient ordinal parsing ' + i + ' year check');
+ assert.equal(testMoment.month(), 0,
+ 'lenient ordinal parsing ' + i + ' month check');
+ assert.equal(testMoment.date(), i,
+ 'lenient ordinal parsing ' + i + ' date check');
+ }
+ });
+
+ test('lenient ordinal parsing of number', function (assert) {
+ var i, testMoment;
+ for (i = 1; i <= 31; ++i) {
+ testMoment = moment('2014 01 ' + i, 'YYYY MM Do');
+ assert.equal(testMoment.year(), 2014,
+ 'lenient ordinal parsing of number ' + i + ' year check');
+ assert.equal(testMoment.month(), 0,
+ 'lenient ordinal parsing of number ' + i + ' month check');
+ assert.equal(testMoment.date(), i,
+ 'lenient ordinal parsing of number ' + i + ' date check');
+ }
+ });
+
+ test('strict ordinal parsing', function (assert) {
+ var i, ordinalStr, testMoment;
+ for (i = 1; i <= 31; ++i) {
+ ordinalStr = moment([2014, 0, i]).format('YYYY MM Do');
+ testMoment = moment(ordinalStr, 'YYYY MM Do', true);
+ assert.ok(testMoment.isValid(), 'strict ordinal parsing ' + i);
+ }
+ });
+
+ test('meridiem invariant', function (assert) {
+ var h, m, t1, t2;
+ for (h = 0; h < 24; ++h) {
+ for (m = 0; m < 60; m += 15) {
+ t1 = moment.utc([2000, 0, 1, h, m]);
+ t2 = moment.utc(t1.format('A h:mm'), 'A h:mm');
+ assert.equal(t2.format('HH:mm'), t1.format('HH:mm'),
+ 'meridiem at ' + t1.format('HH:mm'));
+ }
+ }
+ });
+
+ test('date format correctness', function (assert) {
+ var data, tokens;
+ data = moment.localeData()._longDateFormat;
+ tokens = objectKeys(data);
+ each(tokens, function (srchToken) {
+ // Check each format string to make sure it does not contain any
+ // tokens that need to be expanded.
+ each(tokens, function (baseToken) {
+ // strip escaped sequences
+ var format = data[baseToken].replace(/(\[[^\]]*\])/g, '');
+ assert.equal(false, !!~format.indexOf(srchToken),
+ 'contains ' + srchToken + ' in ' + baseToken);
+ });
+ });
+ });
+
+ test('month parsing correctness', function (assert) {
+ var i, m;
+
+ if (locale === 'tr') {
+ // I can't fix it :(
+ expect(0);
+ return;
+ }
+ function tester(format) {
+ var r;
+ r = moment(m.format(format), format);
+ assert.equal(r.month(), m.month(), 'month ' + i + ' fmt ' + format);
+ r = moment(m.format(format).toLocaleUpperCase(), format);
+ assert.equal(r.month(), m.month(), 'month ' + i + ' fmt ' + format + ' upper');
+ r = moment(m.format(format).toLocaleLowerCase(), format);
+ assert.equal(r.month(), m.month(), 'month ' + i + ' fmt ' + format + ' lower');
+
+ r = moment(m.format(format), format, true);
+ assert.equal(r.month(), m.month(), 'month ' + i + ' fmt ' + format + ' strict');
+ r = moment(m.format(format).toLocaleUpperCase(), format, true);
+ assert.equal(r.month(), m.month(), 'month ' + i + ' fmt ' + format + ' upper strict');
+ r = moment(m.format(format).toLocaleLowerCase(), format, true);
+ assert.equal(r.month(), m.month(), 'month ' + i + ' fmt ' + format + ' lower strict');
+ }
+
+ for (i = 0; i < 12; ++i) {
+ m = moment([2015, i, 15, 18]);
+ tester('MMM');
+ tester('MMM.');
+ tester('MMMM');
+ tester('MMMM.');
+ }
+ });
+
+ test('weekday parsing correctness', function (assert) {
+ var i, m;
+
+ if (locale === 'tr' || locale === 'az') {
+ // There is a lower-case letter (ı), that converted to upper then
+ // lower changes to i
+ expect(0);
+ return;
+ }
+ function tester(format) {
+ var r, baseMsg = 'weekday ' + m.weekday() + ' fmt ' + format;
+ r = moment(m.format(format), format);
+ assert.equal(r.weekday(), m.weekday(), baseMsg);
+ r = moment(m.format(format).toLocaleUpperCase(), format);
+ assert.equal(r.weekday(), m.weekday(), baseMsg + ' upper');
+ r = moment(m.format(format).toLocaleLowerCase(), format);
+ assert.equal(r.weekday(), m.weekday(), baseMsg + ' lower');
+
+ r = moment(m.format(format), format, true);
+ assert.equal(r.weekday(), m.weekday(), baseMsg + ' strict');
+ r = moment(m.format(format).toLocaleUpperCase(), format, true);
+ assert.equal(r.weekday(), m.weekday(), baseMsg + ' upper strict');
+ r = moment(m.format(format).toLocaleLowerCase(), format, true);
+ assert.equal(r.weekday(), m.weekday(), baseMsg + ' lower strict');
+ }
+
+ for (i = 0; i < 7; ++i) {
+ m = moment.utc([2015, i, 15, 18]);
+ tester('dd');
+ tester('ddd');
+ tester('dddd');
+ }
+ });
+ }
+
+ function setupDeprecationHandler(test, moment, scope) {
+ test._expectedDeprecations = null;
+ test._observedDeprecations = null;
+ test._oldSupress = moment.suppressDeprecationWarnings;
+ moment.suppressDeprecationWarnings = true;
+ test.expectedDeprecations = function () {
+ test._expectedDeprecations = arguments;
+ test._observedDeprecations = [];
+ };
+ moment.deprecationHandler = function (name, msg) {
+ var deprecationId = matchedDeprecation(name, msg, test._expectedDeprecations);
+ if (deprecationId === -1) {
+ throw new Error('Unexpected deprecation thrown name=' +
+ name + ' msg=' + msg);
+ }
+ test._observedDeprecations[deprecationId] = 1;
+ };
+ }
+
+ function teardownDeprecationHandler(test, moment, scope) {
+ moment.suppressDeprecationWarnings = test._oldSupress;
+
+ if (test._expectedDeprecations != null) {
+ var missedDeprecations = [];
+ each(test._expectedDeprecations, function (deprecationPattern, id) {
+ if (test._observedDeprecations[id] !== 1) {
+ missedDeprecations.push(deprecationPattern);
+ }
+ });
+ if (missedDeprecations.length !== 0) {
+ throw new Error('Expected deprecation warnings did not happen: ' +
+ missedDeprecations.join(' '));
+ }
+ }
+ }
+
+ function matchedDeprecation(name, msg, deprecations) {
+ if (deprecations == null) {
+ return -1;
+ }
+ for (var i = 0; i < deprecations.length; ++i) {
+ if (name != null && name === deprecations[i]) {
+ return i;
+ }
+ if (msg != null && msg.substring(0, deprecations[i].length) === deprecations[i]) {
+ return i;
+ }
+ }
+ return -1;
+ }
/*global QUnit:false*/
@@ -15210,11 +21087,13 @@
moment.createFromInputFallback = function (config) {
throw new Error('input not handled by moment: ' + config._i);
};
+ setupDeprecationHandler(test, moment, 'core');
if (lifecycle && lifecycle.setup) {
lifecycle.setup();
}
},
teardown : function () {
+ teardownDeprecationHandler(test, moment, 'core');
if (lifecycle && lifecycle.teardown) {
lifecycle.teardown();
}
@@ -15229,17 +21108,20 @@
moment.createFromInputFallback = function (config) {
throw new Error('input not handled by moment: ' + config._i);
};
+ setupDeprecationHandler(test, moment, 'locale');
if (lifecycle && lifecycle.setup) {
lifecycle.setup();
}
},
teardown : function () {
moment.locale('en');
+ teardownDeprecationHandler(test, moment, 'locale');
if (lifecycle && lifecycle.teardown) {
lifecycle.teardown();
}
}
});
+ defineCommonLocaleTests(name, -1, -1);
}
localeModule('hr');
@@ -15393,14 +21275,14 @@
});
test('calendar day', function (assert) {
- var a = moment().hours(2).minutes(0).seconds(0);
-
- assert.equal(moment(a).calendar(), 'danas u 2:00', 'today at the same time');
- assert.equal(moment(a).add({m: 25}).calendar(), 'danas u 2:25', 'Now plus 25 min');
- assert.equal(moment(a).add({h: 1}).calendar(), 'danas u 3:00', 'Now plus 1 hour');
- assert.equal(moment(a).add({d: 1}).calendar(), 'sutra u 2:00', 'tomorrow at the same time');
- assert.equal(moment(a).subtract({h: 1}).calendar(), 'danas u 1:00', 'Now minus 1 hour');
- assert.equal(moment(a).subtract({d: 1}).calendar(), 'jučer u 2:00', 'yesterday at the same time');
+ var a = moment().hours(12).minutes(0).seconds(0);
+
+ assert.equal(moment(a).calendar(), 'danas u 12:00', 'today at the same time');
+ assert.equal(moment(a).add({m: 25}).calendar(), 'danas u 12:25', 'Now plus 25 min');
+ assert.equal(moment(a).add({h: 1}).calendar(), 'danas u 13:00', 'Now plus 1 hour');
+ assert.equal(moment(a).add({d: 1}).calendar(), 'sutra u 12:00', 'tomorrow at the same time');
+ assert.equal(moment(a).subtract({h: 1}).calendar(), 'danas u 11:00', 'Now minus 1 hour');
+ assert.equal(moment(a).subtract({d: 1}).calendar(), 'jučer u 12:00', 'yesterday at the same time');
});
test('calendar next week', function (assert) {
@@ -15474,67 +21356,6 @@
assert.equal(weeksFromNow.calendar(), weeksFromNow.format('L'), 'in 2 weeks');
});
- test('weeks year starting sunday', function (assert) {
- assert.equal(moment([2011, 11, 26]).week(), 1, 'Dec 26 2011 should be week 1');
- assert.equal(moment([2012, 0, 1]).week(), 1, 'Jan 1 2012 should be week 1');
- assert.equal(moment([2012, 0, 2]).week(), 2, 'Jan 2 2012 should be week 2');
- assert.equal(moment([2012, 0, 8]).week(), 2, 'Jan 8 2012 should be week 2');
- assert.equal(moment([2012, 0, 9]).week(), 3, 'Jan 9 2012 should be week 3');
- });
-
- test('weeks year starting monday', function (assert) {
- assert.equal(moment([2007, 0, 1]).week(), 1, 'Jan 1 2007 should be week 1');
- assert.equal(moment([2007, 0, 7]).week(), 1, 'Jan 7 2007 should be week 1');
- assert.equal(moment([2007, 0, 8]).week(), 2, 'Jan 8 2007 should be week 2');
- assert.equal(moment([2007, 0, 14]).week(), 2, 'Jan 14 2007 should be week 2');
- assert.equal(moment([2007, 0, 15]).week(), 3, 'Jan 15 2007 should be week 3');
- });
-
- test('weeks year starting tuesday', function (assert) {
- assert.equal(moment([2007, 11, 31]).week(), 1, 'Dec 31 2007 should be week 1');
- assert.equal(moment([2008, 0, 1]).week(), 1, 'Jan 1 2008 should be week 1');
- assert.equal(moment([2008, 0, 6]).week(), 1, 'Jan 6 2008 should be week 1');
- assert.equal(moment([2008, 0, 7]).week(), 2, 'Jan 7 2008 should be week 2');
- assert.equal(moment([2008, 0, 13]).week(), 2, 'Jan 13 2008 should be week 2');
- assert.equal(moment([2008, 0, 14]).week(), 3, 'Jan 14 2008 should be week 3');
- });
-
- test('weeks year starting wednesday', function (assert) {
- assert.equal(moment([2002, 11, 30]).week(), 1, 'Dec 30 2002 should be week 1');
- assert.equal(moment([2003, 0, 1]).week(), 1, 'Jan 1 2003 should be week 1');
- assert.equal(moment([2003, 0, 5]).week(), 1, 'Jan 5 2003 should be week 1');
- assert.equal(moment([2003, 0, 6]).week(), 2, 'Jan 6 2003 should be week 2');
- assert.equal(moment([2003, 0, 12]).week(), 2, 'Jan 12 2003 should be week 2');
- assert.equal(moment([2003, 0, 13]).week(), 3, 'Jan 13 2003 should be week 3');
- });
-
- test('weeks year starting thursday', function (assert) {
- assert.equal(moment([2008, 11, 29]).week(), 1, 'Dec 29 2008 should be week 1');
- assert.equal(moment([2009, 0, 1]).week(), 1, 'Jan 1 2009 should be week 1');
- assert.equal(moment([2009, 0, 4]).week(), 1, 'Jan 4 2009 should be week 1');
- assert.equal(moment([2009, 0, 5]).week(), 2, 'Jan 5 2009 should be week 2');
- assert.equal(moment([2009, 0, 11]).week(), 2, 'Jan 11 2009 should be week 2');
- assert.equal(moment([2009, 0, 12]).week(), 3, 'Jan 12 2009 should be week 3');
- });
-
- test('weeks year starting friday', function (assert) {
- assert.equal(moment([2009, 11, 28]).week(), 1, 'Dec 28 2009 should be week 1');
- assert.equal(moment([2010, 0, 1]).week(), 1, 'Jan 1 2010 should be week 1');
- assert.equal(moment([2010, 0, 3]).week(), 1, 'Jan 3 2010 should be week 1');
- assert.equal(moment([2010, 0, 4]).week(), 2, 'Jan 4 2010 should be week 2');
- assert.equal(moment([2010, 0, 10]).week(), 2, 'Jan 10 2010 should be week 2');
- assert.equal(moment([2010, 0, 11]).week(), 3, 'Jan 11 2010 should be week 3');
- });
-
- test('weeks year starting saturday', function (assert) {
- assert.equal(moment([2010, 11, 27]).week(), 1, 'Dec 27 2010 should be week 1');
- assert.equal(moment([2011, 0, 1]).week(), 1, 'Jan 1 2011 should be week 1');
- assert.equal(moment([2011, 0, 2]).week(), 1, 'Jan 2 2011 should be week 1');
- assert.equal(moment([2011, 0, 3]).week(), 2, 'Jan 3 2011 should be week 2');
- assert.equal(moment([2011, 0, 9]).week(), 2, 'Jan 9 2011 should be week 2');
- assert.equal(moment([2011, 0, 10]).week(), 3, 'Jan 10 2011 should be week 3');
- });
-
test('weeks year starting sunday formatted', function (assert) {
assert.equal(moment([2011, 11, 26]).format('w ww wo'), '1 01 1.', 'Dec 26 2011 should be week 1');
assert.equal(moment([2012, 0, 1]).format('w ww wo'), '1 01 1.', 'Jan 1 2012 should be week 1');
@@ -15543,42 +21364,6 @@
assert.equal(moment([2012, 0, 9]).format('w ww wo'), '3 03 3.', 'Jan 9 2012 should be week 3');
});
- test('lenient ordinal parsing', function (assert) {
- var i, ordinalStr, testMoment;
- for (i = 1; i <= 31; ++i) {
- ordinalStr = moment([2014, 0, i]).format('YYYY MM Do');
- testMoment = moment(ordinalStr, 'YYYY MM Do');
- assert.equal(testMoment.year(), 2014,
- 'lenient ordinal parsing ' + i + ' year check');
- assert.equal(testMoment.month(), 0,
- 'lenient ordinal parsing ' + i + ' month check');
- assert.equal(testMoment.date(), i,
- 'lenient ordinal parsing ' + i + ' date check');
- }
- });
-
- test('lenient ordinal parsing of number', function (assert) {
- var i, testMoment;
- for (i = 1; i <= 31; ++i) {
- testMoment = moment('2014 01 ' + i, 'YYYY MM Do');
- assert.equal(testMoment.year(), 2014,
- 'lenient ordinal parsing of number ' + i + ' year check');
- assert.equal(testMoment.month(), 0,
- 'lenient ordinal parsing of number ' + i + ' month check');
- assert.equal(testMoment.date(), i,
- 'lenient ordinal parsing of number ' + i + ' date check');
- }
- });
-
- test('strict ordinal parsing', function (assert) {
- var i, ordinalStr, testMoment;
- for (i = 1; i <= 31; ++i) {
- ordinalStr = moment([2014, 0, i]).format('YYYY MM Do');
- testMoment = moment(ordinalStr, 'YYYY MM Do', true);
- assert.ok(testMoment.isValid(), 'strict ordinal parsing ' + i);
- }
- });
-
}));
;(function (global, factory) {
@@ -15587,6 +21372,224 @@
typeof define === 'function' && define.amd ? define(['../../moment'], factory) :
factory(global.moment)
}(this, function (moment) { 'use strict';
+
+ function each(array, callback) {
+ var i;
+ for (i = 0; i < array.length; i++) {
+ callback(array[i], i, array);
+ }
+ }
+
+ function objectKeys(obj) {
+ if (Object.keys) {
+ return Object.keys(obj);
+ } else {
+ // IE8
+ var res = [], i;
+ for (i in obj) {
+ if (obj.hasOwnProperty(i)) {
+ res.push(i);
+ }
+ }
+ return res;
+ }
+ }
+
+ // Pick the first defined of two or three arguments.
+ function defaults(a, b, c) {
+ if (a != null) {
+ return a;
+ }
+ if (b != null) {
+ return b;
+ }
+ return c;
+ }
+
+ function defineCommonLocaleTests(locale, options) {
+ test('lenient ordinal parsing', function (assert) {
+ var i, ordinalStr, testMoment;
+ for (i = 1; i <= 31; ++i) {
+ ordinalStr = moment([2014, 0, i]).format('YYYY MM Do');
+ testMoment = moment(ordinalStr, 'YYYY MM Do');
+ assert.equal(testMoment.year(), 2014,
+ 'lenient ordinal parsing ' + i + ' year check');
+ assert.equal(testMoment.month(), 0,
+ 'lenient ordinal parsing ' + i + ' month check');
+ assert.equal(testMoment.date(), i,
+ 'lenient ordinal parsing ' + i + ' date check');
+ }
+ });
+
+ test('lenient ordinal parsing of number', function (assert) {
+ var i, testMoment;
+ for (i = 1; i <= 31; ++i) {
+ testMoment = moment('2014 01 ' + i, 'YYYY MM Do');
+ assert.equal(testMoment.year(), 2014,
+ 'lenient ordinal parsing of number ' + i + ' year check');
+ assert.equal(testMoment.month(), 0,
+ 'lenient ordinal parsing of number ' + i + ' month check');
+ assert.equal(testMoment.date(), i,
+ 'lenient ordinal parsing of number ' + i + ' date check');
+ }
+ });
+
+ test('strict ordinal parsing', function (assert) {
+ var i, ordinalStr, testMoment;
+ for (i = 1; i <= 31; ++i) {
+ ordinalStr = moment([2014, 0, i]).format('YYYY MM Do');
+ testMoment = moment(ordinalStr, 'YYYY MM Do', true);
+ assert.ok(testMoment.isValid(), 'strict ordinal parsing ' + i);
+ }
+ });
+
+ test('meridiem invariant', function (assert) {
+ var h, m, t1, t2;
+ for (h = 0; h < 24; ++h) {
+ for (m = 0; m < 60; m += 15) {
+ t1 = moment.utc([2000, 0, 1, h, m]);
+ t2 = moment.utc(t1.format('A h:mm'), 'A h:mm');
+ assert.equal(t2.format('HH:mm'), t1.format('HH:mm'),
+ 'meridiem at ' + t1.format('HH:mm'));
+ }
+ }
+ });
+
+ test('date format correctness', function (assert) {
+ var data, tokens;
+ data = moment.localeData()._longDateFormat;
+ tokens = objectKeys(data);
+ each(tokens, function (srchToken) {
+ // Check each format string to make sure it does not contain any
+ // tokens that need to be expanded.
+ each(tokens, function (baseToken) {
+ // strip escaped sequences
+ var format = data[baseToken].replace(/(\[[^\]]*\])/g, '');
+ assert.equal(false, !!~format.indexOf(srchToken),
+ 'contains ' + srchToken + ' in ' + baseToken);
+ });
+ });
+ });
+
+ test('month parsing correctness', function (assert) {
+ var i, m;
+
+ if (locale === 'tr') {
+ // I can't fix it :(
+ expect(0);
+ return;
+ }
+ function tester(format) {
+ var r;
+ r = moment(m.format(format), format);
+ assert.equal(r.month(), m.month(), 'month ' + i + ' fmt ' + format);
+ r = moment(m.format(format).toLocaleUpperCase(), format);
+ assert.equal(r.month(), m.month(), 'month ' + i + ' fmt ' + format + ' upper');
+ r = moment(m.format(format).toLocaleLowerCase(), format);
+ assert.equal(r.month(), m.month(), 'month ' + i + ' fmt ' + format + ' lower');
+
+ r = moment(m.format(format), format, true);
+ assert.equal(r.month(), m.month(), 'month ' + i + ' fmt ' + format + ' strict');
+ r = moment(m.format(format).toLocaleUpperCase(), format, true);
+ assert.equal(r.month(), m.month(), 'month ' + i + ' fmt ' + format + ' upper strict');
+ r = moment(m.format(format).toLocaleLowerCase(), format, true);
+ assert.equal(r.month(), m.month(), 'month ' + i + ' fmt ' + format + ' lower strict');
+ }
+
+ for (i = 0; i < 12; ++i) {
+ m = moment([2015, i, 15, 18]);
+ tester('MMM');
+ tester('MMM.');
+ tester('MMMM');
+ tester('MMMM.');
+ }
+ });
+
+ test('weekday parsing correctness', function (assert) {
+ var i, m;
+
+ if (locale === 'tr' || locale === 'az') {
+ // There is a lower-case letter (ı), that converted to upper then
+ // lower changes to i
+ expect(0);
+ return;
+ }
+ function tester(format) {
+ var r, baseMsg = 'weekday ' + m.weekday() + ' fmt ' + format;
+ r = moment(m.format(format), format);
+ assert.equal(r.weekday(), m.weekday(), baseMsg);
+ r = moment(m.format(format).toLocaleUpperCase(), format);
+ assert.equal(r.weekday(), m.weekday(), baseMsg + ' upper');
+ r = moment(m.format(format).toLocaleLowerCase(), format);
+ assert.equal(r.weekday(), m.weekday(), baseMsg + ' lower');
+
+ r = moment(m.format(format), format, true);
+ assert.equal(r.weekday(), m.weekday(), baseMsg + ' strict');
+ r = moment(m.format(format).toLocaleUpperCase(), format, true);
+ assert.equal(r.weekday(), m.weekday(), baseMsg + ' upper strict');
+ r = moment(m.format(format).toLocaleLowerCase(), format, true);
+ assert.equal(r.weekday(), m.weekday(), baseMsg + ' lower strict');
+ }
+
+ for (i = 0; i < 7; ++i) {
+ m = moment.utc([2015, i, 15, 18]);
+ tester('dd');
+ tester('ddd');
+ tester('dddd');
+ }
+ });
+ }
+
+ function setupDeprecationHandler(test, moment, scope) {
+ test._expectedDeprecations = null;
+ test._observedDeprecations = null;
+ test._oldSupress = moment.suppressDeprecationWarnings;
+ moment.suppressDeprecationWarnings = true;
+ test.expectedDeprecations = function () {
+ test._expectedDeprecations = arguments;
+ test._observedDeprecations = [];
+ };
+ moment.deprecationHandler = function (name, msg) {
+ var deprecationId = matchedDeprecation(name, msg, test._expectedDeprecations);
+ if (deprecationId === -1) {
+ throw new Error('Unexpected deprecation thrown name=' +
+ name + ' msg=' + msg);
+ }
+ test._observedDeprecations[deprecationId] = 1;
+ };
+ }
+
+ function teardownDeprecationHandler(test, moment, scope) {
+ moment.suppressDeprecationWarnings = test._oldSupress;
+
+ if (test._expectedDeprecations != null) {
+ var missedDeprecations = [];
+ each(test._expectedDeprecations, function (deprecationPattern, id) {
+ if (test._observedDeprecations[id] !== 1) {
+ missedDeprecations.push(deprecationPattern);
+ }
+ });
+ if (missedDeprecations.length !== 0) {
+ throw new Error('Expected deprecation warnings did not happen: ' +
+ missedDeprecations.join(' '));
+ }
+ }
+ }
+
+ function matchedDeprecation(name, msg, deprecations) {
+ if (deprecations == null) {
+ return -1;
+ }
+ for (var i = 0; i < deprecations.length; ++i) {
+ if (name != null && name === deprecations[i]) {
+ return i;
+ }
+ if (msg != null && msg.substring(0, deprecations[i].length) === deprecations[i]) {
+ return i;
+ }
+ }
+ return -1;
+ }
/*global QUnit:false*/
@@ -15601,11 +21604,13 @@
moment.createFromInputFallback = function (config) {
throw new Error('input not handled by moment: ' + config._i);
};
+ setupDeprecationHandler(test, moment, 'core');
if (lifecycle && lifecycle.setup) {
lifecycle.setup();
}
},
teardown : function () {
+ teardownDeprecationHandler(test, moment, 'core');
if (lifecycle && lifecycle.teardown) {
lifecycle.teardown();
}
@@ -15620,17 +21625,20 @@
moment.createFromInputFallback = function (config) {
throw new Error('input not handled by moment: ' + config._i);
};
+ setupDeprecationHandler(test, moment, 'locale');
if (lifecycle && lifecycle.setup) {
lifecycle.setup();
}
},
teardown : function () {
moment.locale('en');
+ teardownDeprecationHandler(test, moment, 'locale');
if (lifecycle && lifecycle.teardown) {
lifecycle.teardown();
}
}
});
+ defineCommonLocaleTests(name, -1, -1);
}
localeModule('hu');
@@ -15797,14 +21805,14 @@
});
test('calendar day', function (assert) {
- var a = moment().hours(2).minutes(0).seconds(0);
-
- assert.equal(moment(a).calendar(), 'ma 2:00-kor', 'today at the same time');
- assert.equal(moment(a).add({m: 25}).calendar(), 'ma 2:25-kor', 'Now plus 25 min');
- assert.equal(moment(a).add({h: 1}).calendar(), 'ma 3:00-kor', 'Now plus 1 hour');
- assert.equal(moment(a).add({d: 1}).calendar(), 'holnap 2:00-kor', 'tomorrow at the same time');
- assert.equal(moment(a).subtract({h: 1}).calendar(), 'ma 1:00-kor', 'Now minus 1 hour');
- assert.equal(moment(a).subtract({d: 1}).calendar(), 'tegnap 2:00-kor', 'yesterday at the same time');
+ var a = moment().hours(12).minutes(0).seconds(0);
+
+ assert.equal(moment(a).calendar(), 'ma 12:00-kor', 'today at the same time');
+ assert.equal(moment(a).add({m: 25}).calendar(), 'ma 12:25-kor', 'Now plus 25 min');
+ assert.equal(moment(a).add({h: 1}).calendar(), 'ma 13:00-kor', 'Now plus 1 hour');
+ assert.equal(moment(a).add({d: 1}).calendar(), 'holnap 12:00-kor', 'tomorrow at the same time');
+ assert.equal(moment(a).subtract({h: 1}).calendar(), 'ma 11:00-kor', 'Now minus 1 hour');
+ assert.equal(moment(a).subtract({d: 1}).calendar(), 'tegnap 12:00-kor', 'yesterday at the same time');
});
test('calendar next week', function (assert) {
@@ -15846,67 +21854,6 @@
assert.equal(weeksFromNow.calendar(), weeksFromNow.format('L'), '2 hét múlva');
});
- test('weeks year starting sunday', function (assert) {
- assert.equal(moment([2011, 11, 26]).week(), 1, 'Dec 26 2011 should be week 1');
- assert.equal(moment([2012, 0, 1]).week(), 1, 'Jan 1 2012 should be week 1');
- assert.equal(moment([2012, 0, 2]).week(), 2, 'Jan 2 2012 should be week 2');
- assert.equal(moment([2012, 0, 8]).week(), 2, 'Jan 8 2012 should be week 2');
- assert.equal(moment([2012, 0, 9]).week(), 3, 'Jan 9 2012 should be week 3');
- });
-
- test('weeks year starting monday', function (assert) {
- assert.equal(moment([2007, 0, 1]).week(), 1, 'Jan 1 2007 should be week 1');
- assert.equal(moment([2007, 0, 7]).week(), 1, 'Jan 7 2007 should be week 1');
- assert.equal(moment([2007, 0, 8]).week(), 2, 'Jan 8 2007 should be week 2');
- assert.equal(moment([2007, 0, 14]).week(), 2, 'Jan 14 2007 should be week 2');
- assert.equal(moment([2007, 0, 15]).week(), 3, 'Jan 15 2007 should be week 3');
- });
-
- test('weeks year starting tuesday', function (assert) {
- assert.equal(moment([2007, 11, 31]).week(), 1, 'Dec 31 2007 should be week 1');
- assert.equal(moment([2008, 0, 1]).week(), 1, 'Jan 1 2008 should be week 1');
- assert.equal(moment([2008, 0, 6]).week(), 1, 'Jan 6 2008 should be week 1');
- assert.equal(moment([2008, 0, 7]).week(), 2, 'Jan 7 2008 should be week 2');
- assert.equal(moment([2008, 0, 13]).week(), 2, 'Jan 13 2008 should be week 2');
- assert.equal(moment([2008, 0, 14]).week(), 3, 'Jan 14 2008 should be week 3');
- });
-
- test('weeks year starting wednesday', function (assert) {
- assert.equal(moment([2002, 11, 30]).week(), 1, 'Dec 30 2002 should be week 1');
- assert.equal(moment([2003, 0, 1]).week(), 1, 'Jan 1 2003 should be week 1');
- assert.equal(moment([2003, 0, 5]).week(), 1, 'Jan 5 2003 should be week 1');
- assert.equal(moment([2003, 0, 6]).week(), 2, 'Jan 6 2003 should be week 2');
- assert.equal(moment([2003, 0, 12]).week(), 2, 'Jan 12 2003 should be week 2');
- assert.equal(moment([2003, 0, 13]).week(), 3, 'Jan 13 2003 should be week 3');
- });
-
- test('weeks year starting thursday', function (assert) {
- assert.equal(moment([2008, 11, 29]).week(), 1, 'Dec 29 2008 should be week 1');
- assert.equal(moment([2009, 0, 1]).week(), 1, 'Jan 1 2009 should be week 1');
- assert.equal(moment([2009, 0, 4]).week(), 1, 'Jan 4 2009 should be week 1');
- assert.equal(moment([2009, 0, 5]).week(), 2, 'Jan 5 2009 should be week 2');
- assert.equal(moment([2009, 0, 11]).week(), 2, 'Jan 11 2009 should be week 2');
- assert.equal(moment([2009, 0, 12]).week(), 3, 'Jan 12 2009 should be week 3');
- });
-
- test('weeks year starting friday', function (assert) {
- assert.equal(moment([2009, 11, 28]).week(), 1, 'Dec 28 2009 should be week 1');
- assert.equal(moment([2010, 0, 1]).week(), 1, 'Jan 1 2010 should be week 1');
- assert.equal(moment([2010, 0, 3]).week(), 1, 'Jan 3 2010 should be week 1');
- assert.equal(moment([2010, 0, 4]).week(), 2, 'Jan 4 2010 should be week 2');
- assert.equal(moment([2010, 0, 10]).week(), 2, 'Jan 10 2010 should be week 2');
- assert.equal(moment([2010, 0, 11]).week(), 3, 'Jan 11 2010 should be week 3');
- });
-
- test('weeks year starting saturday', function (assert) {
- assert.equal(moment([2010, 11, 27]).week(), 1, 'Dec 27 2010 should be week 1');
- assert.equal(moment([2011, 0, 1]).week(), 1, 'Jan 1 2011 should be week 1');
- assert.equal(moment([2011, 0, 2]).week(), 1, 'Jan 2 2011 should be week 1');
- assert.equal(moment([2011, 0, 3]).week(), 2, 'Jan 3 2011 should be week 2');
- assert.equal(moment([2011, 0, 9]).week(), 2, 'Jan 9 2011 should be week 2');
- assert.equal(moment([2011, 0, 10]).week(), 3, 'Jan 10 2011 should be week 3');
- });
-
test('weeks year starting sunday formatted', function (assert) {
assert.equal(moment([2011, 11, 26]).format('w ww wo'), '1 01 1.', 'Dec 26 2011 should be week 1');
assert.equal(moment([2012, 0, 1]).format('w ww wo'), '1 01 1.', 'Jan 1 2012 should be week 1');
@@ -15915,42 +21862,6 @@
assert.equal(moment([2012, 0, 9]).format('w ww wo'), '3 03 3.', 'Jan 9 2012 should be week 3');
});
- test('lenient ordinal parsing', function (assert) {
- var i, ordinalStr, testMoment;
- for (i = 1; i <= 31; ++i) {
- ordinalStr = moment([2014, 0, i]).format('YYYY MM Do');
- testMoment = moment(ordinalStr, 'YYYY MM Do');
- assert.equal(testMoment.year(), 2014,
- 'lenient ordinal parsing ' + i + ' year check');
- assert.equal(testMoment.month(), 0,
- 'lenient ordinal parsing ' + i + ' month check');
- assert.equal(testMoment.date(), i,
- 'lenient ordinal parsing ' + i + ' date check');
- }
- });
-
- test('lenient ordinal parsing of number', function (assert) {
- var i, testMoment;
- for (i = 1; i <= 31; ++i) {
- testMoment = moment('2014 01 ' + i, 'YYYY MM Do');
- assert.equal(testMoment.year(), 2014,
- 'lenient ordinal parsing of number ' + i + ' year check');
- assert.equal(testMoment.month(), 0,
- 'lenient ordinal parsing of number ' + i + ' month check');
- assert.equal(testMoment.date(), i,
- 'lenient ordinal parsing of number ' + i + ' date check');
- }
- });
-
- test('strict ordinal parsing', function (assert) {
- var i, ordinalStr, testMoment;
- for (i = 1; i <= 31; ++i) {
- ordinalStr = moment([2014, 0, i]).format('YYYY MM Do');
- testMoment = moment(ordinalStr, 'YYYY MM Do', true);
- assert.ok(testMoment.isValid(), 'strict ordinal parsing ' + i);
- }
- });
-
}));
;(function (global, factory) {
@@ -15959,6 +21870,224 @@
typeof define === 'function' && define.amd ? define(['../../moment'], factory) :
factory(global.moment)
}(this, function (moment) { 'use strict';
+
+ function each(array, callback) {
+ var i;
+ for (i = 0; i < array.length; i++) {
+ callback(array[i], i, array);
+ }
+ }
+
+ function objectKeys(obj) {
+ if (Object.keys) {
+ return Object.keys(obj);
+ } else {
+ // IE8
+ var res = [], i;
+ for (i in obj) {
+ if (obj.hasOwnProperty(i)) {
+ res.push(i);
+ }
+ }
+ return res;
+ }
+ }
+
+ // Pick the first defined of two or three arguments.
+ function defaults(a, b, c) {
+ if (a != null) {
+ return a;
+ }
+ if (b != null) {
+ return b;
+ }
+ return c;
+ }
+
+ function defineCommonLocaleTests(locale, options) {
+ test('lenient ordinal parsing', function (assert) {
+ var i, ordinalStr, testMoment;
+ for (i = 1; i <= 31; ++i) {
+ ordinalStr = moment([2014, 0, i]).format('YYYY MM Do');
+ testMoment = moment(ordinalStr, 'YYYY MM Do');
+ assert.equal(testMoment.year(), 2014,
+ 'lenient ordinal parsing ' + i + ' year check');
+ assert.equal(testMoment.month(), 0,
+ 'lenient ordinal parsing ' + i + ' month check');
+ assert.equal(testMoment.date(), i,
+ 'lenient ordinal parsing ' + i + ' date check');
+ }
+ });
+
+ test('lenient ordinal parsing of number', function (assert) {
+ var i, testMoment;
+ for (i = 1; i <= 31; ++i) {
+ testMoment = moment('2014 01 ' + i, 'YYYY MM Do');
+ assert.equal(testMoment.year(), 2014,
+ 'lenient ordinal parsing of number ' + i + ' year check');
+ assert.equal(testMoment.month(), 0,
+ 'lenient ordinal parsing of number ' + i + ' month check');
+ assert.equal(testMoment.date(), i,
+ 'lenient ordinal parsing of number ' + i + ' date check');
+ }
+ });
+
+ test('strict ordinal parsing', function (assert) {
+ var i, ordinalStr, testMoment;
+ for (i = 1; i <= 31; ++i) {
+ ordinalStr = moment([2014, 0, i]).format('YYYY MM Do');
+ testMoment = moment(ordinalStr, 'YYYY MM Do', true);
+ assert.ok(testMoment.isValid(), 'strict ordinal parsing ' + i);
+ }
+ });
+
+ test('meridiem invariant', function (assert) {
+ var h, m, t1, t2;
+ for (h = 0; h < 24; ++h) {
+ for (m = 0; m < 60; m += 15) {
+ t1 = moment.utc([2000, 0, 1, h, m]);
+ t2 = moment.utc(t1.format('A h:mm'), 'A h:mm');
+ assert.equal(t2.format('HH:mm'), t1.format('HH:mm'),
+ 'meridiem at ' + t1.format('HH:mm'));
+ }
+ }
+ });
+
+ test('date format correctness', function (assert) {
+ var data, tokens;
+ data = moment.localeData()._longDateFormat;
+ tokens = objectKeys(data);
+ each(tokens, function (srchToken) {
+ // Check each format string to make sure it does not contain any
+ // tokens that need to be expanded.
+ each(tokens, function (baseToken) {
+ // strip escaped sequences
+ var format = data[baseToken].replace(/(\[[^\]]*\])/g, '');
+ assert.equal(false, !!~format.indexOf(srchToken),
+ 'contains ' + srchToken + ' in ' + baseToken);
+ });
+ });
+ });
+
+ test('month parsing correctness', function (assert) {
+ var i, m;
+
+ if (locale === 'tr') {
+ // I can't fix it :(
+ expect(0);
+ return;
+ }
+ function tester(format) {
+ var r;
+ r = moment(m.format(format), format);
+ assert.equal(r.month(), m.month(), 'month ' + i + ' fmt ' + format);
+ r = moment(m.format(format).toLocaleUpperCase(), format);
+ assert.equal(r.month(), m.month(), 'month ' + i + ' fmt ' + format + ' upper');
+ r = moment(m.format(format).toLocaleLowerCase(), format);
+ assert.equal(r.month(), m.month(), 'month ' + i + ' fmt ' + format + ' lower');
+
+ r = moment(m.format(format), format, true);
+ assert.equal(r.month(), m.month(), 'month ' + i + ' fmt ' + format + ' strict');
+ r = moment(m.format(format).toLocaleUpperCase(), format, true);
+ assert.equal(r.month(), m.month(), 'month ' + i + ' fmt ' + format + ' upper strict');
+ r = moment(m.format(format).toLocaleLowerCase(), format, true);
+ assert.equal(r.month(), m.month(), 'month ' + i + ' fmt ' + format + ' lower strict');
+ }
+
+ for (i = 0; i < 12; ++i) {
+ m = moment([2015, i, 15, 18]);
+ tester('MMM');
+ tester('MMM.');
+ tester('MMMM');
+ tester('MMMM.');
+ }
+ });
+
+ test('weekday parsing correctness', function (assert) {
+ var i, m;
+
+ if (locale === 'tr' || locale === 'az') {
+ // There is a lower-case letter (ı), that converted to upper then
+ // lower changes to i
+ expect(0);
+ return;
+ }
+ function tester(format) {
+ var r, baseMsg = 'weekday ' + m.weekday() + ' fmt ' + format;
+ r = moment(m.format(format), format);
+ assert.equal(r.weekday(), m.weekday(), baseMsg);
+ r = moment(m.format(format).toLocaleUpperCase(), format);
+ assert.equal(r.weekday(), m.weekday(), baseMsg + ' upper');
+ r = moment(m.format(format).toLocaleLowerCase(), format);
+ assert.equal(r.weekday(), m.weekday(), baseMsg + ' lower');
+
+ r = moment(m.format(format), format, true);
+ assert.equal(r.weekday(), m.weekday(), baseMsg + ' strict');
+ r = moment(m.format(format).toLocaleUpperCase(), format, true);
+ assert.equal(r.weekday(), m.weekday(), baseMsg + ' upper strict');
+ r = moment(m.format(format).toLocaleLowerCase(), format, true);
+ assert.equal(r.weekday(), m.weekday(), baseMsg + ' lower strict');
+ }
+
+ for (i = 0; i < 7; ++i) {
+ m = moment.utc([2015, i, 15, 18]);
+ tester('dd');
+ tester('ddd');
+ tester('dddd');
+ }
+ });
+ }
+
+ function setupDeprecationHandler(test, moment, scope) {
+ test._expectedDeprecations = null;
+ test._observedDeprecations = null;
+ test._oldSupress = moment.suppressDeprecationWarnings;
+ moment.suppressDeprecationWarnings = true;
+ test.expectedDeprecations = function () {
+ test._expectedDeprecations = arguments;
+ test._observedDeprecations = [];
+ };
+ moment.deprecationHandler = function (name, msg) {
+ var deprecationId = matchedDeprecation(name, msg, test._expectedDeprecations);
+ if (deprecationId === -1) {
+ throw new Error('Unexpected deprecation thrown name=' +
+ name + ' msg=' + msg);
+ }
+ test._observedDeprecations[deprecationId] = 1;
+ };
+ }
+
+ function teardownDeprecationHandler(test, moment, scope) {
+ moment.suppressDeprecationWarnings = test._oldSupress;
+
+ if (test._expectedDeprecations != null) {
+ var missedDeprecations = [];
+ each(test._expectedDeprecations, function (deprecationPattern, id) {
+ if (test._observedDeprecations[id] !== 1) {
+ missedDeprecations.push(deprecationPattern);
+ }
+ });
+ if (missedDeprecations.length !== 0) {
+ throw new Error('Expected deprecation warnings did not happen: ' +
+ missedDeprecations.join(' '));
+ }
+ }
+ }
+
+ function matchedDeprecation(name, msg, deprecations) {
+ if (deprecations == null) {
+ return -1;
+ }
+ for (var i = 0; i < deprecations.length; ++i) {
+ if (name != null && name === deprecations[i]) {
+ return i;
+ }
+ if (msg != null && msg.substring(0, deprecations[i].length) === deprecations[i]) {
+ return i;
+ }
+ }
+ return -1;
+ }
/*global QUnit:false*/
@@ -15973,11 +22102,13 @@
moment.createFromInputFallback = function (config) {
throw new Error('input not handled by moment: ' + config._i);
};
+ setupDeprecationHandler(test, moment, 'core');
if (lifecycle && lifecycle.setup) {
lifecycle.setup();
}
},
teardown : function () {
+ teardownDeprecationHandler(test, moment, 'core');
if (lifecycle && lifecycle.teardown) {
lifecycle.teardown();
}
@@ -15992,17 +22123,20 @@
moment.createFromInputFallback = function (config) {
throw new Error('input not handled by moment: ' + config._i);
};
+ setupDeprecationHandler(test, moment, 'locale');
if (lifecycle && lifecycle.setup) {
lifecycle.setup();
}
},
teardown : function () {
moment.locale('en');
+ teardownDeprecationHandler(test, moment, 'locale');
if (lifecycle && lifecycle.teardown) {
lifecycle.teardown();
}
}
});
+ defineCommonLocaleTests(name, -1, -1);
}
localeModule('hy-am');
@@ -16217,14 +22351,14 @@
});
test('calendar day', function (assert) {
- var a = moment().hours(2).minutes(0).seconds(0);
-
- assert.equal(moment(a).calendar(), 'այսօր 02:00', 'today at the same time');
- assert.equal(moment(a).add({m: 25}).calendar(), 'այսօր 02:25', 'Now plus 25 min');
- assert.equal(moment(a).add({h: 1}).calendar(), 'այսօր 03:00', 'Now plus 1 hour');
- assert.equal(moment(a).add({d: 1}).calendar(), 'վաղը 02:00', 'tomorrow at the same time');
- assert.equal(moment(a).subtract({h: 1}).calendar(), 'այսօր 01:00', 'Now minus 1 hour');
- assert.equal(moment(a).subtract({d: 1}).calendar(), 'երեկ 02:00', 'yesterday at the same time');
+ var a = moment().hours(12).minutes(0).seconds(0);
+
+ assert.equal(moment(a).calendar(), 'այսօր 12:00', 'today at the same time');
+ assert.equal(moment(a).add({m: 25}).calendar(), 'այսօր 12:25', 'Now plus 25 min');
+ assert.equal(moment(a).add({h: 1}).calendar(), 'այսօր 13:00', 'Now plus 1 hour');
+ assert.equal(moment(a).add({d: 1}).calendar(), 'վաղը 12:00', 'tomorrow at the same time');
+ assert.equal(moment(a).subtract({h: 1}).calendar(), 'այսօր 11:00', 'Now minus 1 hour');
+ assert.equal(moment(a).subtract({d: 1}).calendar(), 'երեկ 12:00', 'yesterday at the same time');
});
test('calendar next week', function (assert) {
@@ -16274,67 +22408,6 @@
assert.equal(weeksFromNow.calendar(), weeksFromNow.format('L'), 'in 2 weeks');
});
- test('weeks year starting sunday', function (assert) {
- assert.equal(moment([2011, 11, 26]).week(), 1, 'Dec 26 2011 should be week 1');
- assert.equal(moment([2012, 0, 1]).week(), 1, 'Jan 1 2012 should be week 1');
- assert.equal(moment([2012, 0, 2]).week(), 2, 'Jan 2 2012 should be week 2');
- assert.equal(moment([2012, 0, 8]).week(), 2, 'Jan 8 2012 should be week 2');
- assert.equal(moment([2012, 0, 9]).week(), 3, 'Jan 9 2012 should be week 3');
- });
-
- test('weeks year starting monday', function (assert) {
- assert.equal(moment([2007, 0, 1]).week(), 1, 'Jan 1 2007 should be week 1');
- assert.equal(moment([2007, 0, 7]).week(), 1, 'Jan 7 2007 should be week 1');
- assert.equal(moment([2007, 0, 8]).week(), 2, 'Jan 8 2007 should be week 2');
- assert.equal(moment([2007, 0, 14]).week(), 2, 'Jan 14 2007 should be week 2');
- assert.equal(moment([2007, 0, 15]).week(), 3, 'Jan 15 2007 should be week 3');
- });
-
- test('weeks year starting tuesday', function (assert) {
- assert.equal(moment([2007, 11, 31]).week(), 1, 'Dec 31 2007 should be week 1');
- assert.equal(moment([2008, 0, 1]).week(), 1, 'Jan 1 2008 should be week 1');
- assert.equal(moment([2008, 0, 6]).week(), 1, 'Jan 6 2008 should be week 1');
- assert.equal(moment([2008, 0, 7]).week(), 2, 'Jan 7 2008 should be week 2');
- assert.equal(moment([2008, 0, 13]).week(), 2, 'Jan 13 2008 should be week 2');
- assert.equal(moment([2008, 0, 14]).week(), 3, 'Jan 14 2008 should be week 3');
- });
-
- test('weeks year starting wednesday', function (assert) {
- assert.equal(moment([2002, 11, 30]).week(), 1, 'Dec 30 2002 should be week 1');
- assert.equal(moment([2003, 0, 1]).week(), 1, 'Jan 1 2003 should be week 1');
- assert.equal(moment([2003, 0, 5]).week(), 1, 'Jan 5 2003 should be week 1');
- assert.equal(moment([2003, 0, 6]).week(), 2, 'Jan 6 2003 should be week 2');
- assert.equal(moment([2003, 0, 12]).week(), 2, 'Jan 12 2003 should be week 2');
- assert.equal(moment([2003, 0, 13]).week(), 3, 'Jan 13 2003 should be week 3');
- });
-
- test('weeks year starting thursday', function (assert) {
- assert.equal(moment([2008, 11, 29]).week(), 1, 'Dec 29 2008 should be week 1');
- assert.equal(moment([2009, 0, 1]).week(), 1, 'Jan 1 2009 should be week 1');
- assert.equal(moment([2009, 0, 4]).week(), 1, 'Jan 4 2009 should be week 1');
- assert.equal(moment([2009, 0, 5]).week(), 2, 'Jan 5 2009 should be week 2');
- assert.equal(moment([2009, 0, 11]).week(), 2, 'Jan 11 2009 should be week 2');
- assert.equal(moment([2009, 0, 12]).week(), 3, 'Jan 12 2009 should be week 3');
- });
-
- test('weeks year starting friday', function (assert) {
- assert.equal(moment([2009, 11, 28]).week(), 1, 'Dec 28 2009 should be week 1');
- assert.equal(moment([2010, 0, 1]).week(), 1, 'Jan 1 2010 should be week 1');
- assert.equal(moment([2010, 0, 3]).week(), 1, 'Jan 3 2010 should be week 1');
- assert.equal(moment([2010, 0, 4]).week(), 2, 'Jan 4 2010 should be week 2');
- assert.equal(moment([2010, 0, 10]).week(), 2, 'Jan 10 2010 should be week 2');
- assert.equal(moment([2010, 0, 11]).week(), 3, 'Jan 11 2010 should be week 3');
- });
-
- test('weeks year starting saturday', function (assert) {
- assert.equal(moment([2010, 11, 27]).week(), 1, 'Dec 27 2010 should be week 1');
- assert.equal(moment([2011, 0, 1]).week(), 1, 'Jan 1 2011 should be week 1');
- assert.equal(moment([2011, 0, 2]).week(), 1, 'Jan 2 2011 should be week 1');
- assert.equal(moment([2011, 0, 3]).week(), 2, 'Jan 3 2011 should be week 2');
- assert.equal(moment([2011, 0, 9]).week(), 2, 'Jan 9 2011 should be week 2');
- assert.equal(moment([2011, 0, 10]).week(), 3, 'Jan 10 2011 should be week 3');
- });
-
test('weeks year starting sunday formatted', function (assert) {
assert.equal(moment([2011, 11, 26]).format('w ww wo'), '1 01 1-ին', 'Dec 26 2011 should be week 1');
assert.equal(moment([2012, 0, 1]).format('w ww wo'), '1 01 1-ին', 'Jan 1 2012 should be week 1');
@@ -16343,42 +22416,6 @@
assert.equal(moment([2012, 0, 9]).format('w ww wo'), '3 03 3-րդ', 'Jan 9 2012 should be week 3');
});
- test('lenient ordinal parsing', function (assert) {
- var i, ordinalStr, testMoment;
- for (i = 1; i <= 31; ++i) {
- ordinalStr = moment([2014, 0, i]).format('YYYY MM Do');
- testMoment = moment(ordinalStr, 'YYYY MM Do');
- assert.equal(testMoment.year(), 2014,
- 'lenient ordinal parsing ' + i + ' year check');
- assert.equal(testMoment.month(), 0,
- 'lenient ordinal parsing ' + i + ' month check');
- assert.equal(testMoment.date(), i,
- 'lenient ordinal parsing ' + i + ' date check');
- }
- });
-
- test('lenient ordinal parsing of number', function (assert) {
- var i, testMoment;
- for (i = 1; i <= 31; ++i) {
- testMoment = moment('2014 01 ' + i, 'YYYY MM Do');
- assert.equal(testMoment.year(), 2014,
- 'lenient ordinal parsing of number ' + i + ' year check');
- assert.equal(testMoment.month(), 0,
- 'lenient ordinal parsing of number ' + i + ' month check');
- assert.equal(testMoment.date(), i,
- 'lenient ordinal parsing of number ' + i + ' date check');
- }
- });
-
- test('strict ordinal parsing', function (assert) {
- var i, ordinalStr, testMoment;
- for (i = 1; i <= 31; ++i) {
- ordinalStr = moment([2014, 0, i]).format('YYYY MM Do');
- testMoment = moment(ordinalStr, 'YYYY MM Do', true);
- assert.ok(testMoment.isValid(), 'strict ordinal parsing ' + i);
- }
- });
-
}));
;(function (global, factory) {
@@ -16387,6 +22424,224 @@
typeof define === 'function' && define.amd ? define(['../../moment'], factory) :
factory(global.moment)
}(this, function (moment) { 'use strict';
+
+ function each(array, callback) {
+ var i;
+ for (i = 0; i < array.length; i++) {
+ callback(array[i], i, array);
+ }
+ }
+
+ function objectKeys(obj) {
+ if (Object.keys) {
+ return Object.keys(obj);
+ } else {
+ // IE8
+ var res = [], i;
+ for (i in obj) {
+ if (obj.hasOwnProperty(i)) {
+ res.push(i);
+ }
+ }
+ return res;
+ }
+ }
+
+ // Pick the first defined of two or three arguments.
+ function defaults(a, b, c) {
+ if (a != null) {
+ return a;
+ }
+ if (b != null) {
+ return b;
+ }
+ return c;
+ }
+
+ function defineCommonLocaleTests(locale, options) {
+ test('lenient ordinal parsing', function (assert) {
+ var i, ordinalStr, testMoment;
+ for (i = 1; i <= 31; ++i) {
+ ordinalStr = moment([2014, 0, i]).format('YYYY MM Do');
+ testMoment = moment(ordinalStr, 'YYYY MM Do');
+ assert.equal(testMoment.year(), 2014,
+ 'lenient ordinal parsing ' + i + ' year check');
+ assert.equal(testMoment.month(), 0,
+ 'lenient ordinal parsing ' + i + ' month check');
+ assert.equal(testMoment.date(), i,
+ 'lenient ordinal parsing ' + i + ' date check');
+ }
+ });
+
+ test('lenient ordinal parsing of number', function (assert) {
+ var i, testMoment;
+ for (i = 1; i <= 31; ++i) {
+ testMoment = moment('2014 01 ' + i, 'YYYY MM Do');
+ assert.equal(testMoment.year(), 2014,
+ 'lenient ordinal parsing of number ' + i + ' year check');
+ assert.equal(testMoment.month(), 0,
+ 'lenient ordinal parsing of number ' + i + ' month check');
+ assert.equal(testMoment.date(), i,
+ 'lenient ordinal parsing of number ' + i + ' date check');
+ }
+ });
+
+ test('strict ordinal parsing', function (assert) {
+ var i, ordinalStr, testMoment;
+ for (i = 1; i <= 31; ++i) {
+ ordinalStr = moment([2014, 0, i]).format('YYYY MM Do');
+ testMoment = moment(ordinalStr, 'YYYY MM Do', true);
+ assert.ok(testMoment.isValid(), 'strict ordinal parsing ' + i);
+ }
+ });
+
+ test('meridiem invariant', function (assert) {
+ var h, m, t1, t2;
+ for (h = 0; h < 24; ++h) {
+ for (m = 0; m < 60; m += 15) {
+ t1 = moment.utc([2000, 0, 1, h, m]);
+ t2 = moment.utc(t1.format('A h:mm'), 'A h:mm');
+ assert.equal(t2.format('HH:mm'), t1.format('HH:mm'),
+ 'meridiem at ' + t1.format('HH:mm'));
+ }
+ }
+ });
+
+ test('date format correctness', function (assert) {
+ var data, tokens;
+ data = moment.localeData()._longDateFormat;
+ tokens = objectKeys(data);
+ each(tokens, function (srchToken) {
+ // Check each format string to make sure it does not contain any
+ // tokens that need to be expanded.
+ each(tokens, function (baseToken) {
+ // strip escaped sequences
+ var format = data[baseToken].replace(/(\[[^\]]*\])/g, '');
+ assert.equal(false, !!~format.indexOf(srchToken),
+ 'contains ' + srchToken + ' in ' + baseToken);
+ });
+ });
+ });
+
+ test('month parsing correctness', function (assert) {
+ var i, m;
+
+ if (locale === 'tr') {
+ // I can't fix it :(
+ expect(0);
+ return;
+ }
+ function tester(format) {
+ var r;
+ r = moment(m.format(format), format);
+ assert.equal(r.month(), m.month(), 'month ' + i + ' fmt ' + format);
+ r = moment(m.format(format).toLocaleUpperCase(), format);
+ assert.equal(r.month(), m.month(), 'month ' + i + ' fmt ' + format + ' upper');
+ r = moment(m.format(format).toLocaleLowerCase(), format);
+ assert.equal(r.month(), m.month(), 'month ' + i + ' fmt ' + format + ' lower');
+
+ r = moment(m.format(format), format, true);
+ assert.equal(r.month(), m.month(), 'month ' + i + ' fmt ' + format + ' strict');
+ r = moment(m.format(format).toLocaleUpperCase(), format, true);
+ assert.equal(r.month(), m.month(), 'month ' + i + ' fmt ' + format + ' upper strict');
+ r = moment(m.format(format).toLocaleLowerCase(), format, true);
+ assert.equal(r.month(), m.month(), 'month ' + i + ' fmt ' + format + ' lower strict');
+ }
+
+ for (i = 0; i < 12; ++i) {
+ m = moment([2015, i, 15, 18]);
+ tester('MMM');
+ tester('MMM.');
+ tester('MMMM');
+ tester('MMMM.');
+ }
+ });
+
+ test('weekday parsing correctness', function (assert) {
+ var i, m;
+
+ if (locale === 'tr' || locale === 'az') {
+ // There is a lower-case letter (ı), that converted to upper then
+ // lower changes to i
+ expect(0);
+ return;
+ }
+ function tester(format) {
+ var r, baseMsg = 'weekday ' + m.weekday() + ' fmt ' + format;
+ r = moment(m.format(format), format);
+ assert.equal(r.weekday(), m.weekday(), baseMsg);
+ r = moment(m.format(format).toLocaleUpperCase(), format);
+ assert.equal(r.weekday(), m.weekday(), baseMsg + ' upper');
+ r = moment(m.format(format).toLocaleLowerCase(), format);
+ assert.equal(r.weekday(), m.weekday(), baseMsg + ' lower');
+
+ r = moment(m.format(format), format, true);
+ assert.equal(r.weekday(), m.weekday(), baseMsg + ' strict');
+ r = moment(m.format(format).toLocaleUpperCase(), format, true);
+ assert.equal(r.weekday(), m.weekday(), baseMsg + ' upper strict');
+ r = moment(m.format(format).toLocaleLowerCase(), format, true);
+ assert.equal(r.weekday(), m.weekday(), baseMsg + ' lower strict');
+ }
+
+ for (i = 0; i < 7; ++i) {
+ m = moment.utc([2015, i, 15, 18]);
+ tester('dd');
+ tester('ddd');
+ tester('dddd');
+ }
+ });
+ }
+
+ function setupDeprecationHandler(test, moment, scope) {
+ test._expectedDeprecations = null;
+ test._observedDeprecations = null;
+ test._oldSupress = moment.suppressDeprecationWarnings;
+ moment.suppressDeprecationWarnings = true;
+ test.expectedDeprecations = function () {
+ test._expectedDeprecations = arguments;
+ test._observedDeprecations = [];
+ };
+ moment.deprecationHandler = function (name, msg) {
+ var deprecationId = matchedDeprecation(name, msg, test._expectedDeprecations);
+ if (deprecationId === -1) {
+ throw new Error('Unexpected deprecation thrown name=' +
+ name + ' msg=' + msg);
+ }
+ test._observedDeprecations[deprecationId] = 1;
+ };
+ }
+
+ function teardownDeprecationHandler(test, moment, scope) {
+ moment.suppressDeprecationWarnings = test._oldSupress;
+
+ if (test._expectedDeprecations != null) {
+ var missedDeprecations = [];
+ each(test._expectedDeprecations, function (deprecationPattern, id) {
+ if (test._observedDeprecations[id] !== 1) {
+ missedDeprecations.push(deprecationPattern);
+ }
+ });
+ if (missedDeprecations.length !== 0) {
+ throw new Error('Expected deprecation warnings did not happen: ' +
+ missedDeprecations.join(' '));
+ }
+ }
+ }
+
+ function matchedDeprecation(name, msg, deprecations) {
+ if (deprecations == null) {
+ return -1;
+ }
+ for (var i = 0; i < deprecations.length; ++i) {
+ if (name != null && name === deprecations[i]) {
+ return i;
+ }
+ if (msg != null && msg.substring(0, deprecations[i].length) === deprecations[i]) {
+ return i;
+ }
+ }
+ return -1;
+ }
/*global QUnit:false*/
@@ -16401,11 +22656,13 @@
moment.createFromInputFallback = function (config) {
throw new Error('input not handled by moment: ' + config._i);
};
+ setupDeprecationHandler(test, moment, 'core');
if (lifecycle && lifecycle.setup) {
lifecycle.setup();
}
},
teardown : function () {
+ teardownDeprecationHandler(test, moment, 'core');
if (lifecycle && lifecycle.teardown) {
lifecycle.teardown();
}
@@ -16420,17 +22677,20 @@
moment.createFromInputFallback = function (config) {
throw new Error('input not handled by moment: ' + config._i);
};
+ setupDeprecationHandler(test, moment, 'locale');
if (lifecycle && lifecycle.setup) {
lifecycle.setup();
}
},
teardown : function () {
moment.locale('en');
+ teardownDeprecationHandler(test, moment, 'locale');
if (lifecycle && lifecycle.teardown) {
lifecycle.teardown();
}
}
});
+ defineCommonLocaleTests(name, -1, -1);
}
localeModule('id');
@@ -16547,14 +22807,14 @@
});
test('calendar day', function (assert) {
- var a = moment().hours(2).minutes(0).seconds(0);
-
- assert.equal(moment(a).calendar(), 'Hari ini pukul 02.00', 'today at the same time');
- assert.equal(moment(a).add({m: 25}).calendar(), 'Hari ini pukul 02.25', 'Now plus 25 min');
- assert.equal(moment(a).add({h: 1}).calendar(), 'Hari ini pukul 03.00', 'Now plus 1 hour');
- assert.equal(moment(a).add({d: 1}).calendar(), 'Besok pukul 02.00', 'tomorrow at the same time');
- assert.equal(moment(a).subtract({h: 1}).calendar(), 'Hari ini pukul 01.00', 'Now minus 1 hour');
- assert.equal(moment(a).subtract({d: 1}).calendar(), 'Kemarin pukul 02.00', 'yesterday at the same time');
+ var a = moment().hours(12).minutes(0).seconds(0);
+
+ assert.equal(moment(a).calendar(), 'Hari ini pukul 12.00', 'today at the same time');
+ assert.equal(moment(a).add({m: 25}).calendar(), 'Hari ini pukul 12.25', 'Now plus 25 min');
+ assert.equal(moment(a).add({h: 1}).calendar(), 'Hari ini pukul 13.00', 'Now plus 1 hour');
+ assert.equal(moment(a).add({d: 1}).calendar(), 'Besok pukul 12.00', 'tomorrow at the same time');
+ assert.equal(moment(a).subtract({h: 1}).calendar(), 'Hari ini pukul 11.00', 'Now minus 1 hour');
+ assert.equal(moment(a).subtract({d: 1}).calendar(), 'Kemarin pukul 12.00', 'yesterday at the same time');
});
test('calendar next week', function (assert) {
@@ -16595,67 +22855,6 @@
assert.equal(weeksFromNow.calendar(), weeksFromNow.format('L'), 'in 2 weeks');
});
- test('weeks year starting sunday', function (assert) {
- assert.equal(moment([2011, 11, 26]).week(), 1, 'Dec 26 2011 should be week 1');
- assert.equal(moment([2012, 0, 1]).week(), 1, 'Jan 1 2012 should be week 1');
- assert.equal(moment([2012, 0, 2]).week(), 2, 'Jan 2 2012 should be week 2');
- assert.equal(moment([2012, 0, 8]).week(), 2, 'Jan 8 2012 should be week 2');
- assert.equal(moment([2012, 0, 9]).week(), 3, 'Jan 9 2012 should be week 3');
- });
-
- test('weeks year starting monday', function (assert) {
- assert.equal(moment([2007, 0, 1]).week(), 1, 'Jan 1 2007 should be week 1');
- assert.equal(moment([2007, 0, 7]).week(), 1, 'Jan 7 2007 should be week 1');
- assert.equal(moment([2007, 0, 8]).week(), 2, 'Jan 8 2007 should be week 2');
- assert.equal(moment([2007, 0, 14]).week(), 2, 'Jan 14 2007 should be week 2');
- assert.equal(moment([2007, 0, 15]).week(), 3, 'Jan 15 2007 should be week 3');
- });
-
- test('weeks year starting tuesday', function (assert) {
- assert.equal(moment([2007, 11, 31]).week(), 1, 'Dec 31 2007 should be week 1');
- assert.equal(moment([2008, 0, 1]).week(), 1, 'Jan 1 2008 should be week 1');
- assert.equal(moment([2008, 0, 6]).week(), 1, 'Jan 6 2008 should be week 1');
- assert.equal(moment([2008, 0, 7]).week(), 2, 'Jan 7 2008 should be week 2');
- assert.equal(moment([2008, 0, 13]).week(), 2, 'Jan 13 2008 should be week 2');
- assert.equal(moment([2008, 0, 14]).week(), 3, 'Jan 14 2008 should be week 3');
- });
-
- test('weeks year starting wednesday', function (assert) {
- assert.equal(moment([2002, 11, 30]).week(), 1, 'Dec 30 2002 should be week 1');
- assert.equal(moment([2003, 0, 1]).week(), 1, 'Jan 1 2003 should be week 1');
- assert.equal(moment([2003, 0, 5]).week(), 1, 'Jan 5 2003 should be week 1');
- assert.equal(moment([2003, 0, 6]).week(), 2, 'Jan 6 2003 should be week 2');
- assert.equal(moment([2003, 0, 12]).week(), 2, 'Jan 12 2003 should be week 2');
- assert.equal(moment([2003, 0, 13]).week(), 3, 'Jan 13 2003 should be week 3');
- });
-
- test('weeks year starting thursday', function (assert) {
- assert.equal(moment([2008, 11, 29]).week(), 1, 'Dec 29 2008 should be week 1');
- assert.equal(moment([2009, 0, 1]).week(), 1, 'Jan 1 2009 should be week 1');
- assert.equal(moment([2009, 0, 4]).week(), 1, 'Jan 4 2009 should be week 1');
- assert.equal(moment([2009, 0, 5]).week(), 2, 'Jan 5 2009 should be week 2');
- assert.equal(moment([2009, 0, 11]).week(), 2, 'Jan 11 2009 should be week 2');
- assert.equal(moment([2009, 0, 12]).week(), 3, 'Jan 12 2009 should be week 3');
- });
-
- test('weeks year starting friday', function (assert) {
- assert.equal(moment([2009, 11, 28]).week(), 1, 'Dec 28 2009 should be week 1');
- assert.equal(moment([2010, 0, 1]).week(), 1, 'Jan 1 2010 should be week 1');
- assert.equal(moment([2010, 0, 3]).week(), 1, 'Jan 3 2010 should be week 1');
- assert.equal(moment([2010, 0, 4]).week(), 2, 'Jan 4 2010 should be week 2');
- assert.equal(moment([2010, 0, 10]).week(), 2, 'Jan 10 2010 should be week 2');
- assert.equal(moment([2010, 0, 11]).week(), 3, 'Jan 11 2010 should be week 3');
- });
-
- test('weeks year starting saturday', function (assert) {
- assert.equal(moment([2010, 11, 27]).week(), 1, 'Dec 27 2010 should be week 1');
- assert.equal(moment([2011, 0, 1]).week(), 1, 'Jan 1 2011 should be week 1');
- assert.equal(moment([2011, 0, 2]).week(), 1, 'Jan 2 2011 should be week 1');
- assert.equal(moment([2011, 0, 3]).week(), 2, 'Jan 3 2011 should be week 2');
- assert.equal(moment([2011, 0, 9]).week(), 2, 'Jan 9 2011 should be week 2');
- assert.equal(moment([2011, 0, 10]).week(), 3, 'Jan 10 2011 should be week 3');
- });
-
test('weeks year starting sunday formatted', function (assert) {
assert.equal(moment([2011, 11, 26]).format('w ww wo'), '1 01 1', 'Dec 26 2011 should be week 1');
assert.equal(moment([2012, 0, 1]).format('w ww wo'), '1 01 1', 'Jan 1 2012 should be week 1');
@@ -16664,54 +22863,6 @@
assert.equal(moment([2012, 0, 9]).format('w ww wo'), '3 03 3', 'Jan 9 2012 should be week 3');
});
- test('lenient ordinal parsing', function (assert) {
- var i, ordinalStr, testMoment;
- for (i = 1; i <= 31; ++i) {
- ordinalStr = moment([2014, 0, i]).format('YYYY MM Do');
- testMoment = moment(ordinalStr, 'YYYY MM Do');
- assert.equal(testMoment.year(), 2014,
- 'lenient ordinal parsing ' + i + ' year check');
- assert.equal(testMoment.month(), 0,
- 'lenient ordinal parsing ' + i + ' month check');
- assert.equal(testMoment.date(), i,
- 'lenient ordinal parsing ' + i + ' date check');
- }
- });
-
- test('lenient ordinal parsing of number', function (assert) {
- var i, testMoment;
- for (i = 1; i <= 31; ++i) {
- testMoment = moment('2014 01 ' + i, 'YYYY MM Do');
- assert.equal(testMoment.year(), 2014,
- 'lenient ordinal parsing of number ' + i + ' year check');
- assert.equal(testMoment.month(), 0,
- 'lenient ordinal parsing of number ' + i + ' month check');
- assert.equal(testMoment.date(), i,
- 'lenient ordinal parsing of number ' + i + ' date check');
- }
- });
-
- test('meridiem invariant', function (assert) {
- var h, m, t1, t2;
- for (h = 0; h < 24; ++h) {
- for (m = 0; m < 60; m += 15) {
- t1 = moment.utc([2000, 0, 1, h, m]);
- t2 = moment(t1.format('A h:mm'), 'A h:mm');
- assert.equal(t2.format('HH:mm'), t1.format('HH:mm'),
- 'meridiem at ' + t1.format('HH:mm'));
- }
- }
- });
-
- test('strict ordinal parsing', function (assert) {
- var i, ordinalStr, testMoment;
- for (i = 1; i <= 31; ++i) {
- ordinalStr = moment([2014, 0, i]).format('YYYY MM Do');
- testMoment = moment(ordinalStr, 'YYYY MM Do', true);
- assert.ok(testMoment.isValid(), 'strict ordinal parsing ' + i);
- }
- });
-
}));
;(function (global, factory) {
@@ -16720,6 +22871,224 @@
typeof define === 'function' && define.amd ? define(['../../moment'], factory) :
factory(global.moment)
}(this, function (moment) { 'use strict';
+
+ function each(array, callback) {
+ var i;
+ for (i = 0; i < array.length; i++) {
+ callback(array[i], i, array);
+ }
+ }
+
+ function objectKeys(obj) {
+ if (Object.keys) {
+ return Object.keys(obj);
+ } else {
+ // IE8
+ var res = [], i;
+ for (i in obj) {
+ if (obj.hasOwnProperty(i)) {
+ res.push(i);
+ }
+ }
+ return res;
+ }
+ }
+
+ // Pick the first defined of two or three arguments.
+ function defaults(a, b, c) {
+ if (a != null) {
+ return a;
+ }
+ if (b != null) {
+ return b;
+ }
+ return c;
+ }
+
+ function defineCommonLocaleTests(locale, options) {
+ test('lenient ordinal parsing', function (assert) {
+ var i, ordinalStr, testMoment;
+ for (i = 1; i <= 31; ++i) {
+ ordinalStr = moment([2014, 0, i]).format('YYYY MM Do');
+ testMoment = moment(ordinalStr, 'YYYY MM Do');
+ assert.equal(testMoment.year(), 2014,
+ 'lenient ordinal parsing ' + i + ' year check');
+ assert.equal(testMoment.month(), 0,
+ 'lenient ordinal parsing ' + i + ' month check');
+ assert.equal(testMoment.date(), i,
+ 'lenient ordinal parsing ' + i + ' date check');
+ }
+ });
+
+ test('lenient ordinal parsing of number', function (assert) {
+ var i, testMoment;
+ for (i = 1; i <= 31; ++i) {
+ testMoment = moment('2014 01 ' + i, 'YYYY MM Do');
+ assert.equal(testMoment.year(), 2014,
+ 'lenient ordinal parsing of number ' + i + ' year check');
+ assert.equal(testMoment.month(), 0,
+ 'lenient ordinal parsing of number ' + i + ' month check');
+ assert.equal(testMoment.date(), i,
+ 'lenient ordinal parsing of number ' + i + ' date check');
+ }
+ });
+
+ test('strict ordinal parsing', function (assert) {
+ var i, ordinalStr, testMoment;
+ for (i = 1; i <= 31; ++i) {
+ ordinalStr = moment([2014, 0, i]).format('YYYY MM Do');
+ testMoment = moment(ordinalStr, 'YYYY MM Do', true);
+ assert.ok(testMoment.isValid(), 'strict ordinal parsing ' + i);
+ }
+ });
+
+ test('meridiem invariant', function (assert) {
+ var h, m, t1, t2;
+ for (h = 0; h < 24; ++h) {
+ for (m = 0; m < 60; m += 15) {
+ t1 = moment.utc([2000, 0, 1, h, m]);
+ t2 = moment.utc(t1.format('A h:mm'), 'A h:mm');
+ assert.equal(t2.format('HH:mm'), t1.format('HH:mm'),
+ 'meridiem at ' + t1.format('HH:mm'));
+ }
+ }
+ });
+
+ test('date format correctness', function (assert) {
+ var data, tokens;
+ data = moment.localeData()._longDateFormat;
+ tokens = objectKeys(data);
+ each(tokens, function (srchToken) {
+ // Check each format string to make sure it does not contain any
+ // tokens that need to be expanded.
+ each(tokens, function (baseToken) {
+ // strip escaped sequences
+ var format = data[baseToken].replace(/(\[[^\]]*\])/g, '');
+ assert.equal(false, !!~format.indexOf(srchToken),
+ 'contains ' + srchToken + ' in ' + baseToken);
+ });
+ });
+ });
+
+ test('month parsing correctness', function (assert) {
+ var i, m;
+
+ if (locale === 'tr') {
+ // I can't fix it :(
+ expect(0);
+ return;
+ }
+ function tester(format) {
+ var r;
+ r = moment(m.format(format), format);
+ assert.equal(r.month(), m.month(), 'month ' + i + ' fmt ' + format);
+ r = moment(m.format(format).toLocaleUpperCase(), format);
+ assert.equal(r.month(), m.month(), 'month ' + i + ' fmt ' + format + ' upper');
+ r = moment(m.format(format).toLocaleLowerCase(), format);
+ assert.equal(r.month(), m.month(), 'month ' + i + ' fmt ' + format + ' lower');
+
+ r = moment(m.format(format), format, true);
+ assert.equal(r.month(), m.month(), 'month ' + i + ' fmt ' + format + ' strict');
+ r = moment(m.format(format).toLocaleUpperCase(), format, true);
+ assert.equal(r.month(), m.month(), 'month ' + i + ' fmt ' + format + ' upper strict');
+ r = moment(m.format(format).toLocaleLowerCase(), format, true);
+ assert.equal(r.month(), m.month(), 'month ' + i + ' fmt ' + format + ' lower strict');
+ }
+
+ for (i = 0; i < 12; ++i) {
+ m = moment([2015, i, 15, 18]);
+ tester('MMM');
+ tester('MMM.');
+ tester('MMMM');
+ tester('MMMM.');
+ }
+ });
+
+ test('weekday parsing correctness', function (assert) {
+ var i, m;
+
+ if (locale === 'tr' || locale === 'az') {
+ // There is a lower-case letter (ı), that converted to upper then
+ // lower changes to i
+ expect(0);
+ return;
+ }
+ function tester(format) {
+ var r, baseMsg = 'weekday ' + m.weekday() + ' fmt ' + format;
+ r = moment(m.format(format), format);
+ assert.equal(r.weekday(), m.weekday(), baseMsg);
+ r = moment(m.format(format).toLocaleUpperCase(), format);
+ assert.equal(r.weekday(), m.weekday(), baseMsg + ' upper');
+ r = moment(m.format(format).toLocaleLowerCase(), format);
+ assert.equal(r.weekday(), m.weekday(), baseMsg + ' lower');
+
+ r = moment(m.format(format), format, true);
+ assert.equal(r.weekday(), m.weekday(), baseMsg + ' strict');
+ r = moment(m.format(format).toLocaleUpperCase(), format, true);
+ assert.equal(r.weekday(), m.weekday(), baseMsg + ' upper strict');
+ r = moment(m.format(format).toLocaleLowerCase(), format, true);
+ assert.equal(r.weekday(), m.weekday(), baseMsg + ' lower strict');
+ }
+
+ for (i = 0; i < 7; ++i) {
+ m = moment.utc([2015, i, 15, 18]);
+ tester('dd');
+ tester('ddd');
+ tester('dddd');
+ }
+ });
+ }
+
+ function setupDeprecationHandler(test, moment, scope) {
+ test._expectedDeprecations = null;
+ test._observedDeprecations = null;
+ test._oldSupress = moment.suppressDeprecationWarnings;
+ moment.suppressDeprecationWarnings = true;
+ test.expectedDeprecations = function () {
+ test._expectedDeprecations = arguments;
+ test._observedDeprecations = [];
+ };
+ moment.deprecationHandler = function (name, msg) {
+ var deprecationId = matchedDeprecation(name, msg, test._expectedDeprecations);
+ if (deprecationId === -1) {
+ throw new Error('Unexpected deprecation thrown name=' +
+ name + ' msg=' + msg);
+ }
+ test._observedDeprecations[deprecationId] = 1;
+ };
+ }
+
+ function teardownDeprecationHandler(test, moment, scope) {
+ moment.suppressDeprecationWarnings = test._oldSupress;
+
+ if (test._expectedDeprecations != null) {
+ var missedDeprecations = [];
+ each(test._expectedDeprecations, function (deprecationPattern, id) {
+ if (test._observedDeprecations[id] !== 1) {
+ missedDeprecations.push(deprecationPattern);
+ }
+ });
+ if (missedDeprecations.length !== 0) {
+ throw new Error('Expected deprecation warnings did not happen: ' +
+ missedDeprecations.join(' '));
+ }
+ }
+ }
+
+ function matchedDeprecation(name, msg, deprecations) {
+ if (deprecations == null) {
+ return -1;
+ }
+ for (var i = 0; i < deprecations.length; ++i) {
+ if (name != null && name === deprecations[i]) {
+ return i;
+ }
+ if (msg != null && msg.substring(0, deprecations[i].length) === deprecations[i]) {
+ return i;
+ }
+ }
+ return -1;
+ }
/*global QUnit:false*/
@@ -16734,11 +23103,13 @@
moment.createFromInputFallback = function (config) {
throw new Error('input not handled by moment: ' + config._i);
};
+ setupDeprecationHandler(test, moment, 'core');
if (lifecycle && lifecycle.setup) {
lifecycle.setup();
}
},
teardown : function () {
+ teardownDeprecationHandler(test, moment, 'core');
if (lifecycle && lifecycle.teardown) {
lifecycle.teardown();
}
@@ -16753,17 +23124,20 @@
moment.createFromInputFallback = function (config) {
throw new Error('input not handled by moment: ' + config._i);
};
+ setupDeprecationHandler(test, moment, 'locale');
if (lifecycle && lifecycle.setup) {
lifecycle.setup();
}
},
teardown : function () {
moment.locale('en');
+ teardownDeprecationHandler(test, moment, 'locale');
if (lifecycle && lifecycle.teardown) {
lifecycle.teardown();
}
}
});
+ defineCommonLocaleTests(name, -1, -1);
}
localeModule('is');
@@ -16803,11 +23177,11 @@
['a A', 'pm PM'],
['[the] DDDo [day of the year]', 'the 45. day of the year'],
['LTS', '15:25:50'],
- ['L', '14/02/2010'],
+ ['L', '14.02.2010'],
['LL', '14. febrúar 2010'],
['LLL', '14. febrúar 2010 kl. 15:25'],
['LLLL', 'sunnudagur, 14. febrúar 2010 kl. 15:25'],
- ['l', '14/2/2010'],
+ ['l', '14.2.2010'],
['ll', '14. feb 2010'],
['lll', '14. feb 2010 kl. 15:25'],
['llll', 'sun, 14. feb 2010 kl. 15:25']
@@ -16923,14 +23297,14 @@
});
test('calendar day', function (assert) {
- var a = moment().hours(2).minutes(0).seconds(0);
-
- assert.equal(moment(a).calendar(), 'í dag kl. 2:00', 'today at the same time');
- assert.equal(moment(a).add({m: 25}).calendar(), 'í dag kl. 2:25', 'Now plus 25 min');
- assert.equal(moment(a).add({h: 1}).calendar(), 'í dag kl. 3:00', 'Now plus 1 hour');
- assert.equal(moment(a).add({d: 1}).calendar(), 'á morgun kl. 2:00', 'tomorrow at the same time');
- assert.equal(moment(a).subtract({h: 1}).calendar(), 'í dag kl. 1:00', 'Now minus 1 hour');
- assert.equal(moment(a).subtract({d: 1}).calendar(), 'í gær kl. 2:00', 'yesterday at the same time');
+ var a = moment().hours(12).minutes(0).seconds(0);
+
+ assert.equal(moment(a).calendar(), 'í dag kl. 12:00', 'today at the same time');
+ assert.equal(moment(a).add({m: 25}).calendar(), 'í dag kl. 12:25', 'Now plus 25 min');
+ assert.equal(moment(a).add({h: 1}).calendar(), 'í dag kl. 13:00', 'Now plus 1 hour');
+ assert.equal(moment(a).add({d: 1}).calendar(), 'á morgun kl. 12:00', 'tomorrow at the same time');
+ assert.equal(moment(a).subtract({h: 1}).calendar(), 'í dag kl. 11:00', 'Now minus 1 hour');
+ assert.equal(moment(a).subtract({d: 1}).calendar(), 'í gær kl. 12:00', 'yesterday at the same time');
});
test('calendar next week', function (assert) {
@@ -16972,67 +23346,6 @@
assert.equal(weeksFromNow.calendar(), weeksFromNow.format('L'), 'in 2 weeks');
});
- test('weeks year starting sunday', function (assert) {
- assert.equal(moment([2012, 0, 1]).week(), 52, 'Jan 1 2012 should be week 52');
- assert.equal(moment([2012, 0, 2]).week(), 1, 'Jan 2 2012 should be week 1');
- assert.equal(moment([2012, 0, 8]).week(), 1, 'Jan 8 2012 should be week 1');
- assert.equal(moment([2012, 0, 9]).week(), 2, 'Jan 9 2012 should be week 2');
- assert.equal(moment([2012, 0, 15]).week(), 2, 'Jan 15 2012 should be week 2');
- });
-
- test('weeks year starting monday', function (assert) {
- assert.equal(moment([2007, 0, 1]).week(), 1, 'Jan 1 2007 should be week 1');
- assert.equal(moment([2007, 0, 7]).week(), 1, 'Jan 7 2007 should be week 1');
- assert.equal(moment([2007, 0, 8]).week(), 2, 'Jan 8 2007 should be week 2');
- assert.equal(moment([2007, 0, 14]).week(), 2, 'Jan 14 2007 should be week 2');
- assert.equal(moment([2007, 0, 15]).week(), 3, 'Jan 15 2007 should be week 3');
- });
-
- test('weeks year starting tuesday', function (assert) {
- assert.equal(moment([2007, 11, 31]).week(), 1, 'Dec 31 2007 should be week 1');
- assert.equal(moment([2008, 0, 1]).week(), 1, 'Jan 1 2008 should be week 1');
- assert.equal(moment([2008, 0, 6]).week(), 1, 'Jan 6 2008 should be week 1');
- assert.equal(moment([2008, 0, 7]).week(), 2, 'Jan 7 2008 should be week 2');
- assert.equal(moment([2008, 0, 13]).week(), 2, 'Jan 13 2008 should be week 2');
- assert.equal(moment([2008, 0, 14]).week(), 3, 'Jan 14 2008 should be week 3');
- });
-
- test('weeks year starting wednesday', function (assert) {
- assert.equal(moment([2002, 11, 30]).week(), 1, 'Dec 30 2002 should be week 1');
- assert.equal(moment([2003, 0, 1]).week(), 1, 'Jan 1 2003 should be week 1');
- assert.equal(moment([2003, 0, 5]).week(), 1, 'Jan 5 2003 should be week 1');
- assert.equal(moment([2003, 0, 6]).week(), 2, 'Jan 6 2003 should be week 2');
- assert.equal(moment([2003, 0, 12]).week(), 2, 'Jan 12 2003 should be week 2');
- assert.equal(moment([2003, 0, 13]).week(), 3, 'Jan 13 2003 should be week 3');
- });
-
- test('weeks year starting thursday', function (assert) {
- assert.equal(moment([2008, 11, 29]).week(), 1, 'Dec 29 2008 should be week 1');
- assert.equal(moment([2009, 0, 1]).week(), 1, 'Jan 1 2009 should be week 1');
- assert.equal(moment([2009, 0, 4]).week(), 1, 'Jan 4 2009 should be week 1');
- assert.equal(moment([2009, 0, 5]).week(), 2, 'Jan 5 2009 should be week 2');
- assert.equal(moment([2009, 0, 11]).week(), 2, 'Jan 11 2009 should be week 2');
- assert.equal(moment([2009, 0, 13]).week(), 3, 'Jan 12 2009 should be week 3');
- });
-
- test('weeks year starting friday', function (assert) {
- assert.equal(moment([2009, 11, 28]).week(), 53, 'Dec 28 2009 should be week 53');
- assert.equal(moment([2010, 0, 1]).week(), 53, 'Jan 1 2010 should be week 53');
- assert.equal(moment([2010, 0, 3]).week(), 53, 'Jan 3 2010 should be week 53');
- assert.equal(moment([2010, 0, 4]).week(), 1, 'Jan 4 2010 should be week 1');
- assert.equal(moment([2010, 0, 10]).week(), 1, 'Jan 10 2010 should be week 1');
- assert.equal(moment([2010, 0, 11]).week(), 2, 'Jan 11 2010 should be week 2');
- });
-
- test('weeks year starting saturday', function (assert) {
- assert.equal(moment([2010, 11, 27]).week(), 52, 'Dec 27 2010 should be week 52');
- assert.equal(moment([2011, 0, 1]).week(), 52, 'Jan 1 2011 should be week 52');
- assert.equal(moment([2011, 0, 2]).week(), 52, 'Jan 2 2011 should be week 52');
- assert.equal(moment([2011, 0, 3]).week(), 1, 'Jan 3 2011 should be week 1');
- assert.equal(moment([2011, 0, 9]).week(), 1, 'Jan 9 2011 should be week 1');
- assert.equal(moment([2011, 0, 10]).week(), 2, 'Jan 10 2011 should be week 2');
- });
-
test('weeks year starting sunday formatted', function (assert) {
assert.equal(moment([2012, 0, 1]).format('w ww wo'), '52 52 52.', 'Jan 1 2012 should be week 52');
assert.equal(moment([2012, 0, 2]).format('w ww wo'), '1 01 1.', 'Jan 2 2012 should be week 1');
@@ -17041,42 +23354,6 @@
assert.equal(moment([2012, 0, 15]).format('w ww wo'), '2 02 2.', 'Jan 15 2012 should be week 2');
});
- test('lenient ordinal parsing', function (assert) {
- var i, ordinalStr, testMoment;
- for (i = 1; i <= 31; ++i) {
- ordinalStr = moment([2014, 0, i]).format('YYYY MM Do');
- testMoment = moment(ordinalStr, 'YYYY MM Do');
- assert.equal(testMoment.year(), 2014,
- 'lenient ordinal parsing ' + i + ' year check');
- assert.equal(testMoment.month(), 0,
- 'lenient ordinal parsing ' + i + ' month check');
- assert.equal(testMoment.date(), i,
- 'lenient ordinal parsing ' + i + ' date check');
- }
- });
-
- test('lenient ordinal parsing of number', function (assert) {
- var i, testMoment;
- for (i = 1; i <= 31; ++i) {
- testMoment = moment('2014 01 ' + i, 'YYYY MM Do');
- assert.equal(testMoment.year(), 2014,
- 'lenient ordinal parsing of number ' + i + ' year check');
- assert.equal(testMoment.month(), 0,
- 'lenient ordinal parsing of number ' + i + ' month check');
- assert.equal(testMoment.date(), i,
- 'lenient ordinal parsing of number ' + i + ' date check');
- }
- });
-
- test('strict ordinal parsing', function (assert) {
- var i, ordinalStr, testMoment;
- for (i = 1; i <= 31; ++i) {
- ordinalStr = moment([2014, 0, i]).format('YYYY MM Do');
- testMoment = moment(ordinalStr, 'YYYY MM Do', true);
- assert.ok(testMoment.isValid(), 'strict ordinal parsing ' + i);
- }
- });
-
}));
;(function (global, factory) {
@@ -17085,6 +23362,224 @@
typeof define === 'function' && define.amd ? define(['../../moment'], factory) :
factory(global.moment)
}(this, function (moment) { 'use strict';
+
+ function each(array, callback) {
+ var i;
+ for (i = 0; i < array.length; i++) {
+ callback(array[i], i, array);
+ }
+ }
+
+ function objectKeys(obj) {
+ if (Object.keys) {
+ return Object.keys(obj);
+ } else {
+ // IE8
+ var res = [], i;
+ for (i in obj) {
+ if (obj.hasOwnProperty(i)) {
+ res.push(i);
+ }
+ }
+ return res;
+ }
+ }
+
+ // Pick the first defined of two or three arguments.
+ function defaults(a, b, c) {
+ if (a != null) {
+ return a;
+ }
+ if (b != null) {
+ return b;
+ }
+ return c;
+ }
+
+ function defineCommonLocaleTests(locale, options) {
+ test('lenient ordinal parsing', function (assert) {
+ var i, ordinalStr, testMoment;
+ for (i = 1; i <= 31; ++i) {
+ ordinalStr = moment([2014, 0, i]).format('YYYY MM Do');
+ testMoment = moment(ordinalStr, 'YYYY MM Do');
+ assert.equal(testMoment.year(), 2014,
+ 'lenient ordinal parsing ' + i + ' year check');
+ assert.equal(testMoment.month(), 0,
+ 'lenient ordinal parsing ' + i + ' month check');
+ assert.equal(testMoment.date(), i,
+ 'lenient ordinal parsing ' + i + ' date check');
+ }
+ });
+
+ test('lenient ordinal parsing of number', function (assert) {
+ var i, testMoment;
+ for (i = 1; i <= 31; ++i) {
+ testMoment = moment('2014 01 ' + i, 'YYYY MM Do');
+ assert.equal(testMoment.year(), 2014,
+ 'lenient ordinal parsing of number ' + i + ' year check');
+ assert.equal(testMoment.month(), 0,
+ 'lenient ordinal parsing of number ' + i + ' month check');
+ assert.equal(testMoment.date(), i,
+ 'lenient ordinal parsing of number ' + i + ' date check');
+ }
+ });
+
+ test('strict ordinal parsing', function (assert) {
+ var i, ordinalStr, testMoment;
+ for (i = 1; i <= 31; ++i) {
+ ordinalStr = moment([2014, 0, i]).format('YYYY MM Do');
+ testMoment = moment(ordinalStr, 'YYYY MM Do', true);
+ assert.ok(testMoment.isValid(), 'strict ordinal parsing ' + i);
+ }
+ });
+
+ test('meridiem invariant', function (assert) {
+ var h, m, t1, t2;
+ for (h = 0; h < 24; ++h) {
+ for (m = 0; m < 60; m += 15) {
+ t1 = moment.utc([2000, 0, 1, h, m]);
+ t2 = moment.utc(t1.format('A h:mm'), 'A h:mm');
+ assert.equal(t2.format('HH:mm'), t1.format('HH:mm'),
+ 'meridiem at ' + t1.format('HH:mm'));
+ }
+ }
+ });
+
+ test('date format correctness', function (assert) {
+ var data, tokens;
+ data = moment.localeData()._longDateFormat;
+ tokens = objectKeys(data);
+ each(tokens, function (srchToken) {
+ // Check each format string to make sure it does not contain any
+ // tokens that need to be expanded.
+ each(tokens, function (baseToken) {
+ // strip escaped sequences
+ var format = data[baseToken].replace(/(\[[^\]]*\])/g, '');
+ assert.equal(false, !!~format.indexOf(srchToken),
+ 'contains ' + srchToken + ' in ' + baseToken);
+ });
+ });
+ });
+
+ test('month parsing correctness', function (assert) {
+ var i, m;
+
+ if (locale === 'tr') {
+ // I can't fix it :(
+ expect(0);
+ return;
+ }
+ function tester(format) {
+ var r;
+ r = moment(m.format(format), format);
+ assert.equal(r.month(), m.month(), 'month ' + i + ' fmt ' + format);
+ r = moment(m.format(format).toLocaleUpperCase(), format);
+ assert.equal(r.month(), m.month(), 'month ' + i + ' fmt ' + format + ' upper');
+ r = moment(m.format(format).toLocaleLowerCase(), format);
+ assert.equal(r.month(), m.month(), 'month ' + i + ' fmt ' + format + ' lower');
+
+ r = moment(m.format(format), format, true);
+ assert.equal(r.month(), m.month(), 'month ' + i + ' fmt ' + format + ' strict');
+ r = moment(m.format(format).toLocaleUpperCase(), format, true);
+ assert.equal(r.month(), m.month(), 'month ' + i + ' fmt ' + format + ' upper strict');
+ r = moment(m.format(format).toLocaleLowerCase(), format, true);
+ assert.equal(r.month(), m.month(), 'month ' + i + ' fmt ' + format + ' lower strict');
+ }
+
+ for (i = 0; i < 12; ++i) {
+ m = moment([2015, i, 15, 18]);
+ tester('MMM');
+ tester('MMM.');
+ tester('MMMM');
+ tester('MMMM.');
+ }
+ });
+
+ test('weekday parsing correctness', function (assert) {
+ var i, m;
+
+ if (locale === 'tr' || locale === 'az') {
+ // There is a lower-case letter (ı), that converted to upper then
+ // lower changes to i
+ expect(0);
+ return;
+ }
+ function tester(format) {
+ var r, baseMsg = 'weekday ' + m.weekday() + ' fmt ' + format;
+ r = moment(m.format(format), format);
+ assert.equal(r.weekday(), m.weekday(), baseMsg);
+ r = moment(m.format(format).toLocaleUpperCase(), format);
+ assert.equal(r.weekday(), m.weekday(), baseMsg + ' upper');
+ r = moment(m.format(format).toLocaleLowerCase(), format);
+ assert.equal(r.weekday(), m.weekday(), baseMsg + ' lower');
+
+ r = moment(m.format(format), format, true);
+ assert.equal(r.weekday(), m.weekday(), baseMsg + ' strict');
+ r = moment(m.format(format).toLocaleUpperCase(), format, true);
+ assert.equal(r.weekday(), m.weekday(), baseMsg + ' upper strict');
+ r = moment(m.format(format).toLocaleLowerCase(), format, true);
+ assert.equal(r.weekday(), m.weekday(), baseMsg + ' lower strict');
+ }
+
+ for (i = 0; i < 7; ++i) {
+ m = moment.utc([2015, i, 15, 18]);
+ tester('dd');
+ tester('ddd');
+ tester('dddd');
+ }
+ });
+ }
+
+ function setupDeprecationHandler(test, moment, scope) {
+ test._expectedDeprecations = null;
+ test._observedDeprecations = null;
+ test._oldSupress = moment.suppressDeprecationWarnings;
+ moment.suppressDeprecationWarnings = true;
+ test.expectedDeprecations = function () {
+ test._expectedDeprecations = arguments;
+ test._observedDeprecations = [];
+ };
+ moment.deprecationHandler = function (name, msg) {
+ var deprecationId = matchedDeprecation(name, msg, test._expectedDeprecations);
+ if (deprecationId === -1) {
+ throw new Error('Unexpected deprecation thrown name=' +
+ name + ' msg=' + msg);
+ }
+ test._observedDeprecations[deprecationId] = 1;
+ };
+ }
+
+ function teardownDeprecationHandler(test, moment, scope) {
+ moment.suppressDeprecationWarnings = test._oldSupress;
+
+ if (test._expectedDeprecations != null) {
+ var missedDeprecations = [];
+ each(test._expectedDeprecations, function (deprecationPattern, id) {
+ if (test._observedDeprecations[id] !== 1) {
+ missedDeprecations.push(deprecationPattern);
+ }
+ });
+ if (missedDeprecations.length !== 0) {
+ throw new Error('Expected deprecation warnings did not happen: ' +
+ missedDeprecations.join(' '));
+ }
+ }
+ }
+
+ function matchedDeprecation(name, msg, deprecations) {
+ if (deprecations == null) {
+ return -1;
+ }
+ for (var i = 0; i < deprecations.length; ++i) {
+ if (name != null && name === deprecations[i]) {
+ return i;
+ }
+ if (msg != null && msg.substring(0, deprecations[i].length) === deprecations[i]) {
+ return i;
+ }
+ }
+ return -1;
+ }
/*global QUnit:false*/
@@ -17099,11 +23594,13 @@
moment.createFromInputFallback = function (config) {
throw new Error('input not handled by moment: ' + config._i);
};
+ setupDeprecationHandler(test, moment, 'core');
if (lifecycle && lifecycle.setup) {
lifecycle.setup();
}
},
teardown : function () {
+ teardownDeprecationHandler(test, moment, 'core');
if (lifecycle && lifecycle.teardown) {
lifecycle.teardown();
}
@@ -17118,17 +23615,20 @@
moment.createFromInputFallback = function (config) {
throw new Error('input not handled by moment: ' + config._i);
};
+ setupDeprecationHandler(test, moment, 'locale');
if (lifecycle && lifecycle.setup) {
lifecycle.setup();
}
},
teardown : function () {
moment.locale('en');
+ teardownDeprecationHandler(test, moment, 'locale');
if (lifecycle && lifecycle.teardown) {
lifecycle.teardown();
}
}
});
+ defineCommonLocaleTests(name, -1, -1);
}
localeModule('it');
@@ -17278,14 +23778,14 @@
});
test('calendar day', function (assert) {
- var a = moment().hours(2).minutes(0).seconds(0);
-
- assert.equal(moment(a).calendar(), 'Oggi alle 02:00', 'today at the same time');
- assert.equal(moment(a).add({m: 25}).calendar(), 'Oggi alle 02:25', 'Now plus 25 min');
- assert.equal(moment(a).add({h: 1}).calendar(), 'Oggi alle 03:00', 'Now plus 1 hour');
- assert.equal(moment(a).add({d: 1}).calendar(), 'Domani alle 02:00', 'tomorrow at the same time');
- assert.equal(moment(a).subtract({h: 1}).calendar(), 'Oggi alle 01:00', 'Now minus 1 hour');
- assert.equal(moment(a).subtract({d: 1}).calendar(), 'Ieri alle 02:00', 'yesterday at the same time');
+ var a = moment().hours(12).minutes(0).seconds(0);
+
+ assert.equal(moment(a).calendar(), 'Oggi alle 12:00', 'today at the same time');
+ assert.equal(moment(a).add({m: 25}).calendar(), 'Oggi alle 12:25', 'Now plus 25 min');
+ assert.equal(moment(a).add({h: 1}).calendar(), 'Oggi alle 13:00', 'Now plus 1 hour');
+ assert.equal(moment(a).add({d: 1}).calendar(), 'Domani alle 12:00', 'tomorrow at the same time');
+ assert.equal(moment(a).subtract({h: 1}).calendar(), 'Oggi alle 11:00', 'Now minus 1 hour');
+ assert.equal(moment(a).subtract({d: 1}).calendar(), 'Ieri alle 12:00', 'yesterday at the same time');
});
test('calendar next week', function (assert) {
@@ -17329,67 +23829,6 @@
assert.equal(weeksFromNow.calendar(), weeksFromNow.format('L'), 'in 2 weeks');
});
- test('weeks year starting sunday', function (assert) {
- assert.equal(moment([2012, 0, 1]).week(), 52, 'Jan 1 2012 should be week 52');
- assert.equal(moment([2012, 0, 2]).week(), 1, 'Jan 2 2012 should be week 1');
- assert.equal(moment([2012, 0, 8]).week(), 1, 'Jan 8 2012 should be week 1');
- assert.equal(moment([2012, 0, 9]).week(), 2, 'Jan 9 2012 should be week 2');
- assert.equal(moment([2012, 0, 15]).week(), 2, 'Jan 15 2012 should be week 2');
- });
-
- test('weeks year starting monday', function (assert) {
- assert.equal(moment([2007, 0, 1]).week(), 1, 'Jan 1 2007 should be week 1');
- assert.equal(moment([2007, 0, 7]).week(), 1, 'Jan 7 2007 should be week 1');
- assert.equal(moment([2007, 0, 8]).week(), 2, 'Jan 8 2007 should be week 2');
- assert.equal(moment([2007, 0, 14]).week(), 2, 'Jan 14 2007 should be week 2');
- assert.equal(moment([2007, 0, 15]).week(), 3, 'Jan 15 2007 should be week 3');
- });
-
- test('weeks year starting tuesday', function (assert) {
- assert.equal(moment([2007, 11, 31]).week(), 1, 'Dec 31 2007 should be week 1');
- assert.equal(moment([2008, 0, 1]).week(), 1, 'Jan 1 2008 should be week 1');
- assert.equal(moment([2008, 0, 6]).week(), 1, 'Jan 6 2008 should be week 1');
- assert.equal(moment([2008, 0, 7]).week(), 2, 'Jan 7 2008 should be week 2');
- assert.equal(moment([2008, 0, 13]).week(), 2, 'Jan 13 2008 should be week 2');
- assert.equal(moment([2008, 0, 14]).week(), 3, 'Jan 14 2008 should be week 3');
- });
-
- test('weeks year starting wednesday', function (assert) {
- assert.equal(moment([2002, 11, 30]).week(), 1, 'Dec 30 2002 should be week 1');
- assert.equal(moment([2003, 0, 1]).week(), 1, 'Jan 1 2003 should be week 1');
- assert.equal(moment([2003, 0, 5]).week(), 1, 'Jan 5 2003 should be week 1');
- assert.equal(moment([2003, 0, 6]).week(), 2, 'Jan 6 2003 should be week 2');
- assert.equal(moment([2003, 0, 12]).week(), 2, 'Jan 12 2003 should be week 2');
- assert.equal(moment([2003, 0, 13]).week(), 3, 'Jan 13 2003 should be week 3');
- });
-
- test('weeks year starting thursday', function (assert) {
- assert.equal(moment([2008, 11, 29]).week(), 1, 'Dec 29 2008 should be week 1');
- assert.equal(moment([2009, 0, 1]).week(), 1, 'Jan 1 2009 should be week 1');
- assert.equal(moment([2009, 0, 4]).week(), 1, 'Jan 4 2009 should be week 1');
- assert.equal(moment([2009, 0, 5]).week(), 2, 'Jan 5 2009 should be week 2');
- assert.equal(moment([2009, 0, 11]).week(), 2, 'Jan 11 2009 should be week 2');
- assert.equal(moment([2009, 0, 13]).week(), 3, 'Jan 12 2009 should be week 3');
- });
-
- test('weeks year starting friday', function (assert) {
- assert.equal(moment([2009, 11, 28]).week(), 53, 'Dec 28 2009 should be week 53');
- assert.equal(moment([2010, 0, 1]).week(), 53, 'Jan 1 2010 should be week 53');
- assert.equal(moment([2010, 0, 3]).week(), 53, 'Jan 3 2010 should be week 53');
- assert.equal(moment([2010, 0, 4]).week(), 1, 'Jan 4 2010 should be week 1');
- assert.equal(moment([2010, 0, 10]).week(), 1, 'Jan 10 2010 should be week 1');
- assert.equal(moment([2010, 0, 11]).week(), 2, 'Jan 11 2010 should be week 2');
- });
-
- test('weeks year starting saturday', function (assert) {
- assert.equal(moment([2010, 11, 27]).week(), 52, 'Dec 27 2010 should be week 52');
- assert.equal(moment([2011, 0, 1]).week(), 52, 'Jan 1 2011 should be week 52');
- assert.equal(moment([2011, 0, 2]).week(), 52, 'Jan 2 2011 should be week 52');
- assert.equal(moment([2011, 0, 3]).week(), 1, 'Jan 3 2011 should be week 1');
- assert.equal(moment([2011, 0, 9]).week(), 1, 'Jan 9 2011 should be week 1');
- assert.equal(moment([2011, 0, 10]).week(), 2, 'Jan 10 2011 should be week 2');
- });
-
test('weeks year starting sunday formatted', function (assert) {
assert.equal(moment([2012, 0, 1]).format('w ww wo'), '52 52 52º', 'Jan 1 2012 should be week 52');
assert.equal(moment([2012, 0, 2]).format('w ww wo'), '1 01 1º', 'Jan 2 2012 should be week 1');
@@ -17398,42 +23837,6 @@
assert.equal(moment([2012, 0, 15]).format('w ww wo'), '2 02 2º', 'Jan 15 2012 should be week 2');
});
- test('lenient ordinal parsing', function (assert) {
- var i, ordinalStr, testMoment;
- for (i = 1; i <= 31; ++i) {
- ordinalStr = moment([2014, 0, i]).format('YYYY MM Do');
- testMoment = moment(ordinalStr, 'YYYY MM Do');
- assert.equal(testMoment.year(), 2014,
- 'lenient ordinal parsing ' + i + ' year check');
- assert.equal(testMoment.month(), 0,
- 'lenient ordinal parsing ' + i + ' month check');
- assert.equal(testMoment.date(), i,
- 'lenient ordinal parsing ' + i + ' date check');
- }
- });
-
- test('lenient ordinal parsing of number', function (assert) {
- var i, testMoment;
- for (i = 1; i <= 31; ++i) {
- testMoment = moment('2014 01 ' + i, 'YYYY MM Do');
- assert.equal(testMoment.year(), 2014,
- 'lenient ordinal parsing of number ' + i + ' year check');
- assert.equal(testMoment.month(), 0,
- 'lenient ordinal parsing of number ' + i + ' month check');
- assert.equal(testMoment.date(), i,
- 'lenient ordinal parsing of number ' + i + ' date check');
- }
- });
-
- test('strict ordinal parsing', function (assert) {
- var i, ordinalStr, testMoment;
- for (i = 1; i <= 31; ++i) {
- ordinalStr = moment([2014, 0, i]).format('YYYY MM Do');
- testMoment = moment(ordinalStr, 'YYYY MM Do', true);
- assert.ok(testMoment.isValid(), 'strict ordinal parsing ' + i);
- }
- });
-
}));
;(function (global, factory) {
@@ -17442,6 +23845,224 @@
typeof define === 'function' && define.amd ? define(['../../moment'], factory) :
factory(global.moment)
}(this, function (moment) { 'use strict';
+
+ function each(array, callback) {
+ var i;
+ for (i = 0; i < array.length; i++) {
+ callback(array[i], i, array);
+ }
+ }
+
+ function objectKeys(obj) {
+ if (Object.keys) {
+ return Object.keys(obj);
+ } else {
+ // IE8
+ var res = [], i;
+ for (i in obj) {
+ if (obj.hasOwnProperty(i)) {
+ res.push(i);
+ }
+ }
+ return res;
+ }
+ }
+
+ // Pick the first defined of two or three arguments.
+ function defaults(a, b, c) {
+ if (a != null) {
+ return a;
+ }
+ if (b != null) {
+ return b;
+ }
+ return c;
+ }
+
+ function defineCommonLocaleTests(locale, options) {
+ test('lenient ordinal parsing', function (assert) {
+ var i, ordinalStr, testMoment;
+ for (i = 1; i <= 31; ++i) {
+ ordinalStr = moment([2014, 0, i]).format('YYYY MM Do');
+ testMoment = moment(ordinalStr, 'YYYY MM Do');
+ assert.equal(testMoment.year(), 2014,
+ 'lenient ordinal parsing ' + i + ' year check');
+ assert.equal(testMoment.month(), 0,
+ 'lenient ordinal parsing ' + i + ' month check');
+ assert.equal(testMoment.date(), i,
+ 'lenient ordinal parsing ' + i + ' date check');
+ }
+ });
+
+ test('lenient ordinal parsing of number', function (assert) {
+ var i, testMoment;
+ for (i = 1; i <= 31; ++i) {
+ testMoment = moment('2014 01 ' + i, 'YYYY MM Do');
+ assert.equal(testMoment.year(), 2014,
+ 'lenient ordinal parsing of number ' + i + ' year check');
+ assert.equal(testMoment.month(), 0,
+ 'lenient ordinal parsing of number ' + i + ' month check');
+ assert.equal(testMoment.date(), i,
+ 'lenient ordinal parsing of number ' + i + ' date check');
+ }
+ });
+
+ test('strict ordinal parsing', function (assert) {
+ var i, ordinalStr, testMoment;
+ for (i = 1; i <= 31; ++i) {
+ ordinalStr = moment([2014, 0, i]).format('YYYY MM Do');
+ testMoment = moment(ordinalStr, 'YYYY MM Do', true);
+ assert.ok(testMoment.isValid(), 'strict ordinal parsing ' + i);
+ }
+ });
+
+ test('meridiem invariant', function (assert) {
+ var h, m, t1, t2;
+ for (h = 0; h < 24; ++h) {
+ for (m = 0; m < 60; m += 15) {
+ t1 = moment.utc([2000, 0, 1, h, m]);
+ t2 = moment.utc(t1.format('A h:mm'), 'A h:mm');
+ assert.equal(t2.format('HH:mm'), t1.format('HH:mm'),
+ 'meridiem at ' + t1.format('HH:mm'));
+ }
+ }
+ });
+
+ test('date format correctness', function (assert) {
+ var data, tokens;
+ data = moment.localeData()._longDateFormat;
+ tokens = objectKeys(data);
+ each(tokens, function (srchToken) {
+ // Check each format string to make sure it does not contain any
+ // tokens that need to be expanded.
+ each(tokens, function (baseToken) {
+ // strip escaped sequences
+ var format = data[baseToken].replace(/(\[[^\]]*\])/g, '');
+ assert.equal(false, !!~format.indexOf(srchToken),
+ 'contains ' + srchToken + ' in ' + baseToken);
+ });
+ });
+ });
+
+ test('month parsing correctness', function (assert) {
+ var i, m;
+
+ if (locale === 'tr') {
+ // I can't fix it :(
+ expect(0);
+ return;
+ }
+ function tester(format) {
+ var r;
+ r = moment(m.format(format), format);
+ assert.equal(r.month(), m.month(), 'month ' + i + ' fmt ' + format);
+ r = moment(m.format(format).toLocaleUpperCase(), format);
+ assert.equal(r.month(), m.month(), 'month ' + i + ' fmt ' + format + ' upper');
+ r = moment(m.format(format).toLocaleLowerCase(), format);
+ assert.equal(r.month(), m.month(), 'month ' + i + ' fmt ' + format + ' lower');
+
+ r = moment(m.format(format), format, true);
+ assert.equal(r.month(), m.month(), 'month ' + i + ' fmt ' + format + ' strict');
+ r = moment(m.format(format).toLocaleUpperCase(), format, true);
+ assert.equal(r.month(), m.month(), 'month ' + i + ' fmt ' + format + ' upper strict');
+ r = moment(m.format(format).toLocaleLowerCase(), format, true);
+ assert.equal(r.month(), m.month(), 'month ' + i + ' fmt ' + format + ' lower strict');
+ }
+
+ for (i = 0; i < 12; ++i) {
+ m = moment([2015, i, 15, 18]);
+ tester('MMM');
+ tester('MMM.');
+ tester('MMMM');
+ tester('MMMM.');
+ }
+ });
+
+ test('weekday parsing correctness', function (assert) {
+ var i, m;
+
+ if (locale === 'tr' || locale === 'az') {
+ // There is a lower-case letter (ı), that converted to upper then
+ // lower changes to i
+ expect(0);
+ return;
+ }
+ function tester(format) {
+ var r, baseMsg = 'weekday ' + m.weekday() + ' fmt ' + format;
+ r = moment(m.format(format), format);
+ assert.equal(r.weekday(), m.weekday(), baseMsg);
+ r = moment(m.format(format).toLocaleUpperCase(), format);
+ assert.equal(r.weekday(), m.weekday(), baseMsg + ' upper');
+ r = moment(m.format(format).toLocaleLowerCase(), format);
+ assert.equal(r.weekday(), m.weekday(), baseMsg + ' lower');
+
+ r = moment(m.format(format), format, true);
+ assert.equal(r.weekday(), m.weekday(), baseMsg + ' strict');
+ r = moment(m.format(format).toLocaleUpperCase(), format, true);
+ assert.equal(r.weekday(), m.weekday(), baseMsg + ' upper strict');
+ r = moment(m.format(format).toLocaleLowerCase(), format, true);
+ assert.equal(r.weekday(), m.weekday(), baseMsg + ' lower strict');
+ }
+
+ for (i = 0; i < 7; ++i) {
+ m = moment.utc([2015, i, 15, 18]);
+ tester('dd');
+ tester('ddd');
+ tester('dddd');
+ }
+ });
+ }
+
+ function setupDeprecationHandler(test, moment, scope) {
+ test._expectedDeprecations = null;
+ test._observedDeprecations = null;
+ test._oldSupress = moment.suppressDeprecationWarnings;
+ moment.suppressDeprecationWarnings = true;
+ test.expectedDeprecations = function () {
+ test._expectedDeprecations = arguments;
+ test._observedDeprecations = [];
+ };
+ moment.deprecationHandler = function (name, msg) {
+ var deprecationId = matchedDeprecation(name, msg, test._expectedDeprecations);
+ if (deprecationId === -1) {
+ throw new Error('Unexpected deprecation thrown name=' +
+ name + ' msg=' + msg);
+ }
+ test._observedDeprecations[deprecationId] = 1;
+ };
+ }
+
+ function teardownDeprecationHandler(test, moment, scope) {
+ moment.suppressDeprecationWarnings = test._oldSupress;
+
+ if (test._expectedDeprecations != null) {
+ var missedDeprecations = [];
+ each(test._expectedDeprecations, function (deprecationPattern, id) {
+ if (test._observedDeprecations[id] !== 1) {
+ missedDeprecations.push(deprecationPattern);
+ }
+ });
+ if (missedDeprecations.length !== 0) {
+ throw new Error('Expected deprecation warnings did not happen: ' +
+ missedDeprecations.join(' '));
+ }
+ }
+ }
+
+ function matchedDeprecation(name, msg, deprecations) {
+ if (deprecations == null) {
+ return -1;
+ }
+ for (var i = 0; i < deprecations.length; ++i) {
+ if (name != null && name === deprecations[i]) {
+ return i;
+ }
+ if (msg != null && msg.substring(0, deprecations[i].length) === deprecations[i]) {
+ return i;
+ }
+ }
+ return -1;
+ }
/*global QUnit:false*/
@@ -17456,11 +24077,13 @@
moment.createFromInputFallback = function (config) {
throw new Error('input not handled by moment: ' + config._i);
};
+ setupDeprecationHandler(test, moment, 'core');
if (lifecycle && lifecycle.setup) {
lifecycle.setup();
}
},
teardown : function () {
+ teardownDeprecationHandler(test, moment, 'core');
if (lifecycle && lifecycle.teardown) {
lifecycle.teardown();
}
@@ -17475,17 +24098,20 @@
moment.createFromInputFallback = function (config) {
throw new Error('input not handled by moment: ' + config._i);
};
+ setupDeprecationHandler(test, moment, 'locale');
if (lifecycle && lifecycle.setup) {
lifecycle.setup();
}
},
teardown : function () {
moment.locale('en');
+ teardownDeprecationHandler(test, moment, 'locale');
if (lifecycle && lifecycle.teardown) {
lifecycle.teardown();
}
}
});
+ defineCommonLocaleTests(name, -1, -1);
}
localeModule('ja');
@@ -17510,20 +24136,20 @@
test('format', function (assert) {
var a = [
- ['dddd, MMMM Do YYYY, a h:mm:ss', '日曜日, 2月 14 2010, 午後 3:25:50'],
+ ['dddd, MMMM Do YYYY, a h:mm:ss', '日曜日, 2月 14日 2010, 午後 3:25:50'],
['ddd, Ah', '日, 午後3'],
['M Mo MM MMMM MMM', '2 2 02 2月 2月'],
['YYYY YY', '2010 10'],
- ['D Do DD', '14 14 14'],
- ['d do dddd ddd dd', '0 0 日曜日 日 日'],
- ['DDD DDDo DDDD', '45 45 045'],
+ ['D Do DD', '14 14日 14'],
+ ['d do dddd ddd dd', '0 0日 日曜日 日 日'],
+ ['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', '午後 午後'],
- ['[the] DDDo [day of the year]', 'the 45 day of the year'],
+ ['[the] DDDo [day of the year]', 'the 45日 day of the year'],
['LTS', '午後3時25分50秒'],
['L', '2010/02/14'],
['LL', '2010年2月14日'],
@@ -17602,14 +24228,14 @@
});
test('calendar day', function (assert) {
- var a = moment().hours(2).minutes(0).seconds(0);
-
- assert.equal(moment(a).calendar(), '今日 午前2時0分', 'today at the same time');
- assert.equal(moment(a).add({m: 25}).calendar(), '今日 午前2時25分', 'Now plus 25 min');
- assert.equal(moment(a).add({h: 1}).calendar(), '今日 午前3時0分', 'Now plus 1 hour');
- assert.equal(moment(a).add({d: 1}).calendar(), '明日 午前2時0分', 'tomorrow at the same time');
- assert.equal(moment(a).subtract({h: 1}).calendar(), '今日 午前1時0分', 'Now minus 1 hour');
- assert.equal(moment(a).subtract({d: 1}).calendar(), '昨日 午前2時0分', 'yesterday at the same time');
+ var a = moment().hours(12).minutes(0).seconds(0);
+
+ assert.equal(moment(a).calendar(), '今日 午後12時0分', 'today at the same time');
+ assert.equal(moment(a).add({m: 25}).calendar(), '今日 午後12時25分', 'Now plus 25 min');
+ assert.equal(moment(a).add({h: 1}).calendar(), '今日 午後1時0分', 'Now plus 1 hour');
+ assert.equal(moment(a).add({d: 1}).calendar(), '明日 午後12時0分', 'tomorrow at the same time');
+ assert.equal(moment(a).subtract({h: 1}).calendar(), '今日 午前11時0分', 'Now minus 1 hour');
+ assert.equal(moment(a).subtract({d: 1}).calendar(), '昨日 午後12時0分', 'yesterday at the same time');
});
test('calendar next week', function (assert) {
@@ -17650,67 +24276,6 @@
assert.equal(weeksFromNow.calendar(), weeksFromNow.format('L'), 'in 2 weeks');
});
- test('weeks year starting sunday', function (assert) {
- assert.equal(moment([2012, 0, 1]).week(), 1, 'Jan 1 2012 should be week 1');
- assert.equal(moment([2012, 0, 7]).week(), 1, 'Jan 7 2012 should be week 1');
- assert.equal(moment([2012, 0, 8]).week(), 2, 'Jan 8 2012 should be week 2');
- assert.equal(moment([2012, 0, 14]).week(), 2, 'Jan 14 2012 should be week 2');
- assert.equal(moment([2012, 0, 15]).week(), 3, 'Jan 15 2012 should be week 3');
- });
-
- test('weeks year starting monday', function (assert) {
- assert.equal(moment([2006, 11, 31]).week(), 1, 'Dec 31 2006 should be week 1');
- assert.equal(moment([2007, 0, 1]).week(), 1, 'Jan 1 2007 should be week 1');
- assert.equal(moment([2007, 0, 6]).week(), 1, 'Jan 6 2007 should be week 1');
- assert.equal(moment([2007, 0, 7]).week(), 2, 'Jan 7 2007 should be week 2');
- assert.equal(moment([2007, 0, 13]).week(), 2, 'Jan 13 2007 should be week 2');
- assert.equal(moment([2007, 0, 14]).week(), 3, 'Jan 14 2007 should be week 3');
- });
-
- test('weeks year starting tuesday', function (assert) {
- assert.equal(moment([2007, 11, 29]).week(), 52, 'Dec 29 2007 should be week 52');
- assert.equal(moment([2008, 0, 1]).week(), 1, 'Jan 1 2008 should be week 1');
- assert.equal(moment([2008, 0, 5]).week(), 1, 'Jan 5 2008 should be week 1');
- assert.equal(moment([2008, 0, 6]).week(), 2, 'Jan 6 2008 should be week 2');
- assert.equal(moment([2008, 0, 12]).week(), 2, 'Jan 12 2008 should be week 2');
- assert.equal(moment([2008, 0, 13]).week(), 3, 'Jan 13 2008 should be week 3');
- });
-
- test('weeks year starting wednesday', function (assert) {
- assert.equal(moment([2002, 11, 29]).week(), 1, 'Dec 29 2002 should be week 1');
- assert.equal(moment([2003, 0, 1]).week(), 1, 'Jan 1 2003 should be week 1');
- assert.equal(moment([2003, 0, 4]).week(), 1, 'Jan 4 2003 should be week 1');
- assert.equal(moment([2003, 0, 5]).week(), 2, 'Jan 5 2003 should be week 2');
- assert.equal(moment([2003, 0, 11]).week(), 2, 'Jan 11 2003 should be week 2');
- assert.equal(moment([2003, 0, 12]).week(), 3, 'Jan 12 2003 should be week 3');
- });
-
- test('weeks year starting thursday', function (assert) {
- assert.equal(moment([2008, 11, 28]).week(), 1, 'Dec 28 2008 should be week 1');
- assert.equal(moment([2009, 0, 1]).week(), 1, 'Jan 1 2009 should be week 1');
- assert.equal(moment([2009, 0, 3]).week(), 1, 'Jan 3 2009 should be week 1');
- assert.equal(moment([2009, 0, 4]).week(), 2, 'Jan 4 2009 should be week 2');
- assert.equal(moment([2009, 0, 10]).week(), 2, 'Jan 10 2009 should be week 2');
- assert.equal(moment([2009, 0, 11]).week(), 3, 'Jan 11 2009 should be week 3');
- });
-
- test('weeks year starting friday', function (assert) {
- assert.equal(moment([2009, 11, 27]).week(), 1, 'Dec 27 2009 should be week 1');
- assert.equal(moment([2010, 0, 1]).week(), 1, 'Jan 1 2010 should be week 1');
- assert.equal(moment([2010, 0, 2]).week(), 1, 'Jan 2 2010 should be week 1');
- assert.equal(moment([2010, 0, 3]).week(), 2, 'Jan 3 2010 should be week 2');
- assert.equal(moment([2010, 0, 9]).week(), 2, 'Jan 9 2010 should be week 2');
- assert.equal(moment([2010, 0, 10]).week(), 3, 'Jan 10 2010 should be week 3');
- });
-
- test('weeks year starting saturday', function (assert) {
- assert.equal(moment([2010, 11, 26]).week(), 1, 'Dec 26 2010 should be week 1');
- assert.equal(moment([2011, 0, 1]).week(), 1, 'Jan 1 2011 should be week 1');
- assert.equal(moment([2011, 0, 2]).week(), 2, 'Jan 2 2011 should be week 2');
- assert.equal(moment([2011, 0, 8]).week(), 2, 'Jan 8 2011 should be week 2');
- assert.equal(moment([2011, 0, 9]).week(), 3, 'Jan 9 2011 should be week 3');
- });
-
test('weeks year starting sunday format', function (assert) {
assert.equal(moment([2012, 0, 1]).format('w ww wo'), '1 01 1', 'Jan 1 2012 should be week 1');
assert.equal(moment([2012, 0, 7]).format('w ww wo'), '1 01 1', 'Jan 7 2012 should be week 1');
@@ -17719,42 +24284,6 @@
assert.equal(moment([2012, 0, 15]).format('w ww wo'), '3 03 3', 'Jan 15 2012 should be week 3');
});
- test('lenient ordinal parsing', function (assert) {
- var i, ordinalStr, testMoment;
- for (i = 1; i <= 31; ++i) {
- ordinalStr = moment([2014, 0, i]).format('YYYY MM Do');
- testMoment = moment(ordinalStr, 'YYYY MM Do');
- assert.equal(testMoment.year(), 2014,
- 'lenient ordinal parsing ' + i + ' year check');
- assert.equal(testMoment.month(), 0,
- 'lenient ordinal parsing ' + i + ' month check');
- assert.equal(testMoment.date(), i,
- 'lenient ordinal parsing ' + i + ' date check');
- }
- });
-
- test('lenient ordinal parsing of number', function (assert) {
- var i, testMoment;
- for (i = 1; i <= 31; ++i) {
- testMoment = moment('2014 01 ' + i, 'YYYY MM Do');
- assert.equal(testMoment.year(), 2014,
- 'lenient ordinal parsing of number ' + i + ' year check');
- assert.equal(testMoment.month(), 0,
- 'lenient ordinal parsing of number ' + i + ' month check');
- assert.equal(testMoment.date(), i,
- 'lenient ordinal parsing of number ' + i + ' date check');
- }
- });
-
- test('strict ordinal parsing', function (assert) {
- var i, ordinalStr, testMoment;
- for (i = 1; i <= 31; ++i) {
- ordinalStr = moment([2014, 0, i]).format('YYYY MM Do');
- testMoment = moment(ordinalStr, 'YYYY MM Do', true);
- assert.ok(testMoment.isValid(), 'strict ordinal parsing ' + i);
- }
- });
-
}));
;(function (global, factory) {
@@ -17763,6 +24292,224 @@
typeof define === 'function' && define.amd ? define(['../../moment'], factory) :
factory(global.moment)
}(this, function (moment) { 'use strict';
+
+ function each(array, callback) {
+ var i;
+ for (i = 0; i < array.length; i++) {
+ callback(array[i], i, array);
+ }
+ }
+
+ function objectKeys(obj) {
+ if (Object.keys) {
+ return Object.keys(obj);
+ } else {
+ // IE8
+ var res = [], i;
+ for (i in obj) {
+ if (obj.hasOwnProperty(i)) {
+ res.push(i);
+ }
+ }
+ return res;
+ }
+ }
+
+ // Pick the first defined of two or three arguments.
+ function defaults(a, b, c) {
+ if (a != null) {
+ return a;
+ }
+ if (b != null) {
+ return b;
+ }
+ return c;
+ }
+
+ function defineCommonLocaleTests(locale, options) {
+ test('lenient ordinal parsing', function (assert) {
+ var i, ordinalStr, testMoment;
+ for (i = 1; i <= 31; ++i) {
+ ordinalStr = moment([2014, 0, i]).format('YYYY MM Do');
+ testMoment = moment(ordinalStr, 'YYYY MM Do');
+ assert.equal(testMoment.year(), 2014,
+ 'lenient ordinal parsing ' + i + ' year check');
+ assert.equal(testMoment.month(), 0,
+ 'lenient ordinal parsing ' + i + ' month check');
+ assert.equal(testMoment.date(), i,
+ 'lenient ordinal parsing ' + i + ' date check');
+ }
+ });
+
+ test('lenient ordinal parsing of number', function (assert) {
+ var i, testMoment;
+ for (i = 1; i <= 31; ++i) {
+ testMoment = moment('2014 01 ' + i, 'YYYY MM Do');
+ assert.equal(testMoment.year(), 2014,
+ 'lenient ordinal parsing of number ' + i + ' year check');
+ assert.equal(testMoment.month(), 0,
+ 'lenient ordinal parsing of number ' + i + ' month check');
+ assert.equal(testMoment.date(), i,
+ 'lenient ordinal parsing of number ' + i + ' date check');
+ }
+ });
+
+ test('strict ordinal parsing', function (assert) {
+ var i, ordinalStr, testMoment;
+ for (i = 1; i <= 31; ++i) {
+ ordinalStr = moment([2014, 0, i]).format('YYYY MM Do');
+ testMoment = moment(ordinalStr, 'YYYY MM Do', true);
+ assert.ok(testMoment.isValid(), 'strict ordinal parsing ' + i);
+ }
+ });
+
+ test('meridiem invariant', function (assert) {
+ var h, m, t1, t2;
+ for (h = 0; h < 24; ++h) {
+ for (m = 0; m < 60; m += 15) {
+ t1 = moment.utc([2000, 0, 1, h, m]);
+ t2 = moment.utc(t1.format('A h:mm'), 'A h:mm');
+ assert.equal(t2.format('HH:mm'), t1.format('HH:mm'),
+ 'meridiem at ' + t1.format('HH:mm'));
+ }
+ }
+ });
+
+ test('date format correctness', function (assert) {
+ var data, tokens;
+ data = moment.localeData()._longDateFormat;
+ tokens = objectKeys(data);
+ each(tokens, function (srchToken) {
+ // Check each format string to make sure it does not contain any
+ // tokens that need to be expanded.
+ each(tokens, function (baseToken) {
+ // strip escaped sequences
+ var format = data[baseToken].replace(/(\[[^\]]*\])/g, '');
+ assert.equal(false, !!~format.indexOf(srchToken),
+ 'contains ' + srchToken + ' in ' + baseToken);
+ });
+ });
+ });
+
+ test('month parsing correctness', function (assert) {
+ var i, m;
+
+ if (locale === 'tr') {
+ // I can't fix it :(
+ expect(0);
+ return;
+ }
+ function tester(format) {
+ var r;
+ r = moment(m.format(format), format);
+ assert.equal(r.month(), m.month(), 'month ' + i + ' fmt ' + format);
+ r = moment(m.format(format).toLocaleUpperCase(), format);
+ assert.equal(r.month(), m.month(), 'month ' + i + ' fmt ' + format + ' upper');
+ r = moment(m.format(format).toLocaleLowerCase(), format);
+ assert.equal(r.month(), m.month(), 'month ' + i + ' fmt ' + format + ' lower');
+
+ r = moment(m.format(format), format, true);
+ assert.equal(r.month(), m.month(), 'month ' + i + ' fmt ' + format + ' strict');
+ r = moment(m.format(format).toLocaleUpperCase(), format, true);
+ assert.equal(r.month(), m.month(), 'month ' + i + ' fmt ' + format + ' upper strict');
+ r = moment(m.format(format).toLocaleLowerCase(), format, true);
+ assert.equal(r.month(), m.month(), 'month ' + i + ' fmt ' + format + ' lower strict');
+ }
+
+ for (i = 0; i < 12; ++i) {
+ m = moment([2015, i, 15, 18]);
+ tester('MMM');
+ tester('MMM.');
+ tester('MMMM');
+ tester('MMMM.');
+ }
+ });
+
+ test('weekday parsing correctness', function (assert) {
+ var i, m;
+
+ if (locale === 'tr' || locale === 'az') {
+ // There is a lower-case letter (ı), that converted to upper then
+ // lower changes to i
+ expect(0);
+ return;
+ }
+ function tester(format) {
+ var r, baseMsg = 'weekday ' + m.weekday() + ' fmt ' + format;
+ r = moment(m.format(format), format);
+ assert.equal(r.weekday(), m.weekday(), baseMsg);
+ r = moment(m.format(format).toLocaleUpperCase(), format);
+ assert.equal(r.weekday(), m.weekday(), baseMsg + ' upper');
+ r = moment(m.format(format).toLocaleLowerCase(), format);
+ assert.equal(r.weekday(), m.weekday(), baseMsg + ' lower');
+
+ r = moment(m.format(format), format, true);
+ assert.equal(r.weekday(), m.weekday(), baseMsg + ' strict');
+ r = moment(m.format(format).toLocaleUpperCase(), format, true);
+ assert.equal(r.weekday(), m.weekday(), baseMsg + ' upper strict');
+ r = moment(m.format(format).toLocaleLowerCase(), format, true);
+ assert.equal(r.weekday(), m.weekday(), baseMsg + ' lower strict');
+ }
+
+ for (i = 0; i < 7; ++i) {
+ m = moment.utc([2015, i, 15, 18]);
+ tester('dd');
+ tester('ddd');
+ tester('dddd');
+ }
+ });
+ }
+
+ function setupDeprecationHandler(test, moment, scope) {
+ test._expectedDeprecations = null;
+ test._observedDeprecations = null;
+ test._oldSupress = moment.suppressDeprecationWarnings;
+ moment.suppressDeprecationWarnings = true;
+ test.expectedDeprecations = function () {
+ test._expectedDeprecations = arguments;
+ test._observedDeprecations = [];
+ };
+ moment.deprecationHandler = function (name, msg) {
+ var deprecationId = matchedDeprecation(name, msg, test._expectedDeprecations);
+ if (deprecationId === -1) {
+ throw new Error('Unexpected deprecation thrown name=' +
+ name + ' msg=' + msg);
+ }
+ test._observedDeprecations[deprecationId] = 1;
+ };
+ }
+
+ function teardownDeprecationHandler(test, moment, scope) {
+ moment.suppressDeprecationWarnings = test._oldSupress;
+
+ if (test._expectedDeprecations != null) {
+ var missedDeprecations = [];
+ each(test._expectedDeprecations, function (deprecationPattern, id) {
+ if (test._observedDeprecations[id] !== 1) {
+ missedDeprecations.push(deprecationPattern);
+ }
+ });
+ if (missedDeprecations.length !== 0) {
+ throw new Error('Expected deprecation warnings did not happen: ' +
+ missedDeprecations.join(' '));
+ }
+ }
+ }
+
+ function matchedDeprecation(name, msg, deprecations) {
+ if (deprecations == null) {
+ return -1;
+ }
+ for (var i = 0; i < deprecations.length; ++i) {
+ if (name != null && name === deprecations[i]) {
+ return i;
+ }
+ if (msg != null && msg.substring(0, deprecations[i].length) === deprecations[i]) {
+ return i;
+ }
+ }
+ return -1;
+ }
/*global QUnit:false*/
@@ -17777,11 +24524,13 @@
moment.createFromInputFallback = function (config) {
throw new Error('input not handled by moment: ' + config._i);
};
+ setupDeprecationHandler(test, moment, 'core');
if (lifecycle && lifecycle.setup) {
lifecycle.setup();
}
},
teardown : function () {
+ teardownDeprecationHandler(test, moment, 'core');
if (lifecycle && lifecycle.teardown) {
lifecycle.teardown();
}
@@ -17796,21 +24545,23 @@
moment.createFromInputFallback = function (config) {
throw new Error('input not handled by moment: ' + config._i);
};
+ setupDeprecationHandler(test, moment, 'locale');
if (lifecycle && lifecycle.setup) {
lifecycle.setup();
}
},
teardown : function () {
moment.locale('en');
+ teardownDeprecationHandler(test, moment, 'locale');
if (lifecycle && lifecycle.teardown) {
lifecycle.teardown();
}
}
});
+ defineCommonLocaleTests(name, -1, -1);
}
localeModule('jv');
-
test('parse', function (assert) {
var tests = 'Januari Jan_Februari Feb_Maret Mar_April Apr_Mei Mei_Juni Jun_Juli Jul_Agustus Ags_September Sep_Oktober Okt_Nopember Nop_Desember Des'.split('_'), i;
@@ -17924,14 +24675,14 @@
});
test('calendar day', function (assert) {
- var a = moment().hours(2).minutes(0).seconds(0);
-
- assert.equal(moment(a).calendar(), 'Dinten puniko pukul 02.00', 'today at the same time');
- assert.equal(moment(a).add({m: 25}).calendar(), 'Dinten puniko pukul 02.25', 'Now plus 25 min');
- assert.equal(moment(a).add({h: 1}).calendar(), 'Dinten puniko pukul 03.00', 'Now plus 1 hour');
- assert.equal(moment(a).add({d: 1}).calendar(), 'Mbenjang pukul 02.00', 'tomorrow at the same time');
- assert.equal(moment(a).subtract({h: 1}).calendar(), 'Dinten puniko pukul 01.00', 'Now minus 1 hour');
- assert.equal(moment(a).subtract({d: 1}).calendar(), 'Kala wingi pukul 02.00', 'yesterday at the same time');
+ var a = moment().hours(12).minutes(0).seconds(0);
+
+ assert.equal(moment(a).calendar(), 'Dinten puniko pukul 12.00', 'today at the same time');
+ assert.equal(moment(a).add({m: 25}).calendar(), 'Dinten puniko pukul 12.25', 'Now plus 25 min');
+ assert.equal(moment(a).add({h: 1}).calendar(), 'Dinten puniko pukul 13.00', 'Now plus 1 hour');
+ assert.equal(moment(a).add({d: 1}).calendar(), 'Mbenjang pukul 12.00', 'tomorrow at the same time');
+ assert.equal(moment(a).subtract({h: 1}).calendar(), 'Dinten puniko pukul 11.00', 'Now minus 1 hour');
+ assert.equal(moment(a).subtract({d: 1}).calendar(), 'Kala wingi pukul 12.00', 'yesterday at the same time');
});
test('calendar next week', function (assert) {
@@ -17975,67 +24726,6 @@
// Monday is the first day of the week.
// The week that contains Jan 1st is the first week of the year.
- test('weeks year starting sunday', function (assert) {
- assert.equal(moment([2011, 11, 26]).week(), 1, 'Dec 26 2011 should be week 1');
- assert.equal(moment([2012, 0, 1]).week(), 1, 'Jan 1 2012 should be week 1');
- assert.equal(moment([2012, 0, 2]).week(), 2, 'Jan 2 2012 should be week 2');
- assert.equal(moment([2012, 0, 8]).week(), 2, 'Jan 8 2012 should be week 2');
- assert.equal(moment([2012, 0, 9]).week(), 3, 'Jan 9 2012 should be week 3');
- });
-
- test('weeks year starting monday', function (assert) {
- assert.equal(moment([2007, 0, 1]).week(), 1, 'Jan 1 2007 should be week 1');
- assert.equal(moment([2007, 0, 7]).week(), 1, 'Jan 7 2007 should be week 1');
- assert.equal(moment([2007, 0, 8]).week(), 2, 'Jan 8 2007 should be week 2');
- assert.equal(moment([2007, 0, 14]).week(), 2, 'Jan 14 2007 should be week 2');
- assert.equal(moment([2007, 0, 15]).week(), 3, 'Jan 15 2007 should be week 3');
- });
-
- test('weeks year starting tuesday', function (assert) {
- assert.equal(moment([2007, 11, 31]).week(), 1, 'Dec 31 2007 should be week 1');
- assert.equal(moment([2008, 0, 1]).week(), 1, 'Jan 1 2008 should be week 1');
- assert.equal(moment([2008, 0, 6]).week(), 1, 'Jan 6 2008 should be week 1');
- assert.equal(moment([2008, 0, 7]).week(), 2, 'Jan 7 2008 should be week 2');
- assert.equal(moment([2008, 0, 13]).week(), 2, 'Jan 13 2008 should be week 2');
- assert.equal(moment([2008, 0, 14]).week(), 3, 'Jan 14 2008 should be week 3');
- });
-
- test('weeks year starting wednesday', function (assert) {
- assert.equal(moment([2002, 11, 30]).week(), 1, 'Dec 30 2002 should be week 1');
- assert.equal(moment([2003, 0, 1]).week(), 1, 'Jan 1 2003 should be week 1');
- assert.equal(moment([2003, 0, 5]).week(), 1, 'Jan 5 2003 should be week 1');
- assert.equal(moment([2003, 0, 6]).week(), 2, 'Jan 6 2003 should be week 2');
- assert.equal(moment([2003, 0, 12]).week(), 2, 'Jan 12 2003 should be week 2');
- assert.equal(moment([2003, 0, 13]).week(), 3, 'Jan 13 2003 should be week 3');
- });
-
- test('weeks year starting thursday', function (assert) {
- assert.equal(moment([2008, 11, 29]).week(), 1, 'Dec 29 2008 should be week 1');
- assert.equal(moment([2009, 0, 1]).week(), 1, 'Jan 1 2009 should be week 1');
- assert.equal(moment([2009, 0, 4]).week(), 1, 'Jan 4 2009 should be week 1');
- assert.equal(moment([2009, 0, 5]).week(), 2, 'Jan 5 2009 should be week 2');
- assert.equal(moment([2009, 0, 11]).week(), 2, 'Jan 11 2009 should be week 2');
- assert.equal(moment([2009, 0, 12]).week(), 3, 'Jan 12 2009 should be week 3');
- });
-
- test('weeks year starting friday', function (assert) {
- assert.equal(moment([2009, 11, 28]).week(), 1, 'Dec 28 2009 should be week 1');
- assert.equal(moment([2010, 0, 1]).week(), 1, 'Jan 1 2010 should be week 1');
- assert.equal(moment([2010, 0, 3]).week(), 1, 'Jan 3 2010 should be week 1');
- assert.equal(moment([2010, 0, 4]).week(), 2, 'Jan 4 2010 should be week 2');
- assert.equal(moment([2010, 0, 10]).week(), 2, 'Jan 10 2010 should be week 2');
- assert.equal(moment([2010, 0, 11]).week(), 3, 'Jan 11 2010 should be week 3');
- });
-
- test('weeks year starting saturday', function (assert) {
- assert.equal(moment([2010, 11, 27]).week(), 1, 'Dec 27 2010 should be week 1');
- assert.equal(moment([2011, 0, 1]).week(), 1, 'Jan 1 2011 should be week 1');
- assert.equal(moment([2011, 0, 2]).week(), 1, 'Jan 2 2011 should be week 1');
- assert.equal(moment([2011, 0, 3]).week(), 2, 'Jan 3 2011 should be week 2');
- assert.equal(moment([2011, 0, 9]).week(), 2, 'Jan 9 2011 should be week 2');
- assert.equal(moment([2011, 0, 10]).week(), 3, 'Jan 10 2011 should be week 3');
- });
-
test('weeks year starting sunday formatted', function (assert) {
assert.equal(moment([2011, 11, 26]).format('w ww wo'), '1 01 1', 'Dec 26 2011 should be week 1');
assert.equal(moment([2012, 0, 1]).format('w ww wo'), '1 01 1', 'Jan 1 2012 should be week 1');
@@ -18044,54 +24734,6 @@
assert.equal(moment([2012, 0, 9]).format('w ww wo'), '3 03 3', 'Jan 9 2012 should be week 3');
});
- test('lenient ordinal parsing', function (assert) {
- var i, ordinalStr, testMoment;
- for (i = 1; i <= 31; ++i) {
- ordinalStr = moment([2014, 0, i]).format('YYYY MM Do');
- testMoment = moment(ordinalStr, 'YYYY MM Do');
- assert.equal(testMoment.year(), 2014,
- 'lenient ordinal parsing ' + i + ' year check');
- assert.equal(testMoment.month(), 0,
- 'lenient ordinal parsing ' + i + ' month check');
- assert.equal(testMoment.date(), i,
- 'lenient ordinal parsing ' + i + ' date check');
- }
- });
-
- test('lenient ordinal parsing of number', function (assert) {
- var i, testMoment;
- for (i = 1; i <= 31; ++i) {
- testMoment = moment('2014 01 ' + i, 'YYYY MM Do');
- assert.equal(testMoment.year(), 2014,
- 'lenient ordinal parsing of number ' + i + ' year check');
- assert.equal(testMoment.month(), 0,
- 'lenient ordinal parsing of number ' + i + ' month check');
- assert.equal(testMoment.date(), i,
- 'lenient ordinal parsing of number ' + i + ' date check');
- }
- });
-
- test('meridiem invariant', function (assert) {
- var h, m, t1, t2;
- for (h = 0; h < 24; ++h) {
- for (m = 0; m < 60; m += 15) {
- t1 = moment.utc([2000, 0, 1, h, m]);
- t2 = moment(t1.format('A h:mm'), 'A h:mm');
- assert.equal(t2.format('HH:mm'), t1.format('HH:mm'),
- 'meridiem at ' + t1.format('HH:mm'));
- }
- }
- });
-
- test('strict ordinal parsing', function (assert) {
- var i, ordinalStr, testMoment;
- for (i = 1; i <= 31; ++i) {
- ordinalStr = moment([2014, 0, i]).format('YYYY MM Do');
- testMoment = moment(ordinalStr, 'YYYY MM Do', true);
- assert.ok(testMoment.isValid(), 'strict ordinal parsing ' + i);
- }
- });
-
}));
;(function (global, factory) {
@@ -18100,6 +24742,224 @@
typeof define === 'function' && define.amd ? define(['../../moment'], factory) :
factory(global.moment)
}(this, function (moment) { 'use strict';
+
+ function each(array, callback) {
+ var i;
+ for (i = 0; i < array.length; i++) {
+ callback(array[i], i, array);
+ }
+ }
+
+ function objectKeys(obj) {
+ if (Object.keys) {
+ return Object.keys(obj);
+ } else {
+ // IE8
+ var res = [], i;
+ for (i in obj) {
+ if (obj.hasOwnProperty(i)) {
+ res.push(i);
+ }
+ }
+ return res;
+ }
+ }
+
+ // Pick the first defined of two or three arguments.
+ function defaults(a, b, c) {
+ if (a != null) {
+ return a;
+ }
+ if (b != null) {
+ return b;
+ }
+ return c;
+ }
+
+ function defineCommonLocaleTests(locale, options) {
+ test('lenient ordinal parsing', function (assert) {
+ var i, ordinalStr, testMoment;
+ for (i = 1; i <= 31; ++i) {
+ ordinalStr = moment([2014, 0, i]).format('YYYY MM Do');
+ testMoment = moment(ordinalStr, 'YYYY MM Do');
+ assert.equal(testMoment.year(), 2014,
+ 'lenient ordinal parsing ' + i + ' year check');
+ assert.equal(testMoment.month(), 0,
+ 'lenient ordinal parsing ' + i + ' month check');
+ assert.equal(testMoment.date(), i,
+ 'lenient ordinal parsing ' + i + ' date check');
+ }
+ });
+
+ test('lenient ordinal parsing of number', function (assert) {
+ var i, testMoment;
+ for (i = 1; i <= 31; ++i) {
+ testMoment = moment('2014 01 ' + i, 'YYYY MM Do');
+ assert.equal(testMoment.year(), 2014,
+ 'lenient ordinal parsing of number ' + i + ' year check');
+ assert.equal(testMoment.month(), 0,
+ 'lenient ordinal parsing of number ' + i + ' month check');
+ assert.equal(testMoment.date(), i,
+ 'lenient ordinal parsing of number ' + i + ' date check');
+ }
+ });
+
+ test('strict ordinal parsing', function (assert) {
+ var i, ordinalStr, testMoment;
+ for (i = 1; i <= 31; ++i) {
+ ordinalStr = moment([2014, 0, i]).format('YYYY MM Do');
+ testMoment = moment(ordinalStr, 'YYYY MM Do', true);
+ assert.ok(testMoment.isValid(), 'strict ordinal parsing ' + i);
+ }
+ });
+
+ test('meridiem invariant', function (assert) {
+ var h, m, t1, t2;
+ for (h = 0; h < 24; ++h) {
+ for (m = 0; m < 60; m += 15) {
+ t1 = moment.utc([2000, 0, 1, h, m]);
+ t2 = moment.utc(t1.format('A h:mm'), 'A h:mm');
+ assert.equal(t2.format('HH:mm'), t1.format('HH:mm'),
+ 'meridiem at ' + t1.format('HH:mm'));
+ }
+ }
+ });
+
+ test('date format correctness', function (assert) {
+ var data, tokens;
+ data = moment.localeData()._longDateFormat;
+ tokens = objectKeys(data);
+ each(tokens, function (srchToken) {
+ // Check each format string to make sure it does not contain any
+ // tokens that need to be expanded.
+ each(tokens, function (baseToken) {
+ // strip escaped sequences
+ var format = data[baseToken].replace(/(\[[^\]]*\])/g, '');
+ assert.equal(false, !!~format.indexOf(srchToken),
+ 'contains ' + srchToken + ' in ' + baseToken);
+ });
+ });
+ });
+
+ test('month parsing correctness', function (assert) {
+ var i, m;
+
+ if (locale === 'tr') {
+ // I can't fix it :(
+ expect(0);
+ return;
+ }
+ function tester(format) {
+ var r;
+ r = moment(m.format(format), format);
+ assert.equal(r.month(), m.month(), 'month ' + i + ' fmt ' + format);
+ r = moment(m.format(format).toLocaleUpperCase(), format);
+ assert.equal(r.month(), m.month(), 'month ' + i + ' fmt ' + format + ' upper');
+ r = moment(m.format(format).toLocaleLowerCase(), format);
+ assert.equal(r.month(), m.month(), 'month ' + i + ' fmt ' + format + ' lower');
+
+ r = moment(m.format(format), format, true);
+ assert.equal(r.month(), m.month(), 'month ' + i + ' fmt ' + format + ' strict');
+ r = moment(m.format(format).toLocaleUpperCase(), format, true);
+ assert.equal(r.month(), m.month(), 'month ' + i + ' fmt ' + format + ' upper strict');
+ r = moment(m.format(format).toLocaleLowerCase(), format, true);
+ assert.equal(r.month(), m.month(), 'month ' + i + ' fmt ' + format + ' lower strict');
+ }
+
+ for (i = 0; i < 12; ++i) {
+ m = moment([2015, i, 15, 18]);
+ tester('MMM');
+ tester('MMM.');
+ tester('MMMM');
+ tester('MMMM.');
+ }
+ });
+
+ test('weekday parsing correctness', function (assert) {
+ var i, m;
+
+ if (locale === 'tr' || locale === 'az') {
+ // There is a lower-case letter (ı), that converted to upper then
+ // lower changes to i
+ expect(0);
+ return;
+ }
+ function tester(format) {
+ var r, baseMsg = 'weekday ' + m.weekday() + ' fmt ' + format;
+ r = moment(m.format(format), format);
+ assert.equal(r.weekday(), m.weekday(), baseMsg);
+ r = moment(m.format(format).toLocaleUpperCase(), format);
+ assert.equal(r.weekday(), m.weekday(), baseMsg + ' upper');
+ r = moment(m.format(format).toLocaleLowerCase(), format);
+ assert.equal(r.weekday(), m.weekday(), baseMsg + ' lower');
+
+ r = moment(m.format(format), format, true);
+ assert.equal(r.weekday(), m.weekday(), baseMsg + ' strict');
+ r = moment(m.format(format).toLocaleUpperCase(), format, true);
+ assert.equal(r.weekday(), m.weekday(), baseMsg + ' upper strict');
+ r = moment(m.format(format).toLocaleLowerCase(), format, true);
+ assert.equal(r.weekday(), m.weekday(), baseMsg + ' lower strict');
+ }
+
+ for (i = 0; i < 7; ++i) {
+ m = moment.utc([2015, i, 15, 18]);
+ tester('dd');
+ tester('ddd');
+ tester('dddd');
+ }
+ });
+ }
+
+ function setupDeprecationHandler(test, moment, scope) {
+ test._expectedDeprecations = null;
+ test._observedDeprecations = null;
+ test._oldSupress = moment.suppressDeprecationWarnings;
+ moment.suppressDeprecationWarnings = true;
+ test.expectedDeprecations = function () {
+ test._expectedDeprecations = arguments;
+ test._observedDeprecations = [];
+ };
+ moment.deprecationHandler = function (name, msg) {
+ var deprecationId = matchedDeprecation(name, msg, test._expectedDeprecations);
+ if (deprecationId === -1) {
+ throw new Error('Unexpected deprecation thrown name=' +
+ name + ' msg=' + msg);
+ }
+ test._observedDeprecations[deprecationId] = 1;
+ };
+ }
+
+ function teardownDeprecationHandler(test, moment, scope) {
+ moment.suppressDeprecationWarnings = test._oldSupress;
+
+ if (test._expectedDeprecations != null) {
+ var missedDeprecations = [];
+ each(test._expectedDeprecations, function (deprecationPattern, id) {
+ if (test._observedDeprecations[id] !== 1) {
+ missedDeprecations.push(deprecationPattern);
+ }
+ });
+ if (missedDeprecations.length !== 0) {
+ throw new Error('Expected deprecation warnings did not happen: ' +
+ missedDeprecations.join(' '));
+ }
+ }
+ }
+
+ function matchedDeprecation(name, msg, deprecations) {
+ if (deprecations == null) {
+ return -1;
+ }
+ for (var i = 0; i < deprecations.length; ++i) {
+ if (name != null && name === deprecations[i]) {
+ return i;
+ }
+ if (msg != null && msg.substring(0, deprecations[i].length) === deprecations[i]) {
+ return i;
+ }
+ }
+ return -1;
+ }
/*global QUnit:false*/
@@ -18114,11 +24974,13 @@
moment.createFromInputFallback = function (config) {
throw new Error('input not handled by moment: ' + config._i);
};
+ setupDeprecationHandler(test, moment, 'core');
if (lifecycle && lifecycle.setup) {
lifecycle.setup();
}
},
teardown : function () {
+ teardownDeprecationHandler(test, moment, 'core');
if (lifecycle && lifecycle.teardown) {
lifecycle.teardown();
}
@@ -18133,17 +24995,20 @@
moment.createFromInputFallback = function (config) {
throw new Error('input not handled by moment: ' + config._i);
};
+ setupDeprecationHandler(test, moment, 'locale');
if (lifecycle && lifecycle.setup) {
lifecycle.setup();
}
},
teardown : function () {
moment.locale('en');
+ teardownDeprecationHandler(test, moment, 'locale');
if (lifecycle && lifecycle.teardown) {
lifecycle.teardown();
}
}
});
+ defineCommonLocaleTests(name, -1, -1);
}
localeModule('ka');
@@ -18310,14 +25175,14 @@
});
test('calendar day', function (assert) {
- var a = moment().hours(2).minutes(0).seconds(0);
-
- assert.equal(moment(a).calendar(), 'დღეს 2:00 AM-ზე', 'დღეს ამავე დროს');
- assert.equal(moment(a).add({m: 25}).calendar(), 'დღეს 2:25 AM-ზე', 'ახლანდელ დროს დამატებული 25 წუთი');
- assert.equal(moment(a).add({h: 1}).calendar(), 'დღეს 3:00 AM-ზე', 'ახლანდელ დროს დამატებული 1 საათი');
- assert.equal(moment(a).add({d: 1}).calendar(), 'ხვალ 2:00 AM-ზე', 'ხვალ ამავე დროს');
- assert.equal(moment(a).subtract({h: 1}).calendar(), 'დღეს 1:00 AM-ზე', 'ახლანდელ დროს გამოკლებული 1 საათი');
- assert.equal(moment(a).subtract({d: 1}).calendar(), 'გუშინ 2:00 AM-ზე', 'გუშინ ამავე დროს');
+ var a = moment().hours(12).minutes(0).seconds(0);
+
+ assert.equal(moment(a).calendar(), 'დღეს 12:00 PM-ზე', 'დღეს ამავე დროს');
+ assert.equal(moment(a).add({m: 25}).calendar(), 'დღეს 12:25 PM-ზე', 'ახლანდელ დროს დამატებული 25 წუთი');
+ assert.equal(moment(a).add({h: 1}).calendar(), 'დღეს 1:00 PM-ზე', 'ახლანდელ დროს დამატებული 1 საათი');
+ assert.equal(moment(a).add({d: 1}).calendar(), 'ხვალ 12:00 PM-ზე', 'ხვალ ამავე დროს');
+ assert.equal(moment(a).subtract({h: 1}).calendar(), 'დღეს 11:00 AM-ზე', 'ახლანდელ დროს გამოკლებული 1 საათი');
+ assert.equal(moment(a).subtract({d: 1}).calendar(), 'გუშინ 12:00 PM-ზე', 'გუშინ ამავე დროს');
});
test('calendar next week', function (assert) {
@@ -18358,67 +25223,6 @@
assert.equal(weeksFromNow.calendar(), weeksFromNow.format('L'), '2 კვირაში');
});
- test('weeks year starting sunday', function (assert) {
- assert.equal(moment([2011, 11, 26]).week(), 1, 'დეკ 26 2011 უნდა იყოს კვირა 1');
- assert.equal(moment([2012, 0, 1]).week(), 1, 'იან 1 2012 უნდა იყოს კვირა 1');
- assert.equal(moment([2012, 0, 2]).week(), 2, 'იან 2 2012 უნდა იყოს კვირა 2');
- assert.equal(moment([2012, 0, 8]).week(), 2, 'იან 8 2012 უნდა იყოს კვირა 2');
- assert.equal(moment([2012, 0, 9]).week(), 3, 'იან 9 2012 უნდა იყოს კვირა 3');
- });
-
- test('weeks year starting monday', function (assert) {
- assert.equal(moment([2007, 0, 1]).week(), 1, 'იან 1 2007 უნდა იყოს კვირა 1');
- assert.equal(moment([2007, 0, 7]).week(), 1, 'იან 7 2007 უნდა იყოს კვირა 1');
- assert.equal(moment([2007, 0, 8]).week(), 2, 'იან 8 2007 უნდა იყოს კვირა 2');
- assert.equal(moment([2007, 0, 14]).week(), 2, 'იან 14 2007 უნდა იყოს კვირა 2');
- assert.equal(moment([2007, 0, 15]).week(), 3, 'იან 15 2007 უნდა იყოს კვირა 3');
- });
-
- test('weeks year starting tuesday', function (assert) {
- assert.equal(moment([2007, 11, 31]).week(), 1, 'დეკ 31 2007 უნდა იყოს კვირა 1');
- assert.equal(moment([2008, 0, 1]).week(), 1, 'იან 1 2008 უნდა იყოს კვირა 1');
- assert.equal(moment([2008, 0, 6]).week(), 1, 'იან 6 2008 უნდა იყოს კვირა 1');
- assert.equal(moment([2008, 0, 7]).week(), 2, 'იან 7 2008 უნდა იყოს კვირა 2');
- assert.equal(moment([2008, 0, 13]).week(), 2, 'იან 13 2008 უნდა იყოს კვირა 2');
- assert.equal(moment([2008, 0, 14]).week(), 3, 'იან 14 2008 უნდა იყოს კვირა 3');
- });
-
- test('weeks year starting wednesday', function (assert) {
- assert.equal(moment([2002, 11, 30]).week(), 1, 'დეკ 30 2002 უნდა იყოს კვირა 1');
- assert.equal(moment([2003, 0, 1]).week(), 1, 'იან 1 2003 უნდა იყოს კვირა 1');
- assert.equal(moment([2003, 0, 5]).week(), 1, 'იან 5 2003 უნდა იყოს კვირა 1');
- assert.equal(moment([2003, 0, 6]).week(), 2, 'იან 6 2003 უნდა იყოს კვირა 2');
- assert.equal(moment([2003, 0, 12]).week(), 2, 'იან 12 2003 უნდა იყოს კვირა 2');
- assert.equal(moment([2003, 0, 13]).week(), 3, 'იან 13 2003 უნდა იყოს კვირა 3');
- });
-
- test('weeks year starting thursday', function (assert) {
- assert.equal(moment([2008, 11, 29]).week(), 1, 'დეკ 29 2008 უნდა იყოს კვირა 1');
- assert.equal(moment([2009, 0, 1]).week(), 1, 'იან 1 2009 უნდა იყოს კვირა 1');
- assert.equal(moment([2009, 0, 4]).week(), 1, 'იან 4 2009 უნდა იყოს კვირა 1');
- assert.equal(moment([2009, 0, 5]).week(), 2, 'იან 5 2009 უნდა იყოს კვირა 2');
- assert.equal(moment([2009, 0, 11]).week(), 2, 'იან 11 2009 უნდა იყოს კვირა 2');
- assert.equal(moment([2009, 0, 12]).week(), 3, 'იან 12 2009 უნდა იყოს კვირა 3');
- });
-
- test('weeks year starting friday', function (assert) {
- assert.equal(moment([2009, 11, 28]).week(), 1, 'დეკ 28 2009 უნდა იყოს კვირა 1');
- assert.equal(moment([2010, 0, 1]).week(), 1, 'იან 1 2010 უნდა იყოს კვირა 1');
- assert.equal(moment([2010, 0, 3]).week(), 1, 'იან 3 2010 უნდა იყოს კვირა 1');
- assert.equal(moment([2010, 0, 4]).week(), 2, 'იან 4 2010 უნდა იყოს კვირა 2');
- assert.equal(moment([2010, 0, 10]).week(), 2, 'იან 10 2010 უნდა იყოს კვირა 2');
- assert.equal(moment([2010, 0, 11]).week(), 3, 'იან 11 2010 უნდა იყოს კვირა 3');
- });
-
- test('weeks year starting saturday', function (assert) {
- assert.equal(moment([2010, 11, 27]).week(), 1, 'დეკ 27 2010 უნდა იყოს კვირა 1');
- assert.equal(moment([2011, 0, 1]).week(), 1, 'იან 1 2011 უნდა იყოს კვირა 1');
- assert.equal(moment([2011, 0, 2]).week(), 1, 'იან 2 2011 უნდა იყოს კვირა 1');
- assert.equal(moment([2011, 0, 3]).week(), 2, 'იან 3 2011 უნდა იყოს კვირა 2');
- assert.equal(moment([2011, 0, 9]).week(), 2, 'იან 9 2011 უნდა იყოს კვირა 2');
- assert.equal(moment([2011, 0, 10]).week(), 3, 'იან 10 2011 უნდა იყოს კვირა 3');
- });
-
test('weeks year starting sunday formatted', function (assert) {
assert.equal(moment([2011, 11, 26]).format('w ww wo'), '1 01 1-ლი', 'დეკ 26 2011 უნდა იყოს კვირა 1');
assert.equal(moment([2012, 0, 1]).format('w ww wo'), '1 01 1-ლი', 'იან 1 2012 უნდა იყოს კვირა 1');
@@ -18427,42 +25231,6 @@
assert.equal(moment([2012, 0, 9]).format('w ww wo'), '3 03 მე-3', 'იან 9 2012 უნდა იყოს კვირა 3');
});
- test('lenient ordinal parsing', function (assert) {
- var i, ordinalStr, testMoment;
- for (i = 1; i <= 31; ++i) {
- ordinalStr = moment([2014, 0, i]).format('YYYY MM Do');
- testMoment = moment(ordinalStr, 'YYYY MM Do');
- assert.equal(testMoment.year(), 2014,
- 'lenient ordinal parsing ' + i + ' year check');
- assert.equal(testMoment.month(), 0,
- 'lenient ordinal parsing ' + i + ' month check');
- assert.equal(testMoment.date(), i,
- 'lenient ordinal parsing ' + i + ' date check');
- }
- });
-
- test('lenient ordinal parsing of number', function (assert) {
- var i, testMoment;
- for (i = 1; i <= 31; ++i) {
- testMoment = moment('2014 01 ' + i, 'YYYY MM Do');
- assert.equal(testMoment.year(), 2014,
- 'lenient ordinal parsing of number ' + i + ' year check');
- assert.equal(testMoment.month(), 0,
- 'lenient ordinal parsing of number ' + i + ' month check');
- assert.equal(testMoment.date(), i,
- 'lenient ordinal parsing of number ' + i + ' date check');
- }
- });
-
- test('strict ordinal parsing', function (assert) {
- var i, ordinalStr, testMoment;
- for (i = 1; i <= 31; ++i) {
- ordinalStr = moment([2014, 0, i]).format('YYYY MM Do');
- testMoment = moment(ordinalStr, 'YYYY MM Do', true);
- assert.ok(testMoment.isValid(), 'strict ordinal parsing ' + i);
- }
- });
-
}));
;(function (global, factory) {
@@ -18471,6 +25239,224 @@
typeof define === 'function' && define.amd ? define(['../../moment'], factory) :
factory(global.moment)
}(this, function (moment) { 'use strict';
+
+ function each(array, callback) {
+ var i;
+ for (i = 0; i < array.length; i++) {
+ callback(array[i], i, array);
+ }
+ }
+
+ function objectKeys(obj) {
+ if (Object.keys) {
+ return Object.keys(obj);
+ } else {
+ // IE8
+ var res = [], i;
+ for (i in obj) {
+ if (obj.hasOwnProperty(i)) {
+ res.push(i);
+ }
+ }
+ return res;
+ }
+ }
+
+ // Pick the first defined of two or three arguments.
+ function defaults(a, b, c) {
+ if (a != null) {
+ return a;
+ }
+ if (b != null) {
+ return b;
+ }
+ return c;
+ }
+
+ function defineCommonLocaleTests(locale, options) {
+ test('lenient ordinal parsing', function (assert) {
+ var i, ordinalStr, testMoment;
+ for (i = 1; i <= 31; ++i) {
+ ordinalStr = moment([2014, 0, i]).format('YYYY MM Do');
+ testMoment = moment(ordinalStr, 'YYYY MM Do');
+ assert.equal(testMoment.year(), 2014,
+ 'lenient ordinal parsing ' + i + ' year check');
+ assert.equal(testMoment.month(), 0,
+ 'lenient ordinal parsing ' + i + ' month check');
+ assert.equal(testMoment.date(), i,
+ 'lenient ordinal parsing ' + i + ' date check');
+ }
+ });
+
+ test('lenient ordinal parsing of number', function (assert) {
+ var i, testMoment;
+ for (i = 1; i <= 31; ++i) {
+ testMoment = moment('2014 01 ' + i, 'YYYY MM Do');
+ assert.equal(testMoment.year(), 2014,
+ 'lenient ordinal parsing of number ' + i + ' year check');
+ assert.equal(testMoment.month(), 0,
+ 'lenient ordinal parsing of number ' + i + ' month check');
+ assert.equal(testMoment.date(), i,
+ 'lenient ordinal parsing of number ' + i + ' date check');
+ }
+ });
+
+ test('strict ordinal parsing', function (assert) {
+ var i, ordinalStr, testMoment;
+ for (i = 1; i <= 31; ++i) {
+ ordinalStr = moment([2014, 0, i]).format('YYYY MM Do');
+ testMoment = moment(ordinalStr, 'YYYY MM Do', true);
+ assert.ok(testMoment.isValid(), 'strict ordinal parsing ' + i);
+ }
+ });
+
+ test('meridiem invariant', function (assert) {
+ var h, m, t1, t2;
+ for (h = 0; h < 24; ++h) {
+ for (m = 0; m < 60; m += 15) {
+ t1 = moment.utc([2000, 0, 1, h, m]);
+ t2 = moment.utc(t1.format('A h:mm'), 'A h:mm');
+ assert.equal(t2.format('HH:mm'), t1.format('HH:mm'),
+ 'meridiem at ' + t1.format('HH:mm'));
+ }
+ }
+ });
+
+ test('date format correctness', function (assert) {
+ var data, tokens;
+ data = moment.localeData()._longDateFormat;
+ tokens = objectKeys(data);
+ each(tokens, function (srchToken) {
+ // Check each format string to make sure it does not contain any
+ // tokens that need to be expanded.
+ each(tokens, function (baseToken) {
+ // strip escaped sequences
+ var format = data[baseToken].replace(/(\[[^\]]*\])/g, '');
+ assert.equal(false, !!~format.indexOf(srchToken),
+ 'contains ' + srchToken + ' in ' + baseToken);
+ });
+ });
+ });
+
+ test('month parsing correctness', function (assert) {
+ var i, m;
+
+ if (locale === 'tr') {
+ // I can't fix it :(
+ expect(0);
+ return;
+ }
+ function tester(format) {
+ var r;
+ r = moment(m.format(format), format);
+ assert.equal(r.month(), m.month(), 'month ' + i + ' fmt ' + format);
+ r = moment(m.format(format).toLocaleUpperCase(), format);
+ assert.equal(r.month(), m.month(), 'month ' + i + ' fmt ' + format + ' upper');
+ r = moment(m.format(format).toLocaleLowerCase(), format);
+ assert.equal(r.month(), m.month(), 'month ' + i + ' fmt ' + format + ' lower');
+
+ r = moment(m.format(format), format, true);
+ assert.equal(r.month(), m.month(), 'month ' + i + ' fmt ' + format + ' strict');
+ r = moment(m.format(format).toLocaleUpperCase(), format, true);
+ assert.equal(r.month(), m.month(), 'month ' + i + ' fmt ' + format + ' upper strict');
+ r = moment(m.format(format).toLocaleLowerCase(), format, true);
+ assert.equal(r.month(), m.month(), 'month ' + i + ' fmt ' + format + ' lower strict');
+ }
+
+ for (i = 0; i < 12; ++i) {
+ m = moment([2015, i, 15, 18]);
+ tester('MMM');
+ tester('MMM.');
+ tester('MMMM');
+ tester('MMMM.');
+ }
+ });
+
+ test('weekday parsing correctness', function (assert) {
+ var i, m;
+
+ if (locale === 'tr' || locale === 'az') {
+ // There is a lower-case letter (ı), that converted to upper then
+ // lower changes to i
+ expect(0);
+ return;
+ }
+ function tester(format) {
+ var r, baseMsg = 'weekday ' + m.weekday() + ' fmt ' + format;
+ r = moment(m.format(format), format);
+ assert.equal(r.weekday(), m.weekday(), baseMsg);
+ r = moment(m.format(format).toLocaleUpperCase(), format);
+ assert.equal(r.weekday(), m.weekday(), baseMsg + ' upper');
+ r = moment(m.format(format).toLocaleLowerCase(), format);
+ assert.equal(r.weekday(), m.weekday(), baseMsg + ' lower');
+
+ r = moment(m.format(format), format, true);
+ assert.equal(r.weekday(), m.weekday(), baseMsg + ' strict');
+ r = moment(m.format(format).toLocaleUpperCase(), format, true);
+ assert.equal(r.weekday(), m.weekday(), baseMsg + ' upper strict');
+ r = moment(m.format(format).toLocaleLowerCase(), format, true);
+ assert.equal(r.weekday(), m.weekday(), baseMsg + ' lower strict');
+ }
+
+ for (i = 0; i < 7; ++i) {
+ m = moment.utc([2015, i, 15, 18]);
+ tester('dd');
+ tester('ddd');
+ tester('dddd');
+ }
+ });
+ }
+
+ function setupDeprecationHandler(test, moment, scope) {
+ test._expectedDeprecations = null;
+ test._observedDeprecations = null;
+ test._oldSupress = moment.suppressDeprecationWarnings;
+ moment.suppressDeprecationWarnings = true;
+ test.expectedDeprecations = function () {
+ test._expectedDeprecations = arguments;
+ test._observedDeprecations = [];
+ };
+ moment.deprecationHandler = function (name, msg) {
+ var deprecationId = matchedDeprecation(name, msg, test._expectedDeprecations);
+ if (deprecationId === -1) {
+ throw new Error('Unexpected deprecation thrown name=' +
+ name + ' msg=' + msg);
+ }
+ test._observedDeprecations[deprecationId] = 1;
+ };
+ }
+
+ function teardownDeprecationHandler(test, moment, scope) {
+ moment.suppressDeprecationWarnings = test._oldSupress;
+
+ if (test._expectedDeprecations != null) {
+ var missedDeprecations = [];
+ each(test._expectedDeprecations, function (deprecationPattern, id) {
+ if (test._observedDeprecations[id] !== 1) {
+ missedDeprecations.push(deprecationPattern);
+ }
+ });
+ if (missedDeprecations.length !== 0) {
+ throw new Error('Expected deprecation warnings did not happen: ' +
+ missedDeprecations.join(' '));
+ }
+ }
+ }
+
+ function matchedDeprecation(name, msg, deprecations) {
+ if (deprecations == null) {
+ return -1;
+ }
+ for (var i = 0; i < deprecations.length; ++i) {
+ if (name != null && name === deprecations[i]) {
+ return i;
+ }
+ if (msg != null && msg.substring(0, deprecations[i].length) === deprecations[i]) {
+ return i;
+ }
+ }
+ return -1;
+ }
/*global QUnit:false*/
@@ -18485,11 +25471,13 @@
moment.createFromInputFallback = function (config) {
throw new Error('input not handled by moment: ' + config._i);
};
+ setupDeprecationHandler(test, moment, 'core');
if (lifecycle && lifecycle.setup) {
lifecycle.setup();
}
},
teardown : function () {
+ teardownDeprecationHandler(test, moment, 'core');
if (lifecycle && lifecycle.teardown) {
lifecycle.teardown();
}
@@ -18504,23 +25492,26 @@
moment.createFromInputFallback = function (config) {
throw new Error('input not handled by moment: ' + config._i);
};
+ setupDeprecationHandler(test, moment, 'locale');
if (lifecycle && lifecycle.setup) {
lifecycle.setup();
}
},
teardown : function () {
moment.locale('en');
+ teardownDeprecationHandler(test, moment, 'locale');
if (lifecycle && lifecycle.teardown) {
lifecycle.teardown();
}
}
});
+ defineCommonLocaleTests(name, -1, -1);
}
localeModule('kk');
test('parse', function (assert) {
- var tests = 'Қаңтар Қаң_Ақпан Ақп_Наурыз Нау_Сәуір Сәу_Мамыр Мам_Маусым Мау_Шілде Шіл_Тамыз Там_Қыркүйек Қыр_Қазан Қаз_Қараша Қар_Желтоқсан Жел'.split('_'), i;
+ var tests = 'қаңтар қаң_ақпан ақп_наурыз нау_сәуір сәу_мамыр мам_маусым мау_шілде шіл_тамыз там_қыркүйек қыр_қазан қаз_қараша қар_желтоқсан жел'.split('_'), i;
function equalTest(input, mmm, i) {
assert.equal(moment(input, mmm).month(), i, input + ' should be month ' + (i + 1));
}
@@ -18539,12 +25530,12 @@
test('format', function (assert) {
var a = [
- ['dddd, Do MMMM YYYY, HH:mm:ss', 'Жексенбі, 14-ші Ақпан 2010, 15:25:50'],
- ['ddd, hA', 'Жек, 3PM'],
- ['M Mo MM MMMM MMM', '2 2-ші 02 Ақпан Ақп'],
+ ['dddd, Do MMMM YYYY, HH:mm:ss', 'жексенбі, 14-ші ақпан 2010, 15:25:50'],
+ ['ddd, hA', 'жек, 3PM'],
+ ['M Mo MM MMMM MMM', '2 2-ші 02 ақпан ақп'],
['YYYY YY', '2010 10'],
['D Do DD', '14 14-ші 14'],
- ['d do dddd ddd dd', '0 0-ші Жексенбі Жек Жк'],
+ ['d do dddd ddd dd', '0 0-ші жексенбі жек жк'],
['DDD DDDo DDDD', '45 45-ші 045'],
['w wo ww', '7 7-ші 07'],
['h hh', '3 03'],
@@ -18555,13 +25546,13 @@
['[жылдың] DDDo [күні]', 'жылдың 45-ші күні'],
['LTS', '15:25:50'],
['L', '14.02.2010'],
- ['LL', '14 Ақпан 2010'],
- ['LLL', '14 Ақпан 2010 15:25'],
- ['LLLL', 'Жексенбі, 14 Ақпан 2010 15:25'],
+ ['LL', '14 ақпан 2010'],
+ ['LLL', '14 ақпан 2010 15:25'],
+ ['LLLL', 'жексенбі, 14 ақпан 2010 15:25'],
['l', '14.2.2010'],
- ['ll', '14 Ақп 2010'],
- ['lll', '14 Ақп 2010 15:25'],
- ['llll', 'Жек, 14 Ақп 2010 15:25']
+ ['ll', '14 ақп 2010'],
+ ['lll', '14 ақп 2010 15:25'],
+ ['llll', 'жек, 14 ақп 2010 15:25']
],
b = moment(new Date(2010, 1, 14, 15, 25, 50, 125)),
i;
@@ -18608,14 +25599,14 @@
});
test('format month', function (assert) {
- var expected = 'Қаңтар Қаң_Ақпан Ақп_Наурыз Нау_Сәуір Сәу_Мамыр Мам_Маусым Мау_Шілде Шіл_Тамыз Там_Қыркүйек Қыр_Қазан Қаз_Қараша Қар_Желтоқсан Жел'.split('_'), i;
+ var expected = 'қаңтар қаң_ақпан ақп_наурыз нау_сәуір сәу_мамыр мам_маусым мау_шілде шіл_тамыз там_қыркүйек қыр_қазан қаз_қараша қар_желтоқсан жел'.split('_'), i;
for (i = 0; i < expected.length; i++) {
assert.equal(moment([2011, i, 1]).format('MMMM MMM'), expected[i], expected[i]);
}
});
test('format week', function (assert) {
- var expected = 'Жексенбі Жек Жк_Дүйсенбі Дүй Дй_Сейсенбі Сей Сй_Сәрсенбі Сәр Ср_Бейсенбі Бей Бй_Жұма Жұм Жм_Сенбі Сен Сн'.split('_'), i;
+ var expected = 'жексенбі жек жк_дүйсенбі дүй дй_сейсенбі сей сй_сәрсенбі сәр ср_бейсенбі бей бй_жұма жұм жм_сенбі сен сн'.split('_'), i;
for (i = 0; i < expected.length; i++) {
assert.equal(moment([2011, 0, 2 + i]).format('dddd ddd dd'), expected[i], expected[i]);
}
@@ -18668,14 +25659,14 @@
});
test('calendar day', function (assert) {
- var a = moment().hours(2).minutes(0).seconds(0);
-
- assert.equal(moment(a).calendar(), 'Бүгін сағат 02:00', 'today at the same time');
- assert.equal(moment(a).add({m: 25}).calendar(), 'Бүгін сағат 02:25', 'Now plus 25 min');
- assert.equal(moment(a).add({h: 1}).calendar(), 'Бүгін сағат 03:00', 'Now plus 1 hour');
- assert.equal(moment(a).add({d: 1}).calendar(), 'Ертең сағат 02:00', 'tomorrow at the same time');
- assert.equal(moment(a).subtract({h: 1}).calendar(), 'Бүгін сағат 01:00', 'Now minus 1 hour');
- assert.equal(moment(a).subtract({d: 1}).calendar(), 'Кеше сағат 02:00', 'yesterday at the same time');
+ var a = moment().hours(12).minutes(0).seconds(0);
+
+ assert.equal(moment(a).calendar(), 'Бүгін сағат 12:00', 'today at the same time');
+ assert.equal(moment(a).add({m: 25}).calendar(), 'Бүгін сағат 12:25', 'Now plus 25 min');
+ assert.equal(moment(a).add({h: 1}).calendar(), 'Бүгін сағат 13:00', 'Now plus 1 hour');
+ assert.equal(moment(a).add({d: 1}).calendar(), 'Ертең сағат 12:00', 'tomorrow at the same time');
+ assert.equal(moment(a).subtract({h: 1}).calendar(), 'Бүгін сағат 11:00', 'Now minus 1 hour');
+ assert.equal(moment(a).subtract({d: 1}).calendar(), 'Кеше сағат 12:00', 'yesterday at the same time');
});
test('calendar next week', function (assert) {
@@ -18717,67 +25708,6 @@
assert.equal(weeksFromNow.calendar(), weeksFromNow.format('L'), 'in 2 weeks');
});
- test('weeks year starting sunday', function (assert) {
- assert.equal(moment([2011, 11, 25]).week(), 52, 'Dec 25 2011 should be week 52');
- assert.equal(moment([2012, 0, 2]).week(), 2, 'Jan 2 2012 should be week 2');
- assert.equal(moment([2012, 0, 8]).week(), 2, 'Jan 8 2012 should be week 2');
- assert.equal(moment([2012, 0, 9]).week(), 3, 'Jan 9 2012 should be week 3');
- assert.equal(moment([2012, 0, 15]).week(), 3, 'Jan 15 2012 should be week 3');
- });
-
- test('weeks year starting monday', function (assert) {
- assert.equal(moment([2007, 0, 1]).week(), 1, 'Jan 1 2007 should be week 1');
- assert.equal(moment([2007, 0, 7]).week(), 1, 'Jan 7 2007 should be week 1');
- assert.equal(moment([2007, 0, 8]).week(), 2, 'Jan 8 2007 should be week 2');
- assert.equal(moment([2007, 0, 14]).week(), 2, 'Jan 14 2007 should be week 2');
- assert.equal(moment([2007, 0, 15]).week(), 3, 'Jan 15 2007 should be week 3');
- });
-
- test('weeks year starting tuesday', function (assert) {
- assert.equal(moment([2007, 11, 31]).week(), 1, 'Dec 31 2007 should be week 1');
- assert.equal(moment([2008, 0, 1]).week(), 1, 'Jan 1 2008 should be week 1');
- assert.equal(moment([2008, 0, 6]).week(), 1, 'Jan 6 2008 should be week 1');
- assert.equal(moment([2008, 0, 7]).week(), 2, 'Jan 7 2008 should be week 2');
- assert.equal(moment([2008, 0, 13]).week(), 2, 'Jan 13 2008 should be week 2');
- assert.equal(moment([2008, 0, 14]).week(), 3, 'Jan 14 2008 should be week 3');
- });
-
- test('weeks year starting wednesday', function (assert) {
- assert.equal(moment([2002, 11, 30]).week(), 1, 'Dec 30 2002 should be week 1');
- assert.equal(moment([2003, 0, 1]).week(), 1, 'Jan 1 2003 should be week 1');
- assert.equal(moment([2003, 0, 5]).week(), 1, 'Jan 5 2003 should be week 1');
- assert.equal(moment([2003, 0, 6]).week(), 2, 'Jan 6 2003 should be week 2');
- assert.equal(moment([2003, 0, 12]).week(), 2, 'Jan 12 2003 should be week 2');
- assert.equal(moment([2003, 0, 13]).week(), 3, 'Jan 13 2003 should be week 3');
- });
-
- test('weeks year starting thursday', function (assert) {
- assert.equal(moment([2008, 11, 29]).week(), 1, 'Dec 29 2008 should be week 1');
- assert.equal(moment([2009, 0, 1]).week(), 1, 'Jan 1 2009 should be week 1');
- assert.equal(moment([2009, 0, 4]).week(), 1, 'Jan 4 2009 should be week 1');
- assert.equal(moment([2009, 0, 5]).week(), 2, 'Jan 5 2009 should be week 2');
- assert.equal(moment([2009, 0, 11]).week(), 2, 'Jan 11 2009 should be week 2');
- assert.equal(moment([2009, 0, 13]).week(), 3, 'Jan 12 2009 should be week 3');
- });
-
- test('weeks year starting friday', function (assert) {
- assert.equal(moment([2009, 11, 28]).week(), 1, 'Dec 28 2009 should be week 1');
- assert.equal(moment([2010, 0, 1]).week(), 1, 'Jan 1 2010 should be week 1');
- assert.equal(moment([2010, 0, 3]).week(), 1, 'Jan 3 2010 should be week 1');
- assert.equal(moment([2010, 0, 4]).week(), 2, 'Jan 4 2010 should be week 2');
- assert.equal(moment([2010, 0, 10]).week(), 2, 'Jan 10 2010 should be week 2');
- assert.equal(moment([2010, 0, 11]).week(), 3, 'Jan 11 2010 should be week 3');
- });
-
- test('weeks year starting saturday', function (assert) {
- assert.equal(moment([2010, 11, 27]).week(), 1, 'Dec 27 2010 should be week 1');
- assert.equal(moment([2011, 0, 1]).week(), 1, 'Jan 1 2011 should be week 1');
- assert.equal(moment([2011, 0, 2]).week(), 1, 'Jan 2 2011 should be week 1');
- assert.equal(moment([2011, 0, 3]).week(), 2, 'Jan 3 2011 should be week 2');
- assert.equal(moment([2011, 0, 9]).week(), 2, 'Jan 9 2011 should be week 2');
- assert.equal(moment([2011, 0, 10]).week(), 3, 'Jan 10 2011 should be week 3');
- });
-
test('weeks year starting sunday formatted', function (assert) {
assert.equal(moment([2012, 0, 1]).format('w ww wo'), '1 01 1-ші', 'Jan 1 2012 should be week 1');
assert.equal(moment([2012, 0, 2]).format('w ww wo'), '2 02 2-ші', 'Jan 2 2012 should be week 2');
@@ -18786,42 +25716,6 @@
assert.equal(moment([2012, 0, 15]).format('w ww wo'), '3 03 3-ші', 'Jan 15 2012 should be week 3');
});
- test('lenient ordinal parsing', function (assert) {
- var i, ordinalStr, testMoment;
- for (i = 1; i <= 31; ++i) {
- ordinalStr = moment([2014, 0, i]).format('YYYY MM Do');
- testMoment = moment(ordinalStr, 'YYYY MM Do');
- assert.equal(testMoment.year(), 2014,
- 'lenient ordinal parsing ' + i + ' year check');
- assert.equal(testMoment.month(), 0,
- 'lenient ordinal parsing ' + i + ' month check');
- assert.equal(testMoment.date(), i,
- 'lenient ordinal parsing ' + i + ' date check');
- }
- });
-
- test('lenient ordinal parsing of number', function (assert) {
- var i, testMoment;
- for (i = 1; i <= 31; ++i) {
- testMoment = moment('2014 01 ' + i, 'YYYY MM Do');
- assert.equal(testMoment.year(), 2014,
- 'lenient ordinal parsing of number ' + i + ' year check');
- assert.equal(testMoment.month(), 0,
- 'lenient ordinal parsing of number ' + i + ' month check');
- assert.equal(testMoment.date(), i,
- 'lenient ordinal parsing of number ' + i + ' date check');
- }
- });
-
- test('strict ordinal parsing', function (assert) {
- var i, ordinalStr, testMoment;
- for (i = 1; i <= 31; ++i) {
- ordinalStr = moment([2014, 0, i]).format('YYYY MM Do');
- testMoment = moment(ordinalStr, 'YYYY MM Do', true);
- assert.ok(testMoment.isValid(), 'strict ordinal parsing ' + i);
- }
- });
-
}));
;(function (global, factory) {
@@ -18830,6 +25724,224 @@
typeof define === 'function' && define.amd ? define(['../../moment'], factory) :
factory(global.moment)
}(this, function (moment) { 'use strict';
+
+ function each(array, callback) {
+ var i;
+ for (i = 0; i < array.length; i++) {
+ callback(array[i], i, array);
+ }
+ }
+
+ function objectKeys(obj) {
+ if (Object.keys) {
+ return Object.keys(obj);
+ } else {
+ // IE8
+ var res = [], i;
+ for (i in obj) {
+ if (obj.hasOwnProperty(i)) {
+ res.push(i);
+ }
+ }
+ return res;
+ }
+ }
+
+ // Pick the first defined of two or three arguments.
+ function defaults(a, b, c) {
+ if (a != null) {
+ return a;
+ }
+ if (b != null) {
+ return b;
+ }
+ return c;
+ }
+
+ function defineCommonLocaleTests(locale, options) {
+ test('lenient ordinal parsing', function (assert) {
+ var i, ordinalStr, testMoment;
+ for (i = 1; i <= 31; ++i) {
+ ordinalStr = moment([2014, 0, i]).format('YYYY MM Do');
+ testMoment = moment(ordinalStr, 'YYYY MM Do');
+ assert.equal(testMoment.year(), 2014,
+ 'lenient ordinal parsing ' + i + ' year check');
+ assert.equal(testMoment.month(), 0,
+ 'lenient ordinal parsing ' + i + ' month check');
+ assert.equal(testMoment.date(), i,
+ 'lenient ordinal parsing ' + i + ' date check');
+ }
+ });
+
+ test('lenient ordinal parsing of number', function (assert) {
+ var i, testMoment;
+ for (i = 1; i <= 31; ++i) {
+ testMoment = moment('2014 01 ' + i, 'YYYY MM Do');
+ assert.equal(testMoment.year(), 2014,
+ 'lenient ordinal parsing of number ' + i + ' year check');
+ assert.equal(testMoment.month(), 0,
+ 'lenient ordinal parsing of number ' + i + ' month check');
+ assert.equal(testMoment.date(), i,
+ 'lenient ordinal parsing of number ' + i + ' date check');
+ }
+ });
+
+ test('strict ordinal parsing', function (assert) {
+ var i, ordinalStr, testMoment;
+ for (i = 1; i <= 31; ++i) {
+ ordinalStr = moment([2014, 0, i]).format('YYYY MM Do');
+ testMoment = moment(ordinalStr, 'YYYY MM Do', true);
+ assert.ok(testMoment.isValid(), 'strict ordinal parsing ' + i);
+ }
+ });
+
+ test('meridiem invariant', function (assert) {
+ var h, m, t1, t2;
+ for (h = 0; h < 24; ++h) {
+ for (m = 0; m < 60; m += 15) {
+ t1 = moment.utc([2000, 0, 1, h, m]);
+ t2 = moment.utc(t1.format('A h:mm'), 'A h:mm');
+ assert.equal(t2.format('HH:mm'), t1.format('HH:mm'),
+ 'meridiem at ' + t1.format('HH:mm'));
+ }
+ }
+ });
+
+ test('date format correctness', function (assert) {
+ var data, tokens;
+ data = moment.localeData()._longDateFormat;
+ tokens = objectKeys(data);
+ each(tokens, function (srchToken) {
+ // Check each format string to make sure it does not contain any
+ // tokens that need to be expanded.
+ each(tokens, function (baseToken) {
+ // strip escaped sequences
+ var format = data[baseToken].replace(/(\[[^\]]*\])/g, '');
+ assert.equal(false, !!~format.indexOf(srchToken),
+ 'contains ' + srchToken + ' in ' + baseToken);
+ });
+ });
+ });
+
+ test('month parsing correctness', function (assert) {
+ var i, m;
+
+ if (locale === 'tr') {
+ // I can't fix it :(
+ expect(0);
+ return;
+ }
+ function tester(format) {
+ var r;
+ r = moment(m.format(format), format);
+ assert.equal(r.month(), m.month(), 'month ' + i + ' fmt ' + format);
+ r = moment(m.format(format).toLocaleUpperCase(), format);
+ assert.equal(r.month(), m.month(), 'month ' + i + ' fmt ' + format + ' upper');
+ r = moment(m.format(format).toLocaleLowerCase(), format);
+ assert.equal(r.month(), m.month(), 'month ' + i + ' fmt ' + format + ' lower');
+
+ r = moment(m.format(format), format, true);
+ assert.equal(r.month(), m.month(), 'month ' + i + ' fmt ' + format + ' strict');
+ r = moment(m.format(format).toLocaleUpperCase(), format, true);
+ assert.equal(r.month(), m.month(), 'month ' + i + ' fmt ' + format + ' upper strict');
+ r = moment(m.format(format).toLocaleLowerCase(), format, true);
+ assert.equal(r.month(), m.month(), 'month ' + i + ' fmt ' + format + ' lower strict');
+ }
+
+ for (i = 0; i < 12; ++i) {
+ m = moment([2015, i, 15, 18]);
+ tester('MMM');
+ tester('MMM.');
+ tester('MMMM');
+ tester('MMMM.');
+ }
+ });
+
+ test('weekday parsing correctness', function (assert) {
+ var i, m;
+
+ if (locale === 'tr' || locale === 'az') {
+ // There is a lower-case letter (ı), that converted to upper then
+ // lower changes to i
+ expect(0);
+ return;
+ }
+ function tester(format) {
+ var r, baseMsg = 'weekday ' + m.weekday() + ' fmt ' + format;
+ r = moment(m.format(format), format);
+ assert.equal(r.weekday(), m.weekday(), baseMsg);
+ r = moment(m.format(format).toLocaleUpperCase(), format);
+ assert.equal(r.weekday(), m.weekday(), baseMsg + ' upper');
+ r = moment(m.format(format).toLocaleLowerCase(), format);
+ assert.equal(r.weekday(), m.weekday(), baseMsg + ' lower');
+
+ r = moment(m.format(format), format, true);
+ assert.equal(r.weekday(), m.weekday(), baseMsg + ' strict');
+ r = moment(m.format(format).toLocaleUpperCase(), format, true);
+ assert.equal(r.weekday(), m.weekday(), baseMsg + ' upper strict');
+ r = moment(m.format(format).toLocaleLowerCase(), format, true);
+ assert.equal(r.weekday(), m.weekday(), baseMsg + ' lower strict');
+ }
+
+ for (i = 0; i < 7; ++i) {
+ m = moment.utc([2015, i, 15, 18]);
+ tester('dd');
+ tester('ddd');
+ tester('dddd');
+ }
+ });
+ }
+
+ function setupDeprecationHandler(test, moment, scope) {
+ test._expectedDeprecations = null;
+ test._observedDeprecations = null;
+ test._oldSupress = moment.suppressDeprecationWarnings;
+ moment.suppressDeprecationWarnings = true;
+ test.expectedDeprecations = function () {
+ test._expectedDeprecations = arguments;
+ test._observedDeprecations = [];
+ };
+ moment.deprecationHandler = function (name, msg) {
+ var deprecationId = matchedDeprecation(name, msg, test._expectedDeprecations);
+ if (deprecationId === -1) {
+ throw new Error('Unexpected deprecation thrown name=' +
+ name + ' msg=' + msg);
+ }
+ test._observedDeprecations[deprecationId] = 1;
+ };
+ }
+
+ function teardownDeprecationHandler(test, moment, scope) {
+ moment.suppressDeprecationWarnings = test._oldSupress;
+
+ if (test._expectedDeprecations != null) {
+ var missedDeprecations = [];
+ each(test._expectedDeprecations, function (deprecationPattern, id) {
+ if (test._observedDeprecations[id] !== 1) {
+ missedDeprecations.push(deprecationPattern);
+ }
+ });
+ if (missedDeprecations.length !== 0) {
+ throw new Error('Expected deprecation warnings did not happen: ' +
+ missedDeprecations.join(' '));
+ }
+ }
+ }
+
+ function matchedDeprecation(name, msg, deprecations) {
+ if (deprecations == null) {
+ return -1;
+ }
+ for (var i = 0; i < deprecations.length; ++i) {
+ if (name != null && name === deprecations[i]) {
+ return i;
+ }
+ if (msg != null && msg.substring(0, deprecations[i].length) === deprecations[i]) {
+ return i;
+ }
+ }
+ return -1;
+ }
/*global QUnit:false*/
@@ -18844,11 +25956,13 @@
moment.createFromInputFallback = function (config) {
throw new Error('input not handled by moment: ' + config._i);
};
+ setupDeprecationHandler(test, moment, 'core');
if (lifecycle && lifecycle.setup) {
lifecycle.setup();
}
},
teardown : function () {
+ teardownDeprecationHandler(test, moment, 'core');
if (lifecycle && lifecycle.teardown) {
lifecycle.teardown();
}
@@ -18863,23 +25977,26 @@
moment.createFromInputFallback = function (config) {
throw new Error('input not handled by moment: ' + config._i);
};
+ setupDeprecationHandler(test, moment, 'locale');
if (lifecycle && lifecycle.setup) {
lifecycle.setup();
}
},
teardown : function () {
moment.locale('en');
+ teardownDeprecationHandler(test, moment, 'locale');
if (lifecycle && lifecycle.teardown) {
lifecycle.teardown();
}
}
});
+ defineCommonLocaleTests(name, -1, -1);
}
localeModule('km');
test('parse', function (assert) {
- var tests = 'មករា មករា_កុម្ភៈ កុម្ភៈ_មិនា មិនា_មេសា មេសា_ឧសភា ឧសភា_មិថុនា មិថុនា_កក្កដា កក្កដា_សីហា សីហា_កញ្ញា កញ្ញា_តុលា តុលា_វិច្ឆិកា វិច្ឆិកា_ធ្នូ ធ្នូ'.split('_'),
+ var tests = 'មករា មករា_កុម្ភៈ កុម្ភៈ_មីនា មីនា_មេសា មេសា_ឧសភា ឧសភា_មិថុនា មិថុនា_កក្កដា កក្កដា_សីហា សីហា_កញ្ញា កញ្ញា_តុលា តុលា_វិច្ឆិកា វិច្ឆិកា_ធ្នូ ធ្នូ'.split('_'),
i;
function equalTest(input, mmm, i) {
@@ -18969,7 +26086,7 @@
});
test('format month', function (assert) {
- var expected = 'មករា មករា_កុម្ភៈ កុម្ភៈ_មិនា មិនា_មេសា មេសា_ឧសភា ឧសភា_មិថុនា មិថុនា_កក្កដា កក្កដា_សីហា សីហា_កញ្ញា កញ្ញា_តុលា តុលា_វិច្ឆិកា វិច្ឆិកា_ធ្នូ ធ្នូ'.split('_'),
+ var expected = 'មករា មករា_កុម្ភៈ កុម្ភៈ_មីនា មីនា_មេសា មេសា_ឧសភា ឧសភា_មិថុនា មិថុនា_កក្កដា កក្កដា_សីហា សីហា_កញ្ញា កញ្ញា_តុលា តុលា_វិច្ឆិកា វិច្ឆិកា_ធ្នូ ធ្នូ'.split('_'),
i;
for (i = 0; i < expected.length; i++) {
assert.equal(moment([2011, i, 1]).format('MMMM MMM'), expected[i], expected[i]);
@@ -19035,24 +26152,14 @@
});
test('calendar day', function (assert) {
- var a = moment().hours(2).minutes(0).seconds(0);
-
- assert.equal(moment(a).calendar(), 'ថ្ងៃនេះ ម៉ោង 02:00', 'today at the same time');
- assert.equal(moment(a).add({
- m: 25
- }).calendar(), 'ថ្ងៃនេះ ម៉ោង 02:25', 'Now plus 25 min');
- assert.equal(moment(a).add({
- h: 1
- }).calendar(), 'ថ្ងៃនេះ ម៉ោង 03:00', 'Now plus 1 hour');
- assert.equal(moment(a).add({
- d: 1
- }).calendar(), 'ស្អែក ម៉ោង 02:00', 'tomorrow at the same time');
- assert.equal(moment(a).subtract({
- h: 1
- }).calendar(), 'ថ្ងៃនេះ ម៉ោង 01:00', 'Now minus 1 hour');
- assert.equal(moment(a).subtract({
- d: 1
- }).calendar(), 'ម្សិលមិញ ម៉ោង 02:00', 'yesterday at the same time');
+ var a = moment().hours(12).minutes(0).seconds(0);
+
+ assert.equal(moment(a).calendar(), 'ថ្ងៃនេះ ម៉ោង 12:00', 'today at the same time');
+ assert.equal(moment(a).add({m: 25}).calendar(), 'ថ្ងៃនេះ ម៉ោង 12:25', 'Now plus 25 min');
+ assert.equal(moment(a).add({h: 1}).calendar(), 'ថ្ងៃនេះ ម៉ោង 13:00', 'Now plus 1 hour');
+ assert.equal(moment(a).add({d: 1}).calendar(), 'ស្អែក ម៉ោង 12:00', 'tomorrow at the same time');
+ assert.equal(moment(a).subtract({h: 1}).calendar(), 'ថ្ងៃនេះ ម៉ោង 11:00', 'Now minus 1 hour');
+ assert.equal(moment(a).subtract({d: 1}).calendar(), 'ម្សិលមិញ ម៉ោង 12:00', 'yesterday at the same time');
});
test('calendar next week', function (assert) {
@@ -19106,67 +26213,6 @@
assert.equal(weeksFromNow.calendar(), weeksFromNow.format('L'), 'in 2 weeks');
});
- test('weeks year starting sunday', function (assert) {
- assert.equal(moment([2012, 0, 1]).week(), 52, 'Jan 1 2012 should be week 52');
- assert.equal(moment([2012, 0, 2]).week(), 1, 'Jan 2 2012 should be week 1');
- assert.equal(moment([2012, 0, 8]).week(), 1, 'Jan 8 2012 should be week 1');
- assert.equal(moment([2012, 0, 9]).week(), 2, 'Jan 9 2012 should be week 2');
- assert.equal(moment([2012, 0, 15]).week(), 2, 'Jan 15 2012 should be week 2');
- });
-
- test('weeks year starting monday', function (assert) {
- assert.equal(moment([2007, 0, 1]).week(), 1, 'Jan 1 2007 should be week 1');
- assert.equal(moment([2007, 0, 7]).week(), 1, 'Jan 7 2007 should be week 1');
- assert.equal(moment([2007, 0, 8]).week(), 2, 'Jan 8 2007 should be week 2');
- assert.equal(moment([2007, 0, 14]).week(), 2, 'Jan 14 2007 should be week 2');
- assert.equal(moment([2007, 0, 15]).week(), 3, 'Jan 15 2007 should be week 3');
- });
-
- test('weeks year starting tuesday', function (assert) {
- assert.equal(moment([2007, 11, 31]).week(), 1, 'Dec 31 2007 should be week 1');
- assert.equal(moment([2008, 0, 1]).week(), 1, 'Jan 1 2008 should be week 1');
- assert.equal(moment([2008, 0, 6]).week(), 1, 'Jan 6 2008 should be week 1');
- assert.equal(moment([2008, 0, 7]).week(), 2, 'Jan 7 2008 should be week 2');
- assert.equal(moment([2008, 0, 13]).week(), 2, 'Jan 13 2008 should be week 2');
- assert.equal(moment([2008, 0, 14]).week(), 3, 'Jan 14 2008 should be week 3');
- });
-
- test('weeks year starting wednesday', function (assert) {
- assert.equal(moment([2002, 11, 30]).week(), 1, 'Dec 30 2002 should be week 1');
- assert.equal(moment([2003, 0, 1]).week(), 1, 'Jan 1 2003 should be week 1');
- assert.equal(moment([2003, 0, 5]).week(), 1, 'Jan 5 2003 should be week 1');
- assert.equal(moment([2003, 0, 6]).week(), 2, 'Jan 6 2003 should be week 2');
- assert.equal(moment([2003, 0, 12]).week(), 2, 'Jan 12 2003 should be week 2');
- assert.equal(moment([2003, 0, 13]).week(), 3, 'Jan 13 2003 should be week 3');
- });
-
- test('weeks year starting thursday', function (assert) {
- assert.equal(moment([2008, 11, 29]).week(), 1, 'Dec 29 2008 should be week 1');
- assert.equal(moment([2009, 0, 1]).week(), 1, 'Jan 1 2009 should be week 1');
- assert.equal(moment([2009, 0, 4]).week(), 1, 'Jan 4 2009 should be week 1');
- assert.equal(moment([2009, 0, 5]).week(), 2, 'Jan 5 2009 should be week 2');
- assert.equal(moment([2009, 0, 11]).week(), 2, 'Jan 11 2009 should be week 2');
- assert.equal(moment([2009, 0, 13]).week(), 3, 'Jan 12 2009 should be week 3');
- });
-
- test('weeks year starting friday', function (assert) {
- assert.equal(moment([2009, 11, 28]).week(), 53, 'Dec 28 2009 should be week 53');
- assert.equal(moment([2010, 0, 1]).week(), 53, 'Jan 1 2010 should be week 53');
- assert.equal(moment([2010, 0, 3]).week(), 53, 'Jan 3 2010 should be week 53');
- assert.equal(moment([2010, 0, 4]).week(), 1, 'Jan 4 2010 should be week 1');
- assert.equal(moment([2010, 0, 10]).week(), 1, 'Jan 10 2010 should be week 1');
- assert.equal(moment([2010, 0, 11]).week(), 2, 'Jan 11 2010 should be week 2');
- });
-
- test('weeks year starting saturday', function (assert) {
- assert.equal(moment([2010, 11, 27]).week(), 52, 'Dec 27 2010 should be week 52');
- assert.equal(moment([2011, 0, 1]).week(), 52, 'Jan 1 2011 should be week 52');
- assert.equal(moment([2011, 0, 2]).week(), 52, 'Jan 2 2011 should be week 52');
- assert.equal(moment([2011, 0, 3]).week(), 1, 'Jan 3 2011 should be week 1');
- assert.equal(moment([2011, 0, 9]).week(), 1, 'Jan 9 2011 should be week 1');
- assert.equal(moment([2011, 0, 10]).week(), 2, 'Jan 10 2011 should be week 2');
- });
-
test('weeks year starting sunday formatted', function (assert) {
assert.equal(moment([2012, 0, 1]).format('w ww wo'), '52 52 52', 'Jan 1 2012 should be week 52');
assert.equal(moment([2012, 0, 2]).format('w ww wo'), '1 01 1', 'Jan 2 2012 should be week 1');
@@ -19175,42 +26221,6 @@
assert.equal(moment([2012, 0, 15]).format('w ww wo'), '2 02 2', 'Jan 15 2012 should be week 2');
});
- test('lenient ordinal parsing', function (assert) {
- var i, ordinalStr, testMoment;
- for (i = 1; i <= 31; ++i) {
- ordinalStr = moment([2014, 0, i]).format('YYYY MM Do');
- testMoment = moment(ordinalStr, 'YYYY MM Do');
- assert.equal(testMoment.year(), 2014,
- 'lenient ordinal parsing ' + i + ' year check');
- assert.equal(testMoment.month(), 0,
- 'lenient ordinal parsing ' + i + ' month check');
- assert.equal(testMoment.date(), i,
- 'lenient ordinal parsing ' + i + ' date check');
- }
- });
-
- test('lenient ordinal parsing of number', function (assert) {
- var i, testMoment;
- for (i = 1; i <= 31; ++i) {
- testMoment = moment('2014 01 ' + i, 'YYYY MM Do');
- assert.equal(testMoment.year(), 2014,
- 'lenient ordinal parsing of number ' + i + ' year check');
- assert.equal(testMoment.month(), 0,
- 'lenient ordinal parsing of number ' + i + ' month check');
- assert.equal(testMoment.date(), i,
- 'lenient ordinal parsing of number ' + i + ' date check');
- }
- });
-
- test('strict ordinal parsing', function (assert) {
- var i, ordinalStr, testMoment;
- for (i = 1; i <= 31; ++i) {
- ordinalStr = moment([2014, 0, i]).format('YYYY MM Do');
- testMoment = moment(ordinalStr, 'YYYY MM Do', true);
- assert.ok(testMoment.isValid(), 'strict ordinal parsing ' + i);
- }
- });
-
}));
;(function (global, factory) {
@@ -19219,6 +26229,224 @@
typeof define === 'function' && define.amd ? define(['../../moment'], factory) :
factory(global.moment)
}(this, function (moment) { 'use strict';
+
+ function each(array, callback) {
+ var i;
+ for (i = 0; i < array.length; i++) {
+ callback(array[i], i, array);
+ }
+ }
+
+ function objectKeys(obj) {
+ if (Object.keys) {
+ return Object.keys(obj);
+ } else {
+ // IE8
+ var res = [], i;
+ for (i in obj) {
+ if (obj.hasOwnProperty(i)) {
+ res.push(i);
+ }
+ }
+ return res;
+ }
+ }
+
+ // Pick the first defined of two or three arguments.
+ function defaults(a, b, c) {
+ if (a != null) {
+ return a;
+ }
+ if (b != null) {
+ return b;
+ }
+ return c;
+ }
+
+ function defineCommonLocaleTests(locale, options) {
+ test('lenient ordinal parsing', function (assert) {
+ var i, ordinalStr, testMoment;
+ for (i = 1; i <= 31; ++i) {
+ ordinalStr = moment([2014, 0, i]).format('YYYY MM Do');
+ testMoment = moment(ordinalStr, 'YYYY MM Do');
+ assert.equal(testMoment.year(), 2014,
+ 'lenient ordinal parsing ' + i + ' year check');
+ assert.equal(testMoment.month(), 0,
+ 'lenient ordinal parsing ' + i + ' month check');
+ assert.equal(testMoment.date(), i,
+ 'lenient ordinal parsing ' + i + ' date check');
+ }
+ });
+
+ test('lenient ordinal parsing of number', function (assert) {
+ var i, testMoment;
+ for (i = 1; i <= 31; ++i) {
+ testMoment = moment('2014 01 ' + i, 'YYYY MM Do');
+ assert.equal(testMoment.year(), 2014,
+ 'lenient ordinal parsing of number ' + i + ' year check');
+ assert.equal(testMoment.month(), 0,
+ 'lenient ordinal parsing of number ' + i + ' month check');
+ assert.equal(testMoment.date(), i,
+ 'lenient ordinal parsing of number ' + i + ' date check');
+ }
+ });
+
+ test('strict ordinal parsing', function (assert) {
+ var i, ordinalStr, testMoment;
+ for (i = 1; i <= 31; ++i) {
+ ordinalStr = moment([2014, 0, i]).format('YYYY MM Do');
+ testMoment = moment(ordinalStr, 'YYYY MM Do', true);
+ assert.ok(testMoment.isValid(), 'strict ordinal parsing ' + i);
+ }
+ });
+
+ test('meridiem invariant', function (assert) {
+ var h, m, t1, t2;
+ for (h = 0; h < 24; ++h) {
+ for (m = 0; m < 60; m += 15) {
+ t1 = moment.utc([2000, 0, 1, h, m]);
+ t2 = moment.utc(t1.format('A h:mm'), 'A h:mm');
+ assert.equal(t2.format('HH:mm'), t1.format('HH:mm'),
+ 'meridiem at ' + t1.format('HH:mm'));
+ }
+ }
+ });
+
+ test('date format correctness', function (assert) {
+ var data, tokens;
+ data = moment.localeData()._longDateFormat;
+ tokens = objectKeys(data);
+ each(tokens, function (srchToken) {
+ // Check each format string to make sure it does not contain any
+ // tokens that need to be expanded.
+ each(tokens, function (baseToken) {
+ // strip escaped sequences
+ var format = data[baseToken].replace(/(\[[^\]]*\])/g, '');
+ assert.equal(false, !!~format.indexOf(srchToken),
+ 'contains ' + srchToken + ' in ' + baseToken);
+ });
+ });
+ });
+
+ test('month parsing correctness', function (assert) {
+ var i, m;
+
+ if (locale === 'tr') {
+ // I can't fix it :(
+ expect(0);
+ return;
+ }
+ function tester(format) {
+ var r;
+ r = moment(m.format(format), format);
+ assert.equal(r.month(), m.month(), 'month ' + i + ' fmt ' + format);
+ r = moment(m.format(format).toLocaleUpperCase(), format);
+ assert.equal(r.month(), m.month(), 'month ' + i + ' fmt ' + format + ' upper');
+ r = moment(m.format(format).toLocaleLowerCase(), format);
+ assert.equal(r.month(), m.month(), 'month ' + i + ' fmt ' + format + ' lower');
+
+ r = moment(m.format(format), format, true);
+ assert.equal(r.month(), m.month(), 'month ' + i + ' fmt ' + format + ' strict');
+ r = moment(m.format(format).toLocaleUpperCase(), format, true);
+ assert.equal(r.month(), m.month(), 'month ' + i + ' fmt ' + format + ' upper strict');
+ r = moment(m.format(format).toLocaleLowerCase(), format, true);
+ assert.equal(r.month(), m.month(), 'month ' + i + ' fmt ' + format + ' lower strict');
+ }
+
+ for (i = 0; i < 12; ++i) {
+ m = moment([2015, i, 15, 18]);
+ tester('MMM');
+ tester('MMM.');
+ tester('MMMM');
+ tester('MMMM.');
+ }
+ });
+
+ test('weekday parsing correctness', function (assert) {
+ var i, m;
+
+ if (locale === 'tr' || locale === 'az') {
+ // There is a lower-case letter (ı), that converted to upper then
+ // lower changes to i
+ expect(0);
+ return;
+ }
+ function tester(format) {
+ var r, baseMsg = 'weekday ' + m.weekday() + ' fmt ' + format;
+ r = moment(m.format(format), format);
+ assert.equal(r.weekday(), m.weekday(), baseMsg);
+ r = moment(m.format(format).toLocaleUpperCase(), format);
+ assert.equal(r.weekday(), m.weekday(), baseMsg + ' upper');
+ r = moment(m.format(format).toLocaleLowerCase(), format);
+ assert.equal(r.weekday(), m.weekday(), baseMsg + ' lower');
+
+ r = moment(m.format(format), format, true);
+ assert.equal(r.weekday(), m.weekday(), baseMsg + ' strict');
+ r = moment(m.format(format).toLocaleUpperCase(), format, true);
+ assert.equal(r.weekday(), m.weekday(), baseMsg + ' upper strict');
+ r = moment(m.format(format).toLocaleLowerCase(), format, true);
+ assert.equal(r.weekday(), m.weekday(), baseMsg + ' lower strict');
+ }
+
+ for (i = 0; i < 7; ++i) {
+ m = moment.utc([2015, i, 15, 18]);
+ tester('dd');
+ tester('ddd');
+ tester('dddd');
+ }
+ });
+ }
+
+ function setupDeprecationHandler(test, moment, scope) {
+ test._expectedDeprecations = null;
+ test._observedDeprecations = null;
+ test._oldSupress = moment.suppressDeprecationWarnings;
+ moment.suppressDeprecationWarnings = true;
+ test.expectedDeprecations = function () {
+ test._expectedDeprecations = arguments;
+ test._observedDeprecations = [];
+ };
+ moment.deprecationHandler = function (name, msg) {
+ var deprecationId = matchedDeprecation(name, msg, test._expectedDeprecations);
+ if (deprecationId === -1) {
+ throw new Error('Unexpected deprecation thrown name=' +
+ name + ' msg=' + msg);
+ }
+ test._observedDeprecations[deprecationId] = 1;
+ };
+ }
+
+ function teardownDeprecationHandler(test, moment, scope) {
+ moment.suppressDeprecationWarnings = test._oldSupress;
+
+ if (test._expectedDeprecations != null) {
+ var missedDeprecations = [];
+ each(test._expectedDeprecations, function (deprecationPattern, id) {
+ if (test._observedDeprecations[id] !== 1) {
+ missedDeprecations.push(deprecationPattern);
+ }
+ });
+ if (missedDeprecations.length !== 0) {
+ throw new Error('Expected deprecation warnings did not happen: ' +
+ missedDeprecations.join(' '));
+ }
+ }
+ }
+
+ function matchedDeprecation(name, msg, deprecations) {
+ if (deprecations == null) {
+ return -1;
+ }
+ for (var i = 0; i < deprecations.length; ++i) {
+ if (name != null && name === deprecations[i]) {
+ return i;
+ }
+ if (msg != null && msg.substring(0, deprecations[i].length) === deprecations[i]) {
+ return i;
+ }
+ }
+ return -1;
+ }
/*global QUnit:false*/
@@ -19233,11 +26461,13 @@
moment.createFromInputFallback = function (config) {
throw new Error('input not handled by moment: ' + config._i);
};
+ setupDeprecationHandler(test, moment, 'core');
if (lifecycle && lifecycle.setup) {
lifecycle.setup();
}
},
teardown : function () {
+ teardownDeprecationHandler(test, moment, 'core');
if (lifecycle && lifecycle.teardown) {
lifecycle.teardown();
}
@@ -19252,17 +26482,20 @@
moment.createFromInputFallback = function (config) {
throw new Error('input not handled by moment: ' + config._i);
};
+ setupDeprecationHandler(test, moment, 'locale');
if (lifecycle && lifecycle.setup) {
lifecycle.setup();
}
},
teardown : function () {
moment.locale('en');
+ teardownDeprecationHandler(test, moment, 'locale');
if (lifecycle && lifecycle.teardown) {
lifecycle.teardown();
}
}
});
+ defineCommonLocaleTests(name, -1, -1);
}
localeModule('ko');
@@ -19307,7 +26540,6 @@
outputFormat : 'H',
expected : '16'
}], i, l, it, actual;
-
for (i = 0, l = elements.length; i < l; ++i) {
it = elements[i];
@@ -19407,13 +26639,13 @@
test('from', function (assert) {
var start = moment([2007, 1, 28]);
- assert.equal(start.from(moment([2007, 1, 28]).add({s: 44}), true), '몇초', '44초 = 몇초');
+ assert.equal(start.from(moment([2007, 1, 28]).add({s: 44}), true), '몇 초', '44초 = 몇 초');
assert.equal(start.from(moment([2007, 1, 28]).add({s: 45}), true), '일분', '45초 = 일분');
assert.equal(start.from(moment([2007, 1, 28]).add({s: 89}), true), '일분', '89초 = 일분');
assert.equal(start.from(moment([2007, 1, 28]).add({s: 90}), true), '2분', '90초 = 2분');
assert.equal(start.from(moment([2007, 1, 28]).add({m: 44}), true), '44분', '44분 = 44분');
- assert.equal(start.from(moment([2007, 1, 28]).add({m: 45}), true), '한시간', '45분 = 한시간');
- assert.equal(start.from(moment([2007, 1, 28]).add({m: 89}), true), '한시간', '89분 = 한시간');
+ assert.equal(start.from(moment([2007, 1, 28]).add({m: 45}), true), '한 시간', '45분 = 한 시간');
+ assert.equal(start.from(moment([2007, 1, 28]).add({m: 89}), true), '한 시간', '89분 = 한 시간');
assert.equal(start.from(moment([2007, 1, 28]).add({m: 90}), true), '2시간', '90분 = 2시간');
assert.equal(start.from(moment([2007, 1, 28]).add({h: 5}), true), '5시간', '5시간 = 5시간');
assert.equal(start.from(moment([2007, 1, 28]).add({h: 21}), true), '21시간', '21시간 = 21시간');
@@ -19423,43 +26655,43 @@
assert.equal(start.from(moment([2007, 1, 28]).add({d: 1}), true), '하루', '하루 = 하루');
assert.equal(start.from(moment([2007, 1, 28]).add({d: 5}), true), '5일', '5일 = 5일');
assert.equal(start.from(moment([2007, 1, 28]).add({d: 25}), true), '25일', '25일 = 25일');
- assert.equal(start.from(moment([2007, 1, 28]).add({d: 26}), true), '한달', '26일 = 한달');
- assert.equal(start.from(moment([2007, 1, 28]).add({d: 30}), true), '한달', '30일 = 한달');
- assert.equal(start.from(moment([2007, 1, 28]).add({d: 43}), true), '한달', '45일 = 한달');
+ assert.equal(start.from(moment([2007, 1, 28]).add({d: 26}), true), '한 달', '26일 = 한 달');
+ assert.equal(start.from(moment([2007, 1, 28]).add({d: 30}), true), '한 달', '30일 = 한 달');
+ assert.equal(start.from(moment([2007, 1, 28]).add({d: 43}), true), '한 달', '45일 = 한 달');
assert.equal(start.from(moment([2007, 1, 28]).add({d: 46}), true), '2달', '46일 = 2달');
assert.equal(start.from(moment([2007, 1, 28]).add({d: 74}), true), '2달', '75일 = 2달');
assert.equal(start.from(moment([2007, 1, 28]).add({d: 76}), true), '3달', '76일 = 3달');
- assert.equal(start.from(moment([2007, 1, 28]).add({M: 1}), true), '한달', '1달 = 한달');
+ assert.equal(start.from(moment([2007, 1, 28]).add({M: 1}), true), '한 달', '1달 = 한 달');
assert.equal(start.from(moment([2007, 1, 28]).add({M: 5}), true), '5달', '5달 = 5달');
- assert.equal(start.from(moment([2007, 1, 28]).add({d: 345}), true), '일년', '345일 = 일년');
+ assert.equal(start.from(moment([2007, 1, 28]).add({d: 345}), true), '일 년', '345일 = 일 년');
assert.equal(start.from(moment([2007, 1, 28]).add({d: 548}), true), '2년', '548일 = 2년');
- assert.equal(start.from(moment([2007, 1, 28]).add({y: 1}), true), '일년', '일년 = 일년');
+ assert.equal(start.from(moment([2007, 1, 28]).add({y: 1}), true), '일 년', '일 년 = 일 년');
assert.equal(start.from(moment([2007, 1, 28]).add({y: 5}), true), '5년', '5년 = 5년');
});
test('suffix', function (assert) {
- assert.equal(moment(30000).from(0), '몇초 후', 'prefix');
- assert.equal(moment(0).from(30000), '몇초 전', 'suffix');
+ assert.equal(moment(30000).from(0), '몇 초 후', 'prefix');
+ assert.equal(moment(0).from(30000), '몇 초 전', 'suffix');
});
test('now from now', function (assert) {
- assert.equal(moment().fromNow(), '몇초 전', 'now from now should display as in the past');
+ assert.equal(moment().fromNow(), '몇 초 전', 'now from now should display as in the past');
});
test('fromNow', function (assert) {
- assert.equal(moment().add({s: 30}).fromNow(), '몇초 후', 'in a few seconds');
+ assert.equal(moment().add({s: 30}).fromNow(), '몇 초 후', 'in a few seconds');
assert.equal(moment().add({d: 5}).fromNow(), '5일 후', 'in 5 days');
});
test('calendar day', function (assert) {
- var a = moment().hours(2).minutes(0).seconds(0);
-
- assert.equal(moment(a).calendar(), '오늘 오전 2시 0분', 'today at the same time');
- assert.equal(moment(a).add({m: 25}).calendar(), '오늘 오전 2시 25분', 'Now plus 25 min');
- assert.equal(moment(a).add({h: 1}).calendar(), '오늘 오전 3시 0분', 'Now plus 1 hour');
- assert.equal(moment(a).add({d: 1}).calendar(), '내일 오전 2시 0분', 'tomorrow at the same time');
- assert.equal(moment(a).subtract({h: 1}).calendar(), '오늘 오전 1시 0분', 'Now minus 1 hour');
- assert.equal(moment(a).subtract({d: 1}).calendar(), '어제 오전 2시 0분', 'yesterday at the same time');
+ var a = moment().hours(12).minutes(0).seconds(0);
+
+ assert.equal(moment(a).calendar(), '오늘 오후 12시 0분', 'today at the same time');
+ assert.equal(moment(a).add({m: 25}).calendar(), '오늘 오후 12시 25분', 'Now plus 25 min');
+ assert.equal(moment(a).add({h: 1}).calendar(), '오늘 오후 1시 0분', 'Now plus 1 hour');
+ assert.equal(moment(a).add({d: 1}).calendar(), '내일 오후 12시 0분', 'tomorrow at the same time');
+ assert.equal(moment(a).subtract({h: 1}).calendar(), '오늘 오전 11시 0분', 'Now minus 1 hour');
+ assert.equal(moment(a).subtract({d: 1}).calendar(), '어제 오후 12시 0분', 'yesterday at the same time');
});
test('calendar next week', function (assert) {
@@ -19500,67 +26732,6 @@
assert.equal(weeksFromNow.calendar(), weeksFromNow.format('L'), 'in 2 weeks');
});
- test('weeks year starting sunday', function (assert) {
- assert.equal(moment([2012, 0, 1]).week(), 1, 'Jan 1 2012 should be week 1');
- assert.equal(moment([2012, 0, 7]).week(), 1, 'Jan 7 2012 should be week 1');
- assert.equal(moment([2012, 0, 8]).week(), 2, 'Jan 8 2012 should be week 2');
- assert.equal(moment([2012, 0, 14]).week(), 2, 'Jan 14 2012 should be week 2');
- assert.equal(moment([2012, 0, 15]).week(), 3, 'Jan 15 2012 should be week 3');
- });
-
- test('weeks year starting monday', function (assert) {
- assert.equal(moment([2006, 11, 31]).week(), 1, 'Dec 31 2006 should be week 1');
- assert.equal(moment([2007, 0, 1]).week(), 1, 'Jan 1 2007 should be week 1');
- assert.equal(moment([2007, 0, 6]).week(), 1, 'Jan 6 2007 should be week 1');
- assert.equal(moment([2007, 0, 7]).week(), 2, 'Jan 7 2007 should be week 2');
- assert.equal(moment([2007, 0, 13]).week(), 2, 'Jan 13 2007 should be week 2');
- assert.equal(moment([2007, 0, 14]).week(), 3, 'Jan 14 2007 should be week 3');
- });
-
- test('weeks year starting tuesday', function (assert) {
- assert.equal(moment([2007, 11, 29]).week(), 52, 'Dec 29 2007 should be week 52');
- assert.equal(moment([2008, 0, 1]).week(), 1, 'Jan 1 2008 should be week 1');
- assert.equal(moment([2008, 0, 5]).week(), 1, 'Jan 5 2008 should be week 1');
- assert.equal(moment([2008, 0, 6]).week(), 2, 'Jan 6 2008 should be week 2');
- assert.equal(moment([2008, 0, 12]).week(), 2, 'Jan 12 2008 should be week 2');
- assert.equal(moment([2008, 0, 13]).week(), 3, 'Jan 13 2008 should be week 3');
- });
-
- test('weeks year starting wednesday', function (assert) {
- assert.equal(moment([2002, 11, 29]).week(), 1, 'Dec 29 2002 should be week 1');
- assert.equal(moment([2003, 0, 1]).week(), 1, 'Jan 1 2003 should be week 1');
- assert.equal(moment([2003, 0, 4]).week(), 1, 'Jan 4 2003 should be week 1');
- assert.equal(moment([2003, 0, 5]).week(), 2, 'Jan 5 2003 should be week 2');
- assert.equal(moment([2003, 0, 11]).week(), 2, 'Jan 11 2003 should be week 2');
- assert.equal(moment([2003, 0, 12]).week(), 3, 'Jan 12 2003 should be week 3');
- });
-
- test('weeks year starting thursday', function (assert) {
- assert.equal(moment([2008, 11, 28]).week(), 1, 'Dec 28 2008 should be week 1');
- assert.equal(moment([2009, 0, 1]).week(), 1, 'Jan 1 2009 should be week 1');
- assert.equal(moment([2009, 0, 3]).week(), 1, 'Jan 3 2009 should be week 1');
- assert.equal(moment([2009, 0, 4]).week(), 2, 'Jan 4 2009 should be week 2');
- assert.equal(moment([2009, 0, 10]).week(), 2, 'Jan 10 2009 should be week 2');
- assert.equal(moment([2009, 0, 11]).week(), 3, 'Jan 11 2009 should be week 3');
- });
-
- test('weeks year starting friday', function (assert) {
- assert.equal(moment([2009, 11, 27]).week(), 1, 'Dec 27 2009 should be week 1');
- assert.equal(moment([2010, 0, 1]).week(), 1, 'Jan 1 2010 should be week 1');
- assert.equal(moment([2010, 0, 2]).week(), 1, 'Jan 2 2010 should be week 1');
- assert.equal(moment([2010, 0, 3]).week(), 2, 'Jan 3 2010 should be week 2');
- assert.equal(moment([2010, 0, 9]).week(), 2, 'Jan 9 2010 should be week 2');
- assert.equal(moment([2010, 0, 10]).week(), 3, 'Jan 10 2010 should be week 3');
- });
-
- test('weeks year starting saturday', function (assert) {
- assert.equal(moment([2010, 11, 26]).week(), 1, 'Dec 26 2010 should be week 1');
- assert.equal(moment([2011, 0, 1]).week(), 1, 'Jan 1 2011 should be week 1');
- assert.equal(moment([2011, 0, 2]).week(), 2, 'Jan 2 2011 should be week 2');
- assert.equal(moment([2011, 0, 8]).week(), 2, 'Jan 8 2011 should be week 2');
- assert.equal(moment([2011, 0, 9]).week(), 3, 'Jan 9 2011 should be week 3');
- });
-
test('weeks year starting sunday format', function (assert) {
assert.equal(moment([2012, 0, 1]).format('w ww wo'), '1 01 1일', 'Jan 1 2012 should be week 1');
assert.equal(moment([2012, 0, 7]).format('w ww wo'), '1 01 1일', 'Jan 7 2012 should be week 1');
@@ -19569,42 +26740,6 @@
assert.equal(moment([2012, 0, 15]).format('w ww wo'), '3 03 3일', 'Jan 15 2012 should be week 3');
});
- test('lenient ordinal parsing', function (assert) {
- var i, ordinalStr, testMoment;
- for (i = 1; i <= 31; ++i) {
- ordinalStr = moment([2014, 0, i]).format('YYYY MM Do');
- testMoment = moment(ordinalStr, 'YYYY MM Do');
- assert.equal(testMoment.year(), 2014,
- 'lenient ordinal parsing ' + i + ' year check');
- assert.equal(testMoment.month(), 0,
- 'lenient ordinal parsing ' + i + ' month check');
- assert.equal(testMoment.date(), i,
- 'lenient ordinal parsing ' + i + ' date check');
- }
- });
-
- test('lenient ordinal parsing of number', function (assert) {
- var i, testMoment;
- for (i = 1; i <= 31; ++i) {
- testMoment = moment('2014 01 ' + i, 'YYYY MM Do');
- assert.equal(testMoment.year(), 2014,
- 'lenient ordinal parsing of number ' + i + ' year check');
- assert.equal(testMoment.month(), 0,
- 'lenient ordinal parsing of number ' + i + ' month check');
- assert.equal(testMoment.date(), i,
- 'lenient ordinal parsing of number ' + i + ' date check');
- }
- });
-
- test('strict ordinal parsing', function (assert) {
- var i, ordinalStr, testMoment;
- for (i = 1; i <= 31; ++i) {
- ordinalStr = moment([2014, 0, i]).format('YYYY MM Do');
- testMoment = moment(ordinalStr, 'YYYY MM Do', true);
- assert.ok(testMoment.isValid(), 'strict ordinal parsing ' + i);
- }
- });
-
}));
;(function (global, factory) {
@@ -19613,6 +26748,224 @@
typeof define === 'function' && define.amd ? define(['../../moment'], factory) :
factory(global.moment)
}(this, function (moment) { 'use strict';
+
+ function each(array, callback) {
+ var i;
+ for (i = 0; i < array.length; i++) {
+ callback(array[i], i, array);
+ }
+ }
+
+ function objectKeys(obj) {
+ if (Object.keys) {
+ return Object.keys(obj);
+ } else {
+ // IE8
+ var res = [], i;
+ for (i in obj) {
+ if (obj.hasOwnProperty(i)) {
+ res.push(i);
+ }
+ }
+ return res;
+ }
+ }
+
+ // Pick the first defined of two or three arguments.
+ function defaults(a, b, c) {
+ if (a != null) {
+ return a;
+ }
+ if (b != null) {
+ return b;
+ }
+ return c;
+ }
+
+ function defineCommonLocaleTests(locale, options) {
+ test('lenient ordinal parsing', function (assert) {
+ var i, ordinalStr, testMoment;
+ for (i = 1; i <= 31; ++i) {
+ ordinalStr = moment([2014, 0, i]).format('YYYY MM Do');
+ testMoment = moment(ordinalStr, 'YYYY MM Do');
+ assert.equal(testMoment.year(), 2014,
+ 'lenient ordinal parsing ' + i + ' year check');
+ assert.equal(testMoment.month(), 0,
+ 'lenient ordinal parsing ' + i + ' month check');
+ assert.equal(testMoment.date(), i,
+ 'lenient ordinal parsing ' + i + ' date check');
+ }
+ });
+
+ test('lenient ordinal parsing of number', function (assert) {
+ var i, testMoment;
+ for (i = 1; i <= 31; ++i) {
+ testMoment = moment('2014 01 ' + i, 'YYYY MM Do');
+ assert.equal(testMoment.year(), 2014,
+ 'lenient ordinal parsing of number ' + i + ' year check');
+ assert.equal(testMoment.month(), 0,
+ 'lenient ordinal parsing of number ' + i + ' month check');
+ assert.equal(testMoment.date(), i,
+ 'lenient ordinal parsing of number ' + i + ' date check');
+ }
+ });
+
+ test('strict ordinal parsing', function (assert) {
+ var i, ordinalStr, testMoment;
+ for (i = 1; i <= 31; ++i) {
+ ordinalStr = moment([2014, 0, i]).format('YYYY MM Do');
+ testMoment = moment(ordinalStr, 'YYYY MM Do', true);
+ assert.ok(testMoment.isValid(), 'strict ordinal parsing ' + i);
+ }
+ });
+
+ test('meridiem invariant', function (assert) {
+ var h, m, t1, t2;
+ for (h = 0; h < 24; ++h) {
+ for (m = 0; m < 60; m += 15) {
+ t1 = moment.utc([2000, 0, 1, h, m]);
+ t2 = moment.utc(t1.format('A h:mm'), 'A h:mm');
+ assert.equal(t2.format('HH:mm'), t1.format('HH:mm'),
+ 'meridiem at ' + t1.format('HH:mm'));
+ }
+ }
+ });
+
+ test('date format correctness', function (assert) {
+ var data, tokens;
+ data = moment.localeData()._longDateFormat;
+ tokens = objectKeys(data);
+ each(tokens, function (srchToken) {
+ // Check each format string to make sure it does not contain any
+ // tokens that need to be expanded.
+ each(tokens, function (baseToken) {
+ // strip escaped sequences
+ var format = data[baseToken].replace(/(\[[^\]]*\])/g, '');
+ assert.equal(false, !!~format.indexOf(srchToken),
+ 'contains ' + srchToken + ' in ' + baseToken);
+ });
+ });
+ });
+
+ test('month parsing correctness', function (assert) {
+ var i, m;
+
+ if (locale === 'tr') {
+ // I can't fix it :(
+ expect(0);
+ return;
+ }
+ function tester(format) {
+ var r;
+ r = moment(m.format(format), format);
+ assert.equal(r.month(), m.month(), 'month ' + i + ' fmt ' + format);
+ r = moment(m.format(format).toLocaleUpperCase(), format);
+ assert.equal(r.month(), m.month(), 'month ' + i + ' fmt ' + format + ' upper');
+ r = moment(m.format(format).toLocaleLowerCase(), format);
+ assert.equal(r.month(), m.month(), 'month ' + i + ' fmt ' + format + ' lower');
+
+ r = moment(m.format(format), format, true);
+ assert.equal(r.month(), m.month(), 'month ' + i + ' fmt ' + format + ' strict');
+ r = moment(m.format(format).toLocaleUpperCase(), format, true);
+ assert.equal(r.month(), m.month(), 'month ' + i + ' fmt ' + format + ' upper strict');
+ r = moment(m.format(format).toLocaleLowerCase(), format, true);
+ assert.equal(r.month(), m.month(), 'month ' + i + ' fmt ' + format + ' lower strict');
+ }
+
+ for (i = 0; i < 12; ++i) {
+ m = moment([2015, i, 15, 18]);
+ tester('MMM');
+ tester('MMM.');
+ tester('MMMM');
+ tester('MMMM.');
+ }
+ });
+
+ test('weekday parsing correctness', function (assert) {
+ var i, m;
+
+ if (locale === 'tr' || locale === 'az') {
+ // There is a lower-case letter (ı), that converted to upper then
+ // lower changes to i
+ expect(0);
+ return;
+ }
+ function tester(format) {
+ var r, baseMsg = 'weekday ' + m.weekday() + ' fmt ' + format;
+ r = moment(m.format(format), format);
+ assert.equal(r.weekday(), m.weekday(), baseMsg);
+ r = moment(m.format(format).toLocaleUpperCase(), format);
+ assert.equal(r.weekday(), m.weekday(), baseMsg + ' upper');
+ r = moment(m.format(format).toLocaleLowerCase(), format);
+ assert.equal(r.weekday(), m.weekday(), baseMsg + ' lower');
+
+ r = moment(m.format(format), format, true);
+ assert.equal(r.weekday(), m.weekday(), baseMsg + ' strict');
+ r = moment(m.format(format).toLocaleUpperCase(), format, true);
+ assert.equal(r.weekday(), m.weekday(), baseMsg + ' upper strict');
+ r = moment(m.format(format).toLocaleLowerCase(), format, true);
+ assert.equal(r.weekday(), m.weekday(), baseMsg + ' lower strict');
+ }
+
+ for (i = 0; i < 7; ++i) {
+ m = moment.utc([2015, i, 15, 18]);
+ tester('dd');
+ tester('ddd');
+ tester('dddd');
+ }
+ });
+ }
+
+ function setupDeprecationHandler(test, moment, scope) {
+ test._expectedDeprecations = null;
+ test._observedDeprecations = null;
+ test._oldSupress = moment.suppressDeprecationWarnings;
+ moment.suppressDeprecationWarnings = true;
+ test.expectedDeprecations = function () {
+ test._expectedDeprecations = arguments;
+ test._observedDeprecations = [];
+ };
+ moment.deprecationHandler = function (name, msg) {
+ var deprecationId = matchedDeprecation(name, msg, test._expectedDeprecations);
+ if (deprecationId === -1) {
+ throw new Error('Unexpected deprecation thrown name=' +
+ name + ' msg=' + msg);
+ }
+ test._observedDeprecations[deprecationId] = 1;
+ };
+ }
+
+ function teardownDeprecationHandler(test, moment, scope) {
+ moment.suppressDeprecationWarnings = test._oldSupress;
+
+ if (test._expectedDeprecations != null) {
+ var missedDeprecations = [];
+ each(test._expectedDeprecations, function (deprecationPattern, id) {
+ if (test._observedDeprecations[id] !== 1) {
+ missedDeprecations.push(deprecationPattern);
+ }
+ });
+ if (missedDeprecations.length !== 0) {
+ throw new Error('Expected deprecation warnings did not happen: ' +
+ missedDeprecations.join(' '));
+ }
+ }
+ }
+
+ function matchedDeprecation(name, msg, deprecations) {
+ if (deprecations == null) {
+ return -1;
+ }
+ for (var i = 0; i < deprecations.length; ++i) {
+ if (name != null && name === deprecations[i]) {
+ return i;
+ }
+ if (msg != null && msg.substring(0, deprecations[i].length) === deprecations[i]) {
+ return i;
+ }
+ }
+ return -1;
+ }
/*global QUnit:false*/
@@ -19627,11 +26980,13 @@
moment.createFromInputFallback = function (config) {
throw new Error('input not handled by moment: ' + config._i);
};
+ setupDeprecationHandler(test, moment, 'core');
if (lifecycle && lifecycle.setup) {
lifecycle.setup();
}
},
teardown : function () {
+ teardownDeprecationHandler(test, moment, 'core');
if (lifecycle && lifecycle.teardown) {
lifecycle.teardown();
}
@@ -19646,17 +27001,505 @@
moment.createFromInputFallback = function (config) {
throw new Error('input not handled by moment: ' + config._i);
};
+ setupDeprecationHandler(test, moment, 'locale');
if (lifecycle && lifecycle.setup) {
lifecycle.setup();
}
},
teardown : function () {
moment.locale('en');
+ teardownDeprecationHandler(test, moment, 'locale');
if (lifecycle && lifecycle.teardown) {
lifecycle.teardown();
}
}
});
+ defineCommonLocaleTests(name, -1, -1);
+ }
+
+ localeModule('ky');
+
+ test('parse', function (assert) {
+ var tests = 'январь янв_февраль фев_март март_апрель апр_май май_июнь июнь_июль июль_август авг_сентябрь сен_октябрь окт_ноябрь ноя_декабрь дек'.split('_'), i;
+ function equalTest(input, mmm, i) {
+ assert.equal(moment(input, mmm).month(), i, input + ' should be month ' + (i + 1));
+ }
+ for (i = 0; i < 12; i++) {
+ tests[i] = tests[i].split(' ');
+ equalTest(tests[i][0], 'MMM', i);
+ equalTest(tests[i][1], 'MMM', i);
+ equalTest(tests[i][0], 'MMMM', i);
+ equalTest(tests[i][1], 'MMMM', i);
+ equalTest(tests[i][0].toLocaleLowerCase(), 'MMMM', i);
+ equalTest(tests[i][1].toLocaleLowerCase(), 'MMMM', i);
+ equalTest(tests[i][0].toLocaleUpperCase(), 'MMMM', i);
+ equalTest(tests[i][1].toLocaleUpperCase(), 'MMMM', i);
+ }
+ });
+
+ test('format', function (assert) {
+ var a = [
+ ['dddd, Do MMMM YYYY, HH:mm:ss', 'Жекшемби, 14-чү февраль 2010, 15:25:50'],
+ ['ddd, hA', 'Жек, 3PM'],
+ ['M Mo MM MMMM MMM', '2 2-чи 02 февраль фев'],
+ ['YYYY YY', '2010 10'],
+ ['D Do DD', '14 14-чү 14'],
+ ['d do dddd ddd dd', '0 0-чү Жекшемби Жек Жк'],
+ ['DDD DDDo DDDD', '45 45-чи 045'],
+ ['w wo ww', '7 7-чи 07'],
+ ['h hh', '3 03'],
+ ['H HH', '15 15'],
+ ['m mm', '25 25'],
+ ['s ss', '50 50'],
+ ['a A', 'pm PM'],
+ ['[жылдын] DDDo [күнү]', 'жылдын 45-чи күнү'],
+ ['LTS', '15:25:50'],
+ ['L', '14.02.2010'],
+ ['LL', '14 февраль 2010'],
+ ['LLL', '14 февраль 2010 15:25'],
+ ['LLLL', 'Жекшемби, 14 февраль 2010 15:25'],
+ ['l', '14.2.2010'],
+ ['ll', '14 фев 2010'],
+ ['lll', '14 фев 2010 15:25'],
+ ['llll', 'Жек, 14 фев 2010 15:25']
+ ],
+ b = moment(new Date(2010, 1, 14, 15, 25, 50, 125)),
+ i;
+ for (i = 0; i < a.length; i++) {
+ assert.equal(b.format(a[i][0]), a[i][1], a[i][0] + ' ---> ' + a[i][1]);
+ }
+ });
+
+ test('format ordinal', function (assert) {
+ assert.equal(moment([2011, 0, 1]).format('DDDo'), '1-чи', '1st');
+ assert.equal(moment([2011, 0, 2]).format('DDDo'), '2-чи', '2nd');
+ assert.equal(moment([2011, 0, 3]).format('DDDo'), '3-чү', '3rd');
+ assert.equal(moment([2011, 0, 4]).format('DDDo'), '4-чү', '4th');
+ assert.equal(moment([2011, 0, 5]).format('DDDo'), '5-чи', '5th');
+ assert.equal(moment([2011, 0, 6]).format('DDDo'), '6-чы', '6th');
+ assert.equal(moment([2011, 0, 7]).format('DDDo'), '7-чи', '7th');
+ assert.equal(moment([2011, 0, 8]).format('DDDo'), '8-чи', '8th');
+ assert.equal(moment([2011, 0, 9]).format('DDDo'), '9-чу', '9th');
+ assert.equal(moment([2011, 0, 10]).format('DDDo'), '10-чу', '10th');
+
+ assert.equal(moment([2011, 0, 11]).format('DDDo'), '11-чи', '11th');
+ assert.equal(moment([2011, 0, 12]).format('DDDo'), '12-чи', '12th');
+ assert.equal(moment([2011, 0, 13]).format('DDDo'), '13-чү', '13th');
+ assert.equal(moment([2011, 0, 14]).format('DDDo'), '14-чү', '14th');
+ assert.equal(moment([2011, 0, 15]).format('DDDo'), '15-чи', '15th');
+ assert.equal(moment([2011, 0, 16]).format('DDDo'), '16-чы', '16th');
+ assert.equal(moment([2011, 0, 17]).format('DDDo'), '17-чи', '17th');
+ assert.equal(moment([2011, 0, 18]).format('DDDo'), '18-чи', '18th');
+ assert.equal(moment([2011, 0, 19]).format('DDDo'), '19-чу', '19th');
+ assert.equal(moment([2011, 0, 20]).format('DDDo'), '20-чы', '20th');
+
+ assert.equal(moment([2011, 0, 21]).format('DDDo'), '21-чи', '21st');
+ assert.equal(moment([2011, 0, 22]).format('DDDo'), '22-чи', '22nd');
+ assert.equal(moment([2011, 0, 23]).format('DDDo'), '23-чү', '23rd');
+ assert.equal(moment([2011, 0, 24]).format('DDDo'), '24-чү', '24th');
+ assert.equal(moment([2011, 0, 25]).format('DDDo'), '25-чи', '25th');
+ assert.equal(moment([2011, 0, 26]).format('DDDo'), '26-чы', '26th');
+ assert.equal(moment([2011, 0, 27]).format('DDDo'), '27-чи', '27th');
+ assert.equal(moment([2011, 0, 28]).format('DDDo'), '28-чи', '28th');
+ assert.equal(moment([2011, 0, 29]).format('DDDo'), '29-чу', '29th');
+ assert.equal(moment([2011, 0, 30]).format('DDDo'), '30-чу', '30th');
+
+ assert.equal(moment([2011, 0, 31]).format('DDDo'), '31-чи', '31st');
+ });
+
+ test('format month', function (assert) {
+ var expected = 'январь янв_февраль фев_март март_апрель апр_май май_июнь июнь_июль июль_август авг_сентябрь сен_октябрь окт_ноябрь ноя_декабрь дек'.split('_'), i;
+ for (i = 0; i < expected.length; i++) {
+ assert.equal(moment([2011, i, 1]).format('MMMM MMM'), expected[i], expected[i]);
+ }
+ });
+
+ test('format week', function (assert) {
+ var expected = 'Жекшемби Жек Жк_Дүйшөмбү Дүй Дй_Шейшемби Шей Шй_Шаршемби Шар Шр_Бейшемби Бей Бй_Жума Жум Жм_Ишемби Ише Иш'.split('_'), i;
+ for (i = 0; i < expected.length; i++) {
+ assert.equal(moment([2011, 0, 2 + i]).format('dddd ddd dd'), expected[i], expected[i]);
+ }
+ });
+
+ test('from', function (assert) {
+ var start = moment([2007, 1, 28]);
+ assert.equal(start.from(moment([2007, 1, 28]).add({s: 44}), true), 'бирнече секунд', '44 seconds = a few seconds');
+ assert.equal(start.from(moment([2007, 1, 28]).add({s: 45}), true), 'бир мүнөт', '45 seconds = a minute');
+ assert.equal(start.from(moment([2007, 1, 28]).add({s: 89}), true), 'бир мүнөт', '89 seconds = a minute');
+ assert.equal(start.from(moment([2007, 1, 28]).add({s: 90}), true), '2 мүнөт', '90 seconds = 2 minutes');
+ assert.equal(start.from(moment([2007, 1, 28]).add({m: 44}), true), '44 мүнөт', '44 minutes = 44 minutes');
+ assert.equal(start.from(moment([2007, 1, 28]).add({m: 45}), true), 'бир саат', '45 minutes = an hour');
+ assert.equal(start.from(moment([2007, 1, 28]).add({m: 89}), true), 'бир саат', '89 minutes = an hour');
+ assert.equal(start.from(moment([2007, 1, 28]).add({m: 90}), true), '2 саат', '90 minutes = 2 hours');
+ assert.equal(start.from(moment([2007, 1, 28]).add({h: 5}), true), '5 саат', '5 hours = 5 hours');
+ assert.equal(start.from(moment([2007, 1, 28]).add({h: 21}), true), '21 саат', '21 hours = 21 hours');
+ assert.equal(start.from(moment([2007, 1, 28]).add({h: 22}), true), 'бир күн', '22 hours = a day');
+ assert.equal(start.from(moment([2007, 1, 28]).add({h: 35}), true), 'бир күн', '35 hours = a day');
+ assert.equal(start.from(moment([2007, 1, 28]).add({h: 36}), true), '2 күн', '36 hours = 2 days');
+ assert.equal(start.from(moment([2007, 1, 28]).add({d: 1}), true), 'бир күн', '1 day = a day');
+ assert.equal(start.from(moment([2007, 1, 28]).add({d: 5}), true), '5 күн', '5 days = 5 days');
+ assert.equal(start.from(moment([2007, 1, 28]).add({d: 25}), true), '25 күн', '25 days = 25 days');
+ assert.equal(start.from(moment([2007, 1, 28]).add({d: 26}), true), 'бир ай', '26 days = a month');
+ assert.equal(start.from(moment([2007, 1, 28]).add({d: 30}), true), 'бир ай', '30 days = a month');
+ assert.equal(start.from(moment([2007, 1, 28]).add({d: 43}), true), 'бир ай', '43 days = a month');
+ assert.equal(start.from(moment([2007, 1, 28]).add({d: 46}), true), '2 ай', '46 days = 2 months');
+ assert.equal(start.from(moment([2007, 1, 28]).add({d: 74}), true), '2 ай', '75 days = 2 months');
+ assert.equal(start.from(moment([2007, 1, 28]).add({d: 76}), true), '3 ай', '76 days = 3 months');
+ assert.equal(start.from(moment([2007, 1, 28]).add({M: 1}), true), 'бир ай', '1 month = a month');
+ assert.equal(start.from(moment([2007, 1, 28]).add({M: 5}), true), '5 ай', '5 months = 5 months');
+ assert.equal(start.from(moment([2007, 1, 28]).add({d: 345}), true), 'бир жыл', '345 days = a year');
+ assert.equal(start.from(moment([2007, 1, 28]).add({d: 548}), true), '2 жыл', '548 days = 2 years');
+ assert.equal(start.from(moment([2007, 1, 28]).add({y: 1}), true), 'бир жыл', '1 year = a year');
+ assert.equal(start.from(moment([2007, 1, 28]).add({y: 5}), true), '5 жыл', '5 years = 5 years');
+ });
+
+ test('suffix', function (assert) {
+ assert.equal(moment(30000).from(0), 'бирнече секунд ичинде', 'prefix');
+ assert.equal(moment(0).from(30000), 'бирнече секунд мурун', 'suffix');
+ });
+
+ test('now from now', function (assert) {
+ assert.equal(moment().fromNow(), 'бирнече секунд мурун', 'now from now should display as in the past');
+ });
+
+ test('fromNow', function (assert) {
+ assert.equal(moment().add({s: 30}).fromNow(), 'бирнече секунд ичинде', 'in a few seconds');
+ assert.equal(moment().add({d: 5}).fromNow(), '5 күн ичинде', 'in 5 days');
+ });
+
+ test('calendar day', function (assert) {
+ var a = moment().hours(12).minutes(0).seconds(0);
+
+ assert.equal(moment(a).calendar(), 'Бүгүн саат 12:00', 'today at the same time');
+ assert.equal(moment(a).add({m: 25}).calendar(), 'Бүгүн саат 12:25', 'Now plus 25 min');
+ assert.equal(moment(a).add({h: 1}).calendar(), 'Бүгүн саат 13:00', 'Now plus 1 hour');
+ assert.equal(moment(a).add({d: 1}).calendar(), 'Эртең саат 12:00', 'tomorrow at the same time');
+ assert.equal(moment(a).subtract({h: 1}).calendar(), 'Бүгүн саат 11:00', 'Now minus 1 hour');
+ assert.equal(moment(a).subtract({d: 1}).calendar(), 'Кече саат 12:00', 'yesterday at the same time');
+ });
+
+ test('calendar next week', function (assert) {
+ var i, m;
+ for (i = 2; i < 7; i++) {
+ m = moment().add({d: i});
+ assert.equal(m.calendar(), m.format('dddd [саат] LT'), 'Today + ' + i + ' days current time');
+ m.hours(0).minutes(0).seconds(0).milliseconds(0);
+ assert.equal(m.calendar(), m.format('dddd [саат] LT'), 'Today + ' + i + ' days beginning of day');
+ m.hours(23).minutes(59).seconds(59).milliseconds(999);
+ assert.equal(m.calendar(), m.format('dddd [саат] LT'), 'Today + ' + i + ' days end of day');
+ }
+ });
+
+ test('calendar last week', function (assert) {
+ var i, m;
+
+ for (i = 2; i < 7; i++) {
+ m = moment().subtract({d: i});
+ assert.equal(m.calendar(), m.format('[Өткен аптанын] dddd [күнү] [саат] LT'), 'Today - ' + i + ' days current time');
+ m.hours(0).minutes(0).seconds(0).milliseconds(0);
+ assert.equal(m.calendar(), m.format('[Өткен аптанын] dddd [күнү] [саат] LT'), 'Today - ' + i + ' days beginning of day');
+ m.hours(23).minutes(59).seconds(59).milliseconds(999);
+ assert.equal(m.calendar(), m.format('[Өткен аптанын] dddd [күнү] [саат] LT'), 'Today - ' + i + ' days end of day');
+ }
+ });
+
+ test('calendar all else', function (assert) {
+ var weeksAgo = moment().subtract({w: 1}),
+ weeksFromNow = moment().add({w: 1});
+
+ assert.equal(weeksAgo.calendar(), weeksAgo.format('L'), '1 week ago');
+ assert.equal(weeksFromNow.calendar(), weeksFromNow.format('L'), 'in 1 week');
+
+ weeksAgo = moment().subtract({w: 2});
+ weeksFromNow = moment().add({w: 2});
+
+ assert.equal(weeksAgo.calendar(), weeksAgo.format('L'), '2 weeks ago');
+ assert.equal(weeksFromNow.calendar(), weeksFromNow.format('L'), 'in 2 weeks');
+ });
+
+ test('weeks year starting sunday formatted', function (assert) {
+ assert.equal(moment([2012, 0, 1]).format('w ww wo'), '1 01 1-чи', 'Jan 1 2012 should be week 1');
+ assert.equal(moment([2012, 0, 2]).format('w ww wo'), '2 02 2-чи', 'Jan 2 2012 should be week 2');
+ assert.equal(moment([2012, 0, 8]).format('w ww wo'), '2 02 2-чи', 'Jan 8 2012 should be week 2');
+ assert.equal(moment([2012, 0, 9]).format('w ww wo'), '3 03 3-чү', 'Jan 9 2012 should be week 3');
+ assert.equal(moment([2012, 0, 15]).format('w ww wo'), '3 03 3-чү', 'Jan 15 2012 should be week 3');
+ });
+
+}));
+
+;(function (global, factory) {
+ typeof exports === 'object' && typeof module !== 'undefined'
+ && typeof require === 'function' ? factory(require('../../moment')) :
+ typeof define === 'function' && define.amd ? define(['../../moment'], factory) :
+ factory(global.moment)
+}(this, function (moment) { 'use strict';
+
+ function each(array, callback) {
+ var i;
+ for (i = 0; i < array.length; i++) {
+ callback(array[i], i, array);
+ }
+ }
+
+ function objectKeys(obj) {
+ if (Object.keys) {
+ return Object.keys(obj);
+ } else {
+ // IE8
+ var res = [], i;
+ for (i in obj) {
+ if (obj.hasOwnProperty(i)) {
+ res.push(i);
+ }
+ }
+ return res;
+ }
+ }
+
+ // Pick the first defined of two or three arguments.
+ function defaults(a, b, c) {
+ if (a != null) {
+ return a;
+ }
+ if (b != null) {
+ return b;
+ }
+ return c;
+ }
+
+ function defineCommonLocaleTests(locale, options) {
+ test('lenient ordinal parsing', function (assert) {
+ var i, ordinalStr, testMoment;
+ for (i = 1; i <= 31; ++i) {
+ ordinalStr = moment([2014, 0, i]).format('YYYY MM Do');
+ testMoment = moment(ordinalStr, 'YYYY MM Do');
+ assert.equal(testMoment.year(), 2014,
+ 'lenient ordinal parsing ' + i + ' year check');
+ assert.equal(testMoment.month(), 0,
+ 'lenient ordinal parsing ' + i + ' month check');
+ assert.equal(testMoment.date(), i,
+ 'lenient ordinal parsing ' + i + ' date check');
+ }
+ });
+
+ test('lenient ordinal parsing of number', function (assert) {
+ var i, testMoment;
+ for (i = 1; i <= 31; ++i) {
+ testMoment = moment('2014 01 ' + i, 'YYYY MM Do');
+ assert.equal(testMoment.year(), 2014,
+ 'lenient ordinal parsing of number ' + i + ' year check');
+ assert.equal(testMoment.month(), 0,
+ 'lenient ordinal parsing of number ' + i + ' month check');
+ assert.equal(testMoment.date(), i,
+ 'lenient ordinal parsing of number ' + i + ' date check');
+ }
+ });
+
+ test('strict ordinal parsing', function (assert) {
+ var i, ordinalStr, testMoment;
+ for (i = 1; i <= 31; ++i) {
+ ordinalStr = moment([2014, 0, i]).format('YYYY MM Do');
+ testMoment = moment(ordinalStr, 'YYYY MM Do', true);
+ assert.ok(testMoment.isValid(), 'strict ordinal parsing ' + i);
+ }
+ });
+
+ test('meridiem invariant', function (assert) {
+ var h, m, t1, t2;
+ for (h = 0; h < 24; ++h) {
+ for (m = 0; m < 60; m += 15) {
+ t1 = moment.utc([2000, 0, 1, h, m]);
+ t2 = moment.utc(t1.format('A h:mm'), 'A h:mm');
+ assert.equal(t2.format('HH:mm'), t1.format('HH:mm'),
+ 'meridiem at ' + t1.format('HH:mm'));
+ }
+ }
+ });
+
+ test('date format correctness', function (assert) {
+ var data, tokens;
+ data = moment.localeData()._longDateFormat;
+ tokens = objectKeys(data);
+ each(tokens, function (srchToken) {
+ // Check each format string to make sure it does not contain any
+ // tokens that need to be expanded.
+ each(tokens, function (baseToken) {
+ // strip escaped sequences
+ var format = data[baseToken].replace(/(\[[^\]]*\])/g, '');
+ assert.equal(false, !!~format.indexOf(srchToken),
+ 'contains ' + srchToken + ' in ' + baseToken);
+ });
+ });
+ });
+
+ test('month parsing correctness', function (assert) {
+ var i, m;
+
+ if (locale === 'tr') {
+ // I can't fix it :(
+ expect(0);
+ return;
+ }
+ function tester(format) {
+ var r;
+ r = moment(m.format(format), format);
+ assert.equal(r.month(), m.month(), 'month ' + i + ' fmt ' + format);
+ r = moment(m.format(format).toLocaleUpperCase(), format);
+ assert.equal(r.month(), m.month(), 'month ' + i + ' fmt ' + format + ' upper');
+ r = moment(m.format(format).toLocaleLowerCase(), format);
+ assert.equal(r.month(), m.month(), 'month ' + i + ' fmt ' + format + ' lower');
+
+ r = moment(m.format(format), format, true);
+ assert.equal(r.month(), m.month(), 'month ' + i + ' fmt ' + format + ' strict');
+ r = moment(m.format(format).toLocaleUpperCase(), format, true);
+ assert.equal(r.month(), m.month(), 'month ' + i + ' fmt ' + format + ' upper strict');
+ r = moment(m.format(format).toLocaleLowerCase(), format, true);
+ assert.equal(r.month(), m.month(), 'month ' + i + ' fmt ' + format + ' lower strict');
+ }
+
+ for (i = 0; i < 12; ++i) {
+ m = moment([2015, i, 15, 18]);
+ tester('MMM');
+ tester('MMM.');
+ tester('MMMM');
+ tester('MMMM.');
+ }
+ });
+
+ test('weekday parsing correctness', function (assert) {
+ var i, m;
+
+ if (locale === 'tr' || locale === 'az') {
+ // There is a lower-case letter (ı), that converted to upper then
+ // lower changes to i
+ expect(0);
+ return;
+ }
+ function tester(format) {
+ var r, baseMsg = 'weekday ' + m.weekday() + ' fmt ' + format;
+ r = moment(m.format(format), format);
+ assert.equal(r.weekday(), m.weekday(), baseMsg);
+ r = moment(m.format(format).toLocaleUpperCase(), format);
+ assert.equal(r.weekday(), m.weekday(), baseMsg + ' upper');
+ r = moment(m.format(format).toLocaleLowerCase(), format);
+ assert.equal(r.weekday(), m.weekday(), baseMsg + ' lower');
+
+ r = moment(m.format(format), format, true);
+ assert.equal(r.weekday(), m.weekday(), baseMsg + ' strict');
+ r = moment(m.format(format).toLocaleUpperCase(), format, true);
+ assert.equal(r.weekday(), m.weekday(), baseMsg + ' upper strict');
+ r = moment(m.format(format).toLocaleLowerCase(), format, true);
+ assert.equal(r.weekday(), m.weekday(), baseMsg + ' lower strict');
+ }
+
+ for (i = 0; i < 7; ++i) {
+ m = moment.utc([2015, i, 15, 18]);
+ tester('dd');
+ tester('ddd');
+ tester('dddd');
+ }
+ });
+ }
+
+ function setupDeprecationHandler(test, moment, scope) {
+ test._expectedDeprecations = null;
+ test._observedDeprecations = null;
+ test._oldSupress = moment.suppressDeprecationWarnings;
+ moment.suppressDeprecationWarnings = true;
+ test.expectedDeprecations = function () {
+ test._expectedDeprecations = arguments;
+ test._observedDeprecations = [];
+ };
+ moment.deprecationHandler = function (name, msg) {
+ var deprecationId = matchedDeprecation(name, msg, test._expectedDeprecations);
+ if (deprecationId === -1) {
+ throw new Error('Unexpected deprecation thrown name=' +
+ name + ' msg=' + msg);
+ }
+ test._observedDeprecations[deprecationId] = 1;
+ };
+ }
+
+ function teardownDeprecationHandler(test, moment, scope) {
+ moment.suppressDeprecationWarnings = test._oldSupress;
+
+ if (test._expectedDeprecations != null) {
+ var missedDeprecations = [];
+ each(test._expectedDeprecations, function (deprecationPattern, id) {
+ if (test._observedDeprecations[id] !== 1) {
+ missedDeprecations.push(deprecationPattern);
+ }
+ });
+ if (missedDeprecations.length !== 0) {
+ throw new Error('Expected deprecation warnings did not happen: ' +
+ missedDeprecations.join(' '));
+ }
+ }
+ }
+
+ function matchedDeprecation(name, msg, deprecations) {
+ if (deprecations == null) {
+ return -1;
+ }
+ for (var i = 0; i < deprecations.length; ++i) {
+ if (name != null && name === deprecations[i]) {
+ return i;
+ }
+ if (msg != null && msg.substring(0, deprecations[i].length) === deprecations[i]) {
+ return i;
+ }
+ }
+ return -1;
+ }
+
+ /*global QUnit:false*/
+
+ var test = QUnit.test;
+
+ var expect = QUnit.expect;
+
+ function module (name, lifecycle) {
+ QUnit.module(name, {
+ setup : function () {
+ moment.locale('en');
+ moment.createFromInputFallback = function (config) {
+ throw new Error('input not handled by moment: ' + config._i);
+ };
+ setupDeprecationHandler(test, moment, 'core');
+ if (lifecycle && lifecycle.setup) {
+ lifecycle.setup();
+ }
+ },
+ teardown : function () {
+ teardownDeprecationHandler(test, moment, 'core');
+ if (lifecycle && lifecycle.teardown) {
+ lifecycle.teardown();
+ }
+ }
+ });
+ }
+
+ function localeModule (name, lifecycle) {
+ QUnit.module('locale:' + name, {
+ setup : function () {
+ moment.locale(name);
+ moment.createFromInputFallback = function (config) {
+ throw new Error('input not handled by moment: ' + config._i);
+ };
+ setupDeprecationHandler(test, moment, 'locale');
+ if (lifecycle && lifecycle.setup) {
+ lifecycle.setup();
+ }
+ },
+ teardown : function () {
+ moment.locale('en');
+ teardownDeprecationHandler(test, moment, 'locale');
+ if (lifecycle && lifecycle.teardown) {
+ lifecycle.teardown();
+ }
+ }
+ });
+ defineCommonLocaleTests(name, -1, -1);
}
localeModule('lb');
@@ -19781,6 +27624,30 @@
assert.equal(moment().add({y: 400}).fromNow(), 'a 400 Joer', 'in 400 years');
});
+ test('calendar day', function (assert) {
+ var a = moment().hours(12).minutes(0).seconds(0);
+
+ assert.equal(moment(a).calendar(), 'Haut um 12:00 Auer', 'today at the same time');
+ assert.equal(moment(a).add({m: 25}).calendar(), 'Haut um 12:25 Auer', 'Now plus 25 min');
+ assert.equal(moment(a).add({h: 1}).calendar(), 'Haut um 13:00 Auer', 'Now plus 1 hour');
+ assert.equal(moment(a).add({d: 1}).calendar(), 'Muer um 12:00 Auer', 'tomorrow at the same time');
+ assert.equal(moment(a).subtract({h: 1}).calendar(), 'Haut um 11:00 Auer', 'Now minus 1 hour');
+ assert.equal(moment(a).subtract({d: 1}).calendar(), 'Gëschter um 12:00 Auer', 'yesterday at the same time');
+ });
+
+ test('calendar next week', function (assert) {
+ var i, m;
+
+ for (i = 2; i < 7; i++) {
+ m = moment().add({d: i});
+ assert.equal(m.calendar(), m.format('dddd [um] LT'), 'Today + ' + i + ' days current time');
+ m.hours(0).minutes(0).seconds(0).milliseconds(0);
+ assert.equal(m.calendar(), m.format('dddd [um] LT'), 'Today + ' + i + ' days beginning of day');
+ m.hours(23).minutes(59).seconds(59).milliseconds(999);
+ assert.equal(m.calendar(), m.format('dddd [um] LT'), 'Today + ' + i + ' days end of day');
+ }
+ });
+
test('calendar last week', function (assert) {
var i, m, weekday, datestring;
for (i = 2; i < 7; i++) {
@@ -19798,40 +27665,26 @@
}
});
- test('lenient ordinal parsing', function (assert) {
- var i, ordinalStr, testMoment;
- for (i = 1; i <= 31; ++i) {
- ordinalStr = moment([2014, 0, i]).format('YYYY MM Do');
- testMoment = moment(ordinalStr, 'YYYY MM Do');
- assert.equal(testMoment.year(), 2014,
- 'lenient ordinal parsing ' + i + ' year check');
- assert.equal(testMoment.month(), 0,
- 'lenient ordinal parsing ' + i + ' month check');
- assert.equal(testMoment.date(), i,
- 'lenient ordinal parsing ' + i + ' date check');
- }
- });
-
- test('lenient ordinal parsing of number', function (assert) {
- var i, testMoment;
- for (i = 1; i <= 31; ++i) {
- testMoment = moment('2014 01 ' + i, 'YYYY MM Do');
- assert.equal(testMoment.year(), 2014,
- 'lenient ordinal parsing of number ' + i + ' year check');
- assert.equal(testMoment.month(), 0,
- 'lenient ordinal parsing of number ' + i + ' month check');
- assert.equal(testMoment.date(), i,
- 'lenient ordinal parsing of number ' + i + ' date check');
- }
- });
-
- test('strict ordinal parsing', function (assert) {
- var i, ordinalStr, testMoment;
- for (i = 1; i <= 31; ++i) {
- ordinalStr = moment([2014, 0, i]).format('YYYY MM Do');
- testMoment = moment(ordinalStr, 'YYYY MM Do', true);
- assert.ok(testMoment.isValid(), 'strict ordinal parsing ' + i);
- }
+ test('calendar all else', function (assert) {
+ var weeksAgo = moment().subtract({w: 1}),
+ weeksFromNow = moment().add({w: 1});
+
+ assert.equal(weeksAgo.calendar(), weeksAgo.format('L'), '1 week ago');
+ assert.equal(weeksFromNow.calendar(), weeksFromNow.format('L'), 'in 1 week');
+
+ weeksAgo = moment().subtract({w: 2});
+ weeksFromNow = moment().add({w: 2});
+
+ assert.equal(weeksAgo.calendar(), weeksAgo.format('L'), '2 weeks ago');
+ assert.equal(weeksFromNow.calendar(), weeksFromNow.format('L'), 'in 2 weeks');
+ });
+
+ test('weeks year starting sunday format', function (assert) {
+ assert.equal(moment([2012, 0, 1]).format('w ww wo'), '52 52 52.', 'Jan 1 2012 should be week 52');
+ assert.equal(moment([2012, 0, 7]).format('w ww wo'), '1 01 1.', 'Jan 7 2012 should be week 1');
+ assert.equal(moment([2012, 0, 8]).format('w ww wo'), '1 01 1.', 'Jan 8 2012 should be week 1');
+ assert.equal(moment([2012, 0, 14]).format('w ww wo'), '2 02 2.', 'Jan 14 2012 should be week 2');
+ assert.equal(moment([2012, 0, 15]).format('w ww wo'), '2 02 2.', 'Jan 15 2012 should be week 2');
});
}));
@@ -19842,6 +27695,224 @@
typeof define === 'function' && define.amd ? define(['../../moment'], factory) :
factory(global.moment)
}(this, function (moment) { 'use strict';
+
+ function each(array, callback) {
+ var i;
+ for (i = 0; i < array.length; i++) {
+ callback(array[i], i, array);
+ }
+ }
+
+ function objectKeys(obj) {
+ if (Object.keys) {
+ return Object.keys(obj);
+ } else {
+ // IE8
+ var res = [], i;
+ for (i in obj) {
+ if (obj.hasOwnProperty(i)) {
+ res.push(i);
+ }
+ }
+ return res;
+ }
+ }
+
+ // Pick the first defined of two or three arguments.
+ function defaults(a, b, c) {
+ if (a != null) {
+ return a;
+ }
+ if (b != null) {
+ return b;
+ }
+ return c;
+ }
+
+ function defineCommonLocaleTests(locale, options) {
+ test('lenient ordinal parsing', function (assert) {
+ var i, ordinalStr, testMoment;
+ for (i = 1; i <= 31; ++i) {
+ ordinalStr = moment([2014, 0, i]).format('YYYY MM Do');
+ testMoment = moment(ordinalStr, 'YYYY MM Do');
+ assert.equal(testMoment.year(), 2014,
+ 'lenient ordinal parsing ' + i + ' year check');
+ assert.equal(testMoment.month(), 0,
+ 'lenient ordinal parsing ' + i + ' month check');
+ assert.equal(testMoment.date(), i,
+ 'lenient ordinal parsing ' + i + ' date check');
+ }
+ });
+
+ test('lenient ordinal parsing of number', function (assert) {
+ var i, testMoment;
+ for (i = 1; i <= 31; ++i) {
+ testMoment = moment('2014 01 ' + i, 'YYYY MM Do');
+ assert.equal(testMoment.year(), 2014,
+ 'lenient ordinal parsing of number ' + i + ' year check');
+ assert.equal(testMoment.month(), 0,
+ 'lenient ordinal parsing of number ' + i + ' month check');
+ assert.equal(testMoment.date(), i,
+ 'lenient ordinal parsing of number ' + i + ' date check');
+ }
+ });
+
+ test('strict ordinal parsing', function (assert) {
+ var i, ordinalStr, testMoment;
+ for (i = 1; i <= 31; ++i) {
+ ordinalStr = moment([2014, 0, i]).format('YYYY MM Do');
+ testMoment = moment(ordinalStr, 'YYYY MM Do', true);
+ assert.ok(testMoment.isValid(), 'strict ordinal parsing ' + i);
+ }
+ });
+
+ test('meridiem invariant', function (assert) {
+ var h, m, t1, t2;
+ for (h = 0; h < 24; ++h) {
+ for (m = 0; m < 60; m += 15) {
+ t1 = moment.utc([2000, 0, 1, h, m]);
+ t2 = moment.utc(t1.format('A h:mm'), 'A h:mm');
+ assert.equal(t2.format('HH:mm'), t1.format('HH:mm'),
+ 'meridiem at ' + t1.format('HH:mm'));
+ }
+ }
+ });
+
+ test('date format correctness', function (assert) {
+ var data, tokens;
+ data = moment.localeData()._longDateFormat;
+ tokens = objectKeys(data);
+ each(tokens, function (srchToken) {
+ // Check each format string to make sure it does not contain any
+ // tokens that need to be expanded.
+ each(tokens, function (baseToken) {
+ // strip escaped sequences
+ var format = data[baseToken].replace(/(\[[^\]]*\])/g, '');
+ assert.equal(false, !!~format.indexOf(srchToken),
+ 'contains ' + srchToken + ' in ' + baseToken);
+ });
+ });
+ });
+
+ test('month parsing correctness', function (assert) {
+ var i, m;
+
+ if (locale === 'tr') {
+ // I can't fix it :(
+ expect(0);
+ return;
+ }
+ function tester(format) {
+ var r;
+ r = moment(m.format(format), format);
+ assert.equal(r.month(), m.month(), 'month ' + i + ' fmt ' + format);
+ r = moment(m.format(format).toLocaleUpperCase(), format);
+ assert.equal(r.month(), m.month(), 'month ' + i + ' fmt ' + format + ' upper');
+ r = moment(m.format(format).toLocaleLowerCase(), format);
+ assert.equal(r.month(), m.month(), 'month ' + i + ' fmt ' + format + ' lower');
+
+ r = moment(m.format(format), format, true);
+ assert.equal(r.month(), m.month(), 'month ' + i + ' fmt ' + format + ' strict');
+ r = moment(m.format(format).toLocaleUpperCase(), format, true);
+ assert.equal(r.month(), m.month(), 'month ' + i + ' fmt ' + format + ' upper strict');
+ r = moment(m.format(format).toLocaleLowerCase(), format, true);
+ assert.equal(r.month(), m.month(), 'month ' + i + ' fmt ' + format + ' lower strict');
+ }
+
+ for (i = 0; i < 12; ++i) {
+ m = moment([2015, i, 15, 18]);
+ tester('MMM');
+ tester('MMM.');
+ tester('MMMM');
+ tester('MMMM.');
+ }
+ });
+
+ test('weekday parsing correctness', function (assert) {
+ var i, m;
+
+ if (locale === 'tr' || locale === 'az') {
+ // There is a lower-case letter (ı), that converted to upper then
+ // lower changes to i
+ expect(0);
+ return;
+ }
+ function tester(format) {
+ var r, baseMsg = 'weekday ' + m.weekday() + ' fmt ' + format;
+ r = moment(m.format(format), format);
+ assert.equal(r.weekday(), m.weekday(), baseMsg);
+ r = moment(m.format(format).toLocaleUpperCase(), format);
+ assert.equal(r.weekday(), m.weekday(), baseMsg + ' upper');
+ r = moment(m.format(format).toLocaleLowerCase(), format);
+ assert.equal(r.weekday(), m.weekday(), baseMsg + ' lower');
+
+ r = moment(m.format(format), format, true);
+ assert.equal(r.weekday(), m.weekday(), baseMsg + ' strict');
+ r = moment(m.format(format).toLocaleUpperCase(), format, true);
+ assert.equal(r.weekday(), m.weekday(), baseMsg + ' upper strict');
+ r = moment(m.format(format).toLocaleLowerCase(), format, true);
+ assert.equal(r.weekday(), m.weekday(), baseMsg + ' lower strict');
+ }
+
+ for (i = 0; i < 7; ++i) {
+ m = moment.utc([2015, i, 15, 18]);
+ tester('dd');
+ tester('ddd');
+ tester('dddd');
+ }
+ });
+ }
+
+ function setupDeprecationHandler(test, moment, scope) {
+ test._expectedDeprecations = null;
+ test._observedDeprecations = null;
+ test._oldSupress = moment.suppressDeprecationWarnings;
+ moment.suppressDeprecationWarnings = true;
+ test.expectedDeprecations = function () {
+ test._expectedDeprecations = arguments;
+ test._observedDeprecations = [];
+ };
+ moment.deprecationHandler = function (name, msg) {
+ var deprecationId = matchedDeprecation(name, msg, test._expectedDeprecations);
+ if (deprecationId === -1) {
+ throw new Error('Unexpected deprecation thrown name=' +
+ name + ' msg=' + msg);
+ }
+ test._observedDeprecations[deprecationId] = 1;
+ };
+ }
+
+ function teardownDeprecationHandler(test, moment, scope) {
+ moment.suppressDeprecationWarnings = test._oldSupress;
+
+ if (test._expectedDeprecations != null) {
+ var missedDeprecations = [];
+ each(test._expectedDeprecations, function (deprecationPattern, id) {
+ if (test._observedDeprecations[id] !== 1) {
+ missedDeprecations.push(deprecationPattern);
+ }
+ });
+ if (missedDeprecations.length !== 0) {
+ throw new Error('Expected deprecation warnings did not happen: ' +
+ missedDeprecations.join(' '));
+ }
+ }
+ }
+
+ function matchedDeprecation(name, msg, deprecations) {
+ if (deprecations == null) {
+ return -1;
+ }
+ for (var i = 0; i < deprecations.length; ++i) {
+ if (name != null && name === deprecations[i]) {
+ return i;
+ }
+ if (msg != null && msg.substring(0, deprecations[i].length) === deprecations[i]) {
+ return i;
+ }
+ }
+ return -1;
+ }
/*global QUnit:false*/
@@ -19856,11 +27927,13 @@
moment.createFromInputFallback = function (config) {
throw new Error('input not handled by moment: ' + config._i);
};
+ setupDeprecationHandler(test, moment, 'core');
if (lifecycle && lifecycle.setup) {
lifecycle.setup();
}
},
teardown : function () {
+ teardownDeprecationHandler(test, moment, 'core');
if (lifecycle && lifecycle.teardown) {
lifecycle.teardown();
}
@@ -19875,17 +27948,20 @@
moment.createFromInputFallback = function (config) {
throw new Error('input not handled by moment: ' + config._i);
};
+ setupDeprecationHandler(test, moment, 'locale');
if (lifecycle && lifecycle.setup) {
lifecycle.setup();
}
},
teardown : function () {
moment.locale('en');
+ teardownDeprecationHandler(test, moment, 'locale');
if (lifecycle && lifecycle.teardown) {
lifecycle.teardown();
}
}
});
+ defineCommonLocaleTests(name, -1, -1);
}
localeModule('lo');
@@ -20039,14 +28115,14 @@
});
test('calendar day', function (assert) {
- var a = moment().hours(2).minutes(0).seconds(0);
-
- assert.equal(moment(a).calendar(), 'ມື້ນີ້ເວລາ 02:00', 'today at the same time');
- assert.equal(moment(a).add({m: 25}).calendar(), 'ມື້ນີ້ເວລາ 02:25', 'Now plus 25 min');
- assert.equal(moment(a).add({h: 1}).calendar(), 'ມື້ນີ້ເວລາ 03:00', 'Now plus 1 hour');
- assert.equal(moment(a).add({d: 1}).calendar(), 'ມື້ອື່ນເວລາ 02:00', 'tomorrow at the same time');
- assert.equal(moment(a).subtract({h: 1}).calendar(), 'ມື້ນີ້ເວລາ 01:00', 'Now minus 1 hour');
- assert.equal(moment(a).subtract({d: 1}).calendar(), 'ມື້ວານນີ້ເວລາ 02:00', 'yesterday at the same time');
+ var a = moment().hours(12).minutes(0).seconds(0);
+
+ assert.equal(moment(a).calendar(), 'ມື້ນີ້ເວລາ 12:00', 'today at the same time');
+ assert.equal(moment(a).add({m: 25}).calendar(), 'ມື້ນີ້ເວລາ 12:25', 'Now plus 25 min');
+ assert.equal(moment(a).add({h: 1}).calendar(), 'ມື້ນີ້ເວລາ 13:00', 'Now plus 1 hour');
+ assert.equal(moment(a).add({d: 1}).calendar(), 'ມື້ອື່ນເວລາ 12:00', 'tomorrow at the same time');
+ assert.equal(moment(a).subtract({h: 1}).calendar(), 'ມື້ນີ້ເວລາ 11:00', 'Now minus 1 hour');
+ assert.equal(moment(a).subtract({d: 1}).calendar(), 'ມື້ວານນີ້ເວລາ 12:00', 'yesterday at the same time');
});
test('calendar next week', function (assert) {
@@ -20088,67 +28164,6 @@
assert.equal(weeksFromNow.calendar(), weeksFromNow.format('L'), 'in 2 weeks');
});
- test('weeks year starting sunday', function (assert) {
- assert.equal(moment([2012, 0, 1]).week(), 1, 'Jan 1 2012 should be week 1');
- assert.equal(moment([2012, 0, 7]).week(), 1, 'Jan 7 2012 should be week 1');
- assert.equal(moment([2012, 0, 8]).week(), 2, 'Jan 8 2012 should be week 2');
- assert.equal(moment([2012, 0, 14]).week(), 2, 'Jan 14 2012 should be week 2');
- assert.equal(moment([2012, 0, 15]).week(), 3, 'Jan 15 2012 should be week 3');
- });
-
- test('weeks year starting monday', function (assert) {
- assert.equal(moment([2006, 11, 31]).week(), 1, 'Dec 31 2006 should be week 1');
- assert.equal(moment([2007, 0, 1]).week(), 1, 'Jan 1 2007 should be week 1');
- assert.equal(moment([2007, 0, 6]).week(), 1, 'Jan 6 2007 should be week 1');
- assert.equal(moment([2007, 0, 7]).week(), 2, 'Jan 7 2007 should be week 2');
- assert.equal(moment([2007, 0, 13]).week(), 2, 'Jan 13 2007 should be week 2');
- assert.equal(moment([2007, 0, 14]).week(), 3, 'Jan 14 2007 should be week 3');
- });
-
- test('weeks year starting tuesday', function (assert) {
- assert.equal(moment([2007, 11, 29]).week(), 52, 'Dec 29 2007 should be week 52');
- assert.equal(moment([2008, 0, 1]).week(), 1, 'Jan 1 2008 should be week 1');
- assert.equal(moment([2008, 0, 5]).week(), 1, 'Jan 5 2008 should be week 1');
- assert.equal(moment([2008, 0, 6]).week(), 2, 'Jan 6 2008 should be week 2');
- assert.equal(moment([2008, 0, 12]).week(), 2, 'Jan 12 2008 should be week 2');
- assert.equal(moment([2008, 0, 13]).week(), 3, 'Jan 13 2008 should be week 3');
- });
-
- test('weeks year starting wednesday', function (assert) {
- assert.equal(moment([2002, 11, 29]).week(), 1, 'Dec 29 2002 should be week 1');
- assert.equal(moment([2003, 0, 1]).week(), 1, 'Jan 1 2003 should be week 1');
- assert.equal(moment([2003, 0, 4]).week(), 1, 'Jan 4 2003 should be week 1');
- assert.equal(moment([2003, 0, 5]).week(), 2, 'Jan 5 2003 should be week 2');
- assert.equal(moment([2003, 0, 11]).week(), 2, 'Jan 11 2003 should be week 2');
- assert.equal(moment([2003, 0, 12]).week(), 3, 'Jan 12 2003 should be week 3');
- });
-
- test('weeks year starting thursday', function (assert) {
- assert.equal(moment([2008, 11, 28]).week(), 1, 'Dec 28 2008 should be week 1');
- assert.equal(moment([2009, 0, 1]).week(), 1, 'Jan 1 2009 should be week 1');
- assert.equal(moment([2009, 0, 3]).week(), 1, 'Jan 3 2009 should be week 1');
- assert.equal(moment([2009, 0, 4]).week(), 2, 'Jan 4 2009 should be week 2');
- assert.equal(moment([2009, 0, 10]).week(), 2, 'Jan 10 2009 should be week 2');
- assert.equal(moment([2009, 0, 11]).week(), 3, 'Jan 11 2009 should be week 3');
- });
-
- test('weeks year starting friday', function (assert) {
- assert.equal(moment([2009, 11, 27]).week(), 1, 'Dec 27 2009 should be week 1');
- assert.equal(moment([2010, 0, 1]).week(), 1, 'Jan 1 2010 should be week 1');
- assert.equal(moment([2010, 0, 2]).week(), 1, 'Jan 2 2010 should be week 1');
- assert.equal(moment([2010, 0, 3]).week(), 2, 'Jan 3 2010 should be week 2');
- assert.equal(moment([2010, 0, 9]).week(), 2, 'Jan 9 2010 should be week 2');
- assert.equal(moment([2010, 0, 10]).week(), 3, 'Jan 10 2010 should be week 3');
- });
-
- test('weeks year starting saturday', function (assert) {
- assert.equal(moment([2010, 11, 26]).week(), 1, 'Dec 26 2010 should be week 1');
- assert.equal(moment([2011, 0, 1]).week(), 1, 'Jan 1 2011 should be week 1');
- assert.equal(moment([2011, 0, 2]).week(), 2, 'Jan 2 2011 should be week 2');
- assert.equal(moment([2011, 0, 8]).week(), 2, 'Jan 8 2011 should be week 2');
- assert.equal(moment([2011, 0, 9]).week(), 3, 'Jan 9 2011 should be week 3');
- });
-
test('weeks year starting sunday format', function (assert) {
assert.equal(moment([2012, 0, 1]).format('w ww wo'), '1 01 ທີ່1', 'Jan 1 2012 should be week 1');
assert.equal(moment([2012, 0, 7]).format('w ww wo'), '1 01 ທີ່1', 'Jan 7 2012 should be week 1');
@@ -20157,42 +28172,6 @@
assert.equal(moment([2012, 0, 15]).format('w ww wo'), '3 03 ທີ່3', 'Jan 15 2012 should be week 3');
});
- test('lenient ordinal parsing', function (assert) {
- var i, ordinalStr, testMoment;
- for (i = 1; i <= 31; ++i) {
- ordinalStr = moment([2014, 0, i]).format('YYYY MM Do');
- testMoment = moment(ordinalStr, 'YYYY MM Do');
- assert.equal(testMoment.year(), 2014,
- 'lenient ordinal parsing ' + i + ' year check');
- assert.equal(testMoment.month(), 0,
- 'lenient ordinal parsing ' + i + ' month check');
- assert.equal(testMoment.date(), i,
- 'lenient ordinal parsing ' + i + ' date check');
- }
- });
-
- test('lenient ordinal parsing of number', function (assert) {
- var i, testMoment;
- for (i = 1; i <= 31; ++i) {
- testMoment = moment('2014 01 ' + i, 'YYYY MM Do');
- assert.equal(testMoment.year(), 2014,
- 'lenient ordinal parsing of number ' + i + ' year check');
- assert.equal(testMoment.month(), 0,
- 'lenient ordinal parsing of number ' + i + ' month check');
- assert.equal(testMoment.date(), i,
- 'lenient ordinal parsing of number ' + i + ' date check');
- }
- });
-
- test('strict ordinal parsing', function (assert) {
- var i, ordinalStr, testMoment;
- for (i = 1; i <= 31; ++i) {
- ordinalStr = moment([2014, 0, i]).format('YYYY MM Do');
- testMoment = moment(ordinalStr, 'YYYY MM Do', true);
- assert.ok(testMoment.isValid(), 'strict ordinal parsing ' + i);
- }
- });
-
}));
;(function (global, factory) {
@@ -20201,6 +28180,224 @@
typeof define === 'function' && define.amd ? define(['../../moment'], factory) :
factory(global.moment)
}(this, function (moment) { 'use strict';
+
+ function each(array, callback) {
+ var i;
+ for (i = 0; i < array.length; i++) {
+ callback(array[i], i, array);
+ }
+ }
+
+ function objectKeys(obj) {
+ if (Object.keys) {
+ return Object.keys(obj);
+ } else {
+ // IE8
+ var res = [], i;
+ for (i in obj) {
+ if (obj.hasOwnProperty(i)) {
+ res.push(i);
+ }
+ }
+ return res;
+ }
+ }
+
+ // Pick the first defined of two or three arguments.
+ function defaults(a, b, c) {
+ if (a != null) {
+ return a;
+ }
+ if (b != null) {
+ return b;
+ }
+ return c;
+ }
+
+ function defineCommonLocaleTests(locale, options) {
+ test('lenient ordinal parsing', function (assert) {
+ var i, ordinalStr, testMoment;
+ for (i = 1; i <= 31; ++i) {
+ ordinalStr = moment([2014, 0, i]).format('YYYY MM Do');
+ testMoment = moment(ordinalStr, 'YYYY MM Do');
+ assert.equal(testMoment.year(), 2014,
+ 'lenient ordinal parsing ' + i + ' year check');
+ assert.equal(testMoment.month(), 0,
+ 'lenient ordinal parsing ' + i + ' month check');
+ assert.equal(testMoment.date(), i,
+ 'lenient ordinal parsing ' + i + ' date check');
+ }
+ });
+
+ test('lenient ordinal parsing of number', function (assert) {
+ var i, testMoment;
+ for (i = 1; i <= 31; ++i) {
+ testMoment = moment('2014 01 ' + i, 'YYYY MM Do');
+ assert.equal(testMoment.year(), 2014,
+ 'lenient ordinal parsing of number ' + i + ' year check');
+ assert.equal(testMoment.month(), 0,
+ 'lenient ordinal parsing of number ' + i + ' month check');
+ assert.equal(testMoment.date(), i,
+ 'lenient ordinal parsing of number ' + i + ' date check');
+ }
+ });
+
+ test('strict ordinal parsing', function (assert) {
+ var i, ordinalStr, testMoment;
+ for (i = 1; i <= 31; ++i) {
+ ordinalStr = moment([2014, 0, i]).format('YYYY MM Do');
+ testMoment = moment(ordinalStr, 'YYYY MM Do', true);
+ assert.ok(testMoment.isValid(), 'strict ordinal parsing ' + i);
+ }
+ });
+
+ test('meridiem invariant', function (assert) {
+ var h, m, t1, t2;
+ for (h = 0; h < 24; ++h) {
+ for (m = 0; m < 60; m += 15) {
+ t1 = moment.utc([2000, 0, 1, h, m]);
+ t2 = moment.utc(t1.format('A h:mm'), 'A h:mm');
+ assert.equal(t2.format('HH:mm'), t1.format('HH:mm'),
+ 'meridiem at ' + t1.format('HH:mm'));
+ }
+ }
+ });
+
+ test('date format correctness', function (assert) {
+ var data, tokens;
+ data = moment.localeData()._longDateFormat;
+ tokens = objectKeys(data);
+ each(tokens, function (srchToken) {
+ // Check each format string to make sure it does not contain any
+ // tokens that need to be expanded.
+ each(tokens, function (baseToken) {
+ // strip escaped sequences
+ var format = data[baseToken].replace(/(\[[^\]]*\])/g, '');
+ assert.equal(false, !!~format.indexOf(srchToken),
+ 'contains ' + srchToken + ' in ' + baseToken);
+ });
+ });
+ });
+
+ test('month parsing correctness', function (assert) {
+ var i, m;
+
+ if (locale === 'tr') {
+ // I can't fix it :(
+ expect(0);
+ return;
+ }
+ function tester(format) {
+ var r;
+ r = moment(m.format(format), format);
+ assert.equal(r.month(), m.month(), 'month ' + i + ' fmt ' + format);
+ r = moment(m.format(format).toLocaleUpperCase(), format);
+ assert.equal(r.month(), m.month(), 'month ' + i + ' fmt ' + format + ' upper');
+ r = moment(m.format(format).toLocaleLowerCase(), format);
+ assert.equal(r.month(), m.month(), 'month ' + i + ' fmt ' + format + ' lower');
+
+ r = moment(m.format(format), format, true);
+ assert.equal(r.month(), m.month(), 'month ' + i + ' fmt ' + format + ' strict');
+ r = moment(m.format(format).toLocaleUpperCase(), format, true);
+ assert.equal(r.month(), m.month(), 'month ' + i + ' fmt ' + format + ' upper strict');
+ r = moment(m.format(format).toLocaleLowerCase(), format, true);
+ assert.equal(r.month(), m.month(), 'month ' + i + ' fmt ' + format + ' lower strict');
+ }
+
+ for (i = 0; i < 12; ++i) {
+ m = moment([2015, i, 15, 18]);
+ tester('MMM');
+ tester('MMM.');
+ tester('MMMM');
+ tester('MMMM.');
+ }
+ });
+
+ test('weekday parsing correctness', function (assert) {
+ var i, m;
+
+ if (locale === 'tr' || locale === 'az') {
+ // There is a lower-case letter (ı), that converted to upper then
+ // lower changes to i
+ expect(0);
+ return;
+ }
+ function tester(format) {
+ var r, baseMsg = 'weekday ' + m.weekday() + ' fmt ' + format;
+ r = moment(m.format(format), format);
+ assert.equal(r.weekday(), m.weekday(), baseMsg);
+ r = moment(m.format(format).toLocaleUpperCase(), format);
+ assert.equal(r.weekday(), m.weekday(), baseMsg + ' upper');
+ r = moment(m.format(format).toLocaleLowerCase(), format);
+ assert.equal(r.weekday(), m.weekday(), baseMsg + ' lower');
+
+ r = moment(m.format(format), format, true);
+ assert.equal(r.weekday(), m.weekday(), baseMsg + ' strict');
+ r = moment(m.format(format).toLocaleUpperCase(), format, true);
+ assert.equal(r.weekday(), m.weekday(), baseMsg + ' upper strict');
+ r = moment(m.format(format).toLocaleLowerCase(), format, true);
+ assert.equal(r.weekday(), m.weekday(), baseMsg + ' lower strict');
+ }
+
+ for (i = 0; i < 7; ++i) {
+ m = moment.utc([2015, i, 15, 18]);
+ tester('dd');
+ tester('ddd');
+ tester('dddd');
+ }
+ });
+ }
+
+ function setupDeprecationHandler(test, moment, scope) {
+ test._expectedDeprecations = null;
+ test._observedDeprecations = null;
+ test._oldSupress = moment.suppressDeprecationWarnings;
+ moment.suppressDeprecationWarnings = true;
+ test.expectedDeprecations = function () {
+ test._expectedDeprecations = arguments;
+ test._observedDeprecations = [];
+ };
+ moment.deprecationHandler = function (name, msg) {
+ var deprecationId = matchedDeprecation(name, msg, test._expectedDeprecations);
+ if (deprecationId === -1) {
+ throw new Error('Unexpected deprecation thrown name=' +
+ name + ' msg=' + msg);
+ }
+ test._observedDeprecations[deprecationId] = 1;
+ };
+ }
+
+ function teardownDeprecationHandler(test, moment, scope) {
+ moment.suppressDeprecationWarnings = test._oldSupress;
+
+ if (test._expectedDeprecations != null) {
+ var missedDeprecations = [];
+ each(test._expectedDeprecations, function (deprecationPattern, id) {
+ if (test._observedDeprecations[id] !== 1) {
+ missedDeprecations.push(deprecationPattern);
+ }
+ });
+ if (missedDeprecations.length !== 0) {
+ throw new Error('Expected deprecation warnings did not happen: ' +
+ missedDeprecations.join(' '));
+ }
+ }
+ }
+
+ function matchedDeprecation(name, msg, deprecations) {
+ if (deprecations == null) {
+ return -1;
+ }
+ for (var i = 0; i < deprecations.length; ++i) {
+ if (name != null && name === deprecations[i]) {
+ return i;
+ }
+ if (msg != null && msg.substring(0, deprecations[i].length) === deprecations[i]) {
+ return i;
+ }
+ }
+ return -1;
+ }
/*global QUnit:false*/
@@ -20215,11 +28412,13 @@
moment.createFromInputFallback = function (config) {
throw new Error('input not handled by moment: ' + config._i);
};
+ setupDeprecationHandler(test, moment, 'core');
if (lifecycle && lifecycle.setup) {
lifecycle.setup();
}
},
teardown : function () {
+ teardownDeprecationHandler(test, moment, 'core');
if (lifecycle && lifecycle.teardown) {
lifecycle.teardown();
}
@@ -20234,17 +28433,20 @@
moment.createFromInputFallback = function (config) {
throw new Error('input not handled by moment: ' + config._i);
};
+ setupDeprecationHandler(test, moment, 'locale');
if (lifecycle && lifecycle.setup) {
lifecycle.setup();
}
},
teardown : function () {
moment.locale('en');
+ teardownDeprecationHandler(test, moment, 'locale');
if (lifecycle && lifecycle.teardown) {
lifecycle.teardown();
}
}
});
+ defineCommonLocaleTests(name, -1, -1);
}
localeModule('lt');
@@ -20353,12 +28555,12 @@
test('format week on US calendar', function (assert) {
// Tests, whether the weekday names are correct, even if the week does not start on Monday
- moment.locale('lt', {week: {dow: 0, doy: 6}});
+ moment.updateLocale('lt', {week: {dow: 0, doy: 6}});
var expected = 'sekmadienis Sek S_pirmadienis Pir P_antradienis Ant A_trečiadienis Tre T_ketvirtadienis Ket K_penktadienis Pen Pn_šeštadienis Šeš Š'.split('_'), i;
for (i = 0; i < expected.length; i++) {
assert.equal(moment([2011, 0, 2 + i]).format('dddd ddd dd'), expected[i], expected[i]);
}
- moment.locale('lt', {week: {dow: 1, doy: 4}});
+ moment.updateLocale('lt', null);
});
test('from', function (assert) {
@@ -20415,14 +28617,14 @@
});
test('calendar day', function (assert) {
- var a = moment().hours(2).minutes(0).seconds(0);
-
- assert.equal(moment(a).calendar(), 'Šiandien 02:00', 'today at the same time');
- assert.equal(moment(a).add({m: 25}).calendar(), 'Šiandien 02:25', 'Now plus 25 min');
- assert.equal(moment(a).add({h: 1}).calendar(), 'Šiandien 03:00', 'Now plus 1 hour');
- assert.equal(moment(a).add({d: 1}).calendar(), 'Rytoj 02:00', 'tomorrow at the same time');
- assert.equal(moment(a).subtract({h: 1}).calendar(), 'Šiandien 01:00', 'Now minus 1 hour');
- assert.equal(moment(a).subtract({d: 1}).calendar(), 'Vakar 02:00', 'yesterday at the same time');
+ var a = moment().hours(12).minutes(0).seconds(0);
+
+ assert.equal(moment(a).calendar(), 'Šiandien 12:00', 'today at the same time');
+ assert.equal(moment(a).add({m: 25}).calendar(), 'Šiandien 12:25', 'Now plus 25 min');
+ assert.equal(moment(a).add({h: 1}).calendar(), 'Šiandien 13:00', 'Now plus 1 hour');
+ assert.equal(moment(a).add({d: 1}).calendar(), 'Rytoj 12:00', 'tomorrow at the same time');
+ assert.equal(moment(a).subtract({h: 1}).calendar(), 'Šiandien 11:00', 'Now minus 1 hour');
+ assert.equal(moment(a).subtract({d: 1}).calendar(), 'Vakar 12:00', 'yesterday at the same time');
});
test('calendar next week', function (assert) {
@@ -20463,67 +28665,6 @@
assert.equal(weeksFromNow.calendar(), weeksFromNow.format('L'), 'in 2 weeks');
});
- test('weeks year starting sunday', function (assert) {
- assert.equal(moment([2012, 0, 1]).week(), 52, 'Jan 1 2012 should be week 52');
- assert.equal(moment([2012, 0, 2]).week(), 1, 'Jan 2 2012 should be week 1');
- assert.equal(moment([2012, 0, 8]).week(), 1, 'Jan 8 2012 should be week 1');
- assert.equal(moment([2012, 0, 9]).week(), 2, 'Jan 9 2012 should be week 2');
- assert.equal(moment([2012, 0, 15]).week(), 2, 'Jan 15 2012 should be week 2');
- });
-
- test('weeks year starting monday', function (assert) {
- assert.equal(moment([2007, 0, 1]).week(), 1, 'Jan 1 2007 should be week 1');
- assert.equal(moment([2007, 0, 7]).week(), 1, 'Jan 7 2007 should be week 1');
- assert.equal(moment([2007, 0, 8]).week(), 2, 'Jan 8 2007 should be week 2');
- assert.equal(moment([2007, 0, 14]).week(), 2, 'Jan 14 2007 should be week 2');
- assert.equal(moment([2007, 0, 15]).week(), 3, 'Jan 15 2007 should be week 3');
- });
-
- test('weeks year starting tuesday', function (assert) {
- assert.equal(moment([2007, 11, 31]).week(), 1, 'Dec 31 2007 should be week 1');
- assert.equal(moment([2008, 0, 1]).week(), 1, 'Jan 1 2008 should be week 1');
- assert.equal(moment([2008, 0, 6]).week(), 1, 'Jan 6 2008 should be week 1');
- assert.equal(moment([2008, 0, 7]).week(), 2, 'Jan 7 2008 should be week 2');
- assert.equal(moment([2008, 0, 13]).week(), 2, 'Jan 13 2008 should be week 2');
- assert.equal(moment([2008, 0, 14]).week(), 3, 'Jan 14 2008 should be week 3');
- });
-
- test('weeks year starting wednesday', function (assert) {
- assert.equal(moment([2002, 11, 30]).week(), 1, 'Dec 30 2002 should be week 1');
- assert.equal(moment([2003, 0, 1]).week(), 1, 'Jan 1 2003 should be week 1');
- assert.equal(moment([2003, 0, 5]).week(), 1, 'Jan 5 2003 should be week 1');
- assert.equal(moment([2003, 0, 6]).week(), 2, 'Jan 6 2003 should be week 2');
- assert.equal(moment([2003, 0, 12]).week(), 2, 'Jan 12 2003 should be week 2');
- assert.equal(moment([2003, 0, 13]).week(), 3, 'Jan 13 2003 should be week 3');
- });
-
- test('weeks year starting thursday', function (assert) {
- assert.equal(moment([2008, 11, 29]).week(), 1, 'Dec 29 2008 should be week 1');
- assert.equal(moment([2009, 0, 1]).week(), 1, 'Jan 1 2009 should be week 1');
- assert.equal(moment([2009, 0, 4]).week(), 1, 'Jan 4 2009 should be week 1');
- assert.equal(moment([2009, 0, 5]).week(), 2, 'Jan 5 2009 should be week 2');
- assert.equal(moment([2009, 0, 11]).week(), 2, 'Jan 11 2009 should be week 2');
- assert.equal(moment([2009, 0, 13]).week(), 3, 'Jan 12 2009 should be week 3');
- });
-
- test('weeks year starting friday', function (assert) {
- assert.equal(moment([2009, 11, 28]).week(), 53, 'Dec 28 2009 should be week 53');
- assert.equal(moment([2010, 0, 1]).week(), 53, 'Jan 1 2010 should be week 53');
- assert.equal(moment([2010, 0, 3]).week(), 53, 'Jan 3 2010 should be week 53');
- assert.equal(moment([2010, 0, 4]).week(), 1, 'Jan 4 2010 should be week 1');
- assert.equal(moment([2010, 0, 10]).week(), 1, 'Jan 10 2010 should be week 1');
- assert.equal(moment([2010, 0, 11]).week(), 2, 'Jan 11 2010 should be week 2');
- });
-
- test('weeks year starting saturday', function (assert) {
- assert.equal(moment([2010, 11, 27]).week(), 52, 'Dec 27 2010 should be week 52');
- assert.equal(moment([2011, 0, 1]).week(), 52, 'Jan 1 2011 should be week 52');
- assert.equal(moment([2011, 0, 2]).week(), 52, 'Jan 2 2011 should be week 52');
- assert.equal(moment([2011, 0, 3]).week(), 1, 'Jan 3 2011 should be week 1');
- assert.equal(moment([2011, 0, 9]).week(), 1, 'Jan 9 2011 should be week 1');
- assert.equal(moment([2011, 0, 10]).week(), 2, 'Jan 10 2011 should be week 2');
- });
-
test('weeks year starting sunday formatted', function (assert) {
assert.equal(moment([2012, 0, 1]).format('w ww wo'), '52 52 52-oji', 'Jan 1 2012 should be week 52');
assert.equal(moment([2012, 0, 2]).format('w ww wo'), '1 01 1-oji', 'Jan 2 2012 should be week 1');
@@ -20532,42 +28673,6 @@
assert.equal(moment([2012, 0, 15]).format('w ww wo'), '2 02 2-oji', 'Jan 15 2012 should be week 2');
});
- test('lenient ordinal parsing', function (assert) {
- var i, ordinalStr, testMoment;
- for (i = 1; i <= 31; ++i) {
- ordinalStr = moment([2014, 0, i]).format('YYYY MM Do');
- testMoment = moment(ordinalStr, 'YYYY MM Do');
- assert.equal(testMoment.year(), 2014,
- 'lenient ordinal parsing ' + i + ' year check');
- assert.equal(testMoment.month(), 0,
- 'lenient ordinal parsing ' + i + ' month check');
- assert.equal(testMoment.date(), i,
- 'lenient ordinal parsing ' + i + ' date check');
- }
- });
-
- test('lenient ordinal parsing of number', function (assert) {
- var i, testMoment;
- for (i = 1; i <= 31; ++i) {
- testMoment = moment('2014 01 ' + i, 'YYYY MM Do');
- assert.equal(testMoment.year(), 2014,
- 'lenient ordinal parsing of number ' + i + ' year check');
- assert.equal(testMoment.month(), 0,
- 'lenient ordinal parsing of number ' + i + ' month check');
- assert.equal(testMoment.date(), i,
- 'lenient ordinal parsing of number ' + i + ' date check');
- }
- });
-
- test('strict ordinal parsing', function (assert) {
- var i, ordinalStr, testMoment;
- for (i = 1; i <= 31; ++i) {
- ordinalStr = moment([2014, 0, i]).format('YYYY MM Do');
- testMoment = moment(ordinalStr, 'YYYY MM Do', true);
- assert.ok(testMoment.isValid(), 'strict ordinal parsing ' + i);
- }
- });
-
}));
;(function (global, factory) {
@@ -20576,6 +28681,224 @@
typeof define === 'function' && define.amd ? define(['../../moment'], factory) :
factory(global.moment)
}(this, function (moment) { 'use strict';
+
+ function each(array, callback) {
+ var i;
+ for (i = 0; i < array.length; i++) {
+ callback(array[i], i, array);
+ }
+ }
+
+ function objectKeys(obj) {
+ if (Object.keys) {
+ return Object.keys(obj);
+ } else {
+ // IE8
+ var res = [], i;
+ for (i in obj) {
+ if (obj.hasOwnProperty(i)) {
+ res.push(i);
+ }
+ }
+ return res;
+ }
+ }
+
+ // Pick the first defined of two or three arguments.
+ function defaults(a, b, c) {
+ if (a != null) {
+ return a;
+ }
+ if (b != null) {
+ return b;
+ }
+ return c;
+ }
+
+ function defineCommonLocaleTests(locale, options) {
+ test('lenient ordinal parsing', function (assert) {
+ var i, ordinalStr, testMoment;
+ for (i = 1; i <= 31; ++i) {
+ ordinalStr = moment([2014, 0, i]).format('YYYY MM Do');
+ testMoment = moment(ordinalStr, 'YYYY MM Do');
+ assert.equal(testMoment.year(), 2014,
+ 'lenient ordinal parsing ' + i + ' year check');
+ assert.equal(testMoment.month(), 0,
+ 'lenient ordinal parsing ' + i + ' month check');
+ assert.equal(testMoment.date(), i,
+ 'lenient ordinal parsing ' + i + ' date check');
+ }
+ });
+
+ test('lenient ordinal parsing of number', function (assert) {
+ var i, testMoment;
+ for (i = 1; i <= 31; ++i) {
+ testMoment = moment('2014 01 ' + i, 'YYYY MM Do');
+ assert.equal(testMoment.year(), 2014,
+ 'lenient ordinal parsing of number ' + i + ' year check');
+ assert.equal(testMoment.month(), 0,
+ 'lenient ordinal parsing of number ' + i + ' month check');
+ assert.equal(testMoment.date(), i,
+ 'lenient ordinal parsing of number ' + i + ' date check');
+ }
+ });
+
+ test('strict ordinal parsing', function (assert) {
+ var i, ordinalStr, testMoment;
+ for (i = 1; i <= 31; ++i) {
+ ordinalStr = moment([2014, 0, i]).format('YYYY MM Do');
+ testMoment = moment(ordinalStr, 'YYYY MM Do', true);
+ assert.ok(testMoment.isValid(), 'strict ordinal parsing ' + i);
+ }
+ });
+
+ test('meridiem invariant', function (assert) {
+ var h, m, t1, t2;
+ for (h = 0; h < 24; ++h) {
+ for (m = 0; m < 60; m += 15) {
+ t1 = moment.utc([2000, 0, 1, h, m]);
+ t2 = moment.utc(t1.format('A h:mm'), 'A h:mm');
+ assert.equal(t2.format('HH:mm'), t1.format('HH:mm'),
+ 'meridiem at ' + t1.format('HH:mm'));
+ }
+ }
+ });
+
+ test('date format correctness', function (assert) {
+ var data, tokens;
+ data = moment.localeData()._longDateFormat;
+ tokens = objectKeys(data);
+ each(tokens, function (srchToken) {
+ // Check each format string to make sure it does not contain any
+ // tokens that need to be expanded.
+ each(tokens, function (baseToken) {
+ // strip escaped sequences
+ var format = data[baseToken].replace(/(\[[^\]]*\])/g, '');
+ assert.equal(false, !!~format.indexOf(srchToken),
+ 'contains ' + srchToken + ' in ' + baseToken);
+ });
+ });
+ });
+
+ test('month parsing correctness', function (assert) {
+ var i, m;
+
+ if (locale === 'tr') {
+ // I can't fix it :(
+ expect(0);
+ return;
+ }
+ function tester(format) {
+ var r;
+ r = moment(m.format(format), format);
+ assert.equal(r.month(), m.month(), 'month ' + i + ' fmt ' + format);
+ r = moment(m.format(format).toLocaleUpperCase(), format);
+ assert.equal(r.month(), m.month(), 'month ' + i + ' fmt ' + format + ' upper');
+ r = moment(m.format(format).toLocaleLowerCase(), format);
+ assert.equal(r.month(), m.month(), 'month ' + i + ' fmt ' + format + ' lower');
+
+ r = moment(m.format(format), format, true);
+ assert.equal(r.month(), m.month(), 'month ' + i + ' fmt ' + format + ' strict');
+ r = moment(m.format(format).toLocaleUpperCase(), format, true);
+ assert.equal(r.month(), m.month(), 'month ' + i + ' fmt ' + format + ' upper strict');
+ r = moment(m.format(format).toLocaleLowerCase(), format, true);
+ assert.equal(r.month(), m.month(), 'month ' + i + ' fmt ' + format + ' lower strict');
+ }
+
+ for (i = 0; i < 12; ++i) {
+ m = moment([2015, i, 15, 18]);
+ tester('MMM');
+ tester('MMM.');
+ tester('MMMM');
+ tester('MMMM.');
+ }
+ });
+
+ test('weekday parsing correctness', function (assert) {
+ var i, m;
+
+ if (locale === 'tr' || locale === 'az') {
+ // There is a lower-case letter (ı), that converted to upper then
+ // lower changes to i
+ expect(0);
+ return;
+ }
+ function tester(format) {
+ var r, baseMsg = 'weekday ' + m.weekday() + ' fmt ' + format;
+ r = moment(m.format(format), format);
+ assert.equal(r.weekday(), m.weekday(), baseMsg);
+ r = moment(m.format(format).toLocaleUpperCase(), format);
+ assert.equal(r.weekday(), m.weekday(), baseMsg + ' upper');
+ r = moment(m.format(format).toLocaleLowerCase(), format);
+ assert.equal(r.weekday(), m.weekday(), baseMsg + ' lower');
+
+ r = moment(m.format(format), format, true);
+ assert.equal(r.weekday(), m.weekday(), baseMsg + ' strict');
+ r = moment(m.format(format).toLocaleUpperCase(), format, true);
+ assert.equal(r.weekday(), m.weekday(), baseMsg + ' upper strict');
+ r = moment(m.format(format).toLocaleLowerCase(), format, true);
+ assert.equal(r.weekday(), m.weekday(), baseMsg + ' lower strict');
+ }
+
+ for (i = 0; i < 7; ++i) {
+ m = moment.utc([2015, i, 15, 18]);
+ tester('dd');
+ tester('ddd');
+ tester('dddd');
+ }
+ });
+ }
+
+ function setupDeprecationHandler(test, moment, scope) {
+ test._expectedDeprecations = null;
+ test._observedDeprecations = null;
+ test._oldSupress = moment.suppressDeprecationWarnings;
+ moment.suppressDeprecationWarnings = true;
+ test.expectedDeprecations = function () {
+ test._expectedDeprecations = arguments;
+ test._observedDeprecations = [];
+ };
+ moment.deprecationHandler = function (name, msg) {
+ var deprecationId = matchedDeprecation(name, msg, test._expectedDeprecations);
+ if (deprecationId === -1) {
+ throw new Error('Unexpected deprecation thrown name=' +
+ name + ' msg=' + msg);
+ }
+ test._observedDeprecations[deprecationId] = 1;
+ };
+ }
+
+ function teardownDeprecationHandler(test, moment, scope) {
+ moment.suppressDeprecationWarnings = test._oldSupress;
+
+ if (test._expectedDeprecations != null) {
+ var missedDeprecations = [];
+ each(test._expectedDeprecations, function (deprecationPattern, id) {
+ if (test._observedDeprecations[id] !== 1) {
+ missedDeprecations.push(deprecationPattern);
+ }
+ });
+ if (missedDeprecations.length !== 0) {
+ throw new Error('Expected deprecation warnings did not happen: ' +
+ missedDeprecations.join(' '));
+ }
+ }
+ }
+
+ function matchedDeprecation(name, msg, deprecations) {
+ if (deprecations == null) {
+ return -1;
+ }
+ for (var i = 0; i < deprecations.length; ++i) {
+ if (name != null && name === deprecations[i]) {
+ return i;
+ }
+ if (msg != null && msg.substring(0, deprecations[i].length) === deprecations[i]) {
+ return i;
+ }
+ }
+ return -1;
+ }
/*global QUnit:false*/
@@ -20590,11 +28913,13 @@
moment.createFromInputFallback = function (config) {
throw new Error('input not handled by moment: ' + config._i);
};
+ setupDeprecationHandler(test, moment, 'core');
if (lifecycle && lifecycle.setup) {
lifecycle.setup();
}
},
teardown : function () {
+ teardownDeprecationHandler(test, moment, 'core');
if (lifecycle && lifecycle.teardown) {
lifecycle.teardown();
}
@@ -20609,17 +28934,20 @@
moment.createFromInputFallback = function (config) {
throw new Error('input not handled by moment: ' + config._i);
};
+ setupDeprecationHandler(test, moment, 'locale');
if (lifecycle && lifecycle.setup) {
lifecycle.setup();
}
},
teardown : function () {
moment.locale('en');
+ teardownDeprecationHandler(test, moment, 'locale');
if (lifecycle && lifecycle.teardown) {
lifecycle.teardown();
}
}
});
+ defineCommonLocaleTests(name, -1, -1);
}
localeModule('lv');
@@ -20794,14 +29122,14 @@
});
test('calendar day', function (assert) {
- var a = moment().hours(2).minutes(0).seconds(0);
-
- assert.equal(moment(a).calendar(), 'Šodien pulksten 02:00', 'today at the same time');
- assert.equal(moment(a).add({m: 25}).calendar(), 'Šodien pulksten 02:25', 'Now plus 25 min');
- assert.equal(moment(a).add({h: 1}).calendar(), 'Šodien pulksten 03:00', 'Now plus 1 hour');
- assert.equal(moment(a).add({d: 1}).calendar(), 'Rīt pulksten 02:00', 'tomorrow at the same time');
- assert.equal(moment(a).subtract({h: 1}).calendar(), 'Šodien pulksten 01:00', 'Now minus 1 hour');
- assert.equal(moment(a).subtract({d: 1}).calendar(), 'Vakar pulksten 02:00', 'yesterday at the same time');
+ var a = moment().hours(12).minutes(0).seconds(0);
+
+ assert.equal(moment(a).calendar(), 'Šodien pulksten 12:00', 'today at the same time');
+ assert.equal(moment(a).add({m: 25}).calendar(), 'Šodien pulksten 12:25', 'Now plus 25 min');
+ assert.equal(moment(a).add({h: 1}).calendar(), 'Šodien pulksten 13:00', 'Now plus 1 hour');
+ assert.equal(moment(a).add({d: 1}).calendar(), 'Rīt pulksten 12:00', 'tomorrow at the same time');
+ assert.equal(moment(a).subtract({h: 1}).calendar(), 'Šodien pulksten 11:00', 'Now minus 1 hour');
+ assert.equal(moment(a).subtract({d: 1}).calendar(), 'Vakar pulksten 12:00', 'yesterday at the same time');
});
test('calendar next week', function (assert) {
@@ -20842,67 +29170,6 @@
assert.equal(weeksFromNow.calendar(), weeksFromNow.format('L'), 'in 2 weeks');
});
- test('weeks year starting sunday', function (assert) {
- assert.equal(moment([2012, 0, 1]).week(), 52, 'Jan 1 2012 should be week 52');
- assert.equal(moment([2012, 0, 2]).week(), 1, 'Jan 2 2012 should be week 1');
- assert.equal(moment([2012, 0, 8]).week(), 1, 'Jan 8 2012 should be week 1');
- assert.equal(moment([2012, 0, 9]).week(), 2, 'Jan 9 2012 should be week 2');
- assert.equal(moment([2012, 0, 15]).week(), 2, 'Jan 15 2012 should be week 2');
- });
-
- test('weeks year starting monday', function (assert) {
- assert.equal(moment([2007, 0, 1]).week(), 1, 'Jan 1 2007 should be week 1');
- assert.equal(moment([2007, 0, 7]).week(), 1, 'Jan 7 2007 should be week 1');
- assert.equal(moment([2007, 0, 8]).week(), 2, 'Jan 8 2007 should be week 2');
- assert.equal(moment([2007, 0, 14]).week(), 2, 'Jan 14 2007 should be week 2');
- assert.equal(moment([2007, 0, 15]).week(), 3, 'Jan 15 2007 should be week 3');
- });
-
- test('weeks year starting tuesday', function (assert) {
- assert.equal(moment([2007, 11, 31]).week(), 1, 'Dec 31 2007 should be week 1');
- assert.equal(moment([2008, 0, 1]).week(), 1, 'Jan 1 2008 should be week 1');
- assert.equal(moment([2008, 0, 6]).week(), 1, 'Jan 6 2008 should be week 1');
- assert.equal(moment([2008, 0, 7]).week(), 2, 'Jan 7 2008 should be week 2');
- assert.equal(moment([2008, 0, 13]).week(), 2, 'Jan 13 2008 should be week 2');
- assert.equal(moment([2008, 0, 14]).week(), 3, 'Jan 14 2008 should be week 3');
- });
-
- test('weeks year starting wednesday', function (assert) {
- assert.equal(moment([2002, 11, 30]).week(), 1, 'Dec 30 2002 should be week 1');
- assert.equal(moment([2003, 0, 1]).week(), 1, 'Jan 1 2003 should be week 1');
- assert.equal(moment([2003, 0, 5]).week(), 1, 'Jan 5 2003 should be week 1');
- assert.equal(moment([2003, 0, 6]).week(), 2, 'Jan 6 2003 should be week 2');
- assert.equal(moment([2003, 0, 12]).week(), 2, 'Jan 12 2003 should be week 2');
- assert.equal(moment([2003, 0, 13]).week(), 3, 'Jan 13 2003 should be week 3');
- });
-
- test('weeks year starting thursday', function (assert) {
- assert.equal(moment([2008, 11, 29]).week(), 1, 'Dec 29 2008 should be week 1');
- assert.equal(moment([2009, 0, 1]).week(), 1, 'Jan 1 2009 should be week 1');
- assert.equal(moment([2009, 0, 4]).week(), 1, 'Jan 4 2009 should be week 1');
- assert.equal(moment([2009, 0, 5]).week(), 2, 'Jan 5 2009 should be week 2');
- assert.equal(moment([2009, 0, 11]).week(), 2, 'Jan 11 2009 should be week 2');
- assert.equal(moment([2009, 0, 13]).week(), 3, 'Jan 12 2009 should be week 3');
- });
-
- test('weeks year starting friday', function (assert) {
- assert.equal(moment([2009, 11, 28]).week(), 53, 'Dec 28 2009 should be week 53');
- assert.equal(moment([2010, 0, 1]).week(), 53, 'Jan 1 2010 should be week 53');
- assert.equal(moment([2010, 0, 3]).week(), 53, 'Jan 3 2010 should be week 53');
- assert.equal(moment([2010, 0, 4]).week(), 1, 'Jan 4 2010 should be week 1');
- assert.equal(moment([2010, 0, 10]).week(), 1, 'Jan 10 2010 should be week 1');
- assert.equal(moment([2010, 0, 11]).week(), 2, 'Jan 11 2010 should be week 2');
- });
-
- test('weeks year starting saturday', function (assert) {
- assert.equal(moment([2010, 11, 27]).week(), 52, 'Dec 27 2010 should be week 52');
- assert.equal(moment([2011, 0, 1]).week(), 52, 'Jan 1 2011 should be week 52');
- assert.equal(moment([2011, 0, 2]).week(), 52, 'Jan 2 2011 should be week 52');
- assert.equal(moment([2011, 0, 3]).week(), 1, 'Jan 3 2011 should be week 1');
- assert.equal(moment([2011, 0, 9]).week(), 1, 'Jan 9 2011 should be week 1');
- assert.equal(moment([2011, 0, 10]).week(), 2, 'Jan 10 2011 should be week 2');
- });
-
test('weeks year starting sunday formatted', function (assert) {
assert.equal(moment([2012, 0, 1]).format('w ww wo'), '52 52 52.', 'Jan 1 2012 should be week 52');
assert.equal(moment([2012, 0, 2]).format('w ww wo'), '1 01 1.', 'Jan 2 2012 should be week 1');
@@ -20911,42 +29178,6 @@
assert.equal(moment([2012, 0, 15]).format('w ww wo'), '2 02 2.', 'Jan 15 2012 should be week 2');
});
- test('lenient ordinal parsing', function (assert) {
- var i, ordinalStr, testMoment;
- for (i = 1; i <= 31; ++i) {
- ordinalStr = moment([2014, 0, i]).format('YYYY MM Do');
- testMoment = moment(ordinalStr, 'YYYY MM Do');
- assert.equal(testMoment.year(), 2014,
- 'lenient ordinal parsing ' + i + ' year check');
- assert.equal(testMoment.month(), 0,
- 'lenient ordinal parsing ' + i + ' month check');
- assert.equal(testMoment.date(), i,
- 'lenient ordinal parsing ' + i + ' date check');
- }
- });
-
- test('lenient ordinal parsing of number', function (assert) {
- var i, testMoment;
- for (i = 1; i <= 31; ++i) {
- testMoment = moment('2014 01 ' + i, 'YYYY MM Do');
- assert.equal(testMoment.year(), 2014,
- 'lenient ordinal parsing of number ' + i + ' year check');
- assert.equal(testMoment.month(), 0,
- 'lenient ordinal parsing of number ' + i + ' month check');
- assert.equal(testMoment.date(), i,
- 'lenient ordinal parsing of number ' + i + ' date check');
- }
- });
-
- test('strict ordinal parsing', function (assert) {
- var i, ordinalStr, testMoment;
- for (i = 1; i <= 31; ++i) {
- ordinalStr = moment([2014, 0, i]).format('YYYY MM Do');
- testMoment = moment(ordinalStr, 'YYYY MM Do', true);
- assert.ok(testMoment.isValid(), 'strict ordinal parsing ' + i);
- }
- });
-
}));
;(function (global, factory) {
@@ -20955,6 +29186,224 @@
typeof define === 'function' && define.amd ? define(['../../moment'], factory) :
factory(global.moment)
}(this, function (moment) { 'use strict';
+
+ function each(array, callback) {
+ var i;
+ for (i = 0; i < array.length; i++) {
+ callback(array[i], i, array);
+ }
+ }
+
+ function objectKeys(obj) {
+ if (Object.keys) {
+ return Object.keys(obj);
+ } else {
+ // IE8
+ var res = [], i;
+ for (i in obj) {
+ if (obj.hasOwnProperty(i)) {
+ res.push(i);
+ }
+ }
+ return res;
+ }
+ }
+
+ // Pick the first defined of two or three arguments.
+ function defaults(a, b, c) {
+ if (a != null) {
+ return a;
+ }
+ if (b != null) {
+ return b;
+ }
+ return c;
+ }
+
+ function defineCommonLocaleTests(locale, options) {
+ test('lenient ordinal parsing', function (assert) {
+ var i, ordinalStr, testMoment;
+ for (i = 1; i <= 31; ++i) {
+ ordinalStr = moment([2014, 0, i]).format('YYYY MM Do');
+ testMoment = moment(ordinalStr, 'YYYY MM Do');
+ assert.equal(testMoment.year(), 2014,
+ 'lenient ordinal parsing ' + i + ' year check');
+ assert.equal(testMoment.month(), 0,
+ 'lenient ordinal parsing ' + i + ' month check');
+ assert.equal(testMoment.date(), i,
+ 'lenient ordinal parsing ' + i + ' date check');
+ }
+ });
+
+ test('lenient ordinal parsing of number', function (assert) {
+ var i, testMoment;
+ for (i = 1; i <= 31; ++i) {
+ testMoment = moment('2014 01 ' + i, 'YYYY MM Do');
+ assert.equal(testMoment.year(), 2014,
+ 'lenient ordinal parsing of number ' + i + ' year check');
+ assert.equal(testMoment.month(), 0,
+ 'lenient ordinal parsing of number ' + i + ' month check');
+ assert.equal(testMoment.date(), i,
+ 'lenient ordinal parsing of number ' + i + ' date check');
+ }
+ });
+
+ test('strict ordinal parsing', function (assert) {
+ var i, ordinalStr, testMoment;
+ for (i = 1; i <= 31; ++i) {
+ ordinalStr = moment([2014, 0, i]).format('YYYY MM Do');
+ testMoment = moment(ordinalStr, 'YYYY MM Do', true);
+ assert.ok(testMoment.isValid(), 'strict ordinal parsing ' + i);
+ }
+ });
+
+ test('meridiem invariant', function (assert) {
+ var h, m, t1, t2;
+ for (h = 0; h < 24; ++h) {
+ for (m = 0; m < 60; m += 15) {
+ t1 = moment.utc([2000, 0, 1, h, m]);
+ t2 = moment.utc(t1.format('A h:mm'), 'A h:mm');
+ assert.equal(t2.format('HH:mm'), t1.format('HH:mm'),
+ 'meridiem at ' + t1.format('HH:mm'));
+ }
+ }
+ });
+
+ test('date format correctness', function (assert) {
+ var data, tokens;
+ data = moment.localeData()._longDateFormat;
+ tokens = objectKeys(data);
+ each(tokens, function (srchToken) {
+ // Check each format string to make sure it does not contain any
+ // tokens that need to be expanded.
+ each(tokens, function (baseToken) {
+ // strip escaped sequences
+ var format = data[baseToken].replace(/(\[[^\]]*\])/g, '');
+ assert.equal(false, !!~format.indexOf(srchToken),
+ 'contains ' + srchToken + ' in ' + baseToken);
+ });
+ });
+ });
+
+ test('month parsing correctness', function (assert) {
+ var i, m;
+
+ if (locale === 'tr') {
+ // I can't fix it :(
+ expect(0);
+ return;
+ }
+ function tester(format) {
+ var r;
+ r = moment(m.format(format), format);
+ assert.equal(r.month(), m.month(), 'month ' + i + ' fmt ' + format);
+ r = moment(m.format(format).toLocaleUpperCase(), format);
+ assert.equal(r.month(), m.month(), 'month ' + i + ' fmt ' + format + ' upper');
+ r = moment(m.format(format).toLocaleLowerCase(), format);
+ assert.equal(r.month(), m.month(), 'month ' + i + ' fmt ' + format + ' lower');
+
+ r = moment(m.format(format), format, true);
+ assert.equal(r.month(), m.month(), 'month ' + i + ' fmt ' + format + ' strict');
+ r = moment(m.format(format).toLocaleUpperCase(), format, true);
+ assert.equal(r.month(), m.month(), 'month ' + i + ' fmt ' + format + ' upper strict');
+ r = moment(m.format(format).toLocaleLowerCase(), format, true);
+ assert.equal(r.month(), m.month(), 'month ' + i + ' fmt ' + format + ' lower strict');
+ }
+
+ for (i = 0; i < 12; ++i) {
+ m = moment([2015, i, 15, 18]);
+ tester('MMM');
+ tester('MMM.');
+ tester('MMMM');
+ tester('MMMM.');
+ }
+ });
+
+ test('weekday parsing correctness', function (assert) {
+ var i, m;
+
+ if (locale === 'tr' || locale === 'az') {
+ // There is a lower-case letter (ı), that converted to upper then
+ // lower changes to i
+ expect(0);
+ return;
+ }
+ function tester(format) {
+ var r, baseMsg = 'weekday ' + m.weekday() + ' fmt ' + format;
+ r = moment(m.format(format), format);
+ assert.equal(r.weekday(), m.weekday(), baseMsg);
+ r = moment(m.format(format).toLocaleUpperCase(), format);
+ assert.equal(r.weekday(), m.weekday(), baseMsg + ' upper');
+ r = moment(m.format(format).toLocaleLowerCase(), format);
+ assert.equal(r.weekday(), m.weekday(), baseMsg + ' lower');
+
+ r = moment(m.format(format), format, true);
+ assert.equal(r.weekday(), m.weekday(), baseMsg + ' strict');
+ r = moment(m.format(format).toLocaleUpperCase(), format, true);
+ assert.equal(r.weekday(), m.weekday(), baseMsg + ' upper strict');
+ r = moment(m.format(format).toLocaleLowerCase(), format, true);
+ assert.equal(r.weekday(), m.weekday(), baseMsg + ' lower strict');
+ }
+
+ for (i = 0; i < 7; ++i) {
+ m = moment.utc([2015, i, 15, 18]);
+ tester('dd');
+ tester('ddd');
+ tester('dddd');
+ }
+ });
+ }
+
+ function setupDeprecationHandler(test, moment, scope) {
+ test._expectedDeprecations = null;
+ test._observedDeprecations = null;
+ test._oldSupress = moment.suppressDeprecationWarnings;
+ moment.suppressDeprecationWarnings = true;
+ test.expectedDeprecations = function () {
+ test._expectedDeprecations = arguments;
+ test._observedDeprecations = [];
+ };
+ moment.deprecationHandler = function (name, msg) {
+ var deprecationId = matchedDeprecation(name, msg, test._expectedDeprecations);
+ if (deprecationId === -1) {
+ throw new Error('Unexpected deprecation thrown name=' +
+ name + ' msg=' + msg);
+ }
+ test._observedDeprecations[deprecationId] = 1;
+ };
+ }
+
+ function teardownDeprecationHandler(test, moment, scope) {
+ moment.suppressDeprecationWarnings = test._oldSupress;
+
+ if (test._expectedDeprecations != null) {
+ var missedDeprecations = [];
+ each(test._expectedDeprecations, function (deprecationPattern, id) {
+ if (test._observedDeprecations[id] !== 1) {
+ missedDeprecations.push(deprecationPattern);
+ }
+ });
+ if (missedDeprecations.length !== 0) {
+ throw new Error('Expected deprecation warnings did not happen: ' +
+ missedDeprecations.join(' '));
+ }
+ }
+ }
+
+ function matchedDeprecation(name, msg, deprecations) {
+ if (deprecations == null) {
+ return -1;
+ }
+ for (var i = 0; i < deprecations.length; ++i) {
+ if (name != null && name === deprecations[i]) {
+ return i;
+ }
+ if (msg != null && msg.substring(0, deprecations[i].length) === deprecations[i]) {
+ return i;
+ }
+ }
+ return -1;
+ }
/*global QUnit:false*/
@@ -20969,11 +29418,13 @@
moment.createFromInputFallback = function (config) {
throw new Error('input not handled by moment: ' + config._i);
};
+ setupDeprecationHandler(test, moment, 'core');
if (lifecycle && lifecycle.setup) {
lifecycle.setup();
}
},
teardown : function () {
+ teardownDeprecationHandler(test, moment, 'core');
if (lifecycle && lifecycle.teardown) {
lifecycle.teardown();
}
@@ -20988,17 +29439,20 @@
moment.createFromInputFallback = function (config) {
throw new Error('input not handled by moment: ' + config._i);
};
+ setupDeprecationHandler(test, moment, 'locale');
if (lifecycle && lifecycle.setup) {
lifecycle.setup();
}
},
teardown : function () {
moment.locale('en');
+ teardownDeprecationHandler(test, moment, 'locale');
if (lifecycle && lifecycle.teardown) {
lifecycle.teardown();
}
}
});
+ defineCommonLocaleTests(name, -1, -1);
}
localeModule('me');
@@ -21155,14 +29609,14 @@
});
test('calendar day', function (assert) {
- var a = moment().hours(2).minutes(0).seconds(0);
-
- assert.equal(moment(a).calendar(), 'danas u 2:00', 'today at the same time');
- assert.equal(moment(a).add({m: 25}).calendar(), 'danas u 2:25', 'Now plus 25 min');
- assert.equal(moment(a).add({h: 1}).calendar(), 'danas u 3:00', 'Now plus 1 hour');
- assert.equal(moment(a).add({d: 1}).calendar(), 'sjutra u 2:00', 'tomorrow at the same time');
- assert.equal(moment(a).subtract({h: 1}).calendar(), 'danas u 1:00', 'Now minus 1 hour');
- assert.equal(moment(a).subtract({d: 1}).calendar(), 'juče u 2:00', 'yesterday at the same time');
+ var a = moment().hours(12).minutes(0).seconds(0);
+
+ assert.equal(moment(a).calendar(), 'danas u 12:00', 'today at the same time');
+ assert.equal(moment(a).add({m: 25}).calendar(), 'danas u 12:25', 'Now plus 25 min');
+ assert.equal(moment(a).add({h: 1}).calendar(), 'danas u 13:00', 'Now plus 1 hour');
+ assert.equal(moment(a).add({d: 1}).calendar(), 'sjutra u 12:00', 'tomorrow at the same time');
+ assert.equal(moment(a).subtract({h: 1}).calendar(), 'danas u 11:00', 'Now minus 1 hour');
+ assert.equal(moment(a).subtract({d: 1}).calendar(), 'juče u 12:00', 'yesterday at the same time');
});
test('calendar next week', function (assert) {
@@ -21238,67 +29692,6 @@
// Monday is the first day of the week.
// The week that contains Jan 1st is the first week of the year.
- test('weeks year starting sunday', function (assert) {
- assert.equal(moment([2011, 11, 26]).week(), 1, 'Dec 26 2011 should be week 1');
- assert.equal(moment([2012, 0, 1]).week(), 1, 'Jan 1 2012 should be week 1');
- assert.equal(moment([2012, 0, 2]).week(), 2, 'Jan 2 2012 should be week 2');
- assert.equal(moment([2012, 0, 8]).week(), 2, 'Jan 8 2012 should be week 2');
- assert.equal(moment([2012, 0, 9]).week(), 3, 'Jan 9 2012 should be week 3');
- });
-
- test('weeks year starting monday', function (assert) {
- assert.equal(moment([2007, 0, 1]).week(), 1, 'Jan 1 2007 should be week 1');
- assert.equal(moment([2007, 0, 7]).week(), 1, 'Jan 7 2007 should be week 1');
- assert.equal(moment([2007, 0, 8]).week(), 2, 'Jan 8 2007 should be week 2');
- assert.equal(moment([2007, 0, 14]).week(), 2, 'Jan 14 2007 should be week 2');
- assert.equal(moment([2007, 0, 15]).week(), 3, 'Jan 15 2007 should be week 3');
- });
-
- test('weeks year starting tuesday', function (assert) {
- assert.equal(moment([2007, 11, 31]).week(), 1, 'Dec 31 2007 should be week 1');
- assert.equal(moment([2008, 0, 1]).week(), 1, 'Jan 1 2008 should be week 1');
- assert.equal(moment([2008, 0, 6]).week(), 1, 'Jan 6 2008 should be week 1');
- assert.equal(moment([2008, 0, 7]).week(), 2, 'Jan 7 2008 should be week 2');
- assert.equal(moment([2008, 0, 13]).week(), 2, 'Jan 13 2008 should be week 2');
- assert.equal(moment([2008, 0, 14]).week(), 3, 'Jan 14 2008 should be week 3');
- });
-
- test('weeks year starting wednesday', function (assert) {
- assert.equal(moment([2002, 11, 30]).week(), 1, 'Dec 30 2002 should be week 1');
- assert.equal(moment([2003, 0, 1]).week(), 1, 'Jan 1 2003 should be week 1');
- assert.equal(moment([2003, 0, 5]).week(), 1, 'Jan 5 2003 should be week 1');
- assert.equal(moment([2003, 0, 6]).week(), 2, 'Jan 6 2003 should be week 2');
- assert.equal(moment([2003, 0, 12]).week(), 2, 'Jan 12 2003 should be week 2');
- assert.equal(moment([2003, 0, 13]).week(), 3, 'Jan 13 2003 should be week 3');
- });
-
- test('weeks year starting thursday', function (assert) {
- assert.equal(moment([2008, 11, 29]).week(), 1, 'Dec 29 2008 should be week 1');
- assert.equal(moment([2009, 0, 1]).week(), 1, 'Jan 1 2009 should be week 1');
- assert.equal(moment([2009, 0, 4]).week(), 1, 'Jan 4 2009 should be week 1');
- assert.equal(moment([2009, 0, 5]).week(), 2, 'Jan 5 2009 should be week 2');
- assert.equal(moment([2009, 0, 11]).week(), 2, 'Jan 11 2009 should be week 2');
- assert.equal(moment([2009, 0, 12]).week(), 3, 'Jan 12 2009 should be week 3');
- });
-
- test('weeks year starting friday', function (assert) {
- assert.equal(moment([2009, 11, 28]).week(), 1, 'Dec 28 2009 should be week 1');
- assert.equal(moment([2010, 0, 1]).week(), 1, 'Jan 1 2010 should be week 1');
- assert.equal(moment([2010, 0, 3]).week(), 1, 'Jan 3 2010 should be week 1');
- assert.equal(moment([2010, 0, 4]).week(), 2, 'Jan 4 2010 should be week 2');
- assert.equal(moment([2010, 0, 10]).week(), 2, 'Jan 10 2010 should be week 2');
- assert.equal(moment([2010, 0, 11]).week(), 3, 'Jan 11 2010 should be week 3');
- });
-
- test('weeks year starting saturday', function (assert) {
- assert.equal(moment([2010, 11, 27]).week(), 1, 'Dec 27 2010 should be week 1');
- assert.equal(moment([2011, 0, 1]).week(), 1, 'Jan 1 2011 should be week 1');
- assert.equal(moment([2011, 0, 2]).week(), 1, 'Jan 2 2011 should be week 1');
- assert.equal(moment([2011, 0, 3]).week(), 2, 'Jan 3 2011 should be week 2');
- assert.equal(moment([2011, 0, 9]).week(), 2, 'Jan 9 2011 should be week 2');
- assert.equal(moment([2011, 0, 10]).week(), 3, 'Jan 10 2011 should be week 3');
- });
-
test('weeks year starting sunday formatted', function (assert) {
assert.equal(moment([2011, 11, 26]).format('w ww wo'), '1 01 1.', 'Dec 26 2011 should be week 1');
assert.equal(moment([2012, 0, 1]).format('w ww wo'), '1 01 1.', 'Jan 1 2012 should be week 1');
@@ -21307,42 +29700,6 @@
assert.equal(moment([2012, 0, 9]).format('w ww wo'), '3 03 3.', 'Jan 9 2012 should be week 3');
});
- test('lenient ordinal parsing', function (assert) {
- var i, ordinalStr, testMoment;
- for (i = 1; i <= 31; ++i) {
- ordinalStr = moment([2014, 0, i]).format('YYYY MM Do');
- testMoment = moment(ordinalStr, 'YYYY MM Do');
- assert.equal(testMoment.year(), 2014,
- 'lenient ordinal parsing ' + i + ' year check');
- assert.equal(testMoment.month(), 0,
- 'lenient ordinal parsing ' + i + ' month check');
- assert.equal(testMoment.date(), i,
- 'lenient ordinal parsing ' + i + ' date check');
- }
- });
-
- test('lenient ordinal parsing of number', function (assert) {
- var i, testMoment;
- for (i = 1; i <= 31; ++i) {
- testMoment = moment('2014 01 ' + i, 'YYYY MM Do');
- assert.equal(testMoment.year(), 2014,
- 'lenient ordinal parsing of number ' + i + ' year check');
- assert.equal(testMoment.month(), 0,
- 'lenient ordinal parsing of number ' + i + ' month check');
- assert.equal(testMoment.date(), i,
- 'lenient ordinal parsing of number ' + i + ' date check');
- }
- });
-
- test('strict ordinal parsing', function (assert) {
- var i, ordinalStr, testMoment;
- for (i = 1; i <= 31; ++i) {
- ordinalStr = moment([2014, 0, i]).format('YYYY MM Do');
- testMoment = moment(ordinalStr, 'YYYY MM Do', true);
- assert.ok(testMoment.isValid(), 'strict ordinal parsing ' + i);
- }
- });
-
}));
;(function (global, factory) {
@@ -21351,6 +29708,224 @@
typeof define === 'function' && define.amd ? define(['../../moment'], factory) :
factory(global.moment)
}(this, function (moment) { 'use strict';
+
+ function each(array, callback) {
+ var i;
+ for (i = 0; i < array.length; i++) {
+ callback(array[i], i, array);
+ }
+ }
+
+ function objectKeys(obj) {
+ if (Object.keys) {
+ return Object.keys(obj);
+ } else {
+ // IE8
+ var res = [], i;
+ for (i in obj) {
+ if (obj.hasOwnProperty(i)) {
+ res.push(i);
+ }
+ }
+ return res;
+ }
+ }
+
+ // Pick the first defined of two or three arguments.
+ function defaults(a, b, c) {
+ if (a != null) {
+ return a;
+ }
+ if (b != null) {
+ return b;
+ }
+ return c;
+ }
+
+ function defineCommonLocaleTests(locale, options) {
+ test('lenient ordinal parsing', function (assert) {
+ var i, ordinalStr, testMoment;
+ for (i = 1; i <= 31; ++i) {
+ ordinalStr = moment([2014, 0, i]).format('YYYY MM Do');
+ testMoment = moment(ordinalStr, 'YYYY MM Do');
+ assert.equal(testMoment.year(), 2014,
+ 'lenient ordinal parsing ' + i + ' year check');
+ assert.equal(testMoment.month(), 0,
+ 'lenient ordinal parsing ' + i + ' month check');
+ assert.equal(testMoment.date(), i,
+ 'lenient ordinal parsing ' + i + ' date check');
+ }
+ });
+
+ test('lenient ordinal parsing of number', function (assert) {
+ var i, testMoment;
+ for (i = 1; i <= 31; ++i) {
+ testMoment = moment('2014 01 ' + i, 'YYYY MM Do');
+ assert.equal(testMoment.year(), 2014,
+ 'lenient ordinal parsing of number ' + i + ' year check');
+ assert.equal(testMoment.month(), 0,
+ 'lenient ordinal parsing of number ' + i + ' month check');
+ assert.equal(testMoment.date(), i,
+ 'lenient ordinal parsing of number ' + i + ' date check');
+ }
+ });
+
+ test('strict ordinal parsing', function (assert) {
+ var i, ordinalStr, testMoment;
+ for (i = 1; i <= 31; ++i) {
+ ordinalStr = moment([2014, 0, i]).format('YYYY MM Do');
+ testMoment = moment(ordinalStr, 'YYYY MM Do', true);
+ assert.ok(testMoment.isValid(), 'strict ordinal parsing ' + i);
+ }
+ });
+
+ test('meridiem invariant', function (assert) {
+ var h, m, t1, t2;
+ for (h = 0; h < 24; ++h) {
+ for (m = 0; m < 60; m += 15) {
+ t1 = moment.utc([2000, 0, 1, h, m]);
+ t2 = moment.utc(t1.format('A h:mm'), 'A h:mm');
+ assert.equal(t2.format('HH:mm'), t1.format('HH:mm'),
+ 'meridiem at ' + t1.format('HH:mm'));
+ }
+ }
+ });
+
+ test('date format correctness', function (assert) {
+ var data, tokens;
+ data = moment.localeData()._longDateFormat;
+ tokens = objectKeys(data);
+ each(tokens, function (srchToken) {
+ // Check each format string to make sure it does not contain any
+ // tokens that need to be expanded.
+ each(tokens, function (baseToken) {
+ // strip escaped sequences
+ var format = data[baseToken].replace(/(\[[^\]]*\])/g, '');
+ assert.equal(false, !!~format.indexOf(srchToken),
+ 'contains ' + srchToken + ' in ' + baseToken);
+ });
+ });
+ });
+
+ test('month parsing correctness', function (assert) {
+ var i, m;
+
+ if (locale === 'tr') {
+ // I can't fix it :(
+ expect(0);
+ return;
+ }
+ function tester(format) {
+ var r;
+ r = moment(m.format(format), format);
+ assert.equal(r.month(), m.month(), 'month ' + i + ' fmt ' + format);
+ r = moment(m.format(format).toLocaleUpperCase(), format);
+ assert.equal(r.month(), m.month(), 'month ' + i + ' fmt ' + format + ' upper');
+ r = moment(m.format(format).toLocaleLowerCase(), format);
+ assert.equal(r.month(), m.month(), 'month ' + i + ' fmt ' + format + ' lower');
+
+ r = moment(m.format(format), format, true);
+ assert.equal(r.month(), m.month(), 'month ' + i + ' fmt ' + format + ' strict');
+ r = moment(m.format(format).toLocaleUpperCase(), format, true);
+ assert.equal(r.month(), m.month(), 'month ' + i + ' fmt ' + format + ' upper strict');
+ r = moment(m.format(format).toLocaleLowerCase(), format, true);
+ assert.equal(r.month(), m.month(), 'month ' + i + ' fmt ' + format + ' lower strict');
+ }
+
+ for (i = 0; i < 12; ++i) {
+ m = moment([2015, i, 15, 18]);
+ tester('MMM');
+ tester('MMM.');
+ tester('MMMM');
+ tester('MMMM.');
+ }
+ });
+
+ test('weekday parsing correctness', function (assert) {
+ var i, m;
+
+ if (locale === 'tr' || locale === 'az') {
+ // There is a lower-case letter (ı), that converted to upper then
+ // lower changes to i
+ expect(0);
+ return;
+ }
+ function tester(format) {
+ var r, baseMsg = 'weekday ' + m.weekday() + ' fmt ' + format;
+ r = moment(m.format(format), format);
+ assert.equal(r.weekday(), m.weekday(), baseMsg);
+ r = moment(m.format(format).toLocaleUpperCase(), format);
+ assert.equal(r.weekday(), m.weekday(), baseMsg + ' upper');
+ r = moment(m.format(format).toLocaleLowerCase(), format);
+ assert.equal(r.weekday(), m.weekday(), baseMsg + ' lower');
+
+ r = moment(m.format(format), format, true);
+ assert.equal(r.weekday(), m.weekday(), baseMsg + ' strict');
+ r = moment(m.format(format).toLocaleUpperCase(), format, true);
+ assert.equal(r.weekday(), m.weekday(), baseMsg + ' upper strict');
+ r = moment(m.format(format).toLocaleLowerCase(), format, true);
+ assert.equal(r.weekday(), m.weekday(), baseMsg + ' lower strict');
+ }
+
+ for (i = 0; i < 7; ++i) {
+ m = moment.utc([2015, i, 15, 18]);
+ tester('dd');
+ tester('ddd');
+ tester('dddd');
+ }
+ });
+ }
+
+ function setupDeprecationHandler(test, moment, scope) {
+ test._expectedDeprecations = null;
+ test._observedDeprecations = null;
+ test._oldSupress = moment.suppressDeprecationWarnings;
+ moment.suppressDeprecationWarnings = true;
+ test.expectedDeprecations = function () {
+ test._expectedDeprecations = arguments;
+ test._observedDeprecations = [];
+ };
+ moment.deprecationHandler = function (name, msg) {
+ var deprecationId = matchedDeprecation(name, msg, test._expectedDeprecations);
+ if (deprecationId === -1) {
+ throw new Error('Unexpected deprecation thrown name=' +
+ name + ' msg=' + msg);
+ }
+ test._observedDeprecations[deprecationId] = 1;
+ };
+ }
+
+ function teardownDeprecationHandler(test, moment, scope) {
+ moment.suppressDeprecationWarnings = test._oldSupress;
+
+ if (test._expectedDeprecations != null) {
+ var missedDeprecations = [];
+ each(test._expectedDeprecations, function (deprecationPattern, id) {
+ if (test._observedDeprecations[id] !== 1) {
+ missedDeprecations.push(deprecationPattern);
+ }
+ });
+ if (missedDeprecations.length !== 0) {
+ throw new Error('Expected deprecation warnings did not happen: ' +
+ missedDeprecations.join(' '));
+ }
+ }
+ }
+
+ function matchedDeprecation(name, msg, deprecations) {
+ if (deprecations == null) {
+ return -1;
+ }
+ for (var i = 0; i < deprecations.length; ++i) {
+ if (name != null && name === deprecations[i]) {
+ return i;
+ }
+ if (msg != null && msg.substring(0, deprecations[i].length) === deprecations[i]) {
+ return i;
+ }
+ }
+ return -1;
+ }
/*global QUnit:false*/
@@ -21365,11 +29940,13 @@
moment.createFromInputFallback = function (config) {
throw new Error('input not handled by moment: ' + config._i);
};
+ setupDeprecationHandler(test, moment, 'core');
if (lifecycle && lifecycle.setup) {
lifecycle.setup();
}
},
teardown : function () {
+ teardownDeprecationHandler(test, moment, 'core');
if (lifecycle && lifecycle.teardown) {
lifecycle.teardown();
}
@@ -21384,17 +29961,20 @@
moment.createFromInputFallback = function (config) {
throw new Error('input not handled by moment: ' + config._i);
};
+ setupDeprecationHandler(test, moment, 'locale');
if (lifecycle && lifecycle.setup) {
lifecycle.setup();
}
},
teardown : function () {
moment.locale('en');
+ teardownDeprecationHandler(test, moment, 'locale');
if (lifecycle && lifecycle.teardown) {
lifecycle.teardown();
}
}
});
+ defineCommonLocaleTests(name, -1, -1);
}
localeModule('mk');
@@ -21548,14 +30128,14 @@
});
test('calendar day', function (assert) {
- var a = moment().hours(2).minutes(0).seconds(0);
-
- assert.equal(moment(a).calendar(), 'Денес во 2:00', 'today at the same time');
- assert.equal(moment(a).add({m: 25}).calendar(), 'Денес во 2:25', 'Now plus 25 min');
- assert.equal(moment(a).add({h: 1}).calendar(), 'Денес во 3:00', 'Now plus 1 hour');
- assert.equal(moment(a).add({d: 1}).calendar(), 'Утре во 2:00', 'tomorrow at the same time');
- assert.equal(moment(a).subtract({h: 1}).calendar(), 'Денес во 1:00', 'Now minus 1 hour');
- assert.equal(moment(a).subtract({d: 1}).calendar(), 'Вчера во 2:00', 'yesterday at the same time');
+ var a = moment().hours(12).minutes(0).seconds(0);
+
+ assert.equal(moment(a).calendar(), 'Денес во 12:00', 'today at the same time');
+ assert.equal(moment(a).add({m: 25}).calendar(), 'Денес во 12:25', 'Now plus 25 min');
+ assert.equal(moment(a).add({h: 1}).calendar(), 'Денес во 13:00', 'Now plus 1 hour');
+ assert.equal(moment(a).add({d: 1}).calendar(), 'Утре во 12:00', 'tomorrow at the same time');
+ assert.equal(moment(a).subtract({h: 1}).calendar(), 'Денес во 11:00', 'Now minus 1 hour');
+ assert.equal(moment(a).subtract({d: 1}).calendar(), 'Вчера во 12:00', 'yesterday at the same time');
});
test('calendar next week', function (assert) {
@@ -21611,67 +30191,6 @@
assert.equal(weeksFromNow.calendar(), weeksFromNow.format('L'), 'in 2 weeks');
});
- test('weeks year starting sunday', function (assert) {
- assert.equal(moment([2011, 11, 26]).week(), 1, 'Dec 26 2011 should be week 1');
- assert.equal(moment([2012, 0, 1]).week(), 1, 'Jan 1 2012 should be week 1');
- assert.equal(moment([2012, 0, 2]).week(), 2, 'Jan 2 2012 should be week 2');
- assert.equal(moment([2012, 0, 8]).week(), 2, 'Jan 8 2012 should be week 2');
- assert.equal(moment([2012, 0, 9]).week(), 3, 'Jan 9 2012 should be week 3');
- });
-
- test('weeks year starting monday', function (assert) {
- assert.equal(moment([2007, 0, 1]).week(), 1, 'Jan 1 2007 should be week 1');
- assert.equal(moment([2007, 0, 7]).week(), 1, 'Jan 7 2007 should be week 1');
- assert.equal(moment([2007, 0, 8]).week(), 2, 'Jan 8 2007 should be week 2');
- assert.equal(moment([2007, 0, 14]).week(), 2, 'Jan 14 2007 should be week 2');
- assert.equal(moment([2007, 0, 15]).week(), 3, 'Jan 15 2007 should be week 3');
- });
-
- test('weeks year starting tuesday', function (assert) {
- assert.equal(moment([2007, 11, 31]).week(), 1, 'Dec 31 2007 should be week 1');
- assert.equal(moment([2008, 0, 1]).week(), 1, 'Jan 1 2008 should be week 1');
- assert.equal(moment([2008, 0, 6]).week(), 1, 'Jan 6 2008 should be week 1');
- assert.equal(moment([2008, 0, 7]).week(), 2, 'Jan 7 2008 should be week 2');
- assert.equal(moment([2008, 0, 13]).week(), 2, 'Jan 13 2008 should be week 2');
- assert.equal(moment([2008, 0, 14]).week(), 3, 'Jan 14 2008 should be week 3');
- });
-
- test('weeks year starting wednesday', function (assert) {
- assert.equal(moment([2002, 11, 30]).week(), 1, 'Dec 30 2002 should be week 1');
- assert.equal(moment([2003, 0, 1]).week(), 1, 'Jan 1 2003 should be week 1');
- assert.equal(moment([2003, 0, 5]).week(), 1, 'Jan 5 2003 should be week 1');
- assert.equal(moment([2003, 0, 6]).week(), 2, 'Jan 6 2003 should be week 2');
- assert.equal(moment([2003, 0, 12]).week(), 2, 'Jan 12 2003 should be week 2');
- assert.equal(moment([2003, 0, 13]).week(), 3, 'Jan 13 2003 should be week 3');
- });
-
- test('weeks year starting thursday', function (assert) {
- assert.equal(moment([2008, 11, 29]).week(), 1, 'Dec 29 2008 should be week 1');
- assert.equal(moment([2009, 0, 1]).week(), 1, 'Jan 1 2009 should be week 1');
- assert.equal(moment([2009, 0, 4]).week(), 1, 'Jan 4 2009 should be week 1');
- assert.equal(moment([2009, 0, 5]).week(), 2, 'Jan 5 2009 should be week 2');
- assert.equal(moment([2009, 0, 11]).week(), 2, 'Jan 11 2009 should be week 2');
- assert.equal(moment([2009, 0, 12]).week(), 3, 'Jan 12 2009 should be week 3');
- });
-
- test('weeks year starting friday', function (assert) {
- assert.equal(moment([2009, 11, 28]).week(), 1, 'Dec 28 2009 should be week 1');
- assert.equal(moment([2010, 0, 1]).week(), 1, 'Jan 1 2010 should be week 1');
- assert.equal(moment([2010, 0, 3]).week(), 1, 'Jan 3 2010 should be week 1');
- assert.equal(moment([2010, 0, 4]).week(), 2, 'Jan 4 2010 should be week 2');
- assert.equal(moment([2010, 0, 10]).week(), 2, 'Jan 10 2010 should be week 2');
- assert.equal(moment([2010, 0, 11]).week(), 3, 'Jan 11 2010 should be week 3');
- });
-
- test('weeks year starting saturday', function (assert) {
- assert.equal(moment([2010, 11, 27]).week(), 1, 'Dec 27 2010 should be week 1');
- assert.equal(moment([2011, 0, 1]).week(), 1, 'Jan 1 2011 should be week 1');
- assert.equal(moment([2011, 0, 2]).week(), 1, 'Jan 2 2011 should be week 1');
- assert.equal(moment([2011, 0, 3]).week(), 2, 'Jan 3 2011 should be week 2');
- assert.equal(moment([2011, 0, 9]).week(), 2, 'Jan 9 2011 should be week 2');
- assert.equal(moment([2011, 0, 10]).week(), 3, 'Jan 10 2011 should be week 3');
- });
-
test('weeks year starting sunday formatted', function (assert) {
assert.equal(moment([2011, 11, 26]).format('w ww wo'), '1 01 1-ви', 'Dec 26 2011 should be week 1');
assert.equal(moment([2012, 0, 1]).format('w ww wo'), '1 01 1-ви', 'Jan 1 2012 should be week 1');
@@ -21680,42 +30199,6 @@
assert.equal(moment([2012, 0, 9]).format('w ww wo'), '3 03 3-ти', 'Jan 9 2012 should be week 3');
});
- test('lenient ordinal parsing', function (assert) {
- var i, ordinalStr, testMoment;
- for (i = 1; i <= 31; ++i) {
- ordinalStr = moment([2014, 0, i]).format('YYYY MM Do');
- testMoment = moment(ordinalStr, 'YYYY MM Do');
- assert.equal(testMoment.year(), 2014,
- 'lenient ordinal parsing ' + i + ' year check');
- assert.equal(testMoment.month(), 0,
- 'lenient ordinal parsing ' + i + ' month check');
- assert.equal(testMoment.date(), i,
- 'lenient ordinal parsing ' + i + ' date check');
- }
- });
-
- test('lenient ordinal parsing of number', function (assert) {
- var i, testMoment;
- for (i = 1; i <= 31; ++i) {
- testMoment = moment('2014 01 ' + i, 'YYYY MM Do');
- assert.equal(testMoment.year(), 2014,
- 'lenient ordinal parsing of number ' + i + ' year check');
- assert.equal(testMoment.month(), 0,
- 'lenient ordinal parsing of number ' + i + ' month check');
- assert.equal(testMoment.date(), i,
- 'lenient ordinal parsing of number ' + i + ' date check');
- }
- });
-
- test('strict ordinal parsing', function (assert) {
- var i, ordinalStr, testMoment;
- for (i = 1; i <= 31; ++i) {
- ordinalStr = moment([2014, 0, i]).format('YYYY MM Do');
- testMoment = moment(ordinalStr, 'YYYY MM Do', true);
- assert.ok(testMoment.isValid(), 'strict ordinal parsing ' + i);
- }
- });
-
}));
;(function (global, factory) {
@@ -21724,6 +30207,224 @@
typeof define === 'function' && define.amd ? define(['../../moment'], factory) :
factory(global.moment)
}(this, function (moment) { 'use strict';
+
+ function each(array, callback) {
+ var i;
+ for (i = 0; i < array.length; i++) {
+ callback(array[i], i, array);
+ }
+ }
+
+ function objectKeys(obj) {
+ if (Object.keys) {
+ return Object.keys(obj);
+ } else {
+ // IE8
+ var res = [], i;
+ for (i in obj) {
+ if (obj.hasOwnProperty(i)) {
+ res.push(i);
+ }
+ }
+ return res;
+ }
+ }
+
+ // Pick the first defined of two or three arguments.
+ function defaults(a, b, c) {
+ if (a != null) {
+ return a;
+ }
+ if (b != null) {
+ return b;
+ }
+ return c;
+ }
+
+ function defineCommonLocaleTests(locale, options) {
+ test('lenient ordinal parsing', function (assert) {
+ var i, ordinalStr, testMoment;
+ for (i = 1; i <= 31; ++i) {
+ ordinalStr = moment([2014, 0, i]).format('YYYY MM Do');
+ testMoment = moment(ordinalStr, 'YYYY MM Do');
+ assert.equal(testMoment.year(), 2014,
+ 'lenient ordinal parsing ' + i + ' year check');
+ assert.equal(testMoment.month(), 0,
+ 'lenient ordinal parsing ' + i + ' month check');
+ assert.equal(testMoment.date(), i,
+ 'lenient ordinal parsing ' + i + ' date check');
+ }
+ });
+
+ test('lenient ordinal parsing of number', function (assert) {
+ var i, testMoment;
+ for (i = 1; i <= 31; ++i) {
+ testMoment = moment('2014 01 ' + i, 'YYYY MM Do');
+ assert.equal(testMoment.year(), 2014,
+ 'lenient ordinal parsing of number ' + i + ' year check');
+ assert.equal(testMoment.month(), 0,
+ 'lenient ordinal parsing of number ' + i + ' month check');
+ assert.equal(testMoment.date(), i,
+ 'lenient ordinal parsing of number ' + i + ' date check');
+ }
+ });
+
+ test('strict ordinal parsing', function (assert) {
+ var i, ordinalStr, testMoment;
+ for (i = 1; i <= 31; ++i) {
+ ordinalStr = moment([2014, 0, i]).format('YYYY MM Do');
+ testMoment = moment(ordinalStr, 'YYYY MM Do', true);
+ assert.ok(testMoment.isValid(), 'strict ordinal parsing ' + i);
+ }
+ });
+
+ test('meridiem invariant', function (assert) {
+ var h, m, t1, t2;
+ for (h = 0; h < 24; ++h) {
+ for (m = 0; m < 60; m += 15) {
+ t1 = moment.utc([2000, 0, 1, h, m]);
+ t2 = moment.utc(t1.format('A h:mm'), 'A h:mm');
+ assert.equal(t2.format('HH:mm'), t1.format('HH:mm'),
+ 'meridiem at ' + t1.format('HH:mm'));
+ }
+ }
+ });
+
+ test('date format correctness', function (assert) {
+ var data, tokens;
+ data = moment.localeData()._longDateFormat;
+ tokens = objectKeys(data);
+ each(tokens, function (srchToken) {
+ // Check each format string to make sure it does not contain any
+ // tokens that need to be expanded.
+ each(tokens, function (baseToken) {
+ // strip escaped sequences
+ var format = data[baseToken].replace(/(\[[^\]]*\])/g, '');
+ assert.equal(false, !!~format.indexOf(srchToken),
+ 'contains ' + srchToken + ' in ' + baseToken);
+ });
+ });
+ });
+
+ test('month parsing correctness', function (assert) {
+ var i, m;
+
+ if (locale === 'tr') {
+ // I can't fix it :(
+ expect(0);
+ return;
+ }
+ function tester(format) {
+ var r;
+ r = moment(m.format(format), format);
+ assert.equal(r.month(), m.month(), 'month ' + i + ' fmt ' + format);
+ r = moment(m.format(format).toLocaleUpperCase(), format);
+ assert.equal(r.month(), m.month(), 'month ' + i + ' fmt ' + format + ' upper');
+ r = moment(m.format(format).toLocaleLowerCase(), format);
+ assert.equal(r.month(), m.month(), 'month ' + i + ' fmt ' + format + ' lower');
+
+ r = moment(m.format(format), format, true);
+ assert.equal(r.month(), m.month(), 'month ' + i + ' fmt ' + format + ' strict');
+ r = moment(m.format(format).toLocaleUpperCase(), format, true);
+ assert.equal(r.month(), m.month(), 'month ' + i + ' fmt ' + format + ' upper strict');
+ r = moment(m.format(format).toLocaleLowerCase(), format, true);
+ assert.equal(r.month(), m.month(), 'month ' + i + ' fmt ' + format + ' lower strict');
+ }
+
+ for (i = 0; i < 12; ++i) {
+ m = moment([2015, i, 15, 18]);
+ tester('MMM');
+ tester('MMM.');
+ tester('MMMM');
+ tester('MMMM.');
+ }
+ });
+
+ test('weekday parsing correctness', function (assert) {
+ var i, m;
+
+ if (locale === 'tr' || locale === 'az') {
+ // There is a lower-case letter (ı), that converted to upper then
+ // lower changes to i
+ expect(0);
+ return;
+ }
+ function tester(format) {
+ var r, baseMsg = 'weekday ' + m.weekday() + ' fmt ' + format;
+ r = moment(m.format(format), format);
+ assert.equal(r.weekday(), m.weekday(), baseMsg);
+ r = moment(m.format(format).toLocaleUpperCase(), format);
+ assert.equal(r.weekday(), m.weekday(), baseMsg + ' upper');
+ r = moment(m.format(format).toLocaleLowerCase(), format);
+ assert.equal(r.weekday(), m.weekday(), baseMsg + ' lower');
+
+ r = moment(m.format(format), format, true);
+ assert.equal(r.weekday(), m.weekday(), baseMsg + ' strict');
+ r = moment(m.format(format).toLocaleUpperCase(), format, true);
+ assert.equal(r.weekday(), m.weekday(), baseMsg + ' upper strict');
+ r = moment(m.format(format).toLocaleLowerCase(), format, true);
+ assert.equal(r.weekday(), m.weekday(), baseMsg + ' lower strict');
+ }
+
+ for (i = 0; i < 7; ++i) {
+ m = moment.utc([2015, i, 15, 18]);
+ tester('dd');
+ tester('ddd');
+ tester('dddd');
+ }
+ });
+ }
+
+ function setupDeprecationHandler(test, moment, scope) {
+ test._expectedDeprecations = null;
+ test._observedDeprecations = null;
+ test._oldSupress = moment.suppressDeprecationWarnings;
+ moment.suppressDeprecationWarnings = true;
+ test.expectedDeprecations = function () {
+ test._expectedDeprecations = arguments;
+ test._observedDeprecations = [];
+ };
+ moment.deprecationHandler = function (name, msg) {
+ var deprecationId = matchedDeprecation(name, msg, test._expectedDeprecations);
+ if (deprecationId === -1) {
+ throw new Error('Unexpected deprecation thrown name=' +
+ name + ' msg=' + msg);
+ }
+ test._observedDeprecations[deprecationId] = 1;
+ };
+ }
+
+ function teardownDeprecationHandler(test, moment, scope) {
+ moment.suppressDeprecationWarnings = test._oldSupress;
+
+ if (test._expectedDeprecations != null) {
+ var missedDeprecations = [];
+ each(test._expectedDeprecations, function (deprecationPattern, id) {
+ if (test._observedDeprecations[id] !== 1) {
+ missedDeprecations.push(deprecationPattern);
+ }
+ });
+ if (missedDeprecations.length !== 0) {
+ throw new Error('Expected deprecation warnings did not happen: ' +
+ missedDeprecations.join(' '));
+ }
+ }
+ }
+
+ function matchedDeprecation(name, msg, deprecations) {
+ if (deprecations == null) {
+ return -1;
+ }
+ for (var i = 0; i < deprecations.length; ++i) {
+ if (name != null && name === deprecations[i]) {
+ return i;
+ }
+ if (msg != null && msg.substring(0, deprecations[i].length) === deprecations[i]) {
+ return i;
+ }
+ }
+ return -1;
+ }
/*global QUnit:false*/
@@ -21738,11 +30439,13 @@
moment.createFromInputFallback = function (config) {
throw new Error('input not handled by moment: ' + config._i);
};
+ setupDeprecationHandler(test, moment, 'core');
if (lifecycle && lifecycle.setup) {
lifecycle.setup();
}
},
teardown : function () {
+ teardownDeprecationHandler(test, moment, 'core');
if (lifecycle && lifecycle.teardown) {
lifecycle.teardown();
}
@@ -21757,17 +30460,20 @@
moment.createFromInputFallback = function (config) {
throw new Error('input not handled by moment: ' + config._i);
};
+ setupDeprecationHandler(test, moment, 'locale');
if (lifecycle && lifecycle.setup) {
lifecycle.setup();
}
},
teardown : function () {
moment.locale('en');
+ teardownDeprecationHandler(test, moment, 'locale');
if (lifecycle && lifecycle.teardown) {
lifecycle.teardown();
}
}
});
+ defineCommonLocaleTests(name, -1, -1);
}
localeModule('ml');
@@ -21920,14 +30626,14 @@
});
test('calendar day', function (assert) {
- var a = moment().hours(2).minutes(0).seconds(0);
-
- assert.equal(moment(a).calendar(), 'ഇന്ന് രാത്രി 2:00 -നു', 'today at the same time');
- assert.equal(moment(a).add({m: 25}).calendar(), 'ഇന്ന് രാത്രി 2:25 -നു', 'Now plus 25 min');
- assert.equal(moment(a).add({h: 3}).calendar(), 'ഇന്ന് രാവിലെ 5:00 -നു', 'Now plus 3 hour');
- assert.equal(moment(a).add({d: 1}).calendar(), 'നാളെ രാത്രി 2:00 -നു', 'tomorrow at the same time');
- assert.equal(moment(a).subtract({h: 1}).calendar(), 'ഇന്ന് രാത്രി 1:00 -നു', 'Now minus 1 hour');
- assert.equal(moment(a).subtract({d: 1}).calendar(), 'ഇന്നലെ രാത്രി 2:00 -നു', 'yesterday at the same time');
+ var a = moment().hours(12).minutes(0).seconds(0);
+
+ assert.equal(moment(a).calendar(), 'ഇന്ന് ഉച്ച കഴിഞ്ഞ് 12:00 -നു', 'today at the same time');
+ assert.equal(moment(a).add({m: 25}).calendar(), 'ഇന്ന് ഉച്ച കഴിഞ്ഞ് 12:25 -നു', 'Now plus 25 min');
+ assert.equal(moment(a).add({h: 3}).calendar(), 'ഇന്ന് ഉച്ച കഴിഞ്ഞ് 3:00 -നു', 'Now plus 3 hours');
+ assert.equal(moment(a).add({d: 1}).calendar(), 'നാളെ ഉച്ച കഴിഞ്ഞ് 12:00 -നു', 'tomorrow at the same time');
+ assert.equal(moment(a).subtract({h: 1}).calendar(), 'ഇന്ന് രാവിലെ 11:00 -നു', 'Now minus 1 hour');
+ assert.equal(moment(a).subtract({d: 1}).calendar(), 'ഇന്നലെ ഉച്ച കഴിഞ്ഞ് 12:00 -നു', 'yesterday at the same time');
});
test('calendar next week', function (assert) {
@@ -21985,67 +30691,6 @@
assert.equal(moment([2011, 2, 23, 21, 20]).format('A'), 'രാത്രി', 'night');
});
- test('weeks year starting sunday', function (assert) {
- assert.equal(moment([2012, 0, 1]).week(), 1, 'Jan 1 2012 should be week 1');
- assert.equal(moment([2012, 0, 7]).week(), 1, 'Jan 7 2012 should be week 1');
- assert.equal(moment([2012, 0, 8]).week(), 2, 'Jan 8 2012 should be week 2');
- assert.equal(moment([2012, 0, 14]).week(), 2, 'Jan 14 2012 should be week 2');
- assert.equal(moment([2012, 0, 15]).week(), 3, 'Jan 15 2012 should be week 3');
- });
-
- test('weeks year starting monday', function (assert) {
- assert.equal(moment([2006, 11, 31]).week(), 1, 'Dec 31 2006 should be week 1');
- assert.equal(moment([2007, 0, 1]).week(), 1, 'Jan 1 2007 should be week 1');
- assert.equal(moment([2007, 0, 6]).week(), 1, 'Jan 6 2007 should be week 1');
- assert.equal(moment([2007, 0, 7]).week(), 2, 'Jan 7 2007 should be week 2');
- assert.equal(moment([2007, 0, 13]).week(), 2, 'Jan 13 2007 should be week 2');
- assert.equal(moment([2007, 0, 14]).week(), 3, 'Jan 14 2007 should be week 3');
- });
-
- test('weeks year starting tuesday', function (assert) {
- assert.equal(moment([2007, 11, 29]).week(), 52, 'Dec 29 2007 should be week 52');
- assert.equal(moment([2008, 0, 1]).week(), 1, 'Jan 1 2008 should be week 1');
- assert.equal(moment([2008, 0, 5]).week(), 1, 'Jan 5 2008 should be week 1');
- assert.equal(moment([2008, 0, 6]).week(), 2, 'Jan 6 2008 should be week 2');
- assert.equal(moment([2008, 0, 12]).week(), 2, 'Jan 12 2008 should be week 2');
- assert.equal(moment([2008, 0, 13]).week(), 3, 'Jan 13 2008 should be week 3');
- });
-
- test('weeks year starting wednesday', function (assert) {
- assert.equal(moment([2002, 11, 29]).week(), 1, 'Dec 29 2002 should be week 1');
- assert.equal(moment([2003, 0, 1]).week(), 1, 'Jan 1 2003 should be week 1');
- assert.equal(moment([2003, 0, 4]).week(), 1, 'Jan 4 2003 should be week 1');
- assert.equal(moment([2003, 0, 5]).week(), 2, 'Jan 5 2003 should be week 2');
- assert.equal(moment([2003, 0, 11]).week(), 2, 'Jan 11 2003 should be week 2');
- assert.equal(moment([2003, 0, 12]).week(), 3, 'Jan 12 2003 should be week 3');
- });
-
- test('weeks year starting thursday', function (assert) {
- assert.equal(moment([2008, 11, 28]).week(), 1, 'Dec 28 2008 should be week 1');
- assert.equal(moment([2009, 0, 1]).week(), 1, 'Jan 1 2009 should be week 1');
- assert.equal(moment([2009, 0, 3]).week(), 1, 'Jan 3 2009 should be week 1');
- assert.equal(moment([2009, 0, 4]).week(), 2, 'Jan 4 2009 should be week 2');
- assert.equal(moment([2009, 0, 10]).week(), 2, 'Jan 10 2009 should be week 2');
- assert.equal(moment([2009, 0, 11]).week(), 3, 'Jan 11 2009 should be week 3');
- });
-
- test('weeks year starting friday', function (assert) {
- assert.equal(moment([2009, 11, 27]).week(), 1, 'Dec 27 2009 should be week 1');
- assert.equal(moment([2010, 0, 1]).week(), 1, 'Jan 1 2010 should be week 1');
- assert.equal(moment([2010, 0, 2]).week(), 1, 'Jan 2 2010 should be week 1');
- assert.equal(moment([2010, 0, 3]).week(), 2, 'Jan 3 2010 should be week 2');
- assert.equal(moment([2010, 0, 9]).week(), 2, 'Jan 9 2010 should be week 2');
- assert.equal(moment([2010, 0, 10]).week(), 3, 'Jan 10 2010 should be week 3');
- });
-
- test('weeks year starting saturday', function (assert) {
- assert.equal(moment([2010, 11, 26]).week(), 1, 'Dec 26 2010 should be week 1');
- assert.equal(moment([2011, 0, 1]).week(), 1, 'Jan 1 2011 should be week 1');
- assert.equal(moment([2011, 0, 2]).week(), 2, 'Jan 2 2011 should be week 2');
- assert.equal(moment([2011, 0, 8]).week(), 2, 'Jan 8 2011 should be week 2');
- assert.equal(moment([2011, 0, 9]).week(), 3, 'Jan 9 2011 should be week 3');
- });
-
test('weeks year starting sunday formatted', function (assert) {
assert.equal(moment([2012, 0, 1]).format('w ww wo'), '1 01 1', 'Jan 1 2012 should be week 1');
assert.equal(moment([2012, 0, 7]).format('w ww wo'), '1 01 1', 'Jan 7 2012 should be week 1');
@@ -22054,42 +30699,6 @@
assert.equal(moment([2012, 0, 15]).format('w ww wo'), '3 03 3', 'Jan 15 2012 should be week 3');
});
- test('lenient ordinal parsing', function (assert) {
- var i, ordinalStr, testMoment;
- for (i = 1; i <= 31; ++i) {
- ordinalStr = moment([2014, 0, i]).format('YYYY MM Do');
- testMoment = moment(ordinalStr, 'YYYY MM Do');
- assert.equal(testMoment.year(), 2014,
- 'lenient ordinal parsing ' + i + ' year check');
- assert.equal(testMoment.month(), 0,
- 'lenient ordinal parsing ' + i + ' month check');
- assert.equal(testMoment.date(), i,
- 'lenient ordinal parsing ' + i + ' date check');
- }
- });
-
- test('lenient ordinal parsing of number', function (assert) {
- var i, testMoment;
- for (i = 1; i <= 31; ++i) {
- testMoment = moment('2014 01 ' + i, 'YYYY MM Do');
- assert.equal(testMoment.year(), 2014,
- 'lenient ordinal parsing of number ' + i + ' year check');
- assert.equal(testMoment.month(), 0,
- 'lenient ordinal parsing of number ' + i + ' month check');
- assert.equal(testMoment.date(), i,
- 'lenient ordinal parsing of number ' + i + ' date check');
- }
- });
-
- test('strict ordinal parsing', function (assert) {
- var i, ordinalStr, testMoment;
- for (i = 1; i <= 31; ++i) {
- ordinalStr = moment([2014, 0, i]).format('YYYY MM Do');
- testMoment = moment(ordinalStr, 'YYYY MM Do', true);
- assert.ok(testMoment.isValid(), 'strict ordinal parsing ' + i);
- }
- });
-
}));
;(function (global, factory) {
@@ -22098,6 +30707,224 @@
typeof define === 'function' && define.amd ? define(['../../moment'], factory) :
factory(global.moment)
}(this, function (moment) { 'use strict';
+
+ function each(array, callback) {
+ var i;
+ for (i = 0; i < array.length; i++) {
+ callback(array[i], i, array);
+ }
+ }
+
+ function objectKeys(obj) {
+ if (Object.keys) {
+ return Object.keys(obj);
+ } else {
+ // IE8
+ var res = [], i;
+ for (i in obj) {
+ if (obj.hasOwnProperty(i)) {
+ res.push(i);
+ }
+ }
+ return res;
+ }
+ }
+
+ // Pick the first defined of two or three arguments.
+ function defaults(a, b, c) {
+ if (a != null) {
+ return a;
+ }
+ if (b != null) {
+ return b;
+ }
+ return c;
+ }
+
+ function defineCommonLocaleTests(locale, options) {
+ test('lenient ordinal parsing', function (assert) {
+ var i, ordinalStr, testMoment;
+ for (i = 1; i <= 31; ++i) {
+ ordinalStr = moment([2014, 0, i]).format('YYYY MM Do');
+ testMoment = moment(ordinalStr, 'YYYY MM Do');
+ assert.equal(testMoment.year(), 2014,
+ 'lenient ordinal parsing ' + i + ' year check');
+ assert.equal(testMoment.month(), 0,
+ 'lenient ordinal parsing ' + i + ' month check');
+ assert.equal(testMoment.date(), i,
+ 'lenient ordinal parsing ' + i + ' date check');
+ }
+ });
+
+ test('lenient ordinal parsing of number', function (assert) {
+ var i, testMoment;
+ for (i = 1; i <= 31; ++i) {
+ testMoment = moment('2014 01 ' + i, 'YYYY MM Do');
+ assert.equal(testMoment.year(), 2014,
+ 'lenient ordinal parsing of number ' + i + ' year check');
+ assert.equal(testMoment.month(), 0,
+ 'lenient ordinal parsing of number ' + i + ' month check');
+ assert.equal(testMoment.date(), i,
+ 'lenient ordinal parsing of number ' + i + ' date check');
+ }
+ });
+
+ test('strict ordinal parsing', function (assert) {
+ var i, ordinalStr, testMoment;
+ for (i = 1; i <= 31; ++i) {
+ ordinalStr = moment([2014, 0, i]).format('YYYY MM Do');
+ testMoment = moment(ordinalStr, 'YYYY MM Do', true);
+ assert.ok(testMoment.isValid(), 'strict ordinal parsing ' + i);
+ }
+ });
+
+ test('meridiem invariant', function (assert) {
+ var h, m, t1, t2;
+ for (h = 0; h < 24; ++h) {
+ for (m = 0; m < 60; m += 15) {
+ t1 = moment.utc([2000, 0, 1, h, m]);
+ t2 = moment.utc(t1.format('A h:mm'), 'A h:mm');
+ assert.equal(t2.format('HH:mm'), t1.format('HH:mm'),
+ 'meridiem at ' + t1.format('HH:mm'));
+ }
+ }
+ });
+
+ test('date format correctness', function (assert) {
+ var data, tokens;
+ data = moment.localeData()._longDateFormat;
+ tokens = objectKeys(data);
+ each(tokens, function (srchToken) {
+ // Check each format string to make sure it does not contain any
+ // tokens that need to be expanded.
+ each(tokens, function (baseToken) {
+ // strip escaped sequences
+ var format = data[baseToken].replace(/(\[[^\]]*\])/g, '');
+ assert.equal(false, !!~format.indexOf(srchToken),
+ 'contains ' + srchToken + ' in ' + baseToken);
+ });
+ });
+ });
+
+ test('month parsing correctness', function (assert) {
+ var i, m;
+
+ if (locale === 'tr') {
+ // I can't fix it :(
+ expect(0);
+ return;
+ }
+ function tester(format) {
+ var r;
+ r = moment(m.format(format), format);
+ assert.equal(r.month(), m.month(), 'month ' + i + ' fmt ' + format);
+ r = moment(m.format(format).toLocaleUpperCase(), format);
+ assert.equal(r.month(), m.month(), 'month ' + i + ' fmt ' + format + ' upper');
+ r = moment(m.format(format).toLocaleLowerCase(), format);
+ assert.equal(r.month(), m.month(), 'month ' + i + ' fmt ' + format + ' lower');
+
+ r = moment(m.format(format), format, true);
+ assert.equal(r.month(), m.month(), 'month ' + i + ' fmt ' + format + ' strict');
+ r = moment(m.format(format).toLocaleUpperCase(), format, true);
+ assert.equal(r.month(), m.month(), 'month ' + i + ' fmt ' + format + ' upper strict');
+ r = moment(m.format(format).toLocaleLowerCase(), format, true);
+ assert.equal(r.month(), m.month(), 'month ' + i + ' fmt ' + format + ' lower strict');
+ }
+
+ for (i = 0; i < 12; ++i) {
+ m = moment([2015, i, 15, 18]);
+ tester('MMM');
+ tester('MMM.');
+ tester('MMMM');
+ tester('MMMM.');
+ }
+ });
+
+ test('weekday parsing correctness', function (assert) {
+ var i, m;
+
+ if (locale === 'tr' || locale === 'az') {
+ // There is a lower-case letter (ı), that converted to upper then
+ // lower changes to i
+ expect(0);
+ return;
+ }
+ function tester(format) {
+ var r, baseMsg = 'weekday ' + m.weekday() + ' fmt ' + format;
+ r = moment(m.format(format), format);
+ assert.equal(r.weekday(), m.weekday(), baseMsg);
+ r = moment(m.format(format).toLocaleUpperCase(), format);
+ assert.equal(r.weekday(), m.weekday(), baseMsg + ' upper');
+ r = moment(m.format(format).toLocaleLowerCase(), format);
+ assert.equal(r.weekday(), m.weekday(), baseMsg + ' lower');
+
+ r = moment(m.format(format), format, true);
+ assert.equal(r.weekday(), m.weekday(), baseMsg + ' strict');
+ r = moment(m.format(format).toLocaleUpperCase(), format, true);
+ assert.equal(r.weekday(), m.weekday(), baseMsg + ' upper strict');
+ r = moment(m.format(format).toLocaleLowerCase(), format, true);
+ assert.equal(r.weekday(), m.weekday(), baseMsg + ' lower strict');
+ }
+
+ for (i = 0; i < 7; ++i) {
+ m = moment.utc([2015, i, 15, 18]);
+ tester('dd');
+ tester('ddd');
+ tester('dddd');
+ }
+ });
+ }
+
+ function setupDeprecationHandler(test, moment, scope) {
+ test._expectedDeprecations = null;
+ test._observedDeprecations = null;
+ test._oldSupress = moment.suppressDeprecationWarnings;
+ moment.suppressDeprecationWarnings = true;
+ test.expectedDeprecations = function () {
+ test._expectedDeprecations = arguments;
+ test._observedDeprecations = [];
+ };
+ moment.deprecationHandler = function (name, msg) {
+ var deprecationId = matchedDeprecation(name, msg, test._expectedDeprecations);
+ if (deprecationId === -1) {
+ throw new Error('Unexpected deprecation thrown name=' +
+ name + ' msg=' + msg);
+ }
+ test._observedDeprecations[deprecationId] = 1;
+ };
+ }
+
+ function teardownDeprecationHandler(test, moment, scope) {
+ moment.suppressDeprecationWarnings = test._oldSupress;
+
+ if (test._expectedDeprecations != null) {
+ var missedDeprecations = [];
+ each(test._expectedDeprecations, function (deprecationPattern, id) {
+ if (test._observedDeprecations[id] !== 1) {
+ missedDeprecations.push(deprecationPattern);
+ }
+ });
+ if (missedDeprecations.length !== 0) {
+ throw new Error('Expected deprecation warnings did not happen: ' +
+ missedDeprecations.join(' '));
+ }
+ }
+ }
+
+ function matchedDeprecation(name, msg, deprecations) {
+ if (deprecations == null) {
+ return -1;
+ }
+ for (var i = 0; i < deprecations.length; ++i) {
+ if (name != null && name === deprecations[i]) {
+ return i;
+ }
+ if (msg != null && msg.substring(0, deprecations[i].length) === deprecations[i]) {
+ return i;
+ }
+ }
+ return -1;
+ }
/*global QUnit:false*/
@@ -22112,11 +30939,13 @@
moment.createFromInputFallback = function (config) {
throw new Error('input not handled by moment: ' + config._i);
};
+ setupDeprecationHandler(test, moment, 'core');
if (lifecycle && lifecycle.setup) {
lifecycle.setup();
}
},
teardown : function () {
+ teardownDeprecationHandler(test, moment, 'core');
if (lifecycle && lifecycle.teardown) {
lifecycle.teardown();
}
@@ -22131,17 +30960,20 @@
moment.createFromInputFallback = function (config) {
throw new Error('input not handled by moment: ' + config._i);
};
+ setupDeprecationHandler(test, moment, 'locale');
if (lifecycle && lifecycle.setup) {
lifecycle.setup();
}
},
teardown : function () {
moment.locale('en');
+ teardownDeprecationHandler(test, moment, 'locale');
if (lifecycle && lifecycle.teardown) {
lifecycle.teardown();
}
}
});
+ defineCommonLocaleTests(name, -1, -1);
}
localeModule('mr');
@@ -22294,14 +31126,14 @@
});
test('calendar day', function (assert) {
- var a = moment().hours(2).minutes(0).seconds(0);
-
- assert.equal(moment(a).calendar(), 'आज रात्री २:०० वाजता', 'today at the same time');
- assert.equal(moment(a).add({m: 25}).calendar(), 'आज रात्री २:२५ वाजता', 'Now plus 25 min');
- assert.equal(moment(a).add({h: 3}).calendar(), 'आज सकाळी ५:०० वाजता', 'Now plus 3 hour');
- assert.equal(moment(a).add({d: 1}).calendar(), 'उद्या रात्री २:०० वाजता', 'tomorrow at the same time');
- assert.equal(moment(a).subtract({h: 1}).calendar(), 'आज रात्री १:०० वाजता', 'Now minus 1 hour');
- assert.equal(moment(a).subtract({d: 1}).calendar(), 'काल रात्री २:०० वाजता', 'yesterday at the same time');
+ var a = moment().hours(12).minutes(0).seconds(0);
+
+ assert.equal(moment(a).calendar(), 'आज दुपारी १२:०० वाजता', 'today at the same time');
+ assert.equal(moment(a).add({m: 25}).calendar(), 'आज दुपारी १२:२५ वाजता', 'Now plus 25 min');
+ assert.equal(moment(a).add({h: 3}).calendar(), 'आज दुपारी ३:०० वाजता', 'Now plus 3 hours');
+ assert.equal(moment(a).add({d: 1}).calendar(), 'उद्या दुपारी १२:०० वाजता', 'tomorrow at the same time');
+ assert.equal(moment(a).subtract({h: 1}).calendar(), 'आज दुपारी ११:०० वाजता', 'Now minus 1 hour');
+ assert.equal(moment(a).subtract({d: 1}).calendar(), 'काल दुपारी १२:०० वाजता', 'yesterday at the same time');
});
test('calendar next week', function (assert) {
@@ -22359,67 +31191,6 @@
assert.equal(moment([2011, 2, 23, 21, 20]).format('A'), 'रात्री', 'night');
});
- test('weeks year starting sunday', function (assert) {
- assert.equal(moment([2012, 0, 1]).week(), 1, 'Jan 1 2012 should be week 1');
- assert.equal(moment([2012, 0, 7]).week(), 1, 'Jan 7 2012 should be week 1');
- assert.equal(moment([2012, 0, 8]).week(), 2, 'Jan 8 2012 should be week 2');
- assert.equal(moment([2012, 0, 14]).week(), 2, 'Jan 14 2012 should be week 2');
- assert.equal(moment([2012, 0, 15]).week(), 3, 'Jan 15 2012 should be week 3');
- });
-
- test('weeks year starting monday', function (assert) {
- assert.equal(moment([2006, 11, 31]).week(), 1, 'Dec 31 2006 should be week 1');
- assert.equal(moment([2007, 0, 1]).week(), 1, 'Jan 1 2007 should be week 1');
- assert.equal(moment([2007, 0, 6]).week(), 1, 'Jan 6 2007 should be week 1');
- assert.equal(moment([2007, 0, 7]).week(), 2, 'Jan 7 2007 should be week 2');
- assert.equal(moment([2007, 0, 13]).week(), 2, 'Jan 13 2007 should be week 2');
- assert.equal(moment([2007, 0, 14]).week(), 3, 'Jan 14 2007 should be week 3');
- });
-
- test('weeks year starting tuesday', function (assert) {
- assert.equal(moment([2007, 11, 29]).week(), 52, 'Dec 29 2007 should be week 52');
- assert.equal(moment([2008, 0, 1]).week(), 1, 'Jan 1 2008 should be week 1');
- assert.equal(moment([2008, 0, 5]).week(), 1, 'Jan 5 2008 should be week 1');
- assert.equal(moment([2008, 0, 6]).week(), 2, 'Jan 6 2008 should be week 2');
- assert.equal(moment([2008, 0, 12]).week(), 2, 'Jan 12 2008 should be week 2');
- assert.equal(moment([2008, 0, 13]).week(), 3, 'Jan 13 2008 should be week 3');
- });
-
- test('weeks year starting wednesday', function (assert) {
- assert.equal(moment([2002, 11, 29]).week(), 1, 'Dec 29 2002 should be week 1');
- assert.equal(moment([2003, 0, 1]).week(), 1, 'Jan 1 2003 should be week 1');
- assert.equal(moment([2003, 0, 4]).week(), 1, 'Jan 4 2003 should be week 1');
- assert.equal(moment([2003, 0, 5]).week(), 2, 'Jan 5 2003 should be week 2');
- assert.equal(moment([2003, 0, 11]).week(), 2, 'Jan 11 2003 should be week 2');
- assert.equal(moment([2003, 0, 12]).week(), 3, 'Jan 12 2003 should be week 3');
- });
-
- test('weeks year starting thursday', function (assert) {
- assert.equal(moment([2008, 11, 28]).week(), 1, 'Dec 28 2008 should be week 1');
- assert.equal(moment([2009, 0, 1]).week(), 1, 'Jan 1 2009 should be week 1');
- assert.equal(moment([2009, 0, 3]).week(), 1, 'Jan 3 2009 should be week 1');
- assert.equal(moment([2009, 0, 4]).week(), 2, 'Jan 4 2009 should be week 2');
- assert.equal(moment([2009, 0, 10]).week(), 2, 'Jan 10 2009 should be week 2');
- assert.equal(moment([2009, 0, 11]).week(), 3, 'Jan 11 2009 should be week 3');
- });
-
- test('weeks year starting friday', function (assert) {
- assert.equal(moment([2009, 11, 27]).week(), 1, 'Dec 27 2009 should be week 1');
- assert.equal(moment([2010, 0, 1]).week(), 1, 'Jan 1 2010 should be week 1');
- assert.equal(moment([2010, 0, 2]).week(), 1, 'Jan 2 2010 should be week 1');
- assert.equal(moment([2010, 0, 3]).week(), 2, 'Jan 3 2010 should be week 2');
- assert.equal(moment([2010, 0, 9]).week(), 2, 'Jan 9 2010 should be week 2');
- assert.equal(moment([2010, 0, 10]).week(), 3, 'Jan 10 2010 should be week 3');
- });
-
- test('weeks year starting saturday', function (assert) {
- assert.equal(moment([2010, 11, 26]).week(), 1, 'Dec 26 2010 should be week 1');
- assert.equal(moment([2011, 0, 1]).week(), 1, 'Jan 1 2011 should be week 1');
- assert.equal(moment([2011, 0, 2]).week(), 2, 'Jan 2 2011 should be week 2');
- assert.equal(moment([2011, 0, 8]).week(), 2, 'Jan 8 2011 should be week 2');
- assert.equal(moment([2011, 0, 9]).week(), 3, 'Jan 9 2011 should be week 3');
- });
-
test('weeks year starting sunday formatted', function (assert) {
assert.equal(moment([2012, 0, 1]).format('w ww wo'), '१ ०१ १', 'Jan 1 2012 should be week 1');
assert.equal(moment([2012, 0, 7]).format('w ww wo'), '१ ०१ १', 'Jan 7 2012 should be week 1');
@@ -22428,54 +31199,6 @@
assert.equal(moment([2012, 0, 15]).format('w ww wo'), '३ ०३ ३', 'Jan 15 2012 should be week 3');
});
- test('lenient ordinal parsing', function (assert) {
- var i, ordinalStr, testMoment;
- for (i = 1; i <= 31; ++i) {
- ordinalStr = moment([2014, 0, i]).format('YYYY MM Do');
- testMoment = moment(ordinalStr, 'YYYY MM Do');
- assert.equal(testMoment.year(), 2014,
- 'lenient ordinal parsing ' + i + ' year check');
- assert.equal(testMoment.month(), 0,
- 'lenient ordinal parsing ' + i + ' month check');
- assert.equal(testMoment.date(), i,
- 'lenient ordinal parsing ' + i + ' date check');
- }
- });
-
- test('lenient ordinal parsing of number', function (assert) {
- var i, testMoment;
- for (i = 1; i <= 31; ++i) {
- testMoment = moment('2014 01 ' + i, 'YYYY MM Do');
- assert.equal(testMoment.year(), 2014,
- 'lenient ordinal parsing of number ' + i + ' year check');
- assert.equal(testMoment.month(), 0,
- 'lenient ordinal parsing of number ' + i + ' month check');
- assert.equal(testMoment.date(), i,
- 'lenient ordinal parsing of number ' + i + ' date check');
- }
- });
-
- test('meridiem invariant', function (assert) {
- var h, m, t1, t2;
- for (h = 0; h < 24; ++h) {
- for (m = 0; m < 60; m += 15) {
- t1 = moment.utc([2000, 0, 1, h, m]);
- t2 = moment(t1.format('A h:mm'), 'A h:mm');
- assert.equal(t2.format('HH:mm'), t1.format('HH:mm'),
- 'meridiem at ' + t1.format('HH:mm'));
- }
- }
- });
-
- test('strict ordinal parsing', function (assert) {
- var i, ordinalStr, testMoment;
- for (i = 1; i <= 31; ++i) {
- ordinalStr = moment([2014, 0, i]).format('YYYY MM Do');
- testMoment = moment(ordinalStr, 'YYYY MM Do', true);
- assert.ok(testMoment.isValid(), 'strict ordinal parsing ' + i);
- }
- });
-
}));
;(function (global, factory) {
@@ -22484,6 +31207,224 @@
typeof define === 'function' && define.amd ? define(['../../moment'], factory) :
factory(global.moment)
}(this, function (moment) { 'use strict';
+
+ function each(array, callback) {
+ var i;
+ for (i = 0; i < array.length; i++) {
+ callback(array[i], i, array);
+ }
+ }
+
+ function objectKeys(obj) {
+ if (Object.keys) {
+ return Object.keys(obj);
+ } else {
+ // IE8
+ var res = [], i;
+ for (i in obj) {
+ if (obj.hasOwnProperty(i)) {
+ res.push(i);
+ }
+ }
+ return res;
+ }
+ }
+
+ // Pick the first defined of two or three arguments.
+ function defaults(a, b, c) {
+ if (a != null) {
+ return a;
+ }
+ if (b != null) {
+ return b;
+ }
+ return c;
+ }
+
+ function defineCommonLocaleTests(locale, options) {
+ test('lenient ordinal parsing', function (assert) {
+ var i, ordinalStr, testMoment;
+ for (i = 1; i <= 31; ++i) {
+ ordinalStr = moment([2014, 0, i]).format('YYYY MM Do');
+ testMoment = moment(ordinalStr, 'YYYY MM Do');
+ assert.equal(testMoment.year(), 2014,
+ 'lenient ordinal parsing ' + i + ' year check');
+ assert.equal(testMoment.month(), 0,
+ 'lenient ordinal parsing ' + i + ' month check');
+ assert.equal(testMoment.date(), i,
+ 'lenient ordinal parsing ' + i + ' date check');
+ }
+ });
+
+ test('lenient ordinal parsing of number', function (assert) {
+ var i, testMoment;
+ for (i = 1; i <= 31; ++i) {
+ testMoment = moment('2014 01 ' + i, 'YYYY MM Do');
+ assert.equal(testMoment.year(), 2014,
+ 'lenient ordinal parsing of number ' + i + ' year check');
+ assert.equal(testMoment.month(), 0,
+ 'lenient ordinal parsing of number ' + i + ' month check');
+ assert.equal(testMoment.date(), i,
+ 'lenient ordinal parsing of number ' + i + ' date check');
+ }
+ });
+
+ test('strict ordinal parsing', function (assert) {
+ var i, ordinalStr, testMoment;
+ for (i = 1; i <= 31; ++i) {
+ ordinalStr = moment([2014, 0, i]).format('YYYY MM Do');
+ testMoment = moment(ordinalStr, 'YYYY MM Do', true);
+ assert.ok(testMoment.isValid(), 'strict ordinal parsing ' + i);
+ }
+ });
+
+ test('meridiem invariant', function (assert) {
+ var h, m, t1, t2;
+ for (h = 0; h < 24; ++h) {
+ for (m = 0; m < 60; m += 15) {
+ t1 = moment.utc([2000, 0, 1, h, m]);
+ t2 = moment.utc(t1.format('A h:mm'), 'A h:mm');
+ assert.equal(t2.format('HH:mm'), t1.format('HH:mm'),
+ 'meridiem at ' + t1.format('HH:mm'));
+ }
+ }
+ });
+
+ test('date format correctness', function (assert) {
+ var data, tokens;
+ data = moment.localeData()._longDateFormat;
+ tokens = objectKeys(data);
+ each(tokens, function (srchToken) {
+ // Check each format string to make sure it does not contain any
+ // tokens that need to be expanded.
+ each(tokens, function (baseToken) {
+ // strip escaped sequences
+ var format = data[baseToken].replace(/(\[[^\]]*\])/g, '');
+ assert.equal(false, !!~format.indexOf(srchToken),
+ 'contains ' + srchToken + ' in ' + baseToken);
+ });
+ });
+ });
+
+ test('month parsing correctness', function (assert) {
+ var i, m;
+
+ if (locale === 'tr') {
+ // I can't fix it :(
+ expect(0);
+ return;
+ }
+ function tester(format) {
+ var r;
+ r = moment(m.format(format), format);
+ assert.equal(r.month(), m.month(), 'month ' + i + ' fmt ' + format);
+ r = moment(m.format(format).toLocaleUpperCase(), format);
+ assert.equal(r.month(), m.month(), 'month ' + i + ' fmt ' + format + ' upper');
+ r = moment(m.format(format).toLocaleLowerCase(), format);
+ assert.equal(r.month(), m.month(), 'month ' + i + ' fmt ' + format + ' lower');
+
+ r = moment(m.format(format), format, true);
+ assert.equal(r.month(), m.month(), 'month ' + i + ' fmt ' + format + ' strict');
+ r = moment(m.format(format).toLocaleUpperCase(), format, true);
+ assert.equal(r.month(), m.month(), 'month ' + i + ' fmt ' + format + ' upper strict');
+ r = moment(m.format(format).toLocaleLowerCase(), format, true);
+ assert.equal(r.month(), m.month(), 'month ' + i + ' fmt ' + format + ' lower strict');
+ }
+
+ for (i = 0; i < 12; ++i) {
+ m = moment([2015, i, 15, 18]);
+ tester('MMM');
+ tester('MMM.');
+ tester('MMMM');
+ tester('MMMM.');
+ }
+ });
+
+ test('weekday parsing correctness', function (assert) {
+ var i, m;
+
+ if (locale === 'tr' || locale === 'az') {
+ // There is a lower-case letter (ı), that converted to upper then
+ // lower changes to i
+ expect(0);
+ return;
+ }
+ function tester(format) {
+ var r, baseMsg = 'weekday ' + m.weekday() + ' fmt ' + format;
+ r = moment(m.format(format), format);
+ assert.equal(r.weekday(), m.weekday(), baseMsg);
+ r = moment(m.format(format).toLocaleUpperCase(), format);
+ assert.equal(r.weekday(), m.weekday(), baseMsg + ' upper');
+ r = moment(m.format(format).toLocaleLowerCase(), format);
+ assert.equal(r.weekday(), m.weekday(), baseMsg + ' lower');
+
+ r = moment(m.format(format), format, true);
+ assert.equal(r.weekday(), m.weekday(), baseMsg + ' strict');
+ r = moment(m.format(format).toLocaleUpperCase(), format, true);
+ assert.equal(r.weekday(), m.weekday(), baseMsg + ' upper strict');
+ r = moment(m.format(format).toLocaleLowerCase(), format, true);
+ assert.equal(r.weekday(), m.weekday(), baseMsg + ' lower strict');
+ }
+
+ for (i = 0; i < 7; ++i) {
+ m = moment.utc([2015, i, 15, 18]);
+ tester('dd');
+ tester('ddd');
+ tester('dddd');
+ }
+ });
+ }
+
+ function setupDeprecationHandler(test, moment, scope) {
+ test._expectedDeprecations = null;
+ test._observedDeprecations = null;
+ test._oldSupress = moment.suppressDeprecationWarnings;
+ moment.suppressDeprecationWarnings = true;
+ test.expectedDeprecations = function () {
+ test._expectedDeprecations = arguments;
+ test._observedDeprecations = [];
+ };
+ moment.deprecationHandler = function (name, msg) {
+ var deprecationId = matchedDeprecation(name, msg, test._expectedDeprecations);
+ if (deprecationId === -1) {
+ throw new Error('Unexpected deprecation thrown name=' +
+ name + ' msg=' + msg);
+ }
+ test._observedDeprecations[deprecationId] = 1;
+ };
+ }
+
+ function teardownDeprecationHandler(test, moment, scope) {
+ moment.suppressDeprecationWarnings = test._oldSupress;
+
+ if (test._expectedDeprecations != null) {
+ var missedDeprecations = [];
+ each(test._expectedDeprecations, function (deprecationPattern, id) {
+ if (test._observedDeprecations[id] !== 1) {
+ missedDeprecations.push(deprecationPattern);
+ }
+ });
+ if (missedDeprecations.length !== 0) {
+ throw new Error('Expected deprecation warnings did not happen: ' +
+ missedDeprecations.join(' '));
+ }
+ }
+ }
+
+ function matchedDeprecation(name, msg, deprecations) {
+ if (deprecations == null) {
+ return -1;
+ }
+ for (var i = 0; i < deprecations.length; ++i) {
+ if (name != null && name === deprecations[i]) {
+ return i;
+ }
+ if (msg != null && msg.substring(0, deprecations[i].length) === deprecations[i]) {
+ return i;
+ }
+ }
+ return -1;
+ }
/*global QUnit:false*/
@@ -22498,11 +31439,13 @@
moment.createFromInputFallback = function (config) {
throw new Error('input not handled by moment: ' + config._i);
};
+ setupDeprecationHandler(test, moment, 'core');
if (lifecycle && lifecycle.setup) {
lifecycle.setup();
}
},
teardown : function () {
+ teardownDeprecationHandler(test, moment, 'core');
if (lifecycle && lifecycle.teardown) {
lifecycle.teardown();
}
@@ -22517,17 +31460,20 @@
moment.createFromInputFallback = function (config) {
throw new Error('input not handled by moment: ' + config._i);
};
+ setupDeprecationHandler(test, moment, 'locale');
if (lifecycle && lifecycle.setup) {
lifecycle.setup();
}
},
teardown : function () {
moment.locale('en');
+ teardownDeprecationHandler(test, moment, 'locale');
if (lifecycle && lifecycle.teardown) {
lifecycle.teardown();
}
}
});
+ defineCommonLocaleTests(name, -1, -1);
}
localeModule('ms-my');
@@ -22690,14 +31636,14 @@
});
test('calendar day', function (assert) {
- var a = moment().hours(2).minutes(0).seconds(0);
-
- assert.equal(moment(a).calendar(), 'Hari ini pukul 02.00', 'hari ini pada waktu yang sama');
- assert.equal(moment(a).add({m: 25}).calendar(), 'Hari ini pukul 02.25', 'Sekarang tambah 25 minit');
- assert.equal(moment(a).add({h: 1}).calendar(), 'Hari ini pukul 03.00', 'Sekarang tambah 1 jam');
- assert.equal(moment(a).add({d: 1}).calendar(), 'Esok pukul 02.00', 'esok pada waktu yang sama');
- assert.equal(moment(a).subtract({h: 1}).calendar(), 'Hari ini pukul 01.00', 'Sekarang tolak 1 jam');
- assert.equal(moment(a).subtract({d: 1}).calendar(), 'Kelmarin pukul 02.00', 'kelmarin pada waktu yang sama');
+ var a = moment().hours(12).minutes(0).seconds(0);
+
+ assert.equal(moment(a).calendar(), 'Hari ini pukul 12.00', 'hari ini pada waktu yang sama');
+ assert.equal(moment(a).add({m: 25}).calendar(), 'Hari ini pukul 12.25', 'Sekarang tambah 25 minit');
+ assert.equal(moment(a).add({h: 1}).calendar(), 'Hari ini pukul 13.00', 'Sekarang tambah 1 jam');
+ assert.equal(moment(a).add({d: 1}).calendar(), 'Esok pukul 12.00', 'esok pada waktu yang sama');
+ assert.equal(moment(a).subtract({h: 1}).calendar(), 'Hari ini pukul 11.00', 'Sekarang tolak 1 jam');
+ assert.equal(moment(a).subtract({d: 1}).calendar(), 'Kelmarin pukul 12.00', 'kelmarin pada waktu yang sama');
});
test('calendar next week', function (assert) {
@@ -22738,67 +31684,6 @@
assert.equal(weeksFromNow.calendar(), weeksFromNow.format('L'), 'dalam 2 minggu');
});
- test('weeks year starting sunday', function (assert) {
- assert.equal(moment([2012, 0, 1]).week(), 1, 'Jan 1 2012 sepatutnya minggu 1');
- assert.equal(moment([2012, 0, 7]).week(), 2, 'Jan 7 2012 sepatutnya minggu 2');
- assert.equal(moment([2012, 0, 8]).week(), 2, 'Jan 8 2012 sepatutnya minggu 2');
- assert.equal(moment([2012, 0, 14]).week(), 3, 'Jan 14 2012 sepatutnya minggu 3');
- assert.equal(moment([2012, 0, 15]).week(), 3, 'Jan 15 2012 sepatutnya minggu 3');
- });
-
- test('weeks year starting monday', function (assert) {
- assert.equal(moment([2006, 11, 31]).week(), 53, 'Dec 31 2006 sepatutnya minggu 53');
- assert.equal(moment([2007, 0, 1]).week(), 1, 'Jan 1 2007 sepatutnya minggu 1');
- assert.equal(moment([2007, 0, 6]).week(), 1, 'Jan 6 2007 sepatutnya minggu 1');
- assert.equal(moment([2007, 0, 7]).week(), 1, 'Jan 7 2007 sepatutnya minggu 1');
- assert.equal(moment([2007, 0, 13]).week(), 2, 'Jan 13 2007 sepatutnya minggu 2');
- assert.equal(moment([2007, 0, 14]).week(), 2, 'Jan 14 2007 sepatutnya minggu 2');
- });
-
- test('weeks year starting tuesday', function (assert) {
- assert.equal(moment([2007, 11, 30]).week(), 52, 'Dec 30 2007 sepatutnya minggu 52');
- assert.equal(moment([2008, 0, 1]).week(), 1, 'Jan 1 2008 sepatutnya minggu 1');
- assert.equal(moment([2008, 0, 5]).week(), 1, 'Jan 5 2008 sepatutnya minggu 1');
- assert.equal(moment([2008, 0, 6]).week(), 1, 'Jan 6 2008 sepatutnya minggu 1');
- assert.equal(moment([2008, 0, 12]).week(), 2, 'Jan 12 2008 sepatutnya minggu 2');
- assert.equal(moment([2008, 0, 13]).week(), 2, 'Jan 13 2008 sepatutnya minggu 2');
- });
-
- test('weeks year starting wednesday', function (assert) {
- assert.equal(moment([2002, 11, 29]).week(), 52, 'Dec 29 2002 sepatutnya minggu 52');
- assert.equal(moment([2003, 0, 1]).week(), 1, 'Jan 1 2003 sepatutnya minggu 1');
- assert.equal(moment([2003, 0, 4]).week(), 1, 'Jan 4 2003 sepatutnya minggu 1');
- assert.equal(moment([2003, 0, 5]).week(), 1, 'Jan 5 2003 sepatutnya minggu 1');
- assert.equal(moment([2003, 0, 11]).week(), 2, 'Jan 11 2003 sepatutnya minggu 2');
- assert.equal(moment([2003, 0, 12]).week(), 2, 'Jan 12 2003 sepatutnya minggu 2');
- });
-
- test('weeks year starting thursday', function (assert) {
- assert.equal(moment([2008, 11, 28]).week(), 52, 'Dec 28 2008 sepatutnya minggu 52');
- assert.equal(moment([2009, 0, 1]).week(), 1, 'Jan 1 2009 sepatutnya minggu 1');
- assert.equal(moment([2009, 0, 3]).week(), 1, 'Jan 3 2009 sepatutnya minggu 1');
- assert.equal(moment([2009, 0, 4]).week(), 1, 'Jan 4 2009 sepatutnya minggu 1');
- assert.equal(moment([2009, 0, 10]).week(), 2, 'Jan 10 2009 sepatutnya minggu 2');
- assert.equal(moment([2009, 0, 11]).week(), 2, 'Jan 11 2009 sepatutnya minggu 2');
- });
-
- test('weeks year starting friday', function (assert) {
- assert.equal(moment([2009, 11, 27]).week(), 52, 'Dec 27 2009 sepatutnya minggu 52');
- assert.equal(moment([2010, 0, 1]).week(), 1, 'Jan 1 2010 sepatutnya minggu 1');
- assert.equal(moment([2010, 0, 2]).week(), 1, 'Jan 2 2010 sepatutnya minggu 1');
- assert.equal(moment([2010, 0, 3]).week(), 1, 'Jan 3 2010 sepatutnya minggu 1');
- assert.equal(moment([2010, 0, 9]).week(), 2, 'Jan 9 2010 sepatutnya minggu 2');
- assert.equal(moment([2010, 0, 10]).week(), 2, 'Jan 10 2010 sepatutnya minggu 2');
- });
-
- test('weeks year starting saturday', function (assert) {
- assert.equal(moment([2010, 11, 26]).week(), 52, 'Dec 26 2010 sepatutnya minggu 52');
- assert.equal(moment([2011, 0, 1]).week(), 1, 'Jan 1 2011 sepatutnya minggu 1');
- assert.equal(moment([2011, 0, 2]).week(), 1, 'Jan 2 2011 sepatutnya minggu 1');
- assert.equal(moment([2011, 0, 8]).week(), 2, 'Jan 8 2011 sepatutnya minggu 2');
- assert.equal(moment([2011, 0, 9]).week(), 2, 'Jan 9 2011 sepatutnya minggu 2');
- });
-
test('weeks year starting sunday format', function (assert) {
assert.equal(moment([2012, 0, 1]).format('w ww wo'), '1 01 1', 'Jan 1 2012 sepatutnya minggu 1');
assert.equal(moment([2012, 0, 7]).format('w ww wo'), '2 02 2', 'Jan 7 2012 sepatutnya minggu 2');
@@ -22807,54 +31692,6 @@
assert.equal(moment([2012, 0, 15]).format('w ww wo'), '3 03 3', 'Jan 15 2012 sepatutnya minggu 3');
});
- test('lenient ordinal parsing', function (assert) {
- var i, ordinalStr, testMoment;
- for (i = 1; i <= 31; ++i) {
- ordinalStr = moment([2014, 0, i]).format('YYYY MM Do');
- testMoment = moment(ordinalStr, 'YYYY MM Do');
- assert.equal(testMoment.year(), 2014,
- 'lenient ordinal parsing ' + i + ' year check');
- assert.equal(testMoment.month(), 0,
- 'lenient ordinal parsing ' + i + ' month check');
- assert.equal(testMoment.date(), i,
- 'lenient ordinal parsing ' + i + ' date check');
- }
- });
-
- test('meridiem invariant', function (assert) {
- var h, m, t1, t2;
- for (h = 0; h < 24; ++h) {
- for (m = 0; m < 60; m += 15) {
- t1 = moment.utc([2000, 0, 1, h, m]);
- t2 = moment(t1.format('A h:mm'), 'A h:mm');
- assert.equal(t2.format('HH:mm'), t1.format('HH:mm'),
- 'meridiem at ' + t1.format('HH:mm'));
- }
- }
- });
-
- test('lenient ordinal parsing of number', function (assert) {
- var i, testMoment;
- for (i = 1; i <= 31; ++i) {
- testMoment = moment('2014 01 ' + i, 'YYYY MM Do');
- assert.equal(testMoment.year(), 2014,
- 'lenient ordinal parsing of number ' + i + ' year check');
- assert.equal(testMoment.month(), 0,
- 'lenient ordinal parsing of number ' + i + ' month check');
- assert.equal(testMoment.date(), i,
- 'lenient ordinal parsing of number ' + i + ' date check');
- }
- });
-
- test('strict ordinal parsing', function (assert) {
- var i, ordinalStr, testMoment;
- for (i = 1; i <= 31; ++i) {
- ordinalStr = moment([2014, 0, i]).format('YYYY MM Do');
- testMoment = moment(ordinalStr, 'YYYY MM Do', true);
- assert.ok(testMoment.isValid(), 'strict ordinal parsing ' + i);
- }
- });
-
}));
;(function (global, factory) {
@@ -22863,6 +31700,224 @@
typeof define === 'function' && define.amd ? define(['../../moment'], factory) :
factory(global.moment)
}(this, function (moment) { 'use strict';
+
+ function each(array, callback) {
+ var i;
+ for (i = 0; i < array.length; i++) {
+ callback(array[i], i, array);
+ }
+ }
+
+ function objectKeys(obj) {
+ if (Object.keys) {
+ return Object.keys(obj);
+ } else {
+ // IE8
+ var res = [], i;
+ for (i in obj) {
+ if (obj.hasOwnProperty(i)) {
+ res.push(i);
+ }
+ }
+ return res;
+ }
+ }
+
+ // Pick the first defined of two or three arguments.
+ function defaults(a, b, c) {
+ if (a != null) {
+ return a;
+ }
+ if (b != null) {
+ return b;
+ }
+ return c;
+ }
+
+ function defineCommonLocaleTests(locale, options) {
+ test('lenient ordinal parsing', function (assert) {
+ var i, ordinalStr, testMoment;
+ for (i = 1; i <= 31; ++i) {
+ ordinalStr = moment([2014, 0, i]).format('YYYY MM Do');
+ testMoment = moment(ordinalStr, 'YYYY MM Do');
+ assert.equal(testMoment.year(), 2014,
+ 'lenient ordinal parsing ' + i + ' year check');
+ assert.equal(testMoment.month(), 0,
+ 'lenient ordinal parsing ' + i + ' month check');
+ assert.equal(testMoment.date(), i,
+ 'lenient ordinal parsing ' + i + ' date check');
+ }
+ });
+
+ test('lenient ordinal parsing of number', function (assert) {
+ var i, testMoment;
+ for (i = 1; i <= 31; ++i) {
+ testMoment = moment('2014 01 ' + i, 'YYYY MM Do');
+ assert.equal(testMoment.year(), 2014,
+ 'lenient ordinal parsing of number ' + i + ' year check');
+ assert.equal(testMoment.month(), 0,
+ 'lenient ordinal parsing of number ' + i + ' month check');
+ assert.equal(testMoment.date(), i,
+ 'lenient ordinal parsing of number ' + i + ' date check');
+ }
+ });
+
+ test('strict ordinal parsing', function (assert) {
+ var i, ordinalStr, testMoment;
+ for (i = 1; i <= 31; ++i) {
+ ordinalStr = moment([2014, 0, i]).format('YYYY MM Do');
+ testMoment = moment(ordinalStr, 'YYYY MM Do', true);
+ assert.ok(testMoment.isValid(), 'strict ordinal parsing ' + i);
+ }
+ });
+
+ test('meridiem invariant', function (assert) {
+ var h, m, t1, t2;
+ for (h = 0; h < 24; ++h) {
+ for (m = 0; m < 60; m += 15) {
+ t1 = moment.utc([2000, 0, 1, h, m]);
+ t2 = moment.utc(t1.format('A h:mm'), 'A h:mm');
+ assert.equal(t2.format('HH:mm'), t1.format('HH:mm'),
+ 'meridiem at ' + t1.format('HH:mm'));
+ }
+ }
+ });
+
+ test('date format correctness', function (assert) {
+ var data, tokens;
+ data = moment.localeData()._longDateFormat;
+ tokens = objectKeys(data);
+ each(tokens, function (srchToken) {
+ // Check each format string to make sure it does not contain any
+ // tokens that need to be expanded.
+ each(tokens, function (baseToken) {
+ // strip escaped sequences
+ var format = data[baseToken].replace(/(\[[^\]]*\])/g, '');
+ assert.equal(false, !!~format.indexOf(srchToken),
+ 'contains ' + srchToken + ' in ' + baseToken);
+ });
+ });
+ });
+
+ test('month parsing correctness', function (assert) {
+ var i, m;
+
+ if (locale === 'tr') {
+ // I can't fix it :(
+ expect(0);
+ return;
+ }
+ function tester(format) {
+ var r;
+ r = moment(m.format(format), format);
+ assert.equal(r.month(), m.month(), 'month ' + i + ' fmt ' + format);
+ r = moment(m.format(format).toLocaleUpperCase(), format);
+ assert.equal(r.month(), m.month(), 'month ' + i + ' fmt ' + format + ' upper');
+ r = moment(m.format(format).toLocaleLowerCase(), format);
+ assert.equal(r.month(), m.month(), 'month ' + i + ' fmt ' + format + ' lower');
+
+ r = moment(m.format(format), format, true);
+ assert.equal(r.month(), m.month(), 'month ' + i + ' fmt ' + format + ' strict');
+ r = moment(m.format(format).toLocaleUpperCase(), format, true);
+ assert.equal(r.month(), m.month(), 'month ' + i + ' fmt ' + format + ' upper strict');
+ r = moment(m.format(format).toLocaleLowerCase(), format, true);
+ assert.equal(r.month(), m.month(), 'month ' + i + ' fmt ' + format + ' lower strict');
+ }
+
+ for (i = 0; i < 12; ++i) {
+ m = moment([2015, i, 15, 18]);
+ tester('MMM');
+ tester('MMM.');
+ tester('MMMM');
+ tester('MMMM.');
+ }
+ });
+
+ test('weekday parsing correctness', function (assert) {
+ var i, m;
+
+ if (locale === 'tr' || locale === 'az') {
+ // There is a lower-case letter (ı), that converted to upper then
+ // lower changes to i
+ expect(0);
+ return;
+ }
+ function tester(format) {
+ var r, baseMsg = 'weekday ' + m.weekday() + ' fmt ' + format;
+ r = moment(m.format(format), format);
+ assert.equal(r.weekday(), m.weekday(), baseMsg);
+ r = moment(m.format(format).toLocaleUpperCase(), format);
+ assert.equal(r.weekday(), m.weekday(), baseMsg + ' upper');
+ r = moment(m.format(format).toLocaleLowerCase(), format);
+ assert.equal(r.weekday(), m.weekday(), baseMsg + ' lower');
+
+ r = moment(m.format(format), format, true);
+ assert.equal(r.weekday(), m.weekday(), baseMsg + ' strict');
+ r = moment(m.format(format).toLocaleUpperCase(), format, true);
+ assert.equal(r.weekday(), m.weekday(), baseMsg + ' upper strict');
+ r = moment(m.format(format).toLocaleLowerCase(), format, true);
+ assert.equal(r.weekday(), m.weekday(), baseMsg + ' lower strict');
+ }
+
+ for (i = 0; i < 7; ++i) {
+ m = moment.utc([2015, i, 15, 18]);
+ tester('dd');
+ tester('ddd');
+ tester('dddd');
+ }
+ });
+ }
+
+ function setupDeprecationHandler(test, moment, scope) {
+ test._expectedDeprecations = null;
+ test._observedDeprecations = null;
+ test._oldSupress = moment.suppressDeprecationWarnings;
+ moment.suppressDeprecationWarnings = true;
+ test.expectedDeprecations = function () {
+ test._expectedDeprecations = arguments;
+ test._observedDeprecations = [];
+ };
+ moment.deprecationHandler = function (name, msg) {
+ var deprecationId = matchedDeprecation(name, msg, test._expectedDeprecations);
+ if (deprecationId === -1) {
+ throw new Error('Unexpected deprecation thrown name=' +
+ name + ' msg=' + msg);
+ }
+ test._observedDeprecations[deprecationId] = 1;
+ };
+ }
+
+ function teardownDeprecationHandler(test, moment, scope) {
+ moment.suppressDeprecationWarnings = test._oldSupress;
+
+ if (test._expectedDeprecations != null) {
+ var missedDeprecations = [];
+ each(test._expectedDeprecations, function (deprecationPattern, id) {
+ if (test._observedDeprecations[id] !== 1) {
+ missedDeprecations.push(deprecationPattern);
+ }
+ });
+ if (missedDeprecations.length !== 0) {
+ throw new Error('Expected deprecation warnings did not happen: ' +
+ missedDeprecations.join(' '));
+ }
+ }
+ }
+
+ function matchedDeprecation(name, msg, deprecations) {
+ if (deprecations == null) {
+ return -1;
+ }
+ for (var i = 0; i < deprecations.length; ++i) {
+ if (name != null && name === deprecations[i]) {
+ return i;
+ }
+ if (msg != null && msg.substring(0, deprecations[i].length) === deprecations[i]) {
+ return i;
+ }
+ }
+ return -1;
+ }
/*global QUnit:false*/
@@ -22877,11 +31932,13 @@
moment.createFromInputFallback = function (config) {
throw new Error('input not handled by moment: ' + config._i);
};
+ setupDeprecationHandler(test, moment, 'core');
if (lifecycle && lifecycle.setup) {
lifecycle.setup();
}
},
teardown : function () {
+ teardownDeprecationHandler(test, moment, 'core');
if (lifecycle && lifecycle.teardown) {
lifecycle.teardown();
}
@@ -22896,17 +31953,20 @@
moment.createFromInputFallback = function (config) {
throw new Error('input not handled by moment: ' + config._i);
};
+ setupDeprecationHandler(test, moment, 'locale');
if (lifecycle && lifecycle.setup) {
lifecycle.setup();
}
},
teardown : function () {
moment.locale('en');
+ teardownDeprecationHandler(test, moment, 'locale');
if (lifecycle && lifecycle.teardown) {
lifecycle.teardown();
}
}
});
+ defineCommonLocaleTests(name, -1, -1);
}
localeModule('ms');
@@ -23069,14 +32129,14 @@
});
test('calendar day', function (assert) {
- var a = moment().hours(2).minutes(0).seconds(0);
-
- assert.equal(moment(a).calendar(), 'Hari ini pukul 02.00', 'hari ini pada waktu yang sama');
- assert.equal(moment(a).add({m: 25}).calendar(), 'Hari ini pukul 02.25', 'Sekarang tambah 25 minit');
- assert.equal(moment(a).add({h: 1}).calendar(), 'Hari ini pukul 03.00', 'Sekarang tambah 1 jam');
- assert.equal(moment(a).add({d: 1}).calendar(), 'Esok pukul 02.00', 'esok pada waktu yang sama');
- assert.equal(moment(a).subtract({h: 1}).calendar(), 'Hari ini pukul 01.00', 'Sekarang tolak 1 jam');
- assert.equal(moment(a).subtract({d: 1}).calendar(), 'Kelmarin pukul 02.00', 'kelmarin pada waktu yang sama');
+ var a = moment().hours(12).minutes(0).seconds(0);
+
+ assert.equal(moment(a).calendar(), 'Hari ini pukul 12.00', 'hari ini pada waktu yang sama');
+ assert.equal(moment(a).add({m: 25}).calendar(), 'Hari ini pukul 12.25', 'Sekarang tambah 25 minit');
+ assert.equal(moment(a).add({h: 1}).calendar(), 'Hari ini pukul 13.00', 'Sekarang tambah 1 jam');
+ assert.equal(moment(a).add({d: 1}).calendar(), 'Esok pukul 12.00', 'esok pada waktu yang sama');
+ assert.equal(moment(a).subtract({h: 1}).calendar(), 'Hari ini pukul 11.00', 'Sekarang tolak 1 jam');
+ assert.equal(moment(a).subtract({d: 1}).calendar(), 'Kelmarin pukul 12.00', 'kelmarin pada waktu yang sama');
});
test('calendar next week', function (assert) {
@@ -23117,67 +32177,6 @@
assert.equal(weeksFromNow.calendar(), weeksFromNow.format('L'), 'dalam 2 minggu');
});
- test('weeks year starting sunday', function (assert) {
- assert.equal(moment([2012, 0, 1]).week(), 1, 'Jan 1 2012 sepatutnya minggu 1');
- assert.equal(moment([2012, 0, 7]).week(), 2, 'Jan 7 2012 sepatutnya minggu 2');
- assert.equal(moment([2012, 0, 8]).week(), 2, 'Jan 8 2012 sepatutnya minggu 2');
- assert.equal(moment([2012, 0, 14]).week(), 3, 'Jan 14 2012 sepatutnya minggu 3');
- assert.equal(moment([2012, 0, 15]).week(), 3, 'Jan 15 2012 sepatutnya minggu 3');
- });
-
- test('weeks year starting monday', function (assert) {
- assert.equal(moment([2006, 11, 31]).week(), 53, 'Dec 31 2006 sepatutnya minggu 53');
- assert.equal(moment([2007, 0, 1]).week(), 1, 'Jan 1 2007 sepatutnya minggu 1');
- assert.equal(moment([2007, 0, 6]).week(), 1, 'Jan 6 2007 sepatutnya minggu 1');
- assert.equal(moment([2007, 0, 7]).week(), 1, 'Jan 7 2007 sepatutnya minggu 1');
- assert.equal(moment([2007, 0, 13]).week(), 2, 'Jan 13 2007 sepatutnya minggu 2');
- assert.equal(moment([2007, 0, 14]).week(), 2, 'Jan 14 2007 sepatutnya minggu 2');
- });
-
- test('weeks year starting tuesday', function (assert) {
- assert.equal(moment([2007, 11, 30]).week(), 52, 'Dec 30 2007 sepatutnya minggu 52');
- assert.equal(moment([2008, 0, 1]).week(), 1, 'Jan 1 2008 sepatutnya minggu 1');
- assert.equal(moment([2008, 0, 5]).week(), 1, 'Jan 5 2008 sepatutnya minggu 1');
- assert.equal(moment([2008, 0, 6]).week(), 1, 'Jan 6 2008 sepatutnya minggu 1');
- assert.equal(moment([2008, 0, 12]).week(), 2, 'Jan 12 2008 sepatutnya minggu 2');
- assert.equal(moment([2008, 0, 13]).week(), 2, 'Jan 13 2008 sepatutnya minggu 2');
- });
-
- test('weeks year starting wednesday', function (assert) {
- assert.equal(moment([2002, 11, 29]).week(), 52, 'Dec 29 2002 sepatutnya minggu 52');
- assert.equal(moment([2003, 0, 1]).week(), 1, 'Jan 1 2003 sepatutnya minggu 1');
- assert.equal(moment([2003, 0, 4]).week(), 1, 'Jan 4 2003 sepatutnya minggu 1');
- assert.equal(moment([2003, 0, 5]).week(), 1, 'Jan 5 2003 sepatutnya minggu 1');
- assert.equal(moment([2003, 0, 11]).week(), 2, 'Jan 11 2003 sepatutnya minggu 2');
- assert.equal(moment([2003, 0, 12]).week(), 2, 'Jan 12 2003 sepatutnya minggu 2');
- });
-
- test('weeks year starting thursday', function (assert) {
- assert.equal(moment([2008, 11, 28]).week(), 52, 'Dec 28 2008 sepatutnya minggu 52');
- assert.equal(moment([2009, 0, 1]).week(), 1, 'Jan 1 2009 sepatutnya minggu 1');
- assert.equal(moment([2009, 0, 3]).week(), 1, 'Jan 3 2009 sepatutnya minggu 1');
- assert.equal(moment([2009, 0, 4]).week(), 1, 'Jan 4 2009 sepatutnya minggu 1');
- assert.equal(moment([2009, 0, 10]).week(), 2, 'Jan 10 2009 sepatutnya minggu 2');
- assert.equal(moment([2009, 0, 11]).week(), 2, 'Jan 11 2009 sepatutnya minggu 2');
- });
-
- test('weeks year starting friday', function (assert) {
- assert.equal(moment([2009, 11, 27]).week(), 52, 'Dec 27 2009 sepatutnya minggu 52');
- assert.equal(moment([2010, 0, 1]).week(), 1, 'Jan 1 2010 sepatutnya minggu 1');
- assert.equal(moment([2010, 0, 2]).week(), 1, 'Jan 2 2010 sepatutnya minggu 1');
- assert.equal(moment([2010, 0, 3]).week(), 1, 'Jan 3 2010 sepatutnya minggu 1');
- assert.equal(moment([2010, 0, 9]).week(), 2, 'Jan 9 2010 sepatutnya minggu 2');
- assert.equal(moment([2010, 0, 10]).week(), 2, 'Jan 10 2010 sepatutnya minggu 2');
- });
-
- test('weeks year starting saturday', function (assert) {
- assert.equal(moment([2010, 11, 26]).week(), 52, 'Dec 26 2010 sepatutnya minggu 52');
- assert.equal(moment([2011, 0, 1]).week(), 1, 'Jan 1 2011 sepatutnya minggu 1');
- assert.equal(moment([2011, 0, 2]).week(), 1, 'Jan 2 2011 sepatutnya minggu 1');
- assert.equal(moment([2011, 0, 8]).week(), 2, 'Jan 8 2011 sepatutnya minggu 2');
- assert.equal(moment([2011, 0, 9]).week(), 2, 'Jan 9 2011 sepatutnya minggu 2');
- });
-
test('weeks year starting sunday format', function (assert) {
assert.equal(moment([2012, 0, 1]).format('w ww wo'), '1 01 1', 'Jan 1 2012 sepatutnya minggu 1');
assert.equal(moment([2012, 0, 7]).format('w ww wo'), '2 02 2', 'Jan 7 2012 sepatutnya minggu 2');
@@ -23186,54 +32185,6 @@
assert.equal(moment([2012, 0, 15]).format('w ww wo'), '3 03 3', 'Jan 15 2012 sepatutnya minggu 3');
});
- test('lenient ordinal parsing', function (assert) {
- var i, ordinalStr, testMoment;
- for (i = 1; i <= 31; ++i) {
- ordinalStr = moment([2014, 0, i]).format('YYYY MM Do');
- testMoment = moment(ordinalStr, 'YYYY MM Do');
- assert.equal(testMoment.year(), 2014,
- 'lenient ordinal parsing ' + i + ' year check');
- assert.equal(testMoment.month(), 0,
- 'lenient ordinal parsing ' + i + ' month check');
- assert.equal(testMoment.date(), i,
- 'lenient ordinal parsing ' + i + ' date check');
- }
- });
-
- test('meridiem invariant', function (assert) {
- var h, m, t1, t2;
- for (h = 0; h < 24; ++h) {
- for (m = 0; m < 60; m += 15) {
- t1 = moment.utc([2000, 0, 1, h, m]);
- t2 = moment(t1.format('A h:mm'), 'A h:mm');
- assert.equal(t2.format('HH:mm'), t1.format('HH:mm'),
- 'meridiem at ' + t1.format('HH:mm'));
- }
- }
- });
-
- test('lenient ordinal parsing of number', function (assert) {
- var i, testMoment;
- for (i = 1; i <= 31; ++i) {
- testMoment = moment('2014 01 ' + i, 'YYYY MM Do');
- assert.equal(testMoment.year(), 2014,
- 'lenient ordinal parsing of number ' + i + ' year check');
- assert.equal(testMoment.month(), 0,
- 'lenient ordinal parsing of number ' + i + ' month check');
- assert.equal(testMoment.date(), i,
- 'lenient ordinal parsing of number ' + i + ' date check');
- }
- });
-
- test('strict ordinal parsing', function (assert) {
- var i, ordinalStr, testMoment;
- for (i = 1; i <= 31; ++i) {
- ordinalStr = moment([2014, 0, i]).format('YYYY MM Do');
- testMoment = moment(ordinalStr, 'YYYY MM Do', true);
- assert.ok(testMoment.isValid(), 'strict ordinal parsing ' + i);
- }
- });
-
}));
;(function (global, factory) {
@@ -23242,6 +32193,224 @@
typeof define === 'function' && define.amd ? define(['../../moment'], factory) :
factory(global.moment)
}(this, function (moment) { 'use strict';
+
+ function each(array, callback) {
+ var i;
+ for (i = 0; i < array.length; i++) {
+ callback(array[i], i, array);
+ }
+ }
+
+ function objectKeys(obj) {
+ if (Object.keys) {
+ return Object.keys(obj);
+ } else {
+ // IE8
+ var res = [], i;
+ for (i in obj) {
+ if (obj.hasOwnProperty(i)) {
+ res.push(i);
+ }
+ }
+ return res;
+ }
+ }
+
+ // Pick the first defined of two or three arguments.
+ function defaults(a, b, c) {
+ if (a != null) {
+ return a;
+ }
+ if (b != null) {
+ return b;
+ }
+ return c;
+ }
+
+ function defineCommonLocaleTests(locale, options) {
+ test('lenient ordinal parsing', function (assert) {
+ var i, ordinalStr, testMoment;
+ for (i = 1; i <= 31; ++i) {
+ ordinalStr = moment([2014, 0, i]).format('YYYY MM Do');
+ testMoment = moment(ordinalStr, 'YYYY MM Do');
+ assert.equal(testMoment.year(), 2014,
+ 'lenient ordinal parsing ' + i + ' year check');
+ assert.equal(testMoment.month(), 0,
+ 'lenient ordinal parsing ' + i + ' month check');
+ assert.equal(testMoment.date(), i,
+ 'lenient ordinal parsing ' + i + ' date check');
+ }
+ });
+
+ test('lenient ordinal parsing of number', function (assert) {
+ var i, testMoment;
+ for (i = 1; i <= 31; ++i) {
+ testMoment = moment('2014 01 ' + i, 'YYYY MM Do');
+ assert.equal(testMoment.year(), 2014,
+ 'lenient ordinal parsing of number ' + i + ' year check');
+ assert.equal(testMoment.month(), 0,
+ 'lenient ordinal parsing of number ' + i + ' month check');
+ assert.equal(testMoment.date(), i,
+ 'lenient ordinal parsing of number ' + i + ' date check');
+ }
+ });
+
+ test('strict ordinal parsing', function (assert) {
+ var i, ordinalStr, testMoment;
+ for (i = 1; i <= 31; ++i) {
+ ordinalStr = moment([2014, 0, i]).format('YYYY MM Do');
+ testMoment = moment(ordinalStr, 'YYYY MM Do', true);
+ assert.ok(testMoment.isValid(), 'strict ordinal parsing ' + i);
+ }
+ });
+
+ test('meridiem invariant', function (assert) {
+ var h, m, t1, t2;
+ for (h = 0; h < 24; ++h) {
+ for (m = 0; m < 60; m += 15) {
+ t1 = moment.utc([2000, 0, 1, h, m]);
+ t2 = moment.utc(t1.format('A h:mm'), 'A h:mm');
+ assert.equal(t2.format('HH:mm'), t1.format('HH:mm'),
+ 'meridiem at ' + t1.format('HH:mm'));
+ }
+ }
+ });
+
+ test('date format correctness', function (assert) {
+ var data, tokens;
+ data = moment.localeData()._longDateFormat;
+ tokens = objectKeys(data);
+ each(tokens, function (srchToken) {
+ // Check each format string to make sure it does not contain any
+ // tokens that need to be expanded.
+ each(tokens, function (baseToken) {
+ // strip escaped sequences
+ var format = data[baseToken].replace(/(\[[^\]]*\])/g, '');
+ assert.equal(false, !!~format.indexOf(srchToken),
+ 'contains ' + srchToken + ' in ' + baseToken);
+ });
+ });
+ });
+
+ test('month parsing correctness', function (assert) {
+ var i, m;
+
+ if (locale === 'tr') {
+ // I can't fix it :(
+ expect(0);
+ return;
+ }
+ function tester(format) {
+ var r;
+ r = moment(m.format(format), format);
+ assert.equal(r.month(), m.month(), 'month ' + i + ' fmt ' + format);
+ r = moment(m.format(format).toLocaleUpperCase(), format);
+ assert.equal(r.month(), m.month(), 'month ' + i + ' fmt ' + format + ' upper');
+ r = moment(m.format(format).toLocaleLowerCase(), format);
+ assert.equal(r.month(), m.month(), 'month ' + i + ' fmt ' + format + ' lower');
+
+ r = moment(m.format(format), format, true);
+ assert.equal(r.month(), m.month(), 'month ' + i + ' fmt ' + format + ' strict');
+ r = moment(m.format(format).toLocaleUpperCase(), format, true);
+ assert.equal(r.month(), m.month(), 'month ' + i + ' fmt ' + format + ' upper strict');
+ r = moment(m.format(format).toLocaleLowerCase(), format, true);
+ assert.equal(r.month(), m.month(), 'month ' + i + ' fmt ' + format + ' lower strict');
+ }
+
+ for (i = 0; i < 12; ++i) {
+ m = moment([2015, i, 15, 18]);
+ tester('MMM');
+ tester('MMM.');
+ tester('MMMM');
+ tester('MMMM.');
+ }
+ });
+
+ test('weekday parsing correctness', function (assert) {
+ var i, m;
+
+ if (locale === 'tr' || locale === 'az') {
+ // There is a lower-case letter (ı), that converted to upper then
+ // lower changes to i
+ expect(0);
+ return;
+ }
+ function tester(format) {
+ var r, baseMsg = 'weekday ' + m.weekday() + ' fmt ' + format;
+ r = moment(m.format(format), format);
+ assert.equal(r.weekday(), m.weekday(), baseMsg);
+ r = moment(m.format(format).toLocaleUpperCase(), format);
+ assert.equal(r.weekday(), m.weekday(), baseMsg + ' upper');
+ r = moment(m.format(format).toLocaleLowerCase(), format);
+ assert.equal(r.weekday(), m.weekday(), baseMsg + ' lower');
+
+ r = moment(m.format(format), format, true);
+ assert.equal(r.weekday(), m.weekday(), baseMsg + ' strict');
+ r = moment(m.format(format).toLocaleUpperCase(), format, true);
+ assert.equal(r.weekday(), m.weekday(), baseMsg + ' upper strict');
+ r = moment(m.format(format).toLocaleLowerCase(), format, true);
+ assert.equal(r.weekday(), m.weekday(), baseMsg + ' lower strict');
+ }
+
+ for (i = 0; i < 7; ++i) {
+ m = moment.utc([2015, i, 15, 18]);
+ tester('dd');
+ tester('ddd');
+ tester('dddd');
+ }
+ });
+ }
+
+ function setupDeprecationHandler(test, moment, scope) {
+ test._expectedDeprecations = null;
+ test._observedDeprecations = null;
+ test._oldSupress = moment.suppressDeprecationWarnings;
+ moment.suppressDeprecationWarnings = true;
+ test.expectedDeprecations = function () {
+ test._expectedDeprecations = arguments;
+ test._observedDeprecations = [];
+ };
+ moment.deprecationHandler = function (name, msg) {
+ var deprecationId = matchedDeprecation(name, msg, test._expectedDeprecations);
+ if (deprecationId === -1) {
+ throw new Error('Unexpected deprecation thrown name=' +
+ name + ' msg=' + msg);
+ }
+ test._observedDeprecations[deprecationId] = 1;
+ };
+ }
+
+ function teardownDeprecationHandler(test, moment, scope) {
+ moment.suppressDeprecationWarnings = test._oldSupress;
+
+ if (test._expectedDeprecations != null) {
+ var missedDeprecations = [];
+ each(test._expectedDeprecations, function (deprecationPattern, id) {
+ if (test._observedDeprecations[id] !== 1) {
+ missedDeprecations.push(deprecationPattern);
+ }
+ });
+ if (missedDeprecations.length !== 0) {
+ throw new Error('Expected deprecation warnings did not happen: ' +
+ missedDeprecations.join(' '));
+ }
+ }
+ }
+
+ function matchedDeprecation(name, msg, deprecations) {
+ if (deprecations == null) {
+ return -1;
+ }
+ for (var i = 0; i < deprecations.length; ++i) {
+ if (name != null && name === deprecations[i]) {
+ return i;
+ }
+ if (msg != null && msg.substring(0, deprecations[i].length) === deprecations[i]) {
+ return i;
+ }
+ }
+ return -1;
+ }
/*global QUnit:false*/
@@ -23256,11 +32425,13 @@
moment.createFromInputFallback = function (config) {
throw new Error('input not handled by moment: ' + config._i);
};
+ setupDeprecationHandler(test, moment, 'core');
if (lifecycle && lifecycle.setup) {
lifecycle.setup();
}
},
teardown : function () {
+ teardownDeprecationHandler(test, moment, 'core');
if (lifecycle && lifecycle.teardown) {
lifecycle.teardown();
}
@@ -23275,17 +32446,20 @@
moment.createFromInputFallback = function (config) {
throw new Error('input not handled by moment: ' + config._i);
};
+ setupDeprecationHandler(test, moment, 'locale');
if (lifecycle && lifecycle.setup) {
lifecycle.setup();
}
},
teardown : function () {
moment.locale('en');
+ teardownDeprecationHandler(test, moment, 'locale');
if (lifecycle && lifecycle.teardown) {
lifecycle.teardown();
}
}
});
+ defineCommonLocaleTests(name, -1, -1);
}
localeModule('my');
@@ -23504,24 +32678,14 @@
});
test('calendar day', function (assert) {
- var a = moment().hours(2).minutes(0).seconds(0);
-
- assert.equal(moment(a).calendar(), 'ယနေ. ၀၂:၀၀ မှာ', 'ယနေ. ဒီအချိန်');
- assert.equal(moment(a).add({
- m: 25
- }).calendar(), 'ယနေ. ၀၂:၂၅ မှာ', 'ယခုမှ ၂၅ မိနစ်ပေါင်းထည့်');
- assert.equal(moment(a).add({
- h: 1
- }).calendar(), 'ယနေ. ၀၃:၀၀ မှာ', 'ယခုမှ ၁ နာရီပေါင်းထည့်');
- assert.equal(moment(a).add({
- d: 1
- }).calendar(), 'မနက်ဖြန် ၀၂:၀၀ မှာ', 'မနက်ဖြန် ဒီအချိန်');
- assert.equal(moment(a).subtract({
- h: 1
- }).calendar(), 'ယနေ. ၀၁:၀၀ မှာ', 'ယခုမှ ၁ နာရီနှုတ်');
- assert.equal(moment(a).subtract({
- d: 1
- }).calendar(), 'မနေ.က ၀၂:၀၀ မှာ', 'မနေ.က ဒီအချိန်');
+ var a = moment().hours(12).minutes(0).seconds(0);
+
+ assert.equal(moment(a).calendar(), 'ယနေ. ၁၂:၀၀ မှာ', 'ယနေ. ဒီအချိန်');
+ assert.equal(moment(a).add({m: 25}).calendar(), 'ယနေ. ၁၂:၂၅ မှာ', 'ယခုမှ ၂၅ မိနစ်ပေါင်းထည့်');
+ assert.equal(moment(a).add({h: 1}).calendar(), 'ယနေ. ၁၃:၀၀ မှာ', 'ယခုမှ ၁ နာရီပေါင်းထည့်');
+ assert.equal(moment(a).add({d: 1}).calendar(), 'မနက်ဖြန် ၁၂:၀၀ မှာ', 'မနက်ဖြန် ဒီအချိန်');
+ assert.equal(moment(a).subtract({h: 1}).calendar(), 'ယနေ. ၁၁:၀၀ မှာ', 'ယခုမှ ၁ နာရီနှုတ်');
+ assert.equal(moment(a).subtract({d: 1}).calendar(), 'မနေ.က ၁၂:၀၀ မှာ', 'မနေ.က ဒီအချိန်');
});
test('calendar next week', function (assert) {
@@ -23575,67 +32739,6 @@
assert.equal(weeksFromNow.calendar(), weeksFromNow.format('L'), '၂ ပတ် အတွင်း');
});
- test('weeks year starting sunday', function (assert) {
- assert.equal(moment([2012, 0, 1]).week(), 52, 'Jan 1 2012 should be week 52');
- assert.equal(moment([2012, 0, 2]).week(), 1, 'Jan 2 2012 should be week 1');
- assert.equal(moment([2012, 0, 8]).week(), 1, 'Jan 8 2012 should be week 1');
- assert.equal(moment([2012, 0, 9]).week(), 2, 'Jan 9 2012 should be week 2');
- assert.equal(moment([2012, 0, 15]).week(), 2, 'Jan 15 2012 should be week 2');
- });
-
- test('weeks year starting monday', function (assert) {
- assert.equal(moment([2007, 0, 1]).week(), 1, 'Jan 1 2007 should be week 1');
- assert.equal(moment([2007, 0, 7]).week(), 1, 'Jan 7 2007 should be week 1');
- assert.equal(moment([2007, 0, 8]).week(), 2, 'Jan 8 2007 should be week 2');
- assert.equal(moment([2007, 0, 14]).week(), 2, 'Jan 14 2007 should be week 2');
- assert.equal(moment([2007, 0, 15]).week(), 3, 'Jan 15 2007 should be week 3');
- });
-
- test('weeks year starting tuesday', function (assert) {
- assert.equal(moment([2007, 11, 31]).week(), 1, 'Dec 31 2007 should be week 1');
- assert.equal(moment([2008, 0, 1]).week(), 1, 'Jan 1 2008 should be week 1');
- assert.equal(moment([2008, 0, 6]).week(), 1, 'Jan 6 2008 should be week 1');
- assert.equal(moment([2008, 0, 7]).week(), 2, 'Jan 7 2008 should be week 2');
- assert.equal(moment([2008, 0, 13]).week(), 2, 'Jan 13 2008 should be week 2');
- assert.equal(moment([2008, 0, 14]).week(), 3, 'Jan 14 2008 should be week 3');
- });
-
- test('weeks year starting wednesday', function (assert) {
- assert.equal(moment([2002, 11, 30]).week(), 1, 'Dec 30 2002 should be week 1');
- assert.equal(moment([2003, 0, 1]).week(), 1, 'Jan 1 2003 should be week 1');
- assert.equal(moment([2003, 0, 5]).week(), 1, 'Jan 5 2003 should be week 1');
- assert.equal(moment([2003, 0, 6]).week(), 2, 'Jan 6 2003 should be week 2');
- assert.equal(moment([2003, 0, 12]).week(), 2, 'Jan 12 2003 should be week 2');
- assert.equal(moment([2003, 0, 13]).week(), 3, 'Jan 13 2003 should be week 3');
- });
-
- test('weeks year starting thursday', function (assert) {
- assert.equal(moment([2008, 11, 29]).week(), 1, 'Dec 29 2008 should be week 1');
- assert.equal(moment([2009, 0, 1]).week(), 1, 'Jan 1 2009 should be week 1');
- assert.equal(moment([2009, 0, 4]).week(), 1, 'Jan 4 2009 should be week 1');
- assert.equal(moment([2009, 0, 5]).week(), 2, 'Jan 5 2009 should be week 2');
- assert.equal(moment([2009, 0, 11]).week(), 2, 'Jan 11 2009 should be week 2');
- assert.equal(moment([2009, 0, 13]).week(), 3, 'Jan 12 2009 should be week 3');
- });
-
- test('weeks year starting friday', function (assert) {
- assert.equal(moment([2009, 11, 28]).week(), 53, 'Dec 28 2009 should be week 53');
- assert.equal(moment([2010, 0, 1]).week(), 53, 'Jan 1 2010 should be week 53');
- assert.equal(moment([2010, 0, 3]).week(), 53, 'Jan 3 2010 should be week 53');
- assert.equal(moment([2010, 0, 4]).week(), 1, 'Jan 4 2010 should be week 1');
- assert.equal(moment([2010, 0, 10]).week(), 1, 'Jan 10 2010 should be week 1');
- assert.equal(moment([2010, 0, 11]).week(), 2, 'Jan 11 2010 should be week 2');
- });
-
- test('weeks year starting saturday', function (assert) {
- assert.equal(moment([2010, 11, 27]).week(), 52, 'Dec 27 2010 should be week 52');
- assert.equal(moment([2011, 0, 1]).week(), 52, 'Jan 1 2011 should be week 52');
- assert.equal(moment([2011, 0, 2]).week(), 52, 'Jan 2 2011 should be week 52');
- assert.equal(moment([2011, 0, 3]).week(), 1, 'Jan 3 2011 should be week 1');
- assert.equal(moment([2011, 0, 9]).week(), 1, 'Jan 9 2011 should be week 1');
- assert.equal(moment([2011, 0, 10]).week(), 2, 'Jan 10 2011 should be week 2');
- });
-
test('weeks year starting sunday formatted', function (assert) {
assert.equal(moment([2012, 0, 1]).format('w ww wo'), '၅၂ ၅၂ ၅၂', 'Jan 1 2012 should be week 52');
assert.equal(moment([2012, 0, 2]).format('w ww wo'), '၁ ၀၁ ၁', 'Jan 2 2012 should be week 1');
@@ -23644,42 +32747,6 @@
assert.equal(moment([2012, 0, 15]).format('w ww wo'), '၂ ၀၂ ၂', 'Jan 15 2012 should be week 2');
});
- test('lenient ordinal parsing', function (assert) {
- var i, ordinalStr, testMoment;
- for (i = 1; i <= 31; ++i) {
- ordinalStr = moment([2014, 0, i]).format('YYYY MM Do');
- testMoment = moment(ordinalStr, 'YYYY MM Do');
- assert.equal(testMoment.year(), 2014,
- 'lenient ordinal parsing ' + i + ' year check');
- assert.equal(testMoment.month(), 0,
- 'lenient ordinal parsing ' + i + ' month check');
- assert.equal(testMoment.date(), i,
- 'lenient ordinal parsing ' + i + ' date check');
- }
- });
-
- test('lenient ordinal parsing of number', function (assert) {
- var i, testMoment;
- for (i = 1; i <= 31; ++i) {
- testMoment = moment('2014 01 ' + i, 'YYYY MM Do');
- assert.equal(testMoment.year(), 2014,
- 'lenient ordinal parsing of number ' + i + ' year check');
- assert.equal(testMoment.month(), 0,
- 'lenient ordinal parsing of number ' + i + ' month check');
- assert.equal(testMoment.date(), i,
- 'lenient ordinal parsing of number ' + i + ' date check');
- }
- });
-
- test('strict ordinal parsing', function (assert) {
- var i, ordinalStr, testMoment;
- for (i = 1; i <= 31; ++i) {
- ordinalStr = moment([2014, 0, i]).format('YYYY MM Do');
- testMoment = moment(ordinalStr, 'YYYY MM Do', true);
- assert.ok(testMoment.isValid(), 'strict ordinal parsing ' + i);
- }
- });
-
}));
;(function (global, factory) {
@@ -23688,6 +32755,224 @@
typeof define === 'function' && define.amd ? define(['../../moment'], factory) :
factory(global.moment)
}(this, function (moment) { 'use strict';
+
+ function each(array, callback) {
+ var i;
+ for (i = 0; i < array.length; i++) {
+ callback(array[i], i, array);
+ }
+ }
+
+ function objectKeys(obj) {
+ if (Object.keys) {
+ return Object.keys(obj);
+ } else {
+ // IE8
+ var res = [], i;
+ for (i in obj) {
+ if (obj.hasOwnProperty(i)) {
+ res.push(i);
+ }
+ }
+ return res;
+ }
+ }
+
+ // Pick the first defined of two or three arguments.
+ function defaults(a, b, c) {
+ if (a != null) {
+ return a;
+ }
+ if (b != null) {
+ return b;
+ }
+ return c;
+ }
+
+ function defineCommonLocaleTests(locale, options) {
+ test('lenient ordinal parsing', function (assert) {
+ var i, ordinalStr, testMoment;
+ for (i = 1; i <= 31; ++i) {
+ ordinalStr = moment([2014, 0, i]).format('YYYY MM Do');
+ testMoment = moment(ordinalStr, 'YYYY MM Do');
+ assert.equal(testMoment.year(), 2014,
+ 'lenient ordinal parsing ' + i + ' year check');
+ assert.equal(testMoment.month(), 0,
+ 'lenient ordinal parsing ' + i + ' month check');
+ assert.equal(testMoment.date(), i,
+ 'lenient ordinal parsing ' + i + ' date check');
+ }
+ });
+
+ test('lenient ordinal parsing of number', function (assert) {
+ var i, testMoment;
+ for (i = 1; i <= 31; ++i) {
+ testMoment = moment('2014 01 ' + i, 'YYYY MM Do');
+ assert.equal(testMoment.year(), 2014,
+ 'lenient ordinal parsing of number ' + i + ' year check');
+ assert.equal(testMoment.month(), 0,
+ 'lenient ordinal parsing of number ' + i + ' month check');
+ assert.equal(testMoment.date(), i,
+ 'lenient ordinal parsing of number ' + i + ' date check');
+ }
+ });
+
+ test('strict ordinal parsing', function (assert) {
+ var i, ordinalStr, testMoment;
+ for (i = 1; i <= 31; ++i) {
+ ordinalStr = moment([2014, 0, i]).format('YYYY MM Do');
+ testMoment = moment(ordinalStr, 'YYYY MM Do', true);
+ assert.ok(testMoment.isValid(), 'strict ordinal parsing ' + i);
+ }
+ });
+
+ test('meridiem invariant', function (assert) {
+ var h, m, t1, t2;
+ for (h = 0; h < 24; ++h) {
+ for (m = 0; m < 60; m += 15) {
+ t1 = moment.utc([2000, 0, 1, h, m]);
+ t2 = moment.utc(t1.format('A h:mm'), 'A h:mm');
+ assert.equal(t2.format('HH:mm'), t1.format('HH:mm'),
+ 'meridiem at ' + t1.format('HH:mm'));
+ }
+ }
+ });
+
+ test('date format correctness', function (assert) {
+ var data, tokens;
+ data = moment.localeData()._longDateFormat;
+ tokens = objectKeys(data);
+ each(tokens, function (srchToken) {
+ // Check each format string to make sure it does not contain any
+ // tokens that need to be expanded.
+ each(tokens, function (baseToken) {
+ // strip escaped sequences
+ var format = data[baseToken].replace(/(\[[^\]]*\])/g, '');
+ assert.equal(false, !!~format.indexOf(srchToken),
+ 'contains ' + srchToken + ' in ' + baseToken);
+ });
+ });
+ });
+
+ test('month parsing correctness', function (assert) {
+ var i, m;
+
+ if (locale === 'tr') {
+ // I can't fix it :(
+ expect(0);
+ return;
+ }
+ function tester(format) {
+ var r;
+ r = moment(m.format(format), format);
+ assert.equal(r.month(), m.month(), 'month ' + i + ' fmt ' + format);
+ r = moment(m.format(format).toLocaleUpperCase(), format);
+ assert.equal(r.month(), m.month(), 'month ' + i + ' fmt ' + format + ' upper');
+ r = moment(m.format(format).toLocaleLowerCase(), format);
+ assert.equal(r.month(), m.month(), 'month ' + i + ' fmt ' + format + ' lower');
+
+ r = moment(m.format(format), format, true);
+ assert.equal(r.month(), m.month(), 'month ' + i + ' fmt ' + format + ' strict');
+ r = moment(m.format(format).toLocaleUpperCase(), format, true);
+ assert.equal(r.month(), m.month(), 'month ' + i + ' fmt ' + format + ' upper strict');
+ r = moment(m.format(format).toLocaleLowerCase(), format, true);
+ assert.equal(r.month(), m.month(), 'month ' + i + ' fmt ' + format + ' lower strict');
+ }
+
+ for (i = 0; i < 12; ++i) {
+ m = moment([2015, i, 15, 18]);
+ tester('MMM');
+ tester('MMM.');
+ tester('MMMM');
+ tester('MMMM.');
+ }
+ });
+
+ test('weekday parsing correctness', function (assert) {
+ var i, m;
+
+ if (locale === 'tr' || locale === 'az') {
+ // There is a lower-case letter (ı), that converted to upper then
+ // lower changes to i
+ expect(0);
+ return;
+ }
+ function tester(format) {
+ var r, baseMsg = 'weekday ' + m.weekday() + ' fmt ' + format;
+ r = moment(m.format(format), format);
+ assert.equal(r.weekday(), m.weekday(), baseMsg);
+ r = moment(m.format(format).toLocaleUpperCase(), format);
+ assert.equal(r.weekday(), m.weekday(), baseMsg + ' upper');
+ r = moment(m.format(format).toLocaleLowerCase(), format);
+ assert.equal(r.weekday(), m.weekday(), baseMsg + ' lower');
+
+ r = moment(m.format(format), format, true);
+ assert.equal(r.weekday(), m.weekday(), baseMsg + ' strict');
+ r = moment(m.format(format).toLocaleUpperCase(), format, true);
+ assert.equal(r.weekday(), m.weekday(), baseMsg + ' upper strict');
+ r = moment(m.format(format).toLocaleLowerCase(), format, true);
+ assert.equal(r.weekday(), m.weekday(), baseMsg + ' lower strict');
+ }
+
+ for (i = 0; i < 7; ++i) {
+ m = moment.utc([2015, i, 15, 18]);
+ tester('dd');
+ tester('ddd');
+ tester('dddd');
+ }
+ });
+ }
+
+ function setupDeprecationHandler(test, moment, scope) {
+ test._expectedDeprecations = null;
+ test._observedDeprecations = null;
+ test._oldSupress = moment.suppressDeprecationWarnings;
+ moment.suppressDeprecationWarnings = true;
+ test.expectedDeprecations = function () {
+ test._expectedDeprecations = arguments;
+ test._observedDeprecations = [];
+ };
+ moment.deprecationHandler = function (name, msg) {
+ var deprecationId = matchedDeprecation(name, msg, test._expectedDeprecations);
+ if (deprecationId === -1) {
+ throw new Error('Unexpected deprecation thrown name=' +
+ name + ' msg=' + msg);
+ }
+ test._observedDeprecations[deprecationId] = 1;
+ };
+ }
+
+ function teardownDeprecationHandler(test, moment, scope) {
+ moment.suppressDeprecationWarnings = test._oldSupress;
+
+ if (test._expectedDeprecations != null) {
+ var missedDeprecations = [];
+ each(test._expectedDeprecations, function (deprecationPattern, id) {
+ if (test._observedDeprecations[id] !== 1) {
+ missedDeprecations.push(deprecationPattern);
+ }
+ });
+ if (missedDeprecations.length !== 0) {
+ throw new Error('Expected deprecation warnings did not happen: ' +
+ missedDeprecations.join(' '));
+ }
+ }
+ }
+
+ function matchedDeprecation(name, msg, deprecations) {
+ if (deprecations == null) {
+ return -1;
+ }
+ for (var i = 0; i < deprecations.length; ++i) {
+ if (name != null && name === deprecations[i]) {
+ return i;
+ }
+ if (msg != null && msg.substring(0, deprecations[i].length) === deprecations[i]) {
+ return i;
+ }
+ }
+ return -1;
+ }
/*global QUnit:false*/
@@ -23702,11 +32987,13 @@
moment.createFromInputFallback = function (config) {
throw new Error('input not handled by moment: ' + config._i);
};
+ setupDeprecationHandler(test, moment, 'core');
if (lifecycle && lifecycle.setup) {
lifecycle.setup();
}
},
teardown : function () {
+ teardownDeprecationHandler(test, moment, 'core');
if (lifecycle && lifecycle.teardown) {
lifecycle.teardown();
}
@@ -23721,17 +33008,20 @@
moment.createFromInputFallback = function (config) {
throw new Error('input not handled by moment: ' + config._i);
};
+ setupDeprecationHandler(test, moment, 'locale');
if (lifecycle && lifecycle.setup) {
lifecycle.setup();
}
},
teardown : function () {
moment.locale('en');
+ teardownDeprecationHandler(test, moment, 'locale');
if (lifecycle && lifecycle.teardown) {
lifecycle.teardown();
}
}
});
+ defineCommonLocaleTests(name, -1, -1);
}
localeModule('nb');
@@ -23873,11 +33163,11 @@
test('suffix', function (assert) {
assert.equal(moment(30000).from(0), 'om noen sekunder', 'prefix');
- assert.equal(moment(0).from(30000), 'for noen sekunder siden', 'suffix');
+ assert.equal(moment(0).from(30000), 'noen sekunder siden', 'suffix');
});
test('now from now', function (assert) {
- assert.equal(moment().fromNow(), 'for noen sekunder siden', 'now from now should display as in the past');
+ assert.equal(moment().fromNow(), 'noen sekunder siden', 'now from now should display as in the past');
});
test('fromNow', function (assert) {
@@ -23886,14 +33176,14 @@
});
test('calendar day', function (assert) {
- var a = moment().hours(2).minutes(0).seconds(0);
-
- assert.equal(moment(a).calendar(), 'i dag kl. 02:00', 'today at the same time');
- assert.equal(moment(a).add({m: 25}).calendar(), 'i dag kl. 02:25', 'Now plus 25 min');
- assert.equal(moment(a).add({h: 1}).calendar(), 'i dag kl. 03:00', 'Now plus 1 hour');
- assert.equal(moment(a).add({d: 1}).calendar(), 'i morgen kl. 02:00', 'tomorrow at the same time');
- assert.equal(moment(a).subtract({h: 1}).calendar(), 'i dag kl. 01:00', 'Now minus 1 hour');
- assert.equal(moment(a).subtract({d: 1}).calendar(), 'i går kl. 02:00', 'yesterday at the same time');
+ var a = moment().hours(12).minutes(0).seconds(0);
+
+ assert.equal(moment(a).calendar(), 'i dag kl. 12:00', 'today at the same time');
+ assert.equal(moment(a).add({m: 25}).calendar(), 'i dag kl. 12:25', 'Now plus 25 min');
+ assert.equal(moment(a).add({h: 1}).calendar(), 'i dag kl. 13:00', 'Now plus 1 hour');
+ assert.equal(moment(a).add({d: 1}).calendar(), 'i morgen kl. 12:00', 'tomorrow at the same time');
+ assert.equal(moment(a).subtract({h: 1}).calendar(), 'i dag kl. 11:00', 'Now minus 1 hour');
+ assert.equal(moment(a).subtract({d: 1}).calendar(), 'i går kl. 12:00', 'yesterday at the same time');
});
test('calendar next week', function (assert) {
@@ -23934,67 +33224,6 @@
assert.equal(weeksFromNow.calendar(), weeksFromNow.format('L'), 'in 2 weeks');
});
- test('weeks year starting sunday', function (assert) {
- assert.equal(moment([2012, 0, 1]).week(), 52, 'Jan 1 2012 should be week 52');
- assert.equal(moment([2012, 0, 2]).week(), 1, 'Jan 2 2012 should be week 1');
- assert.equal(moment([2012, 0, 8]).week(), 1, 'Jan 8 2012 should be week 1');
- assert.equal(moment([2012, 0, 9]).week(), 2, 'Jan 9 2012 should be week 2');
- assert.equal(moment([2012, 0, 15]).week(), 2, 'Jan 15 2012 should be week 2');
- });
-
- test('weeks year starting monday', function (assert) {
- assert.equal(moment([2007, 0, 1]).week(), 1, 'Jan 1 2007 should be week 1');
- assert.equal(moment([2007, 0, 7]).week(), 1, 'Jan 7 2007 should be week 1');
- assert.equal(moment([2007, 0, 8]).week(), 2, 'Jan 8 2007 should be week 2');
- assert.equal(moment([2007, 0, 14]).week(), 2, 'Jan 14 2007 should be week 2');
- assert.equal(moment([2007, 0, 15]).week(), 3, 'Jan 15 2007 should be week 3');
- });
-
- test('weeks year starting tuesday', function (assert) {
- assert.equal(moment([2007, 11, 31]).week(), 1, 'Dec 31 2007 should be week 1');
- assert.equal(moment([2008, 0, 1]).week(), 1, 'Jan 1 2008 should be week 1');
- assert.equal(moment([2008, 0, 6]).week(), 1, 'Jan 6 2008 should be week 1');
- assert.equal(moment([2008, 0, 7]).week(), 2, 'Jan 7 2008 should be week 2');
- assert.equal(moment([2008, 0, 13]).week(), 2, 'Jan 13 2008 should be week 2');
- assert.equal(moment([2008, 0, 14]).week(), 3, 'Jan 14 2008 should be week 3');
- });
-
- test('weeks year starting wednesday', function (assert) {
- assert.equal(moment([2002, 11, 30]).week(), 1, 'Dec 30 2002 should be week 1');
- assert.equal(moment([2003, 0, 1]).week(), 1, 'Jan 1 2003 should be week 1');
- assert.equal(moment([2003, 0, 5]).week(), 1, 'Jan 5 2003 should be week 1');
- assert.equal(moment([2003, 0, 6]).week(), 2, 'Jan 6 2003 should be week 2');
- assert.equal(moment([2003, 0, 12]).week(), 2, 'Jan 12 2003 should be week 2');
- assert.equal(moment([2003, 0, 13]).week(), 3, 'Jan 13 2003 should be week 3');
- });
-
- test('weeks year starting thursday', function (assert) {
- assert.equal(moment([2008, 11, 29]).week(), 1, 'Dec 29 2008 should be week 1');
- assert.equal(moment([2009, 0, 1]).week(), 1, 'Jan 1 2009 should be week 1');
- assert.equal(moment([2009, 0, 4]).week(), 1, 'Jan 4 2009 should be week 1');
- assert.equal(moment([2009, 0, 5]).week(), 2, 'Jan 5 2009 should be week 2');
- assert.equal(moment([2009, 0, 11]).week(), 2, 'Jan 11 2009 should be week 2');
- assert.equal(moment([2009, 0, 13]).week(), 3, 'Jan 12 2009 should be week 3');
- });
-
- test('weeks year starting friday', function (assert) {
- assert.equal(moment([2009, 11, 28]).week(), 53, 'Dec 28 2009 should be week 53');
- assert.equal(moment([2010, 0, 1]).week(), 53, 'Jan 1 2010 should be week 53');
- assert.equal(moment([2010, 0, 3]).week(), 53, 'Jan 3 2010 should be week 53');
- assert.equal(moment([2010, 0, 4]).week(), 1, 'Jan 4 2010 should be week 1');
- assert.equal(moment([2010, 0, 10]).week(), 1, 'Jan 10 2010 should be week 1');
- assert.equal(moment([2010, 0, 11]).week(), 2, 'Jan 11 2010 should be week 2');
- });
-
- test('weeks year starting saturday', function (assert) {
- assert.equal(moment([2010, 11, 27]).week(), 52, 'Dec 27 2010 should be week 52');
- assert.equal(moment([2011, 0, 1]).week(), 52, 'Jan 1 2011 should be week 52');
- assert.equal(moment([2011, 0, 2]).week(), 52, 'Jan 2 2011 should be week 52');
- assert.equal(moment([2011, 0, 3]).week(), 1, 'Jan 3 2011 should be week 1');
- assert.equal(moment([2011, 0, 9]).week(), 1, 'Jan 9 2011 should be week 1');
- assert.equal(moment([2011, 0, 10]).week(), 2, 'Jan 10 2011 should be week 2');
- });
-
test('weeks year starting sunday formatted', function (assert) {
assert.equal(moment([2012, 0, 1]).format('w ww wo'), '52 52 52.', 'Jan 1 2012 should be week 52');
assert.equal(moment([2012, 0, 2]).format('w ww wo'), '1 01 1.', 'Jan 2 2012 should be week 1');
@@ -24003,42 +33232,6 @@
assert.equal(moment([2012, 0, 15]).format('w ww wo'), '2 02 2.', 'Jan 15 2012 should be week 2');
});
- test('lenient ordinal parsing', function (assert) {
- var i, ordinalStr, testMoment;
- for (i = 1; i <= 31; ++i) {
- ordinalStr = moment([2014, 0, i]).format('YYYY MM Do');
- testMoment = moment(ordinalStr, 'YYYY MM Do');
- assert.equal(testMoment.year(), 2014,
- 'lenient ordinal parsing ' + i + ' year check');
- assert.equal(testMoment.month(), 0,
- 'lenient ordinal parsing ' + i + ' month check');
- assert.equal(testMoment.date(), i,
- 'lenient ordinal parsing ' + i + ' date check');
- }
- });
-
- test('lenient ordinal parsing of number', function (assert) {
- var i, testMoment;
- for (i = 1; i <= 31; ++i) {
- testMoment = moment('2014 01 ' + i, 'YYYY MM Do');
- assert.equal(testMoment.year(), 2014,
- 'lenient ordinal parsing of number ' + i + ' year check');
- assert.equal(testMoment.month(), 0,
- 'lenient ordinal parsing of number ' + i + ' month check');
- assert.equal(testMoment.date(), i,
- 'lenient ordinal parsing of number ' + i + ' date check');
- }
- });
-
- test('strict ordinal parsing', function (assert) {
- var i, ordinalStr, testMoment;
- for (i = 1; i <= 31; ++i) {
- ordinalStr = moment([2014, 0, i]).format('YYYY MM Do');
- testMoment = moment(ordinalStr, 'YYYY MM Do', true);
- assert.ok(testMoment.isValid(), 'strict ordinal parsing ' + i);
- }
- });
-
}));
;(function (global, factory) {
@@ -24047,6 +33240,224 @@
typeof define === 'function' && define.amd ? define(['../../moment'], factory) :
factory(global.moment)
}(this, function (moment) { 'use strict';
+
+ function each(array, callback) {
+ var i;
+ for (i = 0; i < array.length; i++) {
+ callback(array[i], i, array);
+ }
+ }
+
+ function objectKeys(obj) {
+ if (Object.keys) {
+ return Object.keys(obj);
+ } else {
+ // IE8
+ var res = [], i;
+ for (i in obj) {
+ if (obj.hasOwnProperty(i)) {
+ res.push(i);
+ }
+ }
+ return res;
+ }
+ }
+
+ // Pick the first defined of two or three arguments.
+ function defaults(a, b, c) {
+ if (a != null) {
+ return a;
+ }
+ if (b != null) {
+ return b;
+ }
+ return c;
+ }
+
+ function defineCommonLocaleTests(locale, options) {
+ test('lenient ordinal parsing', function (assert) {
+ var i, ordinalStr, testMoment;
+ for (i = 1; i <= 31; ++i) {
+ ordinalStr = moment([2014, 0, i]).format('YYYY MM Do');
+ testMoment = moment(ordinalStr, 'YYYY MM Do');
+ assert.equal(testMoment.year(), 2014,
+ 'lenient ordinal parsing ' + i + ' year check');
+ assert.equal(testMoment.month(), 0,
+ 'lenient ordinal parsing ' + i + ' month check');
+ assert.equal(testMoment.date(), i,
+ 'lenient ordinal parsing ' + i + ' date check');
+ }
+ });
+
+ test('lenient ordinal parsing of number', function (assert) {
+ var i, testMoment;
+ for (i = 1; i <= 31; ++i) {
+ testMoment = moment('2014 01 ' + i, 'YYYY MM Do');
+ assert.equal(testMoment.year(), 2014,
+ 'lenient ordinal parsing of number ' + i + ' year check');
+ assert.equal(testMoment.month(), 0,
+ 'lenient ordinal parsing of number ' + i + ' month check');
+ assert.equal(testMoment.date(), i,
+ 'lenient ordinal parsing of number ' + i + ' date check');
+ }
+ });
+
+ test('strict ordinal parsing', function (assert) {
+ var i, ordinalStr, testMoment;
+ for (i = 1; i <= 31; ++i) {
+ ordinalStr = moment([2014, 0, i]).format('YYYY MM Do');
+ testMoment = moment(ordinalStr, 'YYYY MM Do', true);
+ assert.ok(testMoment.isValid(), 'strict ordinal parsing ' + i);
+ }
+ });
+
+ test('meridiem invariant', function (assert) {
+ var h, m, t1, t2;
+ for (h = 0; h < 24; ++h) {
+ for (m = 0; m < 60; m += 15) {
+ t1 = moment.utc([2000, 0, 1, h, m]);
+ t2 = moment.utc(t1.format('A h:mm'), 'A h:mm');
+ assert.equal(t2.format('HH:mm'), t1.format('HH:mm'),
+ 'meridiem at ' + t1.format('HH:mm'));
+ }
+ }
+ });
+
+ test('date format correctness', function (assert) {
+ var data, tokens;
+ data = moment.localeData()._longDateFormat;
+ tokens = objectKeys(data);
+ each(tokens, function (srchToken) {
+ // Check each format string to make sure it does not contain any
+ // tokens that need to be expanded.
+ each(tokens, function (baseToken) {
+ // strip escaped sequences
+ var format = data[baseToken].replace(/(\[[^\]]*\])/g, '');
+ assert.equal(false, !!~format.indexOf(srchToken),
+ 'contains ' + srchToken + ' in ' + baseToken);
+ });
+ });
+ });
+
+ test('month parsing correctness', function (assert) {
+ var i, m;
+
+ if (locale === 'tr') {
+ // I can't fix it :(
+ expect(0);
+ return;
+ }
+ function tester(format) {
+ var r;
+ r = moment(m.format(format), format);
+ assert.equal(r.month(), m.month(), 'month ' + i + ' fmt ' + format);
+ r = moment(m.format(format).toLocaleUpperCase(), format);
+ assert.equal(r.month(), m.month(), 'month ' + i + ' fmt ' + format + ' upper');
+ r = moment(m.format(format).toLocaleLowerCase(), format);
+ assert.equal(r.month(), m.month(), 'month ' + i + ' fmt ' + format + ' lower');
+
+ r = moment(m.format(format), format, true);
+ assert.equal(r.month(), m.month(), 'month ' + i + ' fmt ' + format + ' strict');
+ r = moment(m.format(format).toLocaleUpperCase(), format, true);
+ assert.equal(r.month(), m.month(), 'month ' + i + ' fmt ' + format + ' upper strict');
+ r = moment(m.format(format).toLocaleLowerCase(), format, true);
+ assert.equal(r.month(), m.month(), 'month ' + i + ' fmt ' + format + ' lower strict');
+ }
+
+ for (i = 0; i < 12; ++i) {
+ m = moment([2015, i, 15, 18]);
+ tester('MMM');
+ tester('MMM.');
+ tester('MMMM');
+ tester('MMMM.');
+ }
+ });
+
+ test('weekday parsing correctness', function (assert) {
+ var i, m;
+
+ if (locale === 'tr' || locale === 'az') {
+ // There is a lower-case letter (ı), that converted to upper then
+ // lower changes to i
+ expect(0);
+ return;
+ }
+ function tester(format) {
+ var r, baseMsg = 'weekday ' + m.weekday() + ' fmt ' + format;
+ r = moment(m.format(format), format);
+ assert.equal(r.weekday(), m.weekday(), baseMsg);
+ r = moment(m.format(format).toLocaleUpperCase(), format);
+ assert.equal(r.weekday(), m.weekday(), baseMsg + ' upper');
+ r = moment(m.format(format).toLocaleLowerCase(), format);
+ assert.equal(r.weekday(), m.weekday(), baseMsg + ' lower');
+
+ r = moment(m.format(format), format, true);
+ assert.equal(r.weekday(), m.weekday(), baseMsg + ' strict');
+ r = moment(m.format(format).toLocaleUpperCase(), format, true);
+ assert.equal(r.weekday(), m.weekday(), baseMsg + ' upper strict');
+ r = moment(m.format(format).toLocaleLowerCase(), format, true);
+ assert.equal(r.weekday(), m.weekday(), baseMsg + ' lower strict');
+ }
+
+ for (i = 0; i < 7; ++i) {
+ m = moment.utc([2015, i, 15, 18]);
+ tester('dd');
+ tester('ddd');
+ tester('dddd');
+ }
+ });
+ }
+
+ function setupDeprecationHandler(test, moment, scope) {
+ test._expectedDeprecations = null;
+ test._observedDeprecations = null;
+ test._oldSupress = moment.suppressDeprecationWarnings;
+ moment.suppressDeprecationWarnings = true;
+ test.expectedDeprecations = function () {
+ test._expectedDeprecations = arguments;
+ test._observedDeprecations = [];
+ };
+ moment.deprecationHandler = function (name, msg) {
+ var deprecationId = matchedDeprecation(name, msg, test._expectedDeprecations);
+ if (deprecationId === -1) {
+ throw new Error('Unexpected deprecation thrown name=' +
+ name + ' msg=' + msg);
+ }
+ test._observedDeprecations[deprecationId] = 1;
+ };
+ }
+
+ function teardownDeprecationHandler(test, moment, scope) {
+ moment.suppressDeprecationWarnings = test._oldSupress;
+
+ if (test._expectedDeprecations != null) {
+ var missedDeprecations = [];
+ each(test._expectedDeprecations, function (deprecationPattern, id) {
+ if (test._observedDeprecations[id] !== 1) {
+ missedDeprecations.push(deprecationPattern);
+ }
+ });
+ if (missedDeprecations.length !== 0) {
+ throw new Error('Expected deprecation warnings did not happen: ' +
+ missedDeprecations.join(' '));
+ }
+ }
+ }
+
+ function matchedDeprecation(name, msg, deprecations) {
+ if (deprecations == null) {
+ return -1;
+ }
+ for (var i = 0; i < deprecations.length; ++i) {
+ if (name != null && name === deprecations[i]) {
+ return i;
+ }
+ if (msg != null && msg.substring(0, deprecations[i].length) === deprecations[i]) {
+ return i;
+ }
+ }
+ return -1;
+ }
/*global QUnit:false*/
@@ -24061,11 +33472,13 @@
moment.createFromInputFallback = function (config) {
throw new Error('input not handled by moment: ' + config._i);
};
+ setupDeprecationHandler(test, moment, 'core');
if (lifecycle && lifecycle.setup) {
lifecycle.setup();
}
},
teardown : function () {
+ teardownDeprecationHandler(test, moment, 'core');
if (lifecycle && lifecycle.teardown) {
lifecycle.teardown();
}
@@ -24080,17 +33493,20 @@
moment.createFromInputFallback = function (config) {
throw new Error('input not handled by moment: ' + config._i);
};
+ setupDeprecationHandler(test, moment, 'locale');
if (lifecycle && lifecycle.setup) {
lifecycle.setup();
}
},
teardown : function () {
moment.locale('en');
+ teardownDeprecationHandler(test, moment, 'locale');
if (lifecycle && lifecycle.teardown) {
lifecycle.teardown();
}
}
});
+ defineCommonLocaleTests(name, -1, -1);
}
localeModule('ne');
@@ -24243,14 +33659,14 @@
});
test('calendar day', function (assert) {
- var a = moment().hours(2).minutes(0).seconds(0);
-
- assert.equal(moment(a).calendar(), 'आज रातिको २:०० बजे', 'today at the same time');
- assert.equal(moment(a).add({m: 25}).calendar(), 'आज रातिको २:२५ बजे', 'Now plus 25 min');
- assert.equal(moment(a).add({h: 1}).calendar(), 'आज बिहानको ३:०० बजे', 'Now plus 1 hour');
- assert.equal(moment(a).add({d: 1}).calendar(), 'भोलि रातिको २:०० बजे', 'tomorrow at the same time');
- assert.equal(moment(a).subtract({h: 1}).calendar(), 'आज रातिको १:०० बजे', 'Now minus 1 hour');
- assert.equal(moment(a).subtract({d: 1}).calendar(), 'हिजो रातिको २:०० बजे', 'yesterday at the same time');
+ var a = moment().hours(12).minutes(0).seconds(0);
+
+ assert.equal(moment(a).calendar(), 'आज दिउँसोको १२:०० बजे', 'today at the same time');
+ assert.equal(moment(a).add({m: 25}).calendar(), 'आज दिउँसोको १२:२५ बजे', 'Now plus 25 min');
+ assert.equal(moment(a).add({h: 1}).calendar(), 'आज दिउँसोको १:०० बजे', 'Now plus 1 hour');
+ assert.equal(moment(a).add({d: 1}).calendar(), 'भोलि दिउँसोको १२:०० बजे', 'tomorrow at the same time');
+ assert.equal(moment(a).subtract({h: 1}).calendar(), 'आज बिहानको ११:०० बजे', 'Now minus 1 hour');
+ assert.equal(moment(a).subtract({d: 1}).calendar(), 'हिजो दिउँसोको १२:०० बजे', 'yesterday at the same time');
});
test('calendar next week', function (assert) {
@@ -24307,68 +33723,6 @@
assert.equal(moment([2011, 2, 23, 21, 20]).format('A'), 'राति', 'night');
});
- test('weeks year starting sunday', function (assert) {
- assert.equal(moment([2012, 0, 1]).week(), 1, 'Jan 1 2012 should be week 1');
- assert.equal(moment([2012, 0, 7]).week(), 1, 'Jan 7 2012 should be week 1');
- assert.equal(moment([2012, 0, 8]).week(), 2, 'Jan 8 2012 should be week 2');
- assert.equal(moment([2012, 0, 14]).week(), 2, 'Jan 14 2012 should be week 2');
- assert.equal(moment([2012, 0, 15]).week(), 3, 'Jan 15 2012 should be week 3');
- });
-
- test('weeks year starting monday', function (assert) {
- assert.equal(moment([2006, 11, 31]).week(), 1, 'Dec 31 2006 should be week 1');
- assert.equal(moment([2007, 0, 1]).week(), 1, 'Jan 1 2007 should be week 1');
- assert.equal(moment([2007, 0, 6]).week(), 1, 'Jan 6 2007 should be week 1');
- assert.equal(moment([2007, 0, 7]).week(), 2, 'Jan 7 2007 should be week 2');
- assert.equal(moment([2007, 0, 13]).week(), 2, 'Jan 13 2007 should be week 2');
- assert.equal(moment([2007, 0, 14]).week(), 3, 'Jan 14 2007 should be week 3');
- });
-
- test('weeks year starting tuesday', function (assert) {
- assert.equal(moment([2007, 11, 29]).week(), 52, 'Dec 29 2007 should be week 52');
- assert.equal(moment([2008, 0, 1]).week(), 1, 'Jan 1 2008 should be week 1');
- assert.equal(moment([2008, 0, 5]).week(), 1, 'Jan 5 2008 should be week 1');
- assert.equal(moment([2008, 0, 6]).week(), 2, 'Jan 6 2008 should be week 2');
- assert.equal(moment([2008, 0, 12]).week(), 2, 'Jan 12 2008 should be week 2');
- assert.equal(moment([2008, 0, 13]).week(), 3, 'Jan 13 2008 should be week 3');
- });
-
- test('weeks year starting wednesday', function (assert) {
- assert.equal(moment([2002, 11, 29]).week(), 1, 'Dec 29 2002 should be week 1');
- assert.equal(moment([2003, 0, 1]).week(), 1, 'Jan 1 2003 should be week 1');
- assert.equal(moment([2003, 0, 4]).week(), 1, 'Jan 4 2003 should be week 1');
- assert.equal(moment([2003, 0, 5]).week(), 2, 'Jan 5 2003 should be week 2');
- assert.equal(moment([2003, 0, 11]).week(), 2, 'Jan 11 2003 should be week 2');
- assert.equal(moment([2003, 0, 12]).week(), 3, 'Jan 12 2003 should be week 3');
- });
-
- test('weeks year starting thursday', function (assert) {
- assert.equal(moment([2008, 11, 28]).week(), 1, 'Dec 28 2008 should be week 1');
- assert.equal(moment([2009, 0, 1]).week(), 1, 'Jan 1 2009 should be week 1');
- assert.equal(moment([2009, 0, 3]).week(), 1, 'Jan 3 2009 should be week 1');
- assert.equal(moment([2009, 0, 4]).week(), 2, 'Jan 4 2009 should be week 2');
- assert.equal(moment([2009, 0, 10]).week(), 2, 'Jan 10 2009 should be week 2');
- assert.equal(moment([2009, 0, 11]).week(), 3, 'Jan 11 2009 should be week 3');
- });
-
- test('weeks year starting friday', function (assert) {
- assert.equal(moment([2009, 11, 27]).week(), 1, 'Dec 27 2009 should be week 1');
- assert.equal(moment([2010, 0, 1]).week(), 1, 'Jan 1 2010 should be week 1');
- assert.equal(moment([2010, 0, 2]).week(), 1, 'Jan 2 2010 should be week 1');
- assert.equal(moment([2010, 0, 3]).week(), 2, 'Jan 3 2010 should be week 2');
- assert.equal(moment([2010, 0, 9]).week(), 2, 'Jan 9 2010 should be week 2');
- assert.equal(moment([2010, 0, 10]).week(), 3, 'Jan 10 2010 should be week 3');
- });
-
- test('weeks year starting saturday', function (assert) {
- assert.equal(moment([2010, 11, 26]).week(), 1, 'Dec 26 2010 should be week 1');
- assert.equal(moment([2011, 0, 1]).week(), 1, 'Jan 1 2011 should be week 1');
- assert.equal(moment([2011, 0, 2]).week(), 2, 'Jan 2 2011 should be week 2');
- assert.equal(moment([2011, 0, 8]).week(), 2, 'Jan 8 2011 should be week 2');
- assert.equal(moment([2011, 0, 9]).week(), 3, 'Jan 9 2011 should be week 3');
- });
-
-
test('weeks year starting sunday formatted', function (assert) {
assert.equal(moment([2011, 11, 26]).format('w ww wo'), '५३ ५३ ५३', 'Dec 26 2011 should be week 53');
assert.equal(moment([2012, 0, 1]).format('w ww wo'), '१ ०१ १', 'Jan 1 2012 should be week 1');
@@ -24377,54 +33731,6 @@
assert.equal(moment([2012, 0, 9]).format('w ww wo'), '२ ०२ २', 'Jan 9 2012 should be week 2');
});
- test('lenient ordinal parsing', function (assert) {
- var i, ordinalStr, testMoment;
- for (i = 1; i <= 31; ++i) {
- ordinalStr = moment([2014, 0, i]).format('YYYY MM Do');
- testMoment = moment(ordinalStr, 'YYYY MM Do');
- assert.equal(testMoment.year(), 2014,
- 'lenient ordinal parsing ' + i + ' year check');
- assert.equal(testMoment.month(), 0,
- 'lenient ordinal parsing ' + i + ' month check');
- assert.equal(testMoment.date(), i,
- 'lenient ordinal parsing ' + i + ' date check');
- }
- });
-
- test('lenient ordinal parsing of number', function (assert) {
- var i, testMoment;
- for (i = 1; i <= 31; ++i) {
- testMoment = moment('2014 01 ' + i, 'YYYY MM Do');
- assert.equal(testMoment.year(), 2014,
- 'lenient ordinal parsing of number ' + i + ' year check');
- assert.equal(testMoment.month(), 0,
- 'lenient ordinal parsing of number ' + i + ' month check');
- assert.equal(testMoment.date(), i,
- 'lenient ordinal parsing of number ' + i + ' date check');
- }
- });
-
- test('meridiem invariant', function (assert) {
- var h, m, t1, t2;
- for (h = 0; h < 24; ++h) {
- for (m = 0; m < 60; m += 15) {
- t1 = moment.utc([2000, 0, 1, h, m]);
- t2 = moment(t1.format('A h:mm'), 'A h:mm');
- assert.equal(t2.format('HH:mm'), t1.format('HH:mm'),
- 'meridiem at ' + t1.format('HH:mm'));
- }
- }
- });
-
- test('strict ordinal parsing', function (assert) {
- var i, ordinalStr, testMoment;
- for (i = 1; i <= 31; ++i) {
- ordinalStr = moment([2014, 0, i]).format('YYYY MM Do');
- testMoment = moment(ordinalStr, 'YYYY MM Do', true);
- assert.ok(testMoment.isValid(), 'strict ordinal parsing ' + i);
- }
- });
-
}));
;(function (global, factory) {
@@ -24433,6 +33739,224 @@
typeof define === 'function' && define.amd ? define(['../../moment'], factory) :
factory(global.moment)
}(this, function (moment) { 'use strict';
+
+ function each(array, callback) {
+ var i;
+ for (i = 0; i < array.length; i++) {
+ callback(array[i], i, array);
+ }
+ }
+
+ function objectKeys(obj) {
+ if (Object.keys) {
+ return Object.keys(obj);
+ } else {
+ // IE8
+ var res = [], i;
+ for (i in obj) {
+ if (obj.hasOwnProperty(i)) {
+ res.push(i);
+ }
+ }
+ return res;
+ }
+ }
+
+ // Pick the first defined of two or three arguments.
+ function defaults(a, b, c) {
+ if (a != null) {
+ return a;
+ }
+ if (b != null) {
+ return b;
+ }
+ return c;
+ }
+
+ function defineCommonLocaleTests(locale, options) {
+ test('lenient ordinal parsing', function (assert) {
+ var i, ordinalStr, testMoment;
+ for (i = 1; i <= 31; ++i) {
+ ordinalStr = moment([2014, 0, i]).format('YYYY MM Do');
+ testMoment = moment(ordinalStr, 'YYYY MM Do');
+ assert.equal(testMoment.year(), 2014,
+ 'lenient ordinal parsing ' + i + ' year check');
+ assert.equal(testMoment.month(), 0,
+ 'lenient ordinal parsing ' + i + ' month check');
+ assert.equal(testMoment.date(), i,
+ 'lenient ordinal parsing ' + i + ' date check');
+ }
+ });
+
+ test('lenient ordinal parsing of number', function (assert) {
+ var i, testMoment;
+ for (i = 1; i <= 31; ++i) {
+ testMoment = moment('2014 01 ' + i, 'YYYY MM Do');
+ assert.equal(testMoment.year(), 2014,
+ 'lenient ordinal parsing of number ' + i + ' year check');
+ assert.equal(testMoment.month(), 0,
+ 'lenient ordinal parsing of number ' + i + ' month check');
+ assert.equal(testMoment.date(), i,
+ 'lenient ordinal parsing of number ' + i + ' date check');
+ }
+ });
+
+ test('strict ordinal parsing', function (assert) {
+ var i, ordinalStr, testMoment;
+ for (i = 1; i <= 31; ++i) {
+ ordinalStr = moment([2014, 0, i]).format('YYYY MM Do');
+ testMoment = moment(ordinalStr, 'YYYY MM Do', true);
+ assert.ok(testMoment.isValid(), 'strict ordinal parsing ' + i);
+ }
+ });
+
+ test('meridiem invariant', function (assert) {
+ var h, m, t1, t2;
+ for (h = 0; h < 24; ++h) {
+ for (m = 0; m < 60; m += 15) {
+ t1 = moment.utc([2000, 0, 1, h, m]);
+ t2 = moment.utc(t1.format('A h:mm'), 'A h:mm');
+ assert.equal(t2.format('HH:mm'), t1.format('HH:mm'),
+ 'meridiem at ' + t1.format('HH:mm'));
+ }
+ }
+ });
+
+ test('date format correctness', function (assert) {
+ var data, tokens;
+ data = moment.localeData()._longDateFormat;
+ tokens = objectKeys(data);
+ each(tokens, function (srchToken) {
+ // Check each format string to make sure it does not contain any
+ // tokens that need to be expanded.
+ each(tokens, function (baseToken) {
+ // strip escaped sequences
+ var format = data[baseToken].replace(/(\[[^\]]*\])/g, '');
+ assert.equal(false, !!~format.indexOf(srchToken),
+ 'contains ' + srchToken + ' in ' + baseToken);
+ });
+ });
+ });
+
+ test('month parsing correctness', function (assert) {
+ var i, m;
+
+ if (locale === 'tr') {
+ // I can't fix it :(
+ expect(0);
+ return;
+ }
+ function tester(format) {
+ var r;
+ r = moment(m.format(format), format);
+ assert.equal(r.month(), m.month(), 'month ' + i + ' fmt ' + format);
+ r = moment(m.format(format).toLocaleUpperCase(), format);
+ assert.equal(r.month(), m.month(), 'month ' + i + ' fmt ' + format + ' upper');
+ r = moment(m.format(format).toLocaleLowerCase(), format);
+ assert.equal(r.month(), m.month(), 'month ' + i + ' fmt ' + format + ' lower');
+
+ r = moment(m.format(format), format, true);
+ assert.equal(r.month(), m.month(), 'month ' + i + ' fmt ' + format + ' strict');
+ r = moment(m.format(format).toLocaleUpperCase(), format, true);
+ assert.equal(r.month(), m.month(), 'month ' + i + ' fmt ' + format + ' upper strict');
+ r = moment(m.format(format).toLocaleLowerCase(), format, true);
+ assert.equal(r.month(), m.month(), 'month ' + i + ' fmt ' + format + ' lower strict');
+ }
+
+ for (i = 0; i < 12; ++i) {
+ m = moment([2015, i, 15, 18]);
+ tester('MMM');
+ tester('MMM.');
+ tester('MMMM');
+ tester('MMMM.');
+ }
+ });
+
+ test('weekday parsing correctness', function (assert) {
+ var i, m;
+
+ if (locale === 'tr' || locale === 'az') {
+ // There is a lower-case letter (ı), that converted to upper then
+ // lower changes to i
+ expect(0);
+ return;
+ }
+ function tester(format) {
+ var r, baseMsg = 'weekday ' + m.weekday() + ' fmt ' + format;
+ r = moment(m.format(format), format);
+ assert.equal(r.weekday(), m.weekday(), baseMsg);
+ r = moment(m.format(format).toLocaleUpperCase(), format);
+ assert.equal(r.weekday(), m.weekday(), baseMsg + ' upper');
+ r = moment(m.format(format).toLocaleLowerCase(), format);
+ assert.equal(r.weekday(), m.weekday(), baseMsg + ' lower');
+
+ r = moment(m.format(format), format, true);
+ assert.equal(r.weekday(), m.weekday(), baseMsg + ' strict');
+ r = moment(m.format(format).toLocaleUpperCase(), format, true);
+ assert.equal(r.weekday(), m.weekday(), baseMsg + ' upper strict');
+ r = moment(m.format(format).toLocaleLowerCase(), format, true);
+ assert.equal(r.weekday(), m.weekday(), baseMsg + ' lower strict');
+ }
+
+ for (i = 0; i < 7; ++i) {
+ m = moment.utc([2015, i, 15, 18]);
+ tester('dd');
+ tester('ddd');
+ tester('dddd');
+ }
+ });
+ }
+
+ function setupDeprecationHandler(test, moment, scope) {
+ test._expectedDeprecations = null;
+ test._observedDeprecations = null;
+ test._oldSupress = moment.suppressDeprecationWarnings;
+ moment.suppressDeprecationWarnings = true;
+ test.expectedDeprecations = function () {
+ test._expectedDeprecations = arguments;
+ test._observedDeprecations = [];
+ };
+ moment.deprecationHandler = function (name, msg) {
+ var deprecationId = matchedDeprecation(name, msg, test._expectedDeprecations);
+ if (deprecationId === -1) {
+ throw new Error('Unexpected deprecation thrown name=' +
+ name + ' msg=' + msg);
+ }
+ test._observedDeprecations[deprecationId] = 1;
+ };
+ }
+
+ function teardownDeprecationHandler(test, moment, scope) {
+ moment.suppressDeprecationWarnings = test._oldSupress;
+
+ if (test._expectedDeprecations != null) {
+ var missedDeprecations = [];
+ each(test._expectedDeprecations, function (deprecationPattern, id) {
+ if (test._observedDeprecations[id] !== 1) {
+ missedDeprecations.push(deprecationPattern);
+ }
+ });
+ if (missedDeprecations.length !== 0) {
+ throw new Error('Expected deprecation warnings did not happen: ' +
+ missedDeprecations.join(' '));
+ }
+ }
+ }
+
+ function matchedDeprecation(name, msg, deprecations) {
+ if (deprecations == null) {
+ return -1;
+ }
+ for (var i = 0; i < deprecations.length; ++i) {
+ if (name != null && name === deprecations[i]) {
+ return i;
+ }
+ if (msg != null && msg.substring(0, deprecations[i].length) === deprecations[i]) {
+ return i;
+ }
+ }
+ return -1;
+ }
/*global QUnit:false*/
@@ -24447,11 +33971,13 @@
moment.createFromInputFallback = function (config) {
throw new Error('input not handled by moment: ' + config._i);
};
+ setupDeprecationHandler(test, moment, 'core');
if (lifecycle && lifecycle.setup) {
lifecycle.setup();
}
},
teardown : function () {
+ teardownDeprecationHandler(test, moment, 'core');
if (lifecycle && lifecycle.teardown) {
lifecycle.teardown();
}
@@ -24466,17 +33992,20 @@
moment.createFromInputFallback = function (config) {
throw new Error('input not handled by moment: ' + config._i);
};
+ setupDeprecationHandler(test, moment, 'locale');
if (lifecycle && lifecycle.setup) {
lifecycle.setup();
}
},
teardown : function () {
moment.locale('en');
+ teardownDeprecationHandler(test, moment, 'locale');
if (lifecycle && lifecycle.teardown) {
lifecycle.teardown();
}
}
});
+ defineCommonLocaleTests(name, -1, -1);
}
localeModule('nl');
@@ -24630,14 +34159,14 @@
});
test('calendar day', function (assert) {
- var a = moment().hours(2).minutes(0).seconds(0);
-
- assert.equal(moment(a).calendar(), 'vandaag om 02:00', 'today at the same time');
- assert.equal(moment(a).add({m: 25}).calendar(), 'vandaag om 02:25', 'Now plus 25 min');
- assert.equal(moment(a).add({h: 1}).calendar(), 'vandaag om 03:00', 'Now plus 1 hour');
- assert.equal(moment(a).add({d: 1}).calendar(), 'morgen om 02:00', 'tomorrow at the same time');
- assert.equal(moment(a).subtract({h: 1}).calendar(), 'vandaag om 01:00', 'Now minus 1 hour');
- assert.equal(moment(a).subtract({d: 1}).calendar(), 'gisteren om 02:00', 'yesterday at the same time');
+ var a = moment().hours(12).minutes(0).seconds(0);
+
+ assert.equal(moment(a).calendar(), 'vandaag om 12:00', 'today at the same time');
+ assert.equal(moment(a).add({m: 25}).calendar(), 'vandaag om 12:25', 'Now plus 25 min');
+ assert.equal(moment(a).add({h: 1}).calendar(), 'vandaag om 13:00', 'Now plus 1 hour');
+ assert.equal(moment(a).add({d: 1}).calendar(), 'morgen om 12:00', 'tomorrow at the same time');
+ assert.equal(moment(a).subtract({h: 1}).calendar(), 'vandaag om 11:00', 'Now minus 1 hour');
+ assert.equal(moment(a).subtract({d: 1}).calendar(), 'gisteren om 12:00', 'yesterday at the same time');
});
test('calendar next week', function (assert) {
@@ -24683,67 +34212,6 @@
assert.equal(moment([2012, 5, 23]).format('D MMM YYYY'), '23 jun. 2012', 'format month abbreviation not surrounded by dashes should include a dot');
});
- test('weeks year starting sunday', function (assert) {
- assert.equal(moment([2012, 0, 1]).week(), 52, 'Jan 1 2012 should be week 52');
- assert.equal(moment([2012, 0, 2]).week(), 1, 'Jan 2 2012 should be week 1');
- assert.equal(moment([2012, 0, 8]).week(), 1, 'Jan 8 2012 should be week 1');
- assert.equal(moment([2012, 0, 9]).week(), 2, 'Jan 9 2012 should be week 2');
- assert.equal(moment([2012, 0, 15]).week(), 2, 'Jan 15 2012 should be week 2');
- });
-
- test('weeks year starting monday', function (assert) {
- assert.equal(moment([2007, 0, 1]).week(), 1, 'Jan 1 2007 should be week 1');
- assert.equal(moment([2007, 0, 7]).week(), 1, 'Jan 7 2007 should be week 1');
- assert.equal(moment([2007, 0, 8]).week(), 2, 'Jan 8 2007 should be week 2');
- assert.equal(moment([2007, 0, 14]).week(), 2, 'Jan 14 2007 should be week 2');
- assert.equal(moment([2007, 0, 15]).week(), 3, 'Jan 15 2007 should be week 3');
- });
-
- test('weeks year starting tuesday', function (assert) {
- assert.equal(moment([2007, 11, 31]).week(), 1, 'Dec 31 2007 should be week 1');
- assert.equal(moment([2008, 0, 1]).week(), 1, 'Jan 1 2008 should be week 1');
- assert.equal(moment([2008, 0, 6]).week(), 1, 'Jan 6 2008 should be week 1');
- assert.equal(moment([2008, 0, 7]).week(), 2, 'Jan 7 2008 should be week 2');
- assert.equal(moment([2008, 0, 13]).week(), 2, 'Jan 13 2008 should be week 2');
- assert.equal(moment([2008, 0, 14]).week(), 3, 'Jan 14 2008 should be week 3');
- });
-
- test('weeks year starting wednesday', function (assert) {
- assert.equal(moment([2002, 11, 30]).week(), 1, 'Dec 30 2002 should be week 1');
- assert.equal(moment([2003, 0, 1]).week(), 1, 'Jan 1 2003 should be week 1');
- assert.equal(moment([2003, 0, 5]).week(), 1, 'Jan 5 2003 should be week 1');
- assert.equal(moment([2003, 0, 6]).week(), 2, 'Jan 6 2003 should be week 2');
- assert.equal(moment([2003, 0, 12]).week(), 2, 'Jan 12 2003 should be week 2');
- assert.equal(moment([2003, 0, 13]).week(), 3, 'Jan 13 2003 should be week 3');
- });
-
- test('weeks year starting thursday', function (assert) {
- assert.equal(moment([2008, 11, 29]).week(), 1, 'Dec 29 2008 should be week 1');
- assert.equal(moment([2009, 0, 1]).week(), 1, 'Jan 1 2009 should be week 1');
- assert.equal(moment([2009, 0, 4]).week(), 1, 'Jan 4 2009 should be week 1');
- assert.equal(moment([2009, 0, 5]).week(), 2, 'Jan 5 2009 should be week 2');
- assert.equal(moment([2009, 0, 11]).week(), 2, 'Jan 11 2009 should be week 2');
- assert.equal(moment([2009, 0, 13]).week(), 3, 'Jan 12 2009 should be week 3');
- });
-
- test('weeks year starting friday', function (assert) {
- assert.equal(moment([2009, 11, 28]).week(), 53, 'Dec 28 2009 should be week 53');
- assert.equal(moment([2010, 0, 1]).week(), 53, 'Jan 1 2010 should be week 53');
- assert.equal(moment([2010, 0, 3]).week(), 53, 'Jan 3 2010 should be week 53');
- assert.equal(moment([2010, 0, 4]).week(), 1, 'Jan 4 2010 should be week 1');
- assert.equal(moment([2010, 0, 10]).week(), 1, 'Jan 10 2010 should be week 1');
- assert.equal(moment([2010, 0, 11]).week(), 2, 'Jan 11 2010 should be week 2');
- });
-
- test('weeks year starting saturday', function (assert) {
- assert.equal(moment([2010, 11, 27]).week(), 52, 'Dec 27 2010 should be week 52');
- assert.equal(moment([2011, 0, 1]).week(), 52, 'Jan 1 2011 should be week 52');
- assert.equal(moment([2011, 0, 2]).week(), 52, 'Jan 2 2011 should be week 52');
- assert.equal(moment([2011, 0, 3]).week(), 1, 'Jan 3 2011 should be week 1');
- assert.equal(moment([2011, 0, 9]).week(), 1, 'Jan 9 2011 should be week 1');
- assert.equal(moment([2011, 0, 10]).week(), 2, 'Jan 10 2011 should be week 2');
- });
-
test('weeks year starting sunday formatted', function (assert) {
assert.equal(moment([2012, 0, 1]).format('w ww wo'), '52 52 52ste', 'Jan 1 2012 should be week 52');
assert.equal(moment([2012, 0, 2]).format('w ww wo'), '1 01 1ste', 'Jan 2 2012 should be week 1');
@@ -24752,42 +34220,6 @@
assert.equal(moment([2012, 0, 15]).format('w ww wo'), '2 02 2de', 'Jan 15 2012 should be week 2');
});
- test('lenient ordinal parsing', function (assert) {
- var i, ordinalStr, testMoment;
- for (i = 1; i <= 31; ++i) {
- ordinalStr = moment([2014, 0, i]).format('YYYY MM Do');
- testMoment = moment(ordinalStr, 'YYYY MM Do');
- assert.equal(testMoment.year(), 2014,
- 'lenient ordinal parsing ' + i + ' year check');
- assert.equal(testMoment.month(), 0,
- 'lenient ordinal parsing ' + i + ' month check');
- assert.equal(testMoment.date(), i,
- 'lenient ordinal parsing ' + i + ' date check');
- }
- });
-
- test('lenient ordinal parsing of number', function (assert) {
- var i, testMoment;
- for (i = 1; i <= 31; ++i) {
- testMoment = moment('2014 01 ' + i, 'YYYY MM Do');
- assert.equal(testMoment.year(), 2014,
- 'lenient ordinal parsing of number ' + i + ' year check');
- assert.equal(testMoment.month(), 0,
- 'lenient ordinal parsing of number ' + i + ' month check');
- assert.equal(testMoment.date(), i,
- 'lenient ordinal parsing of number ' + i + ' date check');
- }
- });
-
- test('strict ordinal parsing', function (assert) {
- var i, ordinalStr, testMoment;
- for (i = 1; i <= 31; ++i) {
- ordinalStr = moment([2014, 0, i]).format('YYYY MM Do');
- testMoment = moment(ordinalStr, 'YYYY MM Do', true);
- assert.ok(testMoment.isValid(), 'strict ordinal parsing ' + i);
- }
- });
-
}));
;(function (global, factory) {
@@ -24796,6 +34228,224 @@
typeof define === 'function' && define.amd ? define(['../../moment'], factory) :
factory(global.moment)
}(this, function (moment) { 'use strict';
+
+ function each(array, callback) {
+ var i;
+ for (i = 0; i < array.length; i++) {
+ callback(array[i], i, array);
+ }
+ }
+
+ function objectKeys(obj) {
+ if (Object.keys) {
+ return Object.keys(obj);
+ } else {
+ // IE8
+ var res = [], i;
+ for (i in obj) {
+ if (obj.hasOwnProperty(i)) {
+ res.push(i);
+ }
+ }
+ return res;
+ }
+ }
+
+ // Pick the first defined of two or three arguments.
+ function defaults(a, b, c) {
+ if (a != null) {
+ return a;
+ }
+ if (b != null) {
+ return b;
+ }
+ return c;
+ }
+
+ function defineCommonLocaleTests(locale, options) {
+ test('lenient ordinal parsing', function (assert) {
+ var i, ordinalStr, testMoment;
+ for (i = 1; i <= 31; ++i) {
+ ordinalStr = moment([2014, 0, i]).format('YYYY MM Do');
+ testMoment = moment(ordinalStr, 'YYYY MM Do');
+ assert.equal(testMoment.year(), 2014,
+ 'lenient ordinal parsing ' + i + ' year check');
+ assert.equal(testMoment.month(), 0,
+ 'lenient ordinal parsing ' + i + ' month check');
+ assert.equal(testMoment.date(), i,
+ 'lenient ordinal parsing ' + i + ' date check');
+ }
+ });
+
+ test('lenient ordinal parsing of number', function (assert) {
+ var i, testMoment;
+ for (i = 1; i <= 31; ++i) {
+ testMoment = moment('2014 01 ' + i, 'YYYY MM Do');
+ assert.equal(testMoment.year(), 2014,
+ 'lenient ordinal parsing of number ' + i + ' year check');
+ assert.equal(testMoment.month(), 0,
+ 'lenient ordinal parsing of number ' + i + ' month check');
+ assert.equal(testMoment.date(), i,
+ 'lenient ordinal parsing of number ' + i + ' date check');
+ }
+ });
+
+ test('strict ordinal parsing', function (assert) {
+ var i, ordinalStr, testMoment;
+ for (i = 1; i <= 31; ++i) {
+ ordinalStr = moment([2014, 0, i]).format('YYYY MM Do');
+ testMoment = moment(ordinalStr, 'YYYY MM Do', true);
+ assert.ok(testMoment.isValid(), 'strict ordinal parsing ' + i);
+ }
+ });
+
+ test('meridiem invariant', function (assert) {
+ var h, m, t1, t2;
+ for (h = 0; h < 24; ++h) {
+ for (m = 0; m < 60; m += 15) {
+ t1 = moment.utc([2000, 0, 1, h, m]);
+ t2 = moment.utc(t1.format('A h:mm'), 'A h:mm');
+ assert.equal(t2.format('HH:mm'), t1.format('HH:mm'),
+ 'meridiem at ' + t1.format('HH:mm'));
+ }
+ }
+ });
+
+ test('date format correctness', function (assert) {
+ var data, tokens;
+ data = moment.localeData()._longDateFormat;
+ tokens = objectKeys(data);
+ each(tokens, function (srchToken) {
+ // Check each format string to make sure it does not contain any
+ // tokens that need to be expanded.
+ each(tokens, function (baseToken) {
+ // strip escaped sequences
+ var format = data[baseToken].replace(/(\[[^\]]*\])/g, '');
+ assert.equal(false, !!~format.indexOf(srchToken),
+ 'contains ' + srchToken + ' in ' + baseToken);
+ });
+ });
+ });
+
+ test('month parsing correctness', function (assert) {
+ var i, m;
+
+ if (locale === 'tr') {
+ // I can't fix it :(
+ expect(0);
+ return;
+ }
+ function tester(format) {
+ var r;
+ r = moment(m.format(format), format);
+ assert.equal(r.month(), m.month(), 'month ' + i + ' fmt ' + format);
+ r = moment(m.format(format).toLocaleUpperCase(), format);
+ assert.equal(r.month(), m.month(), 'month ' + i + ' fmt ' + format + ' upper');
+ r = moment(m.format(format).toLocaleLowerCase(), format);
+ assert.equal(r.month(), m.month(), 'month ' + i + ' fmt ' + format + ' lower');
+
+ r = moment(m.format(format), format, true);
+ assert.equal(r.month(), m.month(), 'month ' + i + ' fmt ' + format + ' strict');
+ r = moment(m.format(format).toLocaleUpperCase(), format, true);
+ assert.equal(r.month(), m.month(), 'month ' + i + ' fmt ' + format + ' upper strict');
+ r = moment(m.format(format).toLocaleLowerCase(), format, true);
+ assert.equal(r.month(), m.month(), 'month ' + i + ' fmt ' + format + ' lower strict');
+ }
+
+ for (i = 0; i < 12; ++i) {
+ m = moment([2015, i, 15, 18]);
+ tester('MMM');
+ tester('MMM.');
+ tester('MMMM');
+ tester('MMMM.');
+ }
+ });
+
+ test('weekday parsing correctness', function (assert) {
+ var i, m;
+
+ if (locale === 'tr' || locale === 'az') {
+ // There is a lower-case letter (ı), that converted to upper then
+ // lower changes to i
+ expect(0);
+ return;
+ }
+ function tester(format) {
+ var r, baseMsg = 'weekday ' + m.weekday() + ' fmt ' + format;
+ r = moment(m.format(format), format);
+ assert.equal(r.weekday(), m.weekday(), baseMsg);
+ r = moment(m.format(format).toLocaleUpperCase(), format);
+ assert.equal(r.weekday(), m.weekday(), baseMsg + ' upper');
+ r = moment(m.format(format).toLocaleLowerCase(), format);
+ assert.equal(r.weekday(), m.weekday(), baseMsg + ' lower');
+
+ r = moment(m.format(format), format, true);
+ assert.equal(r.weekday(), m.weekday(), baseMsg + ' strict');
+ r = moment(m.format(format).toLocaleUpperCase(), format, true);
+ assert.equal(r.weekday(), m.weekday(), baseMsg + ' upper strict');
+ r = moment(m.format(format).toLocaleLowerCase(), format, true);
+ assert.equal(r.weekday(), m.weekday(), baseMsg + ' lower strict');
+ }
+
+ for (i = 0; i < 7; ++i) {
+ m = moment.utc([2015, i, 15, 18]);
+ tester('dd');
+ tester('ddd');
+ tester('dddd');
+ }
+ });
+ }
+
+ function setupDeprecationHandler(test, moment, scope) {
+ test._expectedDeprecations = null;
+ test._observedDeprecations = null;
+ test._oldSupress = moment.suppressDeprecationWarnings;
+ moment.suppressDeprecationWarnings = true;
+ test.expectedDeprecations = function () {
+ test._expectedDeprecations = arguments;
+ test._observedDeprecations = [];
+ };
+ moment.deprecationHandler = function (name, msg) {
+ var deprecationId = matchedDeprecation(name, msg, test._expectedDeprecations);
+ if (deprecationId === -1) {
+ throw new Error('Unexpected deprecation thrown name=' +
+ name + ' msg=' + msg);
+ }
+ test._observedDeprecations[deprecationId] = 1;
+ };
+ }
+
+ function teardownDeprecationHandler(test, moment, scope) {
+ moment.suppressDeprecationWarnings = test._oldSupress;
+
+ if (test._expectedDeprecations != null) {
+ var missedDeprecations = [];
+ each(test._expectedDeprecations, function (deprecationPattern, id) {
+ if (test._observedDeprecations[id] !== 1) {
+ missedDeprecations.push(deprecationPattern);
+ }
+ });
+ if (missedDeprecations.length !== 0) {
+ throw new Error('Expected deprecation warnings did not happen: ' +
+ missedDeprecations.join(' '));
+ }
+ }
+ }
+
+ function matchedDeprecation(name, msg, deprecations) {
+ if (deprecations == null) {
+ return -1;
+ }
+ for (var i = 0; i < deprecations.length; ++i) {
+ if (name != null && name === deprecations[i]) {
+ return i;
+ }
+ if (msg != null && msg.substring(0, deprecations[i].length) === deprecations[i]) {
+ return i;
+ }
+ }
+ return -1;
+ }
/*global QUnit:false*/
@@ -24810,11 +34460,13 @@
moment.createFromInputFallback = function (config) {
throw new Error('input not handled by moment: ' + config._i);
};
+ setupDeprecationHandler(test, moment, 'core');
if (lifecycle && lifecycle.setup) {
lifecycle.setup();
}
},
teardown : function () {
+ teardownDeprecationHandler(test, moment, 'core');
if (lifecycle && lifecycle.teardown) {
lifecycle.teardown();
}
@@ -24829,17 +34481,20 @@
moment.createFromInputFallback = function (config) {
throw new Error('input not handled by moment: ' + config._i);
};
+ setupDeprecationHandler(test, moment, 'locale');
if (lifecycle && lifecycle.setup) {
lifecycle.setup();
}
},
teardown : function () {
moment.locale('en');
+ teardownDeprecationHandler(test, moment, 'locale');
if (lifecycle && lifecycle.teardown) {
lifecycle.teardown();
}
}
});
+ defineCommonLocaleTests(name, -1, -1);
}
localeModule('nn');
@@ -24980,11 +34635,11 @@
test('suffix', function (assert) {
assert.equal(moment(30000).from(0), 'om nokre sekund', 'prefix');
- assert.equal(moment(0).from(30000), 'for nokre sekund sidan', 'suffix');
+ assert.equal(moment(0).from(30000), 'nokre sekund sidan', 'suffix');
});
test('now from now', function (assert) {
- assert.equal(moment().fromNow(), 'for nokre sekund sidan', 'now from now should display as in the past');
+ assert.equal(moment().fromNow(), 'nokre sekund sidan', 'now from now should display as in the past');
});
test('fromNow', function (assert) {
@@ -24993,14 +34648,14 @@
});
test('calendar day', function (assert) {
- var a = moment().hours(2).minutes(0).seconds(0);
-
- assert.equal(moment(a).calendar(), 'I dag klokka 02:00', 'today at the same time');
- assert.equal(moment(a).add({m: 25}).calendar(), 'I dag klokka 02:25', 'Now plus 25 min');
- assert.equal(moment(a).add({h: 1}).calendar(), 'I dag klokka 03:00', 'Now plus 1 hour');
- assert.equal(moment(a).add({d: 1}).calendar(), 'I morgon klokka 02:00', 'tomorrow at the same time');
- assert.equal(moment(a).subtract({h: 1}).calendar(), 'I dag klokka 01:00', 'Now minus 1 hour');
- assert.equal(moment(a).subtract({d: 1}).calendar(), 'I går klokka 02:00', 'yesterday at the same time');
+ var a = moment().hours(12).minutes(0).seconds(0);
+
+ assert.equal(moment(a).calendar(), 'I dag klokka 12:00', 'today at the same time');
+ assert.equal(moment(a).add({m: 25}).calendar(), 'I dag klokka 12:25', 'Now plus 25 min');
+ assert.equal(moment(a).add({h: 1}).calendar(), 'I dag klokka 13:00', 'Now plus 1 hour');
+ assert.equal(moment(a).add({d: 1}).calendar(), 'I morgon klokka 12:00', 'tomorrow at the same time');
+ assert.equal(moment(a).subtract({h: 1}).calendar(), 'I dag klokka 11:00', 'Now minus 1 hour');
+ assert.equal(moment(a).subtract({d: 1}).calendar(), 'I går klokka 12:00', 'yesterday at the same time');
});
test('calendar next week', function (assert) {
@@ -25041,73 +34696,573 @@
assert.equal(weeksFromNow.calendar(), weeksFromNow.format('L'), 'in 2 weeks');
});
- test('weeks year starting sunday', function (assert) {
- assert.equal(moment([2012, 0, 1]).week(), 52, 'Jan 1 2012 should be week 52');
- assert.equal(moment([2012, 0, 2]).week(), 1, 'Jan 2 2012 should be week 1');
- assert.equal(moment([2012, 0, 8]).week(), 1, 'Jan 8 2012 should be week 1');
- assert.equal(moment([2012, 0, 9]).week(), 2, 'Jan 9 2012 should be week 2');
- assert.equal(moment([2012, 0, 15]).week(), 2, 'Jan 15 2012 should be week 2');
- });
-
- test('weeks year starting monday', function (assert) {
- assert.equal(moment([2007, 0, 1]).week(), 1, 'Jan 1 2007 should be week 1');
- assert.equal(moment([2007, 0, 7]).week(), 1, 'Jan 7 2007 should be week 1');
- assert.equal(moment([2007, 0, 8]).week(), 2, 'Jan 8 2007 should be week 2');
- assert.equal(moment([2007, 0, 14]).week(), 2, 'Jan 14 2007 should be week 2');
- assert.equal(moment([2007, 0, 15]).week(), 3, 'Jan 15 2007 should be week 3');
- });
-
- test('weeks year starting tuesday', function (assert) {
- assert.equal(moment([2007, 11, 31]).week(), 1, 'Dec 31 2007 should be week 1');
- assert.equal(moment([2008, 0, 1]).week(), 1, 'Jan 1 2008 should be week 1');
- assert.equal(moment([2008, 0, 6]).week(), 1, 'Jan 6 2008 should be week 1');
- assert.equal(moment([2008, 0, 7]).week(), 2, 'Jan 7 2008 should be week 2');
- assert.equal(moment([2008, 0, 13]).week(), 2, 'Jan 13 2008 should be week 2');
- assert.equal(moment([2008, 0, 14]).week(), 3, 'Jan 14 2008 should be week 3');
- });
-
- test('weeks year starting wednesday', function (assert) {
- assert.equal(moment([2002, 11, 30]).week(), 1, 'Dec 30 2002 should be week 1');
- assert.equal(moment([2003, 0, 1]).week(), 1, 'Jan 1 2003 should be week 1');
- assert.equal(moment([2003, 0, 5]).week(), 1, 'Jan 5 2003 should be week 1');
- assert.equal(moment([2003, 0, 6]).week(), 2, 'Jan 6 2003 should be week 2');
- assert.equal(moment([2003, 0, 12]).week(), 2, 'Jan 12 2003 should be week 2');
- assert.equal(moment([2003, 0, 13]).week(), 3, 'Jan 13 2003 should be week 3');
- });
-
- test('weeks year starting thursday', function (assert) {
- assert.equal(moment([2008, 11, 29]).week(), 1, 'Dec 29 2008 should be week 1');
- assert.equal(moment([2009, 0, 1]).week(), 1, 'Jan 1 2009 should be week 1');
- assert.equal(moment([2009, 0, 4]).week(), 1, 'Jan 4 2009 should be week 1');
- assert.equal(moment([2009, 0, 5]).week(), 2, 'Jan 5 2009 should be week 2');
- assert.equal(moment([2009, 0, 11]).week(), 2, 'Jan 11 2009 should be week 2');
- assert.equal(moment([2009, 0, 13]).week(), 3, 'Jan 12 2009 should be week 3');
- });
-
- test('weeks year starting friday', function (assert) {
- assert.equal(moment([2009, 11, 28]).week(), 53, 'Dec 28 2009 should be week 53');
- assert.equal(moment([2010, 0, 1]).week(), 53, 'Jan 1 2010 should be week 53');
- assert.equal(moment([2010, 0, 3]).week(), 53, 'Jan 3 2010 should be week 53');
- assert.equal(moment([2010, 0, 4]).week(), 1, 'Jan 4 2010 should be week 1');
- assert.equal(moment([2010, 0, 10]).week(), 1, 'Jan 10 2010 should be week 1');
- assert.equal(moment([2010, 0, 11]).week(), 2, 'Jan 11 2010 should be week 2');
- });
-
- test('weeks year starting saturday', function (assert) {
- assert.equal(moment([2010, 11, 27]).week(), 52, 'Dec 27 2010 should be week 52');
- assert.equal(moment([2011, 0, 1]).week(), 52, 'Jan 1 2011 should be week 52');
- assert.equal(moment([2011, 0, 2]).week(), 52, 'Jan 2 2011 should be week 52');
- assert.equal(moment([2011, 0, 3]).week(), 1, 'Jan 3 2011 should be week 1');
- assert.equal(moment([2011, 0, 9]).week(), 1, 'Jan 9 2011 should be week 1');
- assert.equal(moment([2011, 0, 10]).week(), 2, 'Jan 10 2011 should be week 2');
- });
-
test('weeks year starting sunday formatted', function (assert) {
assert.equal(moment([2012, 0, 1]).format('w ww wo'), '52 52 52.', 'Jan 1 2012 should be week 52');
assert.equal(moment([2012, 0, 2]).format('w ww wo'), '1 01 1.', 'Jan 2 2012 should be week 1');
assert.equal(moment([2012, 0, 8]).format('w ww wo'), '1 01 1.', 'Jan 8 2012 should be week 1');
assert.equal(moment([2012, 0, 9]).format('w ww wo'), '2 02 2.', 'Jan 9 2012 should be week 2');
assert.equal(moment([2012, 0, 15]).format('w ww wo'), '2 02 2.', 'Jan 15 2012 should be week 2');
+ });
+
+}));
+
+;(function (global, factory) {
+ typeof exports === 'object' && typeof module !== 'undefined'
+ && typeof require === 'function' ? factory(require('../../moment')) :
+ typeof define === 'function' && define.amd ? define(['../../moment'], factory) :
+ factory(global.moment)
+}(this, function (moment) { 'use strict';
+
+ function each(array, callback) {
+ var i;
+ for (i = 0; i < array.length; i++) {
+ callback(array[i], i, array);
+ }
+ }
+
+ function objectKeys(obj) {
+ if (Object.keys) {
+ return Object.keys(obj);
+ } else {
+ // IE8
+ var res = [], i;
+ for (i in obj) {
+ if (obj.hasOwnProperty(i)) {
+ res.push(i);
+ }
+ }
+ return res;
+ }
+ }
+
+ // Pick the first defined of two or three arguments.
+ function defaults(a, b, c) {
+ if (a != null) {
+ return a;
+ }
+ if (b != null) {
+ return b;
+ }
+ return c;
+ }
+
+ function defineCommonLocaleTests(locale, options) {
+ test('lenient ordinal parsing', function (assert) {
+ var i, ordinalStr, testMoment;
+ for (i = 1; i <= 31; ++i) {
+ ordinalStr = moment([2014, 0, i]).format('YYYY MM Do');
+ testMoment = moment(ordinalStr, 'YYYY MM Do');
+ assert.equal(testMoment.year(), 2014,
+ 'lenient ordinal parsing ' + i + ' year check');
+ assert.equal(testMoment.month(), 0,
+ 'lenient ordinal parsing ' + i + ' month check');
+ assert.equal(testMoment.date(), i,
+ 'lenient ordinal parsing ' + i + ' date check');
+ }
+ });
+
+ test('lenient ordinal parsing of number', function (assert) {
+ var i, testMoment;
+ for (i = 1; i <= 31; ++i) {
+ testMoment = moment('2014 01 ' + i, 'YYYY MM Do');
+ assert.equal(testMoment.year(), 2014,
+ 'lenient ordinal parsing of number ' + i + ' year check');
+ assert.equal(testMoment.month(), 0,
+ 'lenient ordinal parsing of number ' + i + ' month check');
+ assert.equal(testMoment.date(), i,
+ 'lenient ordinal parsing of number ' + i + ' date check');
+ }
+ });
+
+ test('strict ordinal parsing', function (assert) {
+ var i, ordinalStr, testMoment;
+ for (i = 1; i <= 31; ++i) {
+ ordinalStr = moment([2014, 0, i]).format('YYYY MM Do');
+ testMoment = moment(ordinalStr, 'YYYY MM Do', true);
+ assert.ok(testMoment.isValid(), 'strict ordinal parsing ' + i);
+ }
+ });
+
+ test('meridiem invariant', function (assert) {
+ var h, m, t1, t2;
+ for (h = 0; h < 24; ++h) {
+ for (m = 0; m < 60; m += 15) {
+ t1 = moment.utc([2000, 0, 1, h, m]);
+ t2 = moment.utc(t1.format('A h:mm'), 'A h:mm');
+ assert.equal(t2.format('HH:mm'), t1.format('HH:mm'),
+ 'meridiem at ' + t1.format('HH:mm'));
+ }
+ }
+ });
+
+ test('date format correctness', function (assert) {
+ var data, tokens;
+ data = moment.localeData()._longDateFormat;
+ tokens = objectKeys(data);
+ each(tokens, function (srchToken) {
+ // Check each format string to make sure it does not contain any
+ // tokens that need to be expanded.
+ each(tokens, function (baseToken) {
+ // strip escaped sequences
+ var format = data[baseToken].replace(/(\[[^\]]*\])/g, '');
+ assert.equal(false, !!~format.indexOf(srchToken),
+ 'contains ' + srchToken + ' in ' + baseToken);
+ });
+ });
+ });
+
+ test('month parsing correctness', function (assert) {
+ var i, m;
+
+ if (locale === 'tr') {
+ // I can't fix it :(
+ expect(0);
+ return;
+ }
+ function tester(format) {
+ var r;
+ r = moment(m.format(format), format);
+ assert.equal(r.month(), m.month(), 'month ' + i + ' fmt ' + format);
+ r = moment(m.format(format).toLocaleUpperCase(), format);
+ assert.equal(r.month(), m.month(), 'month ' + i + ' fmt ' + format + ' upper');
+ r = moment(m.format(format).toLocaleLowerCase(), format);
+ assert.equal(r.month(), m.month(), 'month ' + i + ' fmt ' + format + ' lower');
+
+ r = moment(m.format(format), format, true);
+ assert.equal(r.month(), m.month(), 'month ' + i + ' fmt ' + format + ' strict');
+ r = moment(m.format(format).toLocaleUpperCase(), format, true);
+ assert.equal(r.month(), m.month(), 'month ' + i + ' fmt ' + format + ' upper strict');
+ r = moment(m.format(format).toLocaleLowerCase(), format, true);
+ assert.equal(r.month(), m.month(), 'month ' + i + ' fmt ' + format + ' lower strict');
+ }
+
+ for (i = 0; i < 12; ++i) {
+ m = moment([2015, i, 15, 18]);
+ tester('MMM');
+ tester('MMM.');
+ tester('MMMM');
+ tester('MMMM.');
+ }
+ });
+
+ test('weekday parsing correctness', function (assert) {
+ var i, m;
+
+ if (locale === 'tr' || locale === 'az') {
+ // There is a lower-case letter (ı), that converted to upper then
+ // lower changes to i
+ expect(0);
+ return;
+ }
+ function tester(format) {
+ var r, baseMsg = 'weekday ' + m.weekday() + ' fmt ' + format;
+ r = moment(m.format(format), format);
+ assert.equal(r.weekday(), m.weekday(), baseMsg);
+ r = moment(m.format(format).toLocaleUpperCase(), format);
+ assert.equal(r.weekday(), m.weekday(), baseMsg + ' upper');
+ r = moment(m.format(format).toLocaleLowerCase(), format);
+ assert.equal(r.weekday(), m.weekday(), baseMsg + ' lower');
+
+ r = moment(m.format(format), format, true);
+ assert.equal(r.weekday(), m.weekday(), baseMsg + ' strict');
+ r = moment(m.format(format).toLocaleUpperCase(), format, true);
+ assert.equal(r.weekday(), m.weekday(), baseMsg + ' upper strict');
+ r = moment(m.format(format).toLocaleLowerCase(), format, true);
+ assert.equal(r.weekday(), m.weekday(), baseMsg + ' lower strict');
+ }
+
+ for (i = 0; i < 7; ++i) {
+ m = moment.utc([2015, i, 15, 18]);
+ tester('dd');
+ tester('ddd');
+ tester('dddd');
+ }
+ });
+ }
+
+ function setupDeprecationHandler(test, moment, scope) {
+ test._expectedDeprecations = null;
+ test._observedDeprecations = null;
+ test._oldSupress = moment.suppressDeprecationWarnings;
+ moment.suppressDeprecationWarnings = true;
+ test.expectedDeprecations = function () {
+ test._expectedDeprecations = arguments;
+ test._observedDeprecations = [];
+ };
+ moment.deprecationHandler = function (name, msg) {
+ var deprecationId = matchedDeprecation(name, msg, test._expectedDeprecations);
+ if (deprecationId === -1) {
+ throw new Error('Unexpected deprecation thrown name=' +
+ name + ' msg=' + msg);
+ }
+ test._observedDeprecations[deprecationId] = 1;
+ };
+ }
+
+ function teardownDeprecationHandler(test, moment, scope) {
+ moment.suppressDeprecationWarnings = test._oldSupress;
+
+ if (test._expectedDeprecations != null) {
+ var missedDeprecations = [];
+ each(test._expectedDeprecations, function (deprecationPattern, id) {
+ if (test._observedDeprecations[id] !== 1) {
+ missedDeprecations.push(deprecationPattern);
+ }
+ });
+ if (missedDeprecations.length !== 0) {
+ throw new Error('Expected deprecation warnings did not happen: ' +
+ missedDeprecations.join(' '));
+ }
+ }
+ }
+
+ function matchedDeprecation(name, msg, deprecations) {
+ if (deprecations == null) {
+ return -1;
+ }
+ for (var i = 0; i < deprecations.length; ++i) {
+ if (name != null && name === deprecations[i]) {
+ return i;
+ }
+ if (msg != null && msg.substring(0, deprecations[i].length) === deprecations[i]) {
+ return i;
+ }
+ }
+ return -1;
+ }
+
+ /*global QUnit:false*/
+
+ var test = QUnit.test;
+
+ var expect = QUnit.expect;
+
+ function module (name, lifecycle) {
+ QUnit.module(name, {
+ setup : function () {
+ moment.locale('en');
+ moment.createFromInputFallback = function (config) {
+ throw new Error('input not handled by moment: ' + config._i);
+ };
+ setupDeprecationHandler(test, moment, 'core');
+ if (lifecycle && lifecycle.setup) {
+ lifecycle.setup();
+ }
+ },
+ teardown : function () {
+ teardownDeprecationHandler(test, moment, 'core');
+ if (lifecycle && lifecycle.teardown) {
+ lifecycle.teardown();
+ }
+ }
+ });
+ }
+
+ function localeModule (name, lifecycle) {
+ QUnit.module('locale:' + name, {
+ setup : function () {
+ moment.locale(name);
+ moment.createFromInputFallback = function (config) {
+ throw new Error('input not handled by moment: ' + config._i);
+ };
+ setupDeprecationHandler(test, moment, 'locale');
+ if (lifecycle && lifecycle.setup) {
+ lifecycle.setup();
+ }
+ },
+ teardown : function () {
+ moment.locale('en');
+ teardownDeprecationHandler(test, moment, 'locale');
+ if (lifecycle && lifecycle.teardown) {
+ lifecycle.teardown();
+ }
+ }
+ });
+ defineCommonLocaleTests(name, -1, -1);
+ }
+
+ localeModule('pa-in');
+
+ test('parse', function (assert) {
+ var tests = 'ਜਨਵਰੀ ਜਨਵਰੀ_ਫ਼ਰਵਰੀ ਫ਼ਰਵਰੀ_ਮਾਰਚ ਮਾਰਚ_ਅਪ੍ਰੈਲ ਅਪ੍ਰੈਲ_ਮਈ ਮਈ_ਜੂਨ ਜੂਨ_ਜੁਲਾਈ ਜੁਲਾਈ_ਅਗਸਤ ਅਗਸਤ_ਸਤੰਬਰ ਸਤੰਬਰ_ਅਕਤੂਬਰ ਅਕਤੂਬਰ_ਨਵੰਬਰ ਨਵੰਬਰ_ਦਸੰਬਰ ਦਸੰਬਰ'.split('_'), i;
+ function equalTest(input, mmm, i) {
+ assert.equal(moment(input, mmm).month(), i, input + ' should be month ' + (i + 1));
+ }
+ for (i = 0; i < 12; i++) {
+ tests[i] = tests[i].split(' ');
+ equalTest(tests[i][0], 'MMM', i);
+ equalTest(tests[i][1], 'MMM', i);
+ equalTest(tests[i][0], 'MMMM', i);
+ equalTest(tests[i][1], 'MMMM', i);
+ equalTest(tests[i][0].toLocaleLowerCase(), 'MMMM', i);
+ equalTest(tests[i][1].toLocaleLowerCase(), 'MMMM', i);
+ equalTest(tests[i][0].toLocaleUpperCase(), 'MMMM', i);
+ equalTest(tests[i][1].toLocaleUpperCase(), 'MMMM', i);
+ }
+ });
+
+ test('format', function (assert) {
+ var a = [
+ ['dddd, Do MMMM YYYY, a h:mm:ss ਵਜੇ', 'ਐਤਵਾਰ, ੧੪ ਫ਼ਰਵਰੀ ੨੦੧੦, ਦੁਪਹਿਰ ੩:੨੫:੫੦ ਵਜੇ'],
+ ['ddd, a h ਵਜੇ', 'ਐਤ, ਦੁਪਹਿਰ ੩ ਵਜੇ'],
+ ['M Mo MM MMMM MMM', '੨ ੨ ੦੨ ਫ਼ਰਵਰੀ ਫ਼ਰਵਰੀ'],
+ ['YYYY YY', '੨੦੧੦ ੧੦'],
+ ['D Do DD', '੧੪ ੧੪ ੧੪'],
+ ['d do dddd ddd dd', '੦ ੦ ਐਤਵਾਰ ਐਤ ਐਤ'],
+ ['DDD DDDo DDDD', '੪੫ ੪੫ ੦੪੫'],
+ ['w wo ww', '੮ ੮ ੦੮'],
+ ['h hh', '੩ ੦੩'],
+ ['H HH', '੧੫ ੧੫'],
+ ['m mm', '੨੫ ੨੫'],
+ ['s ss', '੫੦ ੫੦'],
+ ['a A', 'ਦੁਪਹਿਰ ਦੁਪਹਿਰ'],
+ ['LTS', 'ਦੁਪਹਿਰ ੩:੨੫:੫੦ ਵਜੇ'],
+ ['L', '੧੪/੦੨/੨੦੧੦'],
+ ['LL', '੧੪ ਫ਼ਰਵਰੀ ੨੦੧੦'],
+ ['LLL', '੧੪ ਫ਼ਰਵਰੀ ੨੦੧੦, ਦੁਪਹਿਰ ੩:੨੫ ਵਜੇ'],
+ ['LLLL', 'ਐਤਵਾਰ, ੧੪ ਫ਼ਰਵਰੀ ੨੦੧੦, ਦੁਪਹਿਰ ੩:੨੫ ਵਜੇ'],
+ ['l', '੧੪/੨/੨੦੧੦'],
+ ['ll', '੧੪ ਫ਼ਰਵਰੀ ੨੦੧੦'],
+ ['lll', '੧੪ ਫ਼ਰਵਰੀ ੨੦੧੦, ਦੁਪਹਿਰ ੩:੨੫ ਵਜੇ'],
+ ['llll', 'ਐਤ, ੧੪ ਫ਼ਰਵਰੀ ੨੦੧੦, ਦੁਪਹਿਰ ੩:੨੫ ਵਜੇ']
+ ],
+ b = moment(new Date(2010, 1, 14, 15, 25, 50, 125)),
+ i;
+ for (i = 0; i < a.length; i++) {
+ assert.equal(b.format(a[i][0]), a[i][1], a[i][0] + ' ---> ' + a[i][1]);
+ }
+ });
+
+ test('format ordinal', function (assert) {
+ assert.equal(moment([2011, 0, 1]).format('DDDo'), '੧', '੧');
+ assert.equal(moment([2011, 0, 2]).format('DDDo'), '੨', '੨');
+ assert.equal(moment([2011, 0, 3]).format('DDDo'), '੩', '੩');
+ assert.equal(moment([2011, 0, 4]).format('DDDo'), '੪', '੪');
+ assert.equal(moment([2011, 0, 5]).format('DDDo'), '੫', '੫');
+ assert.equal(moment([2011, 0, 6]).format('DDDo'), '੬', '੬');
+ assert.equal(moment([2011, 0, 7]).format('DDDo'), '੭', '੭');
+ assert.equal(moment([2011, 0, 8]).format('DDDo'), '੮', '੮');
+ assert.equal(moment([2011, 0, 9]).format('DDDo'), '੯', '੯');
+ assert.equal(moment([2011, 0, 10]).format('DDDo'), '੧੦', '੧੦');
+
+ assert.equal(moment([2011, 0, 11]).format('DDDo'), '੧੧', '੧੧');
+ assert.equal(moment([2011, 0, 12]).format('DDDo'), '੧੨', '੧੨');
+ assert.equal(moment([2011, 0, 13]).format('DDDo'), '੧੩', '੧੩');
+ assert.equal(moment([2011, 0, 14]).format('DDDo'), '੧੪', '੧੪');
+ assert.equal(moment([2011, 0, 15]).format('DDDo'), '੧੫', '੧੫');
+ assert.equal(moment([2011, 0, 16]).format('DDDo'), '੧੬', '੧੬');
+ assert.equal(moment([2011, 0, 17]).format('DDDo'), '੧੭', '੧੭');
+ assert.equal(moment([2011, 0, 18]).format('DDDo'), '੧੮', '੧੮');
+ assert.equal(moment([2011, 0, 19]).format('DDDo'), '੧੯', '੧੯');
+ assert.equal(moment([2011, 0, 20]).format('DDDo'), '੨੦', '੨੦');
+
+ assert.equal(moment([2011, 0, 21]).format('DDDo'), '੨੧', '੨੧');
+ assert.equal(moment([2011, 0, 22]).format('DDDo'), '੨੨', '੨੨');
+ assert.equal(moment([2011, 0, 23]).format('DDDo'), '੨੩', '੨੩');
+ assert.equal(moment([2011, 0, 24]).format('DDDo'), '੨੪', '੨੪');
+ assert.equal(moment([2011, 0, 25]).format('DDDo'), '੨੫', '੨੫');
+ assert.equal(moment([2011, 0, 26]).format('DDDo'), '੨੬', '੨੬');
+ assert.equal(moment([2011, 0, 27]).format('DDDo'), '੨੭', '੨੭');
+ assert.equal(moment([2011, 0, 28]).format('DDDo'), '੨੮', '੨੮');
+ assert.equal(moment([2011, 0, 29]).format('DDDo'), '੨੯', '੨੯');
+ assert.equal(moment([2011, 0, 30]).format('DDDo'), '੩੦', '੩੦');
+
+ assert.equal(moment([2011, 0, 31]).format('DDDo'), '੩੧', '੩੧');
+ });
+
+ test('format month', function (assert) {
+ var expected = 'ਜਨਵਰੀ ਜਨਵਰੀ_ਫ਼ਰਵਰੀ ਫ਼ਰਵਰੀ_ਮਾਰਚ ਮਾਰਚ_ਅਪ੍ਰੈਲ ਅਪ੍ਰੈਲ_ਮਈ ਮਈ_ਜੂਨ ਜੂਨ_ਜੁਲਾਈ ਜੁਲਾਈ_ਅਗਸਤ ਅਗਸਤ_ਸਤੰਬਰ ਸਤੰਬਰ_ਅਕਤੂਬਰ ਅਕਤੂਬਰ_ਨਵੰਬਰ ਨਵੰਬਰ_ਦਸੰਬਰ ਦਸੰਬਰ'.split('_'), i;
+ for (i = 0; i < expected.length; i++) {
+ assert.equal(moment([2011, i, 1]).format('MMMM MMM'), expected[i], expected[i]);
+ }
+ });
+
+ test('format week', function (assert) {
+ var expected = 'ਐਤਵਾਰ ਐਤ ਐਤ_ਸੋਮਵਾਰ ਸੋਮ ਸੋਮ_ਮੰਗਲਵਾਰ ਮੰਗਲ ਮੰਗਲ_ਬੁਧਵਾਰ ਬੁਧ ਬੁਧ_ਵੀਰਵਾਰ ਵੀਰ ਵੀਰ_ਸ਼ੁੱਕਰਵਾਰ ਸ਼ੁਕਰ ਸ਼ੁਕਰ_ਸ਼ਨੀਚਰਵਾਰ ਸ਼ਨੀ ਸ਼ਨੀ'.split('_'), i;
+ for (i = 0; i < expected.length; i++) {
+ assert.equal(moment([2011, 0, 2 + i]).format('dddd ddd dd'), expected[i], expected[i]);
+ }
+ });
+
+ test('from', function (assert) {
+ var start = moment([2007, 1, 28]);
+ assert.equal(start.from(moment([2007, 1, 28]).add({s: 44}), true), 'ਕੁਝ ਸਕਿੰਟ', '44 seconds = a few seconds');
+ assert.equal(start.from(moment([2007, 1, 28]).add({s: 45}), true), 'ਇਕ ਮਿੰਟ', '45 seconds = a minute');
+ assert.equal(start.from(moment([2007, 1, 28]).add({s: 89}), true), 'ਇਕ ਮਿੰਟ', '89 seconds = a minute');
+ assert.equal(start.from(moment([2007, 1, 28]).add({s: 90}), true), '੨ ਮਿੰਟ', '90 seconds = 2 minutes');
+ assert.equal(start.from(moment([2007, 1, 28]).add({m: 44}), true), '੪੪ ਮਿੰਟ', '44 minutes = 44 minutes');
+ assert.equal(start.from(moment([2007, 1, 28]).add({m: 45}), true), 'ਇੱਕ ਘੰਟਾ', '45 minutes = an hour');
+ assert.equal(start.from(moment([2007, 1, 28]).add({m: 89}), true), 'ਇੱਕ ਘੰਟਾ', '89 minutes = an hour');
+ assert.equal(start.from(moment([2007, 1, 28]).add({m: 90}), true), '੨ ਘੰਟੇ', '90 minutes = 2 hours');
+ assert.equal(start.from(moment([2007, 1, 28]).add({h: 5}), true), '੫ ਘੰਟੇ', '5 hours = 5 hours');
+ assert.equal(start.from(moment([2007, 1, 28]).add({h: 21}), true), '੨੧ ਘੰਟੇ', '21 hours = 21 hours');
+ assert.equal(start.from(moment([2007, 1, 28]).add({h: 22}), true), 'ਇੱਕ ਦਿਨ', '22 hours = a day');
+ assert.equal(start.from(moment([2007, 1, 28]).add({h: 35}), true), 'ਇੱਕ ਦਿਨ', '35 hours = a day');
+ assert.equal(start.from(moment([2007, 1, 28]).add({h: 36}), true), '੨ ਦਿਨ', '36 hours = 2 days');
+ assert.equal(start.from(moment([2007, 1, 28]).add({d: 1}), true), 'ਇੱਕ ਦਿਨ', '1 day = a day');
+ assert.equal(start.from(moment([2007, 1, 28]).add({d: 5}), true), '੫ ਦਿਨ', '5 days = 5 days');
+ assert.equal(start.from(moment([2007, 1, 28]).add({d: 25}), true), '੨੫ ਦਿਨ', '25 days = 25 days');
+ assert.equal(start.from(moment([2007, 1, 28]).add({d: 26}), true), 'ਇੱਕ ਮਹੀਨਾ', '26 days = a month');
+ assert.equal(start.from(moment([2007, 1, 28]).add({d: 30}), true), 'ਇੱਕ ਮਹੀਨਾ', '30 days = a month');
+ assert.equal(start.from(moment([2007, 1, 28]).add({d: 43}), true), 'ਇੱਕ ਮਹੀਨਾ', '43 days = a month');
+ assert.equal(start.from(moment([2007, 1, 28]).add({d: 46}), true), '੨ ਮਹੀਨੇ', '46 days = 2 months');
+ assert.equal(start.from(moment([2007, 1, 28]).add({d: 74}), true), '੨ ਮਹੀਨੇ', '75 days = 2 months');
+ assert.equal(start.from(moment([2007, 1, 28]).add({d: 76}), true), '੩ ਮਹੀਨੇ', '76 days = 3 months');
+ assert.equal(start.from(moment([2007, 1, 28]).add({M: 1}), true), 'ਇੱਕ ਮਹੀਨਾ', '1 month = a month');
+ assert.equal(start.from(moment([2007, 1, 28]).add({M: 5}), true), '੫ ਮਹੀਨੇ', '5 months = 5 months');
+ assert.equal(start.from(moment([2007, 1, 28]).add({d: 345}), true), 'ਇੱਕ ਸਾਲ', '345 days = a year');
+ assert.equal(start.from(moment([2007, 1, 28]).add({d: 548}), true), '੨ ਸਾਲ', '548 days = 2 years');
+ assert.equal(start.from(moment([2007, 1, 28]).add({y: 1}), true), 'ਇੱਕ ਸਾਲ', '1 year = a year');
+ assert.equal(start.from(moment([2007, 1, 28]).add({y: 5}), true), '੫ ਸਾਲ', '5 years = 5 years');
+ });
+
+ test('suffix', function (assert) {
+ assert.equal(moment(30000).from(0), 'ਕੁਝ ਸਕਿੰਟ ਵਿੱਚ', 'prefix');
+ assert.equal(moment(0).from(30000), 'ਕੁਝ ਸਕਿੰਟ ਪਿਛਲੇ', 'suffix');
+ });
+
+ test('now from now', function (assert) {
+ assert.equal(moment().fromNow(), 'ਕੁਝ ਸਕਿੰਟ ਪਿਛਲੇ', 'now from now should display as in the past');
+ });
+
+ test('fromNow', function (assert) {
+ assert.equal(moment().add({s: 30}).fromNow(), 'ਕੁਝ ਸਕਿੰਟ ਵਿੱਚ', 'ਕੁਝ ਸਕਿੰਟ ਵਿੱਚ');
+ assert.equal(moment().add({d: 5}).fromNow(), '੫ ਦਿਨ ਵਿੱਚ', '੫ ਦਿਨ ਵਿੱਚ');
+ });
+
+ test('calendar day', function (assert) {
+ var a = moment().hours(12).minutes(0).seconds(0);
+
+ assert.equal(moment(a).calendar(), 'ਅਜ ਦੁਪਹਿਰ ੧੨:੦੦ ਵਜੇ', 'today at the same time');
+ assert.equal(moment(a).add({m: 25}).calendar(), 'ਅਜ ਦੁਪਹਿਰ ੧੨:੨੫ ਵਜੇ', 'Now plus 25 min');
+ assert.equal(moment(a).add({h: 3}).calendar(), 'ਅਜ ਦੁਪਹਿਰ ੩:੦੦ ਵਜੇ', 'Now plus 3 hours');
+ assert.equal(moment(a).add({d: 1}).calendar(), 'ਕਲ ਦੁਪਹਿਰ ੧੨:੦੦ ਵਜੇ', 'tomorrow at the same time');
+ assert.equal(moment(a).subtract({h: 1}).calendar(), 'ਅਜ ਦੁਪਹਿਰ ੧੧:੦੦ ਵਜੇ', 'Now minus 1 hour');
+ assert.equal(moment(a).subtract({d: 1}).calendar(), 'ਕਲ ਦੁਪਹਿਰ ੧੨:੦੦ ਵਜੇ', 'yesterday at the same time');
+ });
+
+ test('calendar next week', function (assert) {
+ var i, m;
+ for (i = 2; i < 7; i++) {
+ m = moment().add({d: i});
+ assert.equal(m.calendar(), m.format('dddd[,] LT'), 'Today + ' + i + ' days current time');
+ m.hours(0).minutes(0).seconds(0).milliseconds(0);
+ assert.equal(m.calendar(), m.format('dddd[,] LT'), 'Today + ' + i + ' days beginning of day');
+ m.hours(23).minutes(59).seconds(59).milliseconds(999);
+ assert.equal(m.calendar(), m.format('dddd[,] LT'), 'Today + ' + i + ' days end of day');
+ }
+ });
+
+ test('calendar last week', function (assert) {
+ var i, m;
+
+ for (i = 2; i < 7; i++) {
+ m = moment().subtract({d: i});
+ assert.equal(m.calendar(), m.format('[ਪਿਛਲੇ] dddd[,] LT'), 'Today - ' + i + ' days current time');
+ m.hours(0).minutes(0).seconds(0).milliseconds(0);
+ assert.equal(m.calendar(), m.format('[ਪਿਛਲੇ] dddd[,] LT'), 'Today - ' + i + ' days beginning of day');
+ m.hours(23).minutes(59).seconds(59).milliseconds(999);
+ assert.equal(m.calendar(), m.format('[ਪਿਛਲੇ] dddd[,] LT'), 'Today - ' + i + ' days end of day');
+ }
+ });
+
+ test('calendar all else', function (assert) {
+ var weeksAgo = moment().subtract({w: 1}),
+ weeksFromNow = moment().add({w: 1});
+
+ assert.equal(weeksAgo.calendar(), weeksAgo.format('L'), '1 week ago');
+ assert.equal(weeksFromNow.calendar(), weeksFromNow.format('L'), 'in 1 week');
+
+ weeksAgo = moment().subtract({w: 2});
+ weeksFromNow = moment().add({w: 2});
+
+ assert.equal(weeksAgo.calendar(), weeksAgo.format('L'), '2 weeks ago');
+ assert.equal(weeksFromNow.calendar(), weeksFromNow.format('L'), 'in 2 weeks');
+ });
+
+ test('meridiem invariant', function (assert) {
+ assert.equal(moment([2011, 2, 23, 2, 30]).format('a'), 'ਰਾਤ', 'before dawn');
+ assert.equal(moment([2011, 2, 23, 9, 30]).format('a'), 'ਸਵੇਰ', 'morning');
+ assert.equal(moment([2011, 2, 23, 14, 30]).format('a'), 'ਦੁਪਹਿਰ', 'during day');
+ assert.equal(moment([2011, 2, 23, 17, 30]).format('a'), 'ਸ਼ਾਮ', 'evening');
+ assert.equal(moment([2011, 2, 23, 19, 30]).format('a'), 'ਸ਼ਾਮ', 'late evening');
+ assert.equal(moment([2011, 2, 23, 21, 20]).format('a'), 'ਰਾਤ', 'night');
+
+ assert.equal(moment([2011, 2, 23, 2, 30]).format('A'), 'ਰਾਤ', 'before dawn');
+ assert.equal(moment([2011, 2, 23, 9, 30]).format('A'), 'ਸਵੇਰ', 'morning');
+ assert.equal(moment([2011, 2, 23, 14, 30]).format('A'), 'ਦੁਪਹਿਰ', ' during day');
+ assert.equal(moment([2011, 2, 23, 17, 30]).format('A'), 'ਸ਼ਾਮ', 'evening');
+ assert.equal(moment([2011, 2, 23, 19, 30]).format('A'), 'ਸ਼ਾਮ', 'late evening');
+ assert.equal(moment([2011, 2, 23, 21, 20]).format('A'), 'ਰਾਤ', 'night');
+ });
+
+ test('weeks year starting sunday', function (assert) {
+ assert.equal(moment([2012, 0, 1]).week(), 1, 'Jan 1 2012 should be week 1');
+ assert.equal(moment([2012, 0, 7]).week(), 1, 'Jan 7 2012 should be week 1');
+ assert.equal(moment([2012, 0, 8]).week(), 2, 'Jan 8 2012 should be week 2');
+ assert.equal(moment([2012, 0, 14]).week(), 2, 'Jan 14 2012 should be week 2');
+ assert.equal(moment([2012, 0, 15]).week(), 3, 'Jan 15 2012 should be week 3');
+ });
+
+ test('weeks year starting monday', function (assert) {
+ assert.equal(moment([2006, 11, 31]).week(), 1, 'Dec 31 2006 should be week 1');
+ assert.equal(moment([2007, 0, 1]).week(), 1, 'Jan 1 2007 should be week 1');
+ assert.equal(moment([2007, 0, 6]).week(), 1, 'Jan 6 2007 should be week 1');
+ assert.equal(moment([2007, 0, 7]).week(), 2, 'Jan 7 2007 should be week 2');
+ assert.equal(moment([2007, 0, 13]).week(), 2, 'Jan 13 2007 should be week 2');
+ assert.equal(moment([2007, 0, 14]).week(), 3, 'Jan 14 2007 should be week 3');
+ });
+
+ test('weeks year starting tuesday', function (assert) {
+ assert.equal(moment([2007, 11, 29]).week(), 52, 'Dec 29 2007 should be week 52');
+ assert.equal(moment([2008, 0, 1]).week(), 1, 'Jan 1 2008 should be week 1');
+ assert.equal(moment([2008, 0, 5]).week(), 1, 'Jan 5 2008 should be week 1');
+ assert.equal(moment([2008, 0, 6]).week(), 2, 'Jan 6 2008 should be week 2');
+ assert.equal(moment([2008, 0, 12]).week(), 2, 'Jan 12 2008 should be week 2');
+ assert.equal(moment([2008, 0, 13]).week(), 3, 'Jan 13 2008 should be week 3');
+ });
+
+ test('weeks year starting wednesday', function (assert) {
+ assert.equal(moment([2002, 11, 29]).week(), 1, 'Dec 29 2002 should be week 1');
+ assert.equal(moment([2003, 0, 1]).week(), 1, 'Jan 1 2003 should be week 1');
+ assert.equal(moment([2003, 0, 4]).week(), 1, 'Jan 4 2003 should be week 1');
+ assert.equal(moment([2003, 0, 5]).week(), 2, 'Jan 5 2003 should be week 2');
+ assert.equal(moment([2003, 0, 11]).week(), 2, 'Jan 11 2003 should be week 2');
+ assert.equal(moment([2003, 0, 12]).week(), 3, 'Jan 12 2003 should be week 3');
+ });
+
+ test('weeks year starting thursday', function (assert) {
+ assert.equal(moment([2008, 11, 28]).week(), 1, 'Dec 28 2008 should be week 1');
+ assert.equal(moment([2009, 0, 1]).week(), 1, 'Jan 1 2009 should be week 1');
+ assert.equal(moment([2009, 0, 3]).week(), 1, 'Jan 3 2009 should be week 1');
+ assert.equal(moment([2009, 0, 4]).week(), 2, 'Jan 4 2009 should be week 2');
+ assert.equal(moment([2009, 0, 10]).week(), 2, 'Jan 10 2009 should be week 2');
+ assert.equal(moment([2009, 0, 11]).week(), 3, 'Jan 11 2009 should be week 3');
+ });
+
+ test('weeks year starting friday', function (assert) {
+ assert.equal(moment([2009, 11, 27]).week(), 1, 'Dec 27 2009 should be week 1');
+ assert.equal(moment([2010, 0, 1]).week(), 1, 'Jan 1 2010 should be week 1');
+ assert.equal(moment([2010, 0, 2]).week(), 1, 'Jan 2 2010 should be week 1');
+ assert.equal(moment([2010, 0, 3]).week(), 2, 'Jan 3 2010 should be week 2');
+ assert.equal(moment([2010, 0, 9]).week(), 2, 'Jan 9 2010 should be week 2');
+ assert.equal(moment([2010, 0, 10]).week(), 3, 'Jan 10 2010 should be week 3');
+ });
+
+ test('weeks year starting saturday', function (assert) {
+ assert.equal(moment([2010, 11, 26]).week(), 1, 'Dec 26 2010 should be week 1');
+ assert.equal(moment([2011, 0, 1]).week(), 1, 'Jan 1 2011 should be week 1');
+ assert.equal(moment([2011, 0, 2]).week(), 2, 'Jan 2 2011 should be week 2');
+ assert.equal(moment([2011, 0, 8]).week(), 2, 'Jan 8 2011 should be week 2');
+ assert.equal(moment([2011, 0, 9]).week(), 3, 'Jan 9 2011 should be week 3');
+ });
+
+ test('weeks year starting sunday formatted', function (assert) {
+ assert.equal(moment([2012, 0, 1]).format('w ww wo'), '੧ ੦੧ ੧', 'Jan 1 2012 should be week 1');
+ assert.equal(moment([2012, 0, 7]).format('w ww wo'), '੧ ੦੧ ੧', 'Jan 7 2012 should be week 1');
+ assert.equal(moment([2012, 0, 8]).format('w ww wo'), '੨ ੦੨ ੨', 'Jan 8 2012 should be week 2');
+ assert.equal(moment([2012, 0, 14]).format('w ww wo'), '੨ ੦੨ ੨', 'Jan 14 2012 should be week 2');
+ assert.equal(moment([2012, 0, 15]).format('w ww wo'), '੩ ੦੩ ੩', 'Jan 15 2012 should be week 3');
});
test('lenient ordinal parsing', function (assert) {
@@ -25155,6 +35310,224 @@
factory(global.moment)
}(this, function (moment) { 'use strict';
+ function each(array, callback) {
+ var i;
+ for (i = 0; i < array.length; i++) {
+ callback(array[i], i, array);
+ }
+ }
+
+ function objectKeys(obj) {
+ if (Object.keys) {
+ return Object.keys(obj);
+ } else {
+ // IE8
+ var res = [], i;
+ for (i in obj) {
+ if (obj.hasOwnProperty(i)) {
+ res.push(i);
+ }
+ }
+ return res;
+ }
+ }
+
+ // Pick the first defined of two or three arguments.
+ function defaults(a, b, c) {
+ if (a != null) {
+ return a;
+ }
+ if (b != null) {
+ return b;
+ }
+ return c;
+ }
+
+ function defineCommonLocaleTests(locale, options) {
+ test('lenient ordinal parsing', function (assert) {
+ var i, ordinalStr, testMoment;
+ for (i = 1; i <= 31; ++i) {
+ ordinalStr = moment([2014, 0, i]).format('YYYY MM Do');
+ testMoment = moment(ordinalStr, 'YYYY MM Do');
+ assert.equal(testMoment.year(), 2014,
+ 'lenient ordinal parsing ' + i + ' year check');
+ assert.equal(testMoment.month(), 0,
+ 'lenient ordinal parsing ' + i + ' month check');
+ assert.equal(testMoment.date(), i,
+ 'lenient ordinal parsing ' + i + ' date check');
+ }
+ });
+
+ test('lenient ordinal parsing of number', function (assert) {
+ var i, testMoment;
+ for (i = 1; i <= 31; ++i) {
+ testMoment = moment('2014 01 ' + i, 'YYYY MM Do');
+ assert.equal(testMoment.year(), 2014,
+ 'lenient ordinal parsing of number ' + i + ' year check');
+ assert.equal(testMoment.month(), 0,
+ 'lenient ordinal parsing of number ' + i + ' month check');
+ assert.equal(testMoment.date(), i,
+ 'lenient ordinal parsing of number ' + i + ' date check');
+ }
+ });
+
+ test('strict ordinal parsing', function (assert) {
+ var i, ordinalStr, testMoment;
+ for (i = 1; i <= 31; ++i) {
+ ordinalStr = moment([2014, 0, i]).format('YYYY MM Do');
+ testMoment = moment(ordinalStr, 'YYYY MM Do', true);
+ assert.ok(testMoment.isValid(), 'strict ordinal parsing ' + i);
+ }
+ });
+
+ test('meridiem invariant', function (assert) {
+ var h, m, t1, t2;
+ for (h = 0; h < 24; ++h) {
+ for (m = 0; m < 60; m += 15) {
+ t1 = moment.utc([2000, 0, 1, h, m]);
+ t2 = moment.utc(t1.format('A h:mm'), 'A h:mm');
+ assert.equal(t2.format('HH:mm'), t1.format('HH:mm'),
+ 'meridiem at ' + t1.format('HH:mm'));
+ }
+ }
+ });
+
+ test('date format correctness', function (assert) {
+ var data, tokens;
+ data = moment.localeData()._longDateFormat;
+ tokens = objectKeys(data);
+ each(tokens, function (srchToken) {
+ // Check each format string to make sure it does not contain any
+ // tokens that need to be expanded.
+ each(tokens, function (baseToken) {
+ // strip escaped sequences
+ var format = data[baseToken].replace(/(\[[^\]]*\])/g, '');
+ assert.equal(false, !!~format.indexOf(srchToken),
+ 'contains ' + srchToken + ' in ' + baseToken);
+ });
+ });
+ });
+
+ test('month parsing correctness', function (assert) {
+ var i, m;
+
+ if (locale === 'tr') {
+ // I can't fix it :(
+ expect(0);
+ return;
+ }
+ function tester(format) {
+ var r;
+ r = moment(m.format(format), format);
+ assert.equal(r.month(), m.month(), 'month ' + i + ' fmt ' + format);
+ r = moment(m.format(format).toLocaleUpperCase(), format);
+ assert.equal(r.month(), m.month(), 'month ' + i + ' fmt ' + format + ' upper');
+ r = moment(m.format(format).toLocaleLowerCase(), format);
+ assert.equal(r.month(), m.month(), 'month ' + i + ' fmt ' + format + ' lower');
+
+ r = moment(m.format(format), format, true);
+ assert.equal(r.month(), m.month(), 'month ' + i + ' fmt ' + format + ' strict');
+ r = moment(m.format(format).toLocaleUpperCase(), format, true);
+ assert.equal(r.month(), m.month(), 'month ' + i + ' fmt ' + format + ' upper strict');
+ r = moment(m.format(format).toLocaleLowerCase(), format, true);
+ assert.equal(r.month(), m.month(), 'month ' + i + ' fmt ' + format + ' lower strict');
+ }
+
+ for (i = 0; i < 12; ++i) {
+ m = moment([2015, i, 15, 18]);
+ tester('MMM');
+ tester('MMM.');
+ tester('MMMM');
+ tester('MMMM.');
+ }
+ });
+
+ test('weekday parsing correctness', function (assert) {
+ var i, m;
+
+ if (locale === 'tr' || locale === 'az') {
+ // There is a lower-case letter (ı), that converted to upper then
+ // lower changes to i
+ expect(0);
+ return;
+ }
+ function tester(format) {
+ var r, baseMsg = 'weekday ' + m.weekday() + ' fmt ' + format;
+ r = moment(m.format(format), format);
+ assert.equal(r.weekday(), m.weekday(), baseMsg);
+ r = moment(m.format(format).toLocaleUpperCase(), format);
+ assert.equal(r.weekday(), m.weekday(), baseMsg + ' upper');
+ r = moment(m.format(format).toLocaleLowerCase(), format);
+ assert.equal(r.weekday(), m.weekday(), baseMsg + ' lower');
+
+ r = moment(m.format(format), format, true);
+ assert.equal(r.weekday(), m.weekday(), baseMsg + ' strict');
+ r = moment(m.format(format).toLocaleUpperCase(), format, true);
+ assert.equal(r.weekday(), m.weekday(), baseMsg + ' upper strict');
+ r = moment(m.format(format).toLocaleLowerCase(), format, true);
+ assert.equal(r.weekday(), m.weekday(), baseMsg + ' lower strict');
+ }
+
+ for (i = 0; i < 7; ++i) {
+ m = moment.utc([2015, i, 15, 18]);
+ tester('dd');
+ tester('ddd');
+ tester('dddd');
+ }
+ });
+ }
+
+ function setupDeprecationHandler(test, moment, scope) {
+ test._expectedDeprecations = null;
+ test._observedDeprecations = null;
+ test._oldSupress = moment.suppressDeprecationWarnings;
+ moment.suppressDeprecationWarnings = true;
+ test.expectedDeprecations = function () {
+ test._expectedDeprecations = arguments;
+ test._observedDeprecations = [];
+ };
+ moment.deprecationHandler = function (name, msg) {
+ var deprecationId = matchedDeprecation(name, msg, test._expectedDeprecations);
+ if (deprecationId === -1) {
+ throw new Error('Unexpected deprecation thrown name=' +
+ name + ' msg=' + msg);
+ }
+ test._observedDeprecations[deprecationId] = 1;
+ };
+ }
+
+ function teardownDeprecationHandler(test, moment, scope) {
+ moment.suppressDeprecationWarnings = test._oldSupress;
+
+ if (test._expectedDeprecations != null) {
+ var missedDeprecations = [];
+ each(test._expectedDeprecations, function (deprecationPattern, id) {
+ if (test._observedDeprecations[id] !== 1) {
+ missedDeprecations.push(deprecationPattern);
+ }
+ });
+ if (missedDeprecations.length !== 0) {
+ throw new Error('Expected deprecation warnings did not happen: ' +
+ missedDeprecations.join(' '));
+ }
+ }
+ }
+
+ function matchedDeprecation(name, msg, deprecations) {
+ if (deprecations == null) {
+ return -1;
+ }
+ for (var i = 0; i < deprecations.length; ++i) {
+ if (name != null && name === deprecations[i]) {
+ return i;
+ }
+ if (msg != null && msg.substring(0, deprecations[i].length) === deprecations[i]) {
+ return i;
+ }
+ }
+ return -1;
+ }
+
/*global QUnit:false*/
var test = QUnit.test;
@@ -25168,11 +35541,13 @@
moment.createFromInputFallback = function (config) {
throw new Error('input not handled by moment: ' + config._i);
};
+ setupDeprecationHandler(test, moment, 'core');
if (lifecycle && lifecycle.setup) {
lifecycle.setup();
}
},
teardown : function () {
+ teardownDeprecationHandler(test, moment, 'core');
if (lifecycle && lifecycle.teardown) {
lifecycle.teardown();
}
@@ -25187,17 +35562,20 @@
moment.createFromInputFallback = function (config) {
throw new Error('input not handled by moment: ' + config._i);
};
+ setupDeprecationHandler(test, moment, 'locale');
if (lifecycle && lifecycle.setup) {
lifecycle.setup();
}
},
teardown : function () {
moment.locale('en');
+ teardownDeprecationHandler(test, moment, 'locale');
if (lifecycle && lifecycle.teardown) {
lifecycle.teardown();
}
}
});
+ defineCommonLocaleTests(name, -1, -1);
}
localeModule('pl');
@@ -25379,14 +35757,14 @@
});
test('calendar day', function (assert) {
- var a = moment().hours(2).minutes(0).seconds(0);
-
- assert.equal(moment(a).calendar(), 'Dziś o 02:00', 'today at the same time');
- assert.equal(moment(a).add({m: 25}).calendar(), 'Dziś o 02:25', 'Now plus 25 min');
- assert.equal(moment(a).add({h: 1}).calendar(), 'Dziś o 03:00', 'Now plus 1 hour');
- assert.equal(moment(a).add({d: 1}).calendar(), 'Jutro o 02:00', 'tomorrow at the same time');
- assert.equal(moment(a).subtract({h: 1}).calendar(), 'Dziś o 01:00', 'Now minus 1 hour');
- assert.equal(moment(a).subtract({d: 1}).calendar(), 'Wczoraj o 02:00', 'yesterday at the same time');
+ var a = moment().hours(12).minutes(0).seconds(0);
+
+ assert.equal(moment(a).calendar(), 'Dziś o 12:00', 'today at the same time');
+ assert.equal(moment(a).add({m: 25}).calendar(), 'Dziś o 12:25', 'Now plus 25 min');
+ assert.equal(moment(a).add({h: 1}).calendar(), 'Dziś o 13:00', 'Now plus 1 hour');
+ assert.equal(moment(a).add({d: 1}).calendar(), 'Jutro o 12:00', 'tomorrow at the same time');
+ assert.equal(moment(a).subtract({h: 1}).calendar(), 'Dziś o 11:00', 'Now minus 1 hour');
+ assert.equal(moment(a).subtract({d: 1}).calendar(), 'Wczoraj o 12:00', 'yesterday at the same time');
});
test('calendar next week', function (assert) {
@@ -25443,67 +35821,6 @@
assert.equal(weeksFromNow.calendar(), weeksFromNow.format('L'), 'in 2 weeks');
});
- test('weeks year starting sunday', function (assert) {
- assert.equal(moment([2012, 0, 1]).week(), 52, 'Jan 1 2012 should be week 52');
- assert.equal(moment([2012, 0, 2]).week(), 1, 'Jan 2 2012 should be week 1');
- assert.equal(moment([2012, 0, 8]).week(), 1, 'Jan 8 2012 should be week 1');
- assert.equal(moment([2012, 0, 9]).week(), 2, 'Jan 9 2012 should be week 2');
- assert.equal(moment([2012, 0, 15]).week(), 2, 'Jan 15 2012 should be week 2');
- });
-
- test('weeks year starting monday', function (assert) {
- assert.equal(moment([2007, 0, 1]).week(), 1, 'Jan 1 2007 should be week 1');
- assert.equal(moment([2007, 0, 7]).week(), 1, 'Jan 7 2007 should be week 1');
- assert.equal(moment([2007, 0, 8]).week(), 2, 'Jan 8 2007 should be week 2');
- assert.equal(moment([2007, 0, 14]).week(), 2, 'Jan 14 2007 should be week 2');
- assert.equal(moment([2007, 0, 15]).week(), 3, 'Jan 15 2007 should be week 3');
- });
-
- test('weeks year starting tuesday', function (assert) {
- assert.equal(moment([2007, 11, 31]).week(), 1, 'Dec 31 2007 should be week 1');
- assert.equal(moment([2008, 0, 1]).week(), 1, 'Jan 1 2008 should be week 1');
- assert.equal(moment([2008, 0, 6]).week(), 1, 'Jan 6 2008 should be week 1');
- assert.equal(moment([2008, 0, 7]).week(), 2, 'Jan 7 2008 should be week 2');
- assert.equal(moment([2008, 0, 13]).week(), 2, 'Jan 13 2008 should be week 2');
- assert.equal(moment([2008, 0, 14]).week(), 3, 'Jan 14 2008 should be week 3');
- });
-
- test('weeks year starting wednesday', function (assert) {
- assert.equal(moment([2002, 11, 30]).week(), 1, 'Dec 30 2002 should be week 1');
- assert.equal(moment([2003, 0, 1]).week(), 1, 'Jan 1 2003 should be week 1');
- assert.equal(moment([2003, 0, 5]).week(), 1, 'Jan 5 2003 should be week 1');
- assert.equal(moment([2003, 0, 6]).week(), 2, 'Jan 6 2003 should be week 2');
- assert.equal(moment([2003, 0, 12]).week(), 2, 'Jan 12 2003 should be week 2');
- assert.equal(moment([2003, 0, 13]).week(), 3, 'Jan 13 2003 should be week 3');
- });
-
- test('weeks year starting thursday', function (assert) {
- assert.equal(moment([2008, 11, 29]).week(), 1, 'Dec 29 2008 should be week 1');
- assert.equal(moment([2009, 0, 1]).week(), 1, 'Jan 1 2009 should be week 1');
- assert.equal(moment([2009, 0, 4]).week(), 1, 'Jan 4 2009 should be week 1');
- assert.equal(moment([2009, 0, 5]).week(), 2, 'Jan 5 2009 should be week 2');
- assert.equal(moment([2009, 0, 11]).week(), 2, 'Jan 11 2009 should be week 2');
- assert.equal(moment([2009, 0, 13]).week(), 3, 'Jan 12 2009 should be week 3');
- });
-
- test('weeks year starting friday', function (assert) {
- assert.equal(moment([2009, 11, 28]).week(), 53, 'Dec 28 2009 should be week 53');
- assert.equal(moment([2010, 0, 1]).week(), 53, 'Jan 1 2010 should be week 53');
- assert.equal(moment([2010, 0, 3]).week(), 53, 'Jan 3 2010 should be week 53');
- assert.equal(moment([2010, 0, 4]).week(), 1, 'Jan 4 2010 should be week 1');
- assert.equal(moment([2010, 0, 10]).week(), 1, 'Jan 10 2010 should be week 1');
- assert.equal(moment([2010, 0, 11]).week(), 2, 'Jan 11 2010 should be week 2');
- });
-
- test('weeks year starting saturday', function (assert) {
- assert.equal(moment([2010, 11, 27]).week(), 52, 'Dec 27 2010 should be week 52');
- assert.equal(moment([2011, 0, 1]).week(), 52, 'Jan 1 2011 should be week 52');
- assert.equal(moment([2011, 0, 2]).week(), 52, 'Jan 2 2011 should be week 52');
- assert.equal(moment([2011, 0, 3]).week(), 1, 'Jan 3 2011 should be week 1');
- assert.equal(moment([2011, 0, 9]).week(), 1, 'Jan 9 2011 should be week 1');
- assert.equal(moment([2011, 0, 10]).week(), 2, 'Jan 10 2011 should be week 2');
- });
-
test('weeks year starting sunday formatted', function (assert) {
assert.equal(moment([2012, 0, 1]).format('w ww wo'), '52 52 52.', 'Jan 1 2012 should be week 52');
assert.equal(moment([2012, 0, 2]).format('w ww wo'), '1 01 1.', 'Jan 2 2012 should be week 1');
@@ -25512,42 +35829,6 @@
assert.equal(moment([2012, 0, 15]).format('w ww wo'), '2 02 2.', 'Jan 15 2012 should be week 2');
});
- test('lenient ordinal parsing', function (assert) {
- var i, ordinalStr, testMoment;
- for (i = 1; i <= 31; ++i) {
- ordinalStr = moment([2014, 0, i]).format('YYYY MM Do');
- testMoment = moment(ordinalStr, 'YYYY MM Do');
- assert.equal(testMoment.year(), 2014,
- 'lenient ordinal parsing ' + i + ' year check');
- assert.equal(testMoment.month(), 0,
- 'lenient ordinal parsing ' + i + ' month check');
- assert.equal(testMoment.date(), i,
- 'lenient ordinal parsing ' + i + ' date check');
- }
- });
-
- test('lenient ordinal parsing of number', function (assert) {
- var i, testMoment;
- for (i = 1; i <= 31; ++i) {
- testMoment = moment('2014 01 ' + i, 'YYYY MM Do');
- assert.equal(testMoment.year(), 2014,
- 'lenient ordinal parsing of number ' + i + ' year check');
- assert.equal(testMoment.month(), 0,
- 'lenient ordinal parsing of number ' + i + ' month check');
- assert.equal(testMoment.date(), i,
- 'lenient ordinal parsing of number ' + i + ' date check');
- }
- });
-
- test('strict ordinal parsing', function (assert) {
- var i, ordinalStr, testMoment;
- for (i = 1; i <= 31; ++i) {
- ordinalStr = moment([2014, 0, i]).format('YYYY MM Do');
- testMoment = moment(ordinalStr, 'YYYY MM Do', true);
- assert.ok(testMoment.isValid(), 'strict ordinal parsing ' + i);
- }
- });
-
}));
;(function (global, factory) {
@@ -25556,6 +35837,224 @@
typeof define === 'function' && define.amd ? define(['../../moment'], factory) :
factory(global.moment)
}(this, function (moment) { 'use strict';
+
+ function each(array, callback) {
+ var i;
+ for (i = 0; i < array.length; i++) {
+ callback(array[i], i, array);
+ }
+ }
+
+ function objectKeys(obj) {
+ if (Object.keys) {
+ return Object.keys(obj);
+ } else {
+ // IE8
+ var res = [], i;
+ for (i in obj) {
+ if (obj.hasOwnProperty(i)) {
+ res.push(i);
+ }
+ }
+ return res;
+ }
+ }
+
+ // Pick the first defined of two or three arguments.
+ function defaults(a, b, c) {
+ if (a != null) {
+ return a;
+ }
+ if (b != null) {
+ return b;
+ }
+ return c;
+ }
+
+ function defineCommonLocaleTests(locale, options) {
+ test('lenient ordinal parsing', function (assert) {
+ var i, ordinalStr, testMoment;
+ for (i = 1; i <= 31; ++i) {
+ ordinalStr = moment([2014, 0, i]).format('YYYY MM Do');
+ testMoment = moment(ordinalStr, 'YYYY MM Do');
+ assert.equal(testMoment.year(), 2014,
+ 'lenient ordinal parsing ' + i + ' year check');
+ assert.equal(testMoment.month(), 0,
+ 'lenient ordinal parsing ' + i + ' month check');
+ assert.equal(testMoment.date(), i,
+ 'lenient ordinal parsing ' + i + ' date check');
+ }
+ });
+
+ test('lenient ordinal parsing of number', function (assert) {
+ var i, testMoment;
+ for (i = 1; i <= 31; ++i) {
+ testMoment = moment('2014 01 ' + i, 'YYYY MM Do');
+ assert.equal(testMoment.year(), 2014,
+ 'lenient ordinal parsing of number ' + i + ' year check');
+ assert.equal(testMoment.month(), 0,
+ 'lenient ordinal parsing of number ' + i + ' month check');
+ assert.equal(testMoment.date(), i,
+ 'lenient ordinal parsing of number ' + i + ' date check');
+ }
+ });
+
+ test('strict ordinal parsing', function (assert) {
+ var i, ordinalStr, testMoment;
+ for (i = 1; i <= 31; ++i) {
+ ordinalStr = moment([2014, 0, i]).format('YYYY MM Do');
+ testMoment = moment(ordinalStr, 'YYYY MM Do', true);
+ assert.ok(testMoment.isValid(), 'strict ordinal parsing ' + i);
+ }
+ });
+
+ test('meridiem invariant', function (assert) {
+ var h, m, t1, t2;
+ for (h = 0; h < 24; ++h) {
+ for (m = 0; m < 60; m += 15) {
+ t1 = moment.utc([2000, 0, 1, h, m]);
+ t2 = moment.utc(t1.format('A h:mm'), 'A h:mm');
+ assert.equal(t2.format('HH:mm'), t1.format('HH:mm'),
+ 'meridiem at ' + t1.format('HH:mm'));
+ }
+ }
+ });
+
+ test('date format correctness', function (assert) {
+ var data, tokens;
+ data = moment.localeData()._longDateFormat;
+ tokens = objectKeys(data);
+ each(tokens, function (srchToken) {
+ // Check each format string to make sure it does not contain any
+ // tokens that need to be expanded.
+ each(tokens, function (baseToken) {
+ // strip escaped sequences
+ var format = data[baseToken].replace(/(\[[^\]]*\])/g, '');
+ assert.equal(false, !!~format.indexOf(srchToken),
+ 'contains ' + srchToken + ' in ' + baseToken);
+ });
+ });
+ });
+
+ test('month parsing correctness', function (assert) {
+ var i, m;
+
+ if (locale === 'tr') {
+ // I can't fix it :(
+ expect(0);
+ return;
+ }
+ function tester(format) {
+ var r;
+ r = moment(m.format(format), format);
+ assert.equal(r.month(), m.month(), 'month ' + i + ' fmt ' + format);
+ r = moment(m.format(format).toLocaleUpperCase(), format);
+ assert.equal(r.month(), m.month(), 'month ' + i + ' fmt ' + format + ' upper');
+ r = moment(m.format(format).toLocaleLowerCase(), format);
+ assert.equal(r.month(), m.month(), 'month ' + i + ' fmt ' + format + ' lower');
+
+ r = moment(m.format(format), format, true);
+ assert.equal(r.month(), m.month(), 'month ' + i + ' fmt ' + format + ' strict');
+ r = moment(m.format(format).toLocaleUpperCase(), format, true);
+ assert.equal(r.month(), m.month(), 'month ' + i + ' fmt ' + format + ' upper strict');
+ r = moment(m.format(format).toLocaleLowerCase(), format, true);
+ assert.equal(r.month(), m.month(), 'month ' + i + ' fmt ' + format + ' lower strict');
+ }
+
+ for (i = 0; i < 12; ++i) {
+ m = moment([2015, i, 15, 18]);
+ tester('MMM');
+ tester('MMM.');
+ tester('MMMM');
+ tester('MMMM.');
+ }
+ });
+
+ test('weekday parsing correctness', function (assert) {
+ var i, m;
+
+ if (locale === 'tr' || locale === 'az') {
+ // There is a lower-case letter (ı), that converted to upper then
+ // lower changes to i
+ expect(0);
+ return;
+ }
+ function tester(format) {
+ var r, baseMsg = 'weekday ' + m.weekday() + ' fmt ' + format;
+ r = moment(m.format(format), format);
+ assert.equal(r.weekday(), m.weekday(), baseMsg);
+ r = moment(m.format(format).toLocaleUpperCase(), format);
+ assert.equal(r.weekday(), m.weekday(), baseMsg + ' upper');
+ r = moment(m.format(format).toLocaleLowerCase(), format);
+ assert.equal(r.weekday(), m.weekday(), baseMsg + ' lower');
+
+ r = moment(m.format(format), format, true);
+ assert.equal(r.weekday(), m.weekday(), baseMsg + ' strict');
+ r = moment(m.format(format).toLocaleUpperCase(), format, true);
+ assert.equal(r.weekday(), m.weekday(), baseMsg + ' upper strict');
+ r = moment(m.format(format).toLocaleLowerCase(), format, true);
+ assert.equal(r.weekday(), m.weekday(), baseMsg + ' lower strict');
+ }
+
+ for (i = 0; i < 7; ++i) {
+ m = moment.utc([2015, i, 15, 18]);
+ tester('dd');
+ tester('ddd');
+ tester('dddd');
+ }
+ });
+ }
+
+ function setupDeprecationHandler(test, moment, scope) {
+ test._expectedDeprecations = null;
+ test._observedDeprecations = null;
+ test._oldSupress = moment.suppressDeprecationWarnings;
+ moment.suppressDeprecationWarnings = true;
+ test.expectedDeprecations = function () {
+ test._expectedDeprecations = arguments;
+ test._observedDeprecations = [];
+ };
+ moment.deprecationHandler = function (name, msg) {
+ var deprecationId = matchedDeprecation(name, msg, test._expectedDeprecations);
+ if (deprecationId === -1) {
+ throw new Error('Unexpected deprecation thrown name=' +
+ name + ' msg=' + msg);
+ }
+ test._observedDeprecations[deprecationId] = 1;
+ };
+ }
+
+ function teardownDeprecationHandler(test, moment, scope) {
+ moment.suppressDeprecationWarnings = test._oldSupress;
+
+ if (test._expectedDeprecations != null) {
+ var missedDeprecations = [];
+ each(test._expectedDeprecations, function (deprecationPattern, id) {
+ if (test._observedDeprecations[id] !== 1) {
+ missedDeprecations.push(deprecationPattern);
+ }
+ });
+ if (missedDeprecations.length !== 0) {
+ throw new Error('Expected deprecation warnings did not happen: ' +
+ missedDeprecations.join(' '));
+ }
+ }
+ }
+
+ function matchedDeprecation(name, msg, deprecations) {
+ if (deprecations == null) {
+ return -1;
+ }
+ for (var i = 0; i < deprecations.length; ++i) {
+ if (name != null && name === deprecations[i]) {
+ return i;
+ }
+ if (msg != null && msg.substring(0, deprecations[i].length) === deprecations[i]) {
+ return i;
+ }
+ }
+ return -1;
+ }
/*global QUnit:false*/
@@ -25570,11 +36069,13 @@
moment.createFromInputFallback = function (config) {
throw new Error('input not handled by moment: ' + config._i);
};
+ setupDeprecationHandler(test, moment, 'core');
if (lifecycle && lifecycle.setup) {
lifecycle.setup();
}
},
teardown : function () {
+ teardownDeprecationHandler(test, moment, 'core');
if (lifecycle && lifecycle.teardown) {
lifecycle.teardown();
}
@@ -25589,17 +36090,20 @@
moment.createFromInputFallback = function (config) {
throw new Error('input not handled by moment: ' + config._i);
};
+ setupDeprecationHandler(test, moment, 'locale');
if (lifecycle && lifecycle.setup) {
lifecycle.setup();
}
},
teardown : function () {
moment.locale('en');
+ teardownDeprecationHandler(test, moment, 'locale');
if (lifecycle && lifecycle.teardown) {
lifecycle.teardown();
}
}
});
+ defineCommonLocaleTests(name, -1, -1);
}
localeModule('pt-br');
@@ -25702,7 +36206,7 @@
});
test('format week', function (assert) {
- 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('_'), i;
+ 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('_'), i;
for (i = 0; i < expected.length; i++) {
assert.equal(moment([2011, 0, 2 + i]).format('dddd ddd'), expected[i], expected[i]);
}
@@ -25751,14 +36255,14 @@
});
test('calendar day', function (assert) {
- var a = moment().hours(2).minutes(0).seconds(0);
-
- assert.equal(moment(a).calendar(), 'Hoje às 02:00', 'today at the same time');
- assert.equal(moment(a).add({m: 25}).calendar(), 'Hoje às 02:25', 'Now plus 25 min');
- assert.equal(moment(a).add({h: 1}).calendar(), 'Hoje às 03:00', 'Now plus 1 hour');
- assert.equal(moment(a).add({d: 1}).calendar(), 'Amanhã às 02:00', 'tomorrow at the same time');
- assert.equal(moment(a).subtract({h: 1}).calendar(), 'Hoje às 01:00', 'Now minus 1 hour');
- assert.equal(moment(a).subtract({d: 1}).calendar(), 'Ontem às 02:00', 'yesterday at the same time');
+ var a = moment().hours(12).minutes(0).seconds(0);
+
+ assert.equal(moment(a).calendar(), 'Hoje às 12:00', 'today at the same time');
+ assert.equal(moment(a).add({m: 25}).calendar(), 'Hoje às 12:25', 'Now plus 25 min');
+ assert.equal(moment(a).add({h: 1}).calendar(), 'Hoje às 13:00', 'Now plus 1 hour');
+ assert.equal(moment(a).add({d: 1}).calendar(), 'Amanhã às 12:00', 'tomorrow at the same time');
+ assert.equal(moment(a).subtract({h: 1}).calendar(), 'Hoje às 11:00', 'Now minus 1 hour');
+ assert.equal(moment(a).subtract({d: 1}).calendar(), 'Ontem às 12:00', 'yesterday at the same time');
});
test('calendar next week', function (assert) {
@@ -25799,67 +36303,6 @@
assert.equal(weeksFromNow.calendar(), weeksFromNow.format('L'), 'in 2 weeks');
});
- test('weeks year starting sunday', function (assert) {
- assert.equal(moment([2012, 0, 1]).week(), 1, 'Jan 1 2012 should be week 1');
- assert.equal(moment([2012, 0, 7]).week(), 1, 'Jan 7 2012 should be week 1');
- assert.equal(moment([2012, 0, 8]).week(), 2, 'Jan 8 2012 should be week 2');
- assert.equal(moment([2012, 0, 14]).week(), 2, 'Jan 14 2012 should be week 2');
- assert.equal(moment([2012, 0, 15]).week(), 3, 'Jan 15 2012 should be week 3');
- });
-
- test('weeks year starting monday', function (assert) {
- assert.equal(moment([2006, 11, 31]).week(), 1, 'Dec 31 2006 should be week 1');
- assert.equal(moment([2007, 0, 1]).week(), 1, 'Jan 1 2007 should be week 1');
- assert.equal(moment([2007, 0, 6]).week(), 1, 'Jan 6 2007 should be week 1');
- assert.equal(moment([2007, 0, 7]).week(), 2, 'Jan 7 2007 should be week 2');
- assert.equal(moment([2007, 0, 13]).week(), 2, 'Jan 13 2007 should be week 2');
- assert.equal(moment([2007, 0, 14]).week(), 3, 'Jan 14 2007 should be week 3');
- });
-
- test('weeks year starting tuesday', function (assert) {
- assert.equal(moment([2007, 11, 29]).week(), 52, 'Dec 29 2007 should be week 52');
- assert.equal(moment([2008, 0, 1]).week(), 1, 'Jan 1 2008 should be week 1');
- assert.equal(moment([2008, 0, 5]).week(), 1, 'Jan 5 2008 should be week 1');
- assert.equal(moment([2008, 0, 6]).week(), 2, 'Jan 6 2008 should be week 2');
- assert.equal(moment([2008, 0, 12]).week(), 2, 'Jan 12 2008 should be week 2');
- assert.equal(moment([2008, 0, 13]).week(), 3, 'Jan 13 2008 should be week 3');
- });
-
- test('weeks year starting wednesday', function (assert) {
- assert.equal(moment([2002, 11, 29]).week(), 1, 'Dec 29 2002 should be week 1');
- assert.equal(moment([2003, 0, 1]).week(), 1, 'Jan 1 2003 should be week 1');
- assert.equal(moment([2003, 0, 4]).week(), 1, 'Jan 4 2003 should be week 1');
- assert.equal(moment([2003, 0, 5]).week(), 2, 'Jan 5 2003 should be week 2');
- assert.equal(moment([2003, 0, 11]).week(), 2, 'Jan 11 2003 should be week 2');
- assert.equal(moment([2003, 0, 12]).week(), 3, 'Jan 12 2003 should be week 3');
- });
-
- test('weeks year starting thursday', function (assert) {
- assert.equal(moment([2008, 11, 28]).week(), 1, 'Dec 28 2008 should be week 1');
- assert.equal(moment([2009, 0, 1]).week(), 1, 'Jan 1 2009 should be week 1');
- assert.equal(moment([2009, 0, 3]).week(), 1, 'Jan 3 2009 should be week 1');
- assert.equal(moment([2009, 0, 4]).week(), 2, 'Jan 4 2009 should be week 2');
- assert.equal(moment([2009, 0, 10]).week(), 2, 'Jan 10 2009 should be week 2');
- assert.equal(moment([2009, 0, 11]).week(), 3, 'Jan 11 2009 should be week 3');
- });
-
- test('weeks year starting friday', function (assert) {
- assert.equal(moment([2009, 11, 27]).week(), 1, 'Dec 27 2009 should be week 1');
- assert.equal(moment([2010, 0, 1]).week(), 1, 'Jan 1 2010 should be week 1');
- assert.equal(moment([2010, 0, 2]).week(), 1, 'Jan 2 2010 should be week 1');
- assert.equal(moment([2010, 0, 3]).week(), 2, 'Jan 3 2010 should be week 2');
- assert.equal(moment([2010, 0, 9]).week(), 2, 'Jan 9 2010 should be week 2');
- assert.equal(moment([2010, 0, 10]).week(), 3, 'Jan 10 2010 should be week 3');
- });
-
- test('weeks year starting saturday', function (assert) {
- assert.equal(moment([2010, 11, 26]).week(), 1, 'Dec 26 2010 should be week 1');
- assert.equal(moment([2011, 0, 1]).week(), 1, 'Jan 1 2011 should be week 1');
- assert.equal(moment([2011, 0, 2]).week(), 2, 'Jan 2 2011 should be week 2');
- assert.equal(moment([2011, 0, 8]).week(), 2, 'Jan 8 2011 should be week 2');
- assert.equal(moment([2011, 0, 9]).week(), 3, 'Jan 9 2011 should be week 3');
- });
-
test('weeks year starting sunday format', function (assert) {
assert.equal(moment([2012, 0, 1]).format('w ww wo'), '1 01 1º', 'Jan 1 2012 should be week 1');
assert.equal(moment([2012, 0, 7]).format('w ww wo'), '1 01 1º', 'Jan 7 2012 should be week 1');
@@ -25868,42 +36311,6 @@
assert.equal(moment([2012, 0, 15]).format('w ww wo'), '3 03 3º', 'Jan 15 2012 should be week 3');
});
- test('lenient ordinal parsing', function (assert) {
- var i, ordinalStr, testMoment;
- for (i = 1; i <= 31; ++i) {
- ordinalStr = moment([2014, 0, i]).format('YYYY MM Do');
- testMoment = moment(ordinalStr, 'YYYY MM Do');
- assert.equal(testMoment.year(), 2014,
- 'lenient ordinal parsing ' + i + ' year check');
- assert.equal(testMoment.month(), 0,
- 'lenient ordinal parsing ' + i + ' month check');
- assert.equal(testMoment.date(), i,
- 'lenient ordinal parsing ' + i + ' date check');
- }
- });
-
- test('lenient ordinal parsing of number', function (assert) {
- var i, testMoment;
- for (i = 1; i <= 31; ++i) {
- testMoment = moment('2014 01 ' + i, 'YYYY MM Do');
- assert.equal(testMoment.year(), 2014,
- 'lenient ordinal parsing of number ' + i + ' year check');
- assert.equal(testMoment.month(), 0,
- 'lenient ordinal parsing of number ' + i + ' month check');
- assert.equal(testMoment.date(), i,
- 'lenient ordinal parsing of number ' + i + ' date check');
- }
- });
-
- test('strict ordinal parsing', function (assert) {
- var i, ordinalStr, testMoment;
- for (i = 1; i <= 31; ++i) {
- ordinalStr = moment([2014, 0, i]).format('YYYY MM Do');
- testMoment = moment(ordinalStr, 'YYYY MM Do', true);
- assert.ok(testMoment.isValid(), 'strict ordinal parsing ' + i);
- }
- });
-
}));
;(function (global, factory) {
@@ -25912,6 +36319,224 @@
typeof define === 'function' && define.amd ? define(['../../moment'], factory) :
factory(global.moment)
}(this, function (moment) { 'use strict';
+
+ function each(array, callback) {
+ var i;
+ for (i = 0; i < array.length; i++) {
+ callback(array[i], i, array);
+ }
+ }
+
+ function objectKeys(obj) {
+ if (Object.keys) {
+ return Object.keys(obj);
+ } else {
+ // IE8
+ var res = [], i;
+ for (i in obj) {
+ if (obj.hasOwnProperty(i)) {
+ res.push(i);
+ }
+ }
+ return res;
+ }
+ }
+
+ // Pick the first defined of two or three arguments.
+ function defaults(a, b, c) {
+ if (a != null) {
+ return a;
+ }
+ if (b != null) {
+ return b;
+ }
+ return c;
+ }
+
+ function defineCommonLocaleTests(locale, options) {
+ test('lenient ordinal parsing', function (assert) {
+ var i, ordinalStr, testMoment;
+ for (i = 1; i <= 31; ++i) {
+ ordinalStr = moment([2014, 0, i]).format('YYYY MM Do');
+ testMoment = moment(ordinalStr, 'YYYY MM Do');
+ assert.equal(testMoment.year(), 2014,
+ 'lenient ordinal parsing ' + i + ' year check');
+ assert.equal(testMoment.month(), 0,
+ 'lenient ordinal parsing ' + i + ' month check');
+ assert.equal(testMoment.date(), i,
+ 'lenient ordinal parsing ' + i + ' date check');
+ }
+ });
+
+ test('lenient ordinal parsing of number', function (assert) {
+ var i, testMoment;
+ for (i = 1; i <= 31; ++i) {
+ testMoment = moment('2014 01 ' + i, 'YYYY MM Do');
+ assert.equal(testMoment.year(), 2014,
+ 'lenient ordinal parsing of number ' + i + ' year check');
+ assert.equal(testMoment.month(), 0,
+ 'lenient ordinal parsing of number ' + i + ' month check');
+ assert.equal(testMoment.date(), i,
+ 'lenient ordinal parsing of number ' + i + ' date check');
+ }
+ });
+
+ test('strict ordinal parsing', function (assert) {
+ var i, ordinalStr, testMoment;
+ for (i = 1; i <= 31; ++i) {
+ ordinalStr = moment([2014, 0, i]).format('YYYY MM Do');
+ testMoment = moment(ordinalStr, 'YYYY MM Do', true);
+ assert.ok(testMoment.isValid(), 'strict ordinal parsing ' + i);
+ }
+ });
+
+ test('meridiem invariant', function (assert) {
+ var h, m, t1, t2;
+ for (h = 0; h < 24; ++h) {
+ for (m = 0; m < 60; m += 15) {
+ t1 = moment.utc([2000, 0, 1, h, m]);
+ t2 = moment.utc(t1.format('A h:mm'), 'A h:mm');
+ assert.equal(t2.format('HH:mm'), t1.format('HH:mm'),
+ 'meridiem at ' + t1.format('HH:mm'));
+ }
+ }
+ });
+
+ test('date format correctness', function (assert) {
+ var data, tokens;
+ data = moment.localeData()._longDateFormat;
+ tokens = objectKeys(data);
+ each(tokens, function (srchToken) {
+ // Check each format string to make sure it does not contain any
+ // tokens that need to be expanded.
+ each(tokens, function (baseToken) {
+ // strip escaped sequences
+ var format = data[baseToken].replace(/(\[[^\]]*\])/g, '');
+ assert.equal(false, !!~format.indexOf(srchToken),
+ 'contains ' + srchToken + ' in ' + baseToken);
+ });
+ });
+ });
+
+ test('month parsing correctness', function (assert) {
+ var i, m;
+
+ if (locale === 'tr') {
+ // I can't fix it :(
+ expect(0);
+ return;
+ }
+ function tester(format) {
+ var r;
+ r = moment(m.format(format), format);
+ assert.equal(r.month(), m.month(), 'month ' + i + ' fmt ' + format);
+ r = moment(m.format(format).toLocaleUpperCase(), format);
+ assert.equal(r.month(), m.month(), 'month ' + i + ' fmt ' + format + ' upper');
+ r = moment(m.format(format).toLocaleLowerCase(), format);
+ assert.equal(r.month(), m.month(), 'month ' + i + ' fmt ' + format + ' lower');
+
+ r = moment(m.format(format), format, true);
+ assert.equal(r.month(), m.month(), 'month ' + i + ' fmt ' + format + ' strict');
+ r = moment(m.format(format).toLocaleUpperCase(), format, true);
+ assert.equal(r.month(), m.month(), 'month ' + i + ' fmt ' + format + ' upper strict');
+ r = moment(m.format(format).toLocaleLowerCase(), format, true);
+ assert.equal(r.month(), m.month(), 'month ' + i + ' fmt ' + format + ' lower strict');
+ }
+
+ for (i = 0; i < 12; ++i) {
+ m = moment([2015, i, 15, 18]);
+ tester('MMM');
+ tester('MMM.');
+ tester('MMMM');
+ tester('MMMM.');
+ }
+ });
+
+ test('weekday parsing correctness', function (assert) {
+ var i, m;
+
+ if (locale === 'tr' || locale === 'az') {
+ // There is a lower-case letter (ı), that converted to upper then
+ // lower changes to i
+ expect(0);
+ return;
+ }
+ function tester(format) {
+ var r, baseMsg = 'weekday ' + m.weekday() + ' fmt ' + format;
+ r = moment(m.format(format), format);
+ assert.equal(r.weekday(), m.weekday(), baseMsg);
+ r = moment(m.format(format).toLocaleUpperCase(), format);
+ assert.equal(r.weekday(), m.weekday(), baseMsg + ' upper');
+ r = moment(m.format(format).toLocaleLowerCase(), format);
+ assert.equal(r.weekday(), m.weekday(), baseMsg + ' lower');
+
+ r = moment(m.format(format), format, true);
+ assert.equal(r.weekday(), m.weekday(), baseMsg + ' strict');
+ r = moment(m.format(format).toLocaleUpperCase(), format, true);
+ assert.equal(r.weekday(), m.weekday(), baseMsg + ' upper strict');
+ r = moment(m.format(format).toLocaleLowerCase(), format, true);
+ assert.equal(r.weekday(), m.weekday(), baseMsg + ' lower strict');
+ }
+
+ for (i = 0; i < 7; ++i) {
+ m = moment.utc([2015, i, 15, 18]);
+ tester('dd');
+ tester('ddd');
+ tester('dddd');
+ }
+ });
+ }
+
+ function setupDeprecationHandler(test, moment, scope) {
+ test._expectedDeprecations = null;
+ test._observedDeprecations = null;
+ test._oldSupress = moment.suppressDeprecationWarnings;
+ moment.suppressDeprecationWarnings = true;
+ test.expectedDeprecations = function () {
+ test._expectedDeprecations = arguments;
+ test._observedDeprecations = [];
+ };
+ moment.deprecationHandler = function (name, msg) {
+ var deprecationId = matchedDeprecation(name, msg, test._expectedDeprecations);
+ if (deprecationId === -1) {
+ throw new Error('Unexpected deprecation thrown name=' +
+ name + ' msg=' + msg);
+ }
+ test._observedDeprecations[deprecationId] = 1;
+ };
+ }
+
+ function teardownDeprecationHandler(test, moment, scope) {
+ moment.suppressDeprecationWarnings = test._oldSupress;
+
+ if (test._expectedDeprecations != null) {
+ var missedDeprecations = [];
+ each(test._expectedDeprecations, function (deprecationPattern, id) {
+ if (test._observedDeprecations[id] !== 1) {
+ missedDeprecations.push(deprecationPattern);
+ }
+ });
+ if (missedDeprecations.length !== 0) {
+ throw new Error('Expected deprecation warnings did not happen: ' +
+ missedDeprecations.join(' '));
+ }
+ }
+ }
+
+ function matchedDeprecation(name, msg, deprecations) {
+ if (deprecations == null) {
+ return -1;
+ }
+ for (var i = 0; i < deprecations.length; ++i) {
+ if (name != null && name === deprecations[i]) {
+ return i;
+ }
+ if (msg != null && msg.substring(0, deprecations[i].length) === deprecations[i]) {
+ return i;
+ }
+ }
+ return -1;
+ }
/*global QUnit:false*/
@@ -25926,11 +36551,13 @@
moment.createFromInputFallback = function (config) {
throw new Error('input not handled by moment: ' + config._i);
};
+ setupDeprecationHandler(test, moment, 'core');
if (lifecycle && lifecycle.setup) {
lifecycle.setup();
}
},
teardown : function () {
+ teardownDeprecationHandler(test, moment, 'core');
if (lifecycle && lifecycle.teardown) {
lifecycle.teardown();
}
@@ -25945,17 +36572,20 @@
moment.createFromInputFallback = function (config) {
throw new Error('input not handled by moment: ' + config._i);
};
+ setupDeprecationHandler(test, moment, 'locale');
if (lifecycle && lifecycle.setup) {
lifecycle.setup();
}
},
teardown : function () {
moment.locale('en');
+ teardownDeprecationHandler(test, moment, 'locale');
if (lifecycle && lifecycle.teardown) {
lifecycle.teardown();
}
}
});
+ defineCommonLocaleTests(name, -1, -1);
}
localeModule('pt');
@@ -26105,14 +36735,14 @@
});
test('calendar day', function (assert) {
- var a = moment().hours(2).minutes(0).seconds(0);
-
- assert.equal(moment(a).calendar(), 'Hoje às 02:00', 'today at the same time');
- assert.equal(moment(a).add({m: 25}).calendar(), 'Hoje às 02:25', 'Now plus 25 min');
- assert.equal(moment(a).add({h: 1}).calendar(), 'Hoje às 03:00', 'Now plus 1 hour');
- assert.equal(moment(a).add({d: 1}).calendar(), 'Amanhã às 02:00', 'tomorrow at the same time');
- assert.equal(moment(a).subtract({h: 1}).calendar(), 'Hoje às 01:00', 'Now minus 1 hour');
- assert.equal(moment(a).subtract({d: 1}).calendar(), 'Ontem às 02:00', 'yesterday at the same time');
+ var a = moment().hours(12).minutes(0).seconds(0);
+
+ assert.equal(moment(a).calendar(), 'Hoje às 12:00', 'today at the same time');
+ assert.equal(moment(a).add({m: 25}).calendar(), 'Hoje às 12:25', 'Now plus 25 min');
+ assert.equal(moment(a).add({h: 1}).calendar(), 'Hoje às 13:00', 'Now plus 1 hour');
+ assert.equal(moment(a).add({d: 1}).calendar(), 'Amanhã às 12:00', 'tomorrow at the same time');
+ assert.equal(moment(a).subtract({h: 1}).calendar(), 'Hoje às 11:00', 'Now minus 1 hour');
+ assert.equal(moment(a).subtract({d: 1}).calendar(), 'Ontem às 12:00', 'yesterday at the same time');
});
test('calendar next week', function (assert) {
@@ -26153,67 +36783,6 @@
assert.equal(weeksFromNow.calendar(), weeksFromNow.format('L'), 'in 2 weeks');
});
- test('weeks year starting sunday', function (assert) {
- assert.equal(moment([2012, 0, 1]).week(), 52, 'Jan 1 2012 should be week 52');
- assert.equal(moment([2012, 0, 2]).week(), 1, 'Jan 2 2012 should be week 1');
- assert.equal(moment([2012, 0, 8]).week(), 1, 'Jan 8 2012 should be week 1');
- assert.equal(moment([2012, 0, 9]).week(), 2, 'Jan 9 2012 should be week 2');
- assert.equal(moment([2012, 0, 15]).week(), 2, 'Jan 15 2012 should be week 2');
- });
-
- test('weeks year starting monday', function (assert) {
- assert.equal(moment([2007, 0, 1]).week(), 1, 'Jan 1 2007 should be week 1');
- assert.equal(moment([2007, 0, 7]).week(), 1, 'Jan 7 2007 should be week 1');
- assert.equal(moment([2007, 0, 8]).week(), 2, 'Jan 8 2007 should be week 2');
- assert.equal(moment([2007, 0, 14]).week(), 2, 'Jan 14 2007 should be week 2');
- assert.equal(moment([2007, 0, 15]).week(), 3, 'Jan 15 2007 should be week 3');
- });
-
- test('weeks year starting tuesday', function (assert) {
- assert.equal(moment([2007, 11, 31]).week(), 1, 'Dec 31 2007 should be week 1');
- assert.equal(moment([2008, 0, 1]).week(), 1, 'Jan 1 2008 should be week 1');
- assert.equal(moment([2008, 0, 6]).week(), 1, 'Jan 6 2008 should be week 1');
- assert.equal(moment([2008, 0, 7]).week(), 2, 'Jan 7 2008 should be week 2');
- assert.equal(moment([2008, 0, 13]).week(), 2, 'Jan 13 2008 should be week 2');
- assert.equal(moment([2008, 0, 14]).week(), 3, 'Jan 14 2008 should be week 3');
- });
-
- test('weeks year starting wednesday', function (assert) {
- assert.equal(moment([2002, 11, 30]).week(), 1, 'Dec 30 2002 should be week 1');
- assert.equal(moment([2003, 0, 1]).week(), 1, 'Jan 1 2003 should be week 1');
- assert.equal(moment([2003, 0, 5]).week(), 1, 'Jan 5 2003 should be week 1');
- assert.equal(moment([2003, 0, 6]).week(), 2, 'Jan 6 2003 should be week 2');
- assert.equal(moment([2003, 0, 12]).week(), 2, 'Jan 12 2003 should be week 2');
- assert.equal(moment([2003, 0, 13]).week(), 3, 'Jan 13 2003 should be week 3');
- });
-
- test('weeks year starting thursday', function (assert) {
- assert.equal(moment([2008, 11, 29]).week(), 1, 'Dec 29 2008 should be week 1');
- assert.equal(moment([2009, 0, 1]).week(), 1, 'Jan 1 2009 should be week 1');
- assert.equal(moment([2009, 0, 4]).week(), 1, 'Jan 4 2009 should be week 1');
- assert.equal(moment([2009, 0, 5]).week(), 2, 'Jan 5 2009 should be week 2');
- assert.equal(moment([2009, 0, 11]).week(), 2, 'Jan 11 2009 should be week 2');
- assert.equal(moment([2009, 0, 13]).week(), 3, 'Jan 12 2009 should be week 3');
- });
-
- test('weeks year starting friday', function (assert) {
- assert.equal(moment([2009, 11, 28]).week(), 53, 'Dec 28 2009 should be week 53');
- assert.equal(moment([2010, 0, 1]).week(), 53, 'Jan 1 2010 should be week 53');
- assert.equal(moment([2010, 0, 3]).week(), 53, 'Jan 3 2010 should be week 53');
- assert.equal(moment([2010, 0, 4]).week(), 1, 'Jan 4 2010 should be week 1');
- assert.equal(moment([2010, 0, 10]).week(), 1, 'Jan 10 2010 should be week 1');
- assert.equal(moment([2010, 0, 11]).week(), 2, 'Jan 11 2010 should be week 2');
- });
-
- test('weeks year starting saturday', function (assert) {
- assert.equal(moment([2010, 11, 27]).week(), 52, 'Dec 27 2010 should be week 52');
- assert.equal(moment([2011, 0, 1]).week(), 52, 'Jan 1 2011 should be week 52');
- assert.equal(moment([2011, 0, 2]).week(), 52, 'Jan 2 2011 should be week 52');
- assert.equal(moment([2011, 0, 3]).week(), 1, 'Jan 3 2011 should be week 1');
- assert.equal(moment([2011, 0, 9]).week(), 1, 'Jan 9 2011 should be week 1');
- assert.equal(moment([2011, 0, 10]).week(), 2, 'Jan 10 2011 should be week 2');
- });
-
test('weeks year starting sunday formatted', function (assert) {
assert.equal(moment([2012, 0, 1]).format('w ww wo'), '52 52 52º', 'Jan 1 2012 should be week 52');
assert.equal(moment([2012, 0, 2]).format('w ww wo'), '1 01 1º', 'Jan 2 2012 should be week 1');
@@ -26222,42 +36791,6 @@
assert.equal(moment([2012, 0, 15]).format('w ww wo'), '2 02 2º', 'Jan 15 2012 should be week 2');
});
- test('lenient ordinal parsing', function (assert) {
- var i, ordinalStr, testMoment;
- for (i = 1; i <= 31; ++i) {
- ordinalStr = moment([2014, 0, i]).format('YYYY MM Do');
- testMoment = moment(ordinalStr, 'YYYY MM Do');
- assert.equal(testMoment.year(), 2014,
- 'lenient ordinal parsing ' + i + ' year check');
- assert.equal(testMoment.month(), 0,
- 'lenient ordinal parsing ' + i + ' month check');
- assert.equal(testMoment.date(), i,
- 'lenient ordinal parsing ' + i + ' date check');
- }
- });
-
- test('lenient ordinal parsing of number', function (assert) {
- var i, testMoment;
- for (i = 1; i <= 31; ++i) {
- testMoment = moment('2014 01 ' + i, 'YYYY MM Do');
- assert.equal(testMoment.year(), 2014,
- 'lenient ordinal parsing of number ' + i + ' year check');
- assert.equal(testMoment.month(), 0,
- 'lenient ordinal parsing of number ' + i + ' month check');
- assert.equal(testMoment.date(), i,
- 'lenient ordinal parsing of number ' + i + ' date check');
- }
- });
-
- test('strict ordinal parsing', function (assert) {
- var i, ordinalStr, testMoment;
- for (i = 1; i <= 31; ++i) {
- ordinalStr = moment([2014, 0, i]).format('YYYY MM Do');
- testMoment = moment(ordinalStr, 'YYYY MM Do', true);
- assert.ok(testMoment.isValid(), 'strict ordinal parsing ' + i);
- }
- });
-
}));
;(function (global, factory) {
@@ -26266,6 +36799,224 @@
typeof define === 'function' && define.amd ? define(['../../moment'], factory) :
factory(global.moment)
}(this, function (moment) { 'use strict';
+
+ function each(array, callback) {
+ var i;
+ for (i = 0; i < array.length; i++) {
+ callback(array[i], i, array);
+ }
+ }
+
+ function objectKeys(obj) {
+ if (Object.keys) {
+ return Object.keys(obj);
+ } else {
+ // IE8
+ var res = [], i;
+ for (i in obj) {
+ if (obj.hasOwnProperty(i)) {
+ res.push(i);
+ }
+ }
+ return res;
+ }
+ }
+
+ // Pick the first defined of two or three arguments.
+ function defaults(a, b, c) {
+ if (a != null) {
+ return a;
+ }
+ if (b != null) {
+ return b;
+ }
+ return c;
+ }
+
+ function defineCommonLocaleTests(locale, options) {
+ test('lenient ordinal parsing', function (assert) {
+ var i, ordinalStr, testMoment;
+ for (i = 1; i <= 31; ++i) {
+ ordinalStr = moment([2014, 0, i]).format('YYYY MM Do');
+ testMoment = moment(ordinalStr, 'YYYY MM Do');
+ assert.equal(testMoment.year(), 2014,
+ 'lenient ordinal parsing ' + i + ' year check');
+ assert.equal(testMoment.month(), 0,
+ 'lenient ordinal parsing ' + i + ' month check');
+ assert.equal(testMoment.date(), i,
+ 'lenient ordinal parsing ' + i + ' date check');
+ }
+ });
+
+ test('lenient ordinal parsing of number', function (assert) {
+ var i, testMoment;
+ for (i = 1; i <= 31; ++i) {
+ testMoment = moment('2014 01 ' + i, 'YYYY MM Do');
+ assert.equal(testMoment.year(), 2014,
+ 'lenient ordinal parsing of number ' + i + ' year check');
+ assert.equal(testMoment.month(), 0,
+ 'lenient ordinal parsing of number ' + i + ' month check');
+ assert.equal(testMoment.date(), i,
+ 'lenient ordinal parsing of number ' + i + ' date check');
+ }
+ });
+
+ test('strict ordinal parsing', function (assert) {
+ var i, ordinalStr, testMoment;
+ for (i = 1; i <= 31; ++i) {
+ ordinalStr = moment([2014, 0, i]).format('YYYY MM Do');
+ testMoment = moment(ordinalStr, 'YYYY MM Do', true);
+ assert.ok(testMoment.isValid(), 'strict ordinal parsing ' + i);
+ }
+ });
+
+ test('meridiem invariant', function (assert) {
+ var h, m, t1, t2;
+ for (h = 0; h < 24; ++h) {
+ for (m = 0; m < 60; m += 15) {
+ t1 = moment.utc([2000, 0, 1, h, m]);
+ t2 = moment.utc(t1.format('A h:mm'), 'A h:mm');
+ assert.equal(t2.format('HH:mm'), t1.format('HH:mm'),
+ 'meridiem at ' + t1.format('HH:mm'));
+ }
+ }
+ });
+
+ test('date format correctness', function (assert) {
+ var data, tokens;
+ data = moment.localeData()._longDateFormat;
+ tokens = objectKeys(data);
+ each(tokens, function (srchToken) {
+ // Check each format string to make sure it does not contain any
+ // tokens that need to be expanded.
+ each(tokens, function (baseToken) {
+ // strip escaped sequences
+ var format = data[baseToken].replace(/(\[[^\]]*\])/g, '');
+ assert.equal(false, !!~format.indexOf(srchToken),
+ 'contains ' + srchToken + ' in ' + baseToken);
+ });
+ });
+ });
+
+ test('month parsing correctness', function (assert) {
+ var i, m;
+
+ if (locale === 'tr') {
+ // I can't fix it :(
+ expect(0);
+ return;
+ }
+ function tester(format) {
+ var r;
+ r = moment(m.format(format), format);
+ assert.equal(r.month(), m.month(), 'month ' + i + ' fmt ' + format);
+ r = moment(m.format(format).toLocaleUpperCase(), format);
+ assert.equal(r.month(), m.month(), 'month ' + i + ' fmt ' + format + ' upper');
+ r = moment(m.format(format).toLocaleLowerCase(), format);
+ assert.equal(r.month(), m.month(), 'month ' + i + ' fmt ' + format + ' lower');
+
+ r = moment(m.format(format), format, true);
+ assert.equal(r.month(), m.month(), 'month ' + i + ' fmt ' + format + ' strict');
+ r = moment(m.format(format).toLocaleUpperCase(), format, true);
+ assert.equal(r.month(), m.month(), 'month ' + i + ' fmt ' + format + ' upper strict');
+ r = moment(m.format(format).toLocaleLowerCase(), format, true);
+ assert.equal(r.month(), m.month(), 'month ' + i + ' fmt ' + format + ' lower strict');
+ }
+
+ for (i = 0; i < 12; ++i) {
+ m = moment([2015, i, 15, 18]);
+ tester('MMM');
+ tester('MMM.');
+ tester('MMMM');
+ tester('MMMM.');
+ }
+ });
+
+ test('weekday parsing correctness', function (assert) {
+ var i, m;
+
+ if (locale === 'tr' || locale === 'az') {
+ // There is a lower-case letter (ı), that converted to upper then
+ // lower changes to i
+ expect(0);
+ return;
+ }
+ function tester(format) {
+ var r, baseMsg = 'weekday ' + m.weekday() + ' fmt ' + format;
+ r = moment(m.format(format), format);
+ assert.equal(r.weekday(), m.weekday(), baseMsg);
+ r = moment(m.format(format).toLocaleUpperCase(), format);
+ assert.equal(r.weekday(), m.weekday(), baseMsg + ' upper');
+ r = moment(m.format(format).toLocaleLowerCase(), format);
+ assert.equal(r.weekday(), m.weekday(), baseMsg + ' lower');
+
+ r = moment(m.format(format), format, true);
+ assert.equal(r.weekday(), m.weekday(), baseMsg + ' strict');
+ r = moment(m.format(format).toLocaleUpperCase(), format, true);
+ assert.equal(r.weekday(), m.weekday(), baseMsg + ' upper strict');
+ r = moment(m.format(format).toLocaleLowerCase(), format, true);
+ assert.equal(r.weekday(), m.weekday(), baseMsg + ' lower strict');
+ }
+
+ for (i = 0; i < 7; ++i) {
+ m = moment.utc([2015, i, 15, 18]);
+ tester('dd');
+ tester('ddd');
+ tester('dddd');
+ }
+ });
+ }
+
+ function setupDeprecationHandler(test, moment, scope) {
+ test._expectedDeprecations = null;
+ test._observedDeprecations = null;
+ test._oldSupress = moment.suppressDeprecationWarnings;
+ moment.suppressDeprecationWarnings = true;
+ test.expectedDeprecations = function () {
+ test._expectedDeprecations = arguments;
+ test._observedDeprecations = [];
+ };
+ moment.deprecationHandler = function (name, msg) {
+ var deprecationId = matchedDeprecation(name, msg, test._expectedDeprecations);
+ if (deprecationId === -1) {
+ throw new Error('Unexpected deprecation thrown name=' +
+ name + ' msg=' + msg);
+ }
+ test._observedDeprecations[deprecationId] = 1;
+ };
+ }
+
+ function teardownDeprecationHandler(test, moment, scope) {
+ moment.suppressDeprecationWarnings = test._oldSupress;
+
+ if (test._expectedDeprecations != null) {
+ var missedDeprecations = [];
+ each(test._expectedDeprecations, function (deprecationPattern, id) {
+ if (test._observedDeprecations[id] !== 1) {
+ missedDeprecations.push(deprecationPattern);
+ }
+ });
+ if (missedDeprecations.length !== 0) {
+ throw new Error('Expected deprecation warnings did not happen: ' +
+ missedDeprecations.join(' '));
+ }
+ }
+ }
+
+ function matchedDeprecation(name, msg, deprecations) {
+ if (deprecations == null) {
+ return -1;
+ }
+ for (var i = 0; i < deprecations.length; ++i) {
+ if (name != null && name === deprecations[i]) {
+ return i;
+ }
+ if (msg != null && msg.substring(0, deprecations[i].length) === deprecations[i]) {
+ return i;
+ }
+ }
+ return -1;
+ }
/*global QUnit:false*/
@@ -26280,11 +37031,13 @@
moment.createFromInputFallback = function (config) {
throw new Error('input not handled by moment: ' + config._i);
};
+ setupDeprecationHandler(test, moment, 'core');
if (lifecycle && lifecycle.setup) {
lifecycle.setup();
}
},
teardown : function () {
+ teardownDeprecationHandler(test, moment, 'core');
if (lifecycle && lifecycle.teardown) {
lifecycle.teardown();
}
@@ -26299,17 +37052,20 @@
moment.createFromInputFallback = function (config) {
throw new Error('input not handled by moment: ' + config._i);
};
+ setupDeprecationHandler(test, moment, 'locale');
if (lifecycle && lifecycle.setup) {
lifecycle.setup();
}
},
teardown : function () {
moment.locale('en');
+ teardownDeprecationHandler(test, moment, 'locale');
if (lifecycle && lifecycle.teardown) {
lifecycle.teardown();
}
}
});
+ defineCommonLocaleTests(name, -1, -1);
}
localeModule('ro');
@@ -26471,14 +37227,14 @@
});
test('calendar day', function (assert) {
- var a = moment().hours(2).minutes(0).seconds(0);
-
- assert.equal(moment(a).calendar(), 'azi la 2:00', 'today at the same time');
- assert.equal(moment(a).add({m: 25}).calendar(), 'azi la 2:25', 'Now plus 25 min');
- assert.equal(moment(a).add({h: 1}).calendar(), 'azi la 3:00', 'Now plus 1 hour');
- assert.equal(moment(a).add({d: 1}).calendar(), 'mâine la 2:00', 'tomorrow at the same time');
- assert.equal(moment(a).subtract({h: 1}).calendar(), 'azi la 1:00', 'Now minus 1 hour');
- assert.equal(moment(a).subtract({d: 1}).calendar(), 'ieri la 2:00', 'yesterday at the same time');
+ var a = moment().hours(12).minutes(0).seconds(0);
+
+ assert.equal(moment(a).calendar(), 'azi la 12:00', 'today at the same time');
+ assert.equal(moment(a).add({m: 25}).calendar(), 'azi la 12:25', 'Now plus 25 min');
+ assert.equal(moment(a).add({h: 1}).calendar(), 'azi la 13:00', 'Now plus 1 hour');
+ assert.equal(moment(a).add({d: 1}).calendar(), 'mâine la 12:00', 'tomorrow at the same time');
+ assert.equal(moment(a).subtract({h: 1}).calendar(), 'azi la 11:00', 'Now minus 1 hour');
+ assert.equal(moment(a).subtract({d: 1}).calendar(), 'ieri la 12:00', 'yesterday at the same time');
});
test('calendar next week', function (assert) {
@@ -26519,67 +37275,6 @@
assert.equal(weeksFromNow.calendar(), weeksFromNow.format('L'), 'in 2 weeks');
});
- test('weeks year starting sunday', function (assert) {
- assert.equal(moment([2011, 11, 26]).week(), 1, 'Dec 26 2011 should be week 1');
- assert.equal(moment([2012, 0, 1]).week(), 1, 'Jan 1 2012 should be week 1');
- assert.equal(moment([2012, 0, 2]).week(), 2, 'Jan 2 2012 should be week 2');
- assert.equal(moment([2012, 0, 8]).week(), 2, 'Jan 8 2012 should be week 2');
- assert.equal(moment([2012, 0, 9]).week(), 3, 'Jan 9 2012 should be week 3');
- });
-
- test('weeks year starting monday', function (assert) {
- assert.equal(moment([2007, 0, 1]).week(), 1, 'Jan 1 2007 should be week 1');
- assert.equal(moment([2007, 0, 7]).week(), 1, 'Jan 7 2007 should be week 1');
- assert.equal(moment([2007, 0, 8]).week(), 2, 'Jan 8 2007 should be week 2');
- assert.equal(moment([2007, 0, 14]).week(), 2, 'Jan 14 2007 should be week 2');
- assert.equal(moment([2007, 0, 15]).week(), 3, 'Jan 15 2007 should be week 3');
- });
-
- test('weeks year starting tuesday', function (assert) {
- assert.equal(moment([2007, 11, 31]).week(), 1, 'Dec 31 2007 should be week 1');
- assert.equal(moment([2008, 0, 1]).week(), 1, 'Jan 1 2008 should be week 1');
- assert.equal(moment([2008, 0, 6]).week(), 1, 'Jan 6 2008 should be week 1');
- assert.equal(moment([2008, 0, 7]).week(), 2, 'Jan 7 2008 should be week 2');
- assert.equal(moment([2008, 0, 13]).week(), 2, 'Jan 13 2008 should be week 2');
- assert.equal(moment([2008, 0, 14]).week(), 3, 'Jan 14 2008 should be week 3');
- });
-
- test('weeks year starting wednesday', function (assert) {
- assert.equal(moment([2002, 11, 30]).week(), 1, 'Dec 30 2002 should be week 1');
- assert.equal(moment([2003, 0, 1]).week(), 1, 'Jan 1 2003 should be week 1');
- assert.equal(moment([2003, 0, 5]).week(), 1, 'Jan 5 2003 should be week 1');
- assert.equal(moment([2003, 0, 6]).week(), 2, 'Jan 6 2003 should be week 2');
- assert.equal(moment([2003, 0, 12]).week(), 2, 'Jan 12 2003 should be week 2');
- assert.equal(moment([2003, 0, 13]).week(), 3, 'Jan 13 2003 should be week 3');
- });
-
- test('weeks year starting thursday', function (assert) {
- assert.equal(moment([2008, 11, 29]).week(), 1, 'Dec 29 2008 should be week 1');
- assert.equal(moment([2009, 0, 1]).week(), 1, 'Jan 1 2009 should be week 1');
- assert.equal(moment([2009, 0, 4]).week(), 1, 'Jan 4 2009 should be week 1');
- assert.equal(moment([2009, 0, 5]).week(), 2, 'Jan 5 2009 should be week 2');
- assert.equal(moment([2009, 0, 11]).week(), 2, 'Jan 11 2009 should be week 2');
- assert.equal(moment([2009, 0, 12]).week(), 3, 'Jan 12 2009 should be week 3');
- });
-
- test('weeks year starting friday', function (assert) {
- assert.equal(moment([2009, 11, 28]).week(), 1, 'Dec 28 2009 should be week 1');
- assert.equal(moment([2010, 0, 1]).week(), 1, 'Jan 1 2010 should be week 1');
- assert.equal(moment([2010, 0, 3]).week(), 1, 'Jan 3 2010 should be week 1');
- assert.equal(moment([2010, 0, 4]).week(), 2, 'Jan 4 2010 should be week 2');
- assert.equal(moment([2010, 0, 10]).week(), 2, 'Jan 10 2010 should be week 2');
- assert.equal(moment([2010, 0, 11]).week(), 3, 'Jan 11 2010 should be week 3');
- });
-
- test('weeks year starting saturday', function (assert) {
- assert.equal(moment([2010, 11, 27]).week(), 1, 'Dec 27 2010 should be week 1');
- assert.equal(moment([2011, 0, 1]).week(), 1, 'Jan 1 2011 should be week 1');
- assert.equal(moment([2011, 0, 2]).week(), 1, 'Jan 2 2011 should be week 1');
- assert.equal(moment([2011, 0, 3]).week(), 2, 'Jan 3 2011 should be week 2');
- assert.equal(moment([2011, 0, 9]).week(), 2, 'Jan 9 2011 should be week 2');
- assert.equal(moment([2011, 0, 10]).week(), 3, 'Jan 10 2011 should be week 3');
- });
-
test('weeks year starting sunday formatted', function (assert) {
assert.equal(moment([2011, 11, 26]).format('w ww wo'), '1 01 1', 'Dec 26 2011 should be week 1');
assert.equal(moment([2012, 0, 1]).format('w ww wo'), '1 01 1', 'Jan 1 2012 should be week 1');
@@ -26588,42 +37283,6 @@
assert.equal(moment([2012, 0, 9]).format('w ww wo'), '3 03 3', 'Jan 9 2012 should be week 3');
});
- test('lenient ordinal parsing', function (assert) {
- var i, ordinalStr, testMoment;
- for (i = 1; i <= 31; ++i) {
- ordinalStr = moment([2014, 0, i]).format('YYYY MM Do');
- testMoment = moment(ordinalStr, 'YYYY MM Do');
- assert.equal(testMoment.year(), 2014,
- 'lenient ordinal parsing ' + i + ' year check');
- assert.equal(testMoment.month(), 0,
- 'lenient ordinal parsing ' + i + ' month check');
- assert.equal(testMoment.date(), i,
- 'lenient ordinal parsing ' + i + ' date check');
- }
- });
-
- test('lenient ordinal parsing of number', function (assert) {
- var i, testMoment;
- for (i = 1; i <= 31; ++i) {
- testMoment = moment('2014 01 ' + i, 'YYYY MM Do');
- assert.equal(testMoment.year(), 2014,
- 'lenient ordinal parsing of number ' + i + ' year check');
- assert.equal(testMoment.month(), 0,
- 'lenient ordinal parsing of number ' + i + ' month check');
- assert.equal(testMoment.date(), i,
- 'lenient ordinal parsing of number ' + i + ' date check');
- }
- });
-
- test('strict ordinal parsing', function (assert) {
- var i, ordinalStr, testMoment;
- for (i = 1; i <= 31; ++i) {
- ordinalStr = moment([2014, 0, i]).format('YYYY MM Do');
- testMoment = moment(ordinalStr, 'YYYY MM Do', true);
- assert.ok(testMoment.isValid(), 'strict ordinal parsing ' + i);
- }
- });
-
}));
;(function (global, factory) {
@@ -26632,6 +37291,224 @@
typeof define === 'function' && define.amd ? define(['../../moment'], factory) :
factory(global.moment)
}(this, function (moment) { 'use strict';
+
+ function each(array, callback) {
+ var i;
+ for (i = 0; i < array.length; i++) {
+ callback(array[i], i, array);
+ }
+ }
+
+ function objectKeys(obj) {
+ if (Object.keys) {
+ return Object.keys(obj);
+ } else {
+ // IE8
+ var res = [], i;
+ for (i in obj) {
+ if (obj.hasOwnProperty(i)) {
+ res.push(i);
+ }
+ }
+ return res;
+ }
+ }
+
+ // Pick the first defined of two or three arguments.
+ function defaults(a, b, c) {
+ if (a != null) {
+ return a;
+ }
+ if (b != null) {
+ return b;
+ }
+ return c;
+ }
+
+ function defineCommonLocaleTests(locale, options) {
+ test('lenient ordinal parsing', function (assert) {
+ var i, ordinalStr, testMoment;
+ for (i = 1; i <= 31; ++i) {
+ ordinalStr = moment([2014, 0, i]).format('YYYY MM Do');
+ testMoment = moment(ordinalStr, 'YYYY MM Do');
+ assert.equal(testMoment.year(), 2014,
+ 'lenient ordinal parsing ' + i + ' year check');
+ assert.equal(testMoment.month(), 0,
+ 'lenient ordinal parsing ' + i + ' month check');
+ assert.equal(testMoment.date(), i,
+ 'lenient ordinal parsing ' + i + ' date check');
+ }
+ });
+
+ test('lenient ordinal parsing of number', function (assert) {
+ var i, testMoment;
+ for (i = 1; i <= 31; ++i) {
+ testMoment = moment('2014 01 ' + i, 'YYYY MM Do');
+ assert.equal(testMoment.year(), 2014,
+ 'lenient ordinal parsing of number ' + i + ' year check');
+ assert.equal(testMoment.month(), 0,
+ 'lenient ordinal parsing of number ' + i + ' month check');
+ assert.equal(testMoment.date(), i,
+ 'lenient ordinal parsing of number ' + i + ' date check');
+ }
+ });
+
+ test('strict ordinal parsing', function (assert) {
+ var i, ordinalStr, testMoment;
+ for (i = 1; i <= 31; ++i) {
+ ordinalStr = moment([2014, 0, i]).format('YYYY MM Do');
+ testMoment = moment(ordinalStr, 'YYYY MM Do', true);
+ assert.ok(testMoment.isValid(), 'strict ordinal parsing ' + i);
+ }
+ });
+
+ test('meridiem invariant', function (assert) {
+ var h, m, t1, t2;
+ for (h = 0; h < 24; ++h) {
+ for (m = 0; m < 60; m += 15) {
+ t1 = moment.utc([2000, 0, 1, h, m]);
+ t2 = moment.utc(t1.format('A h:mm'), 'A h:mm');
+ assert.equal(t2.format('HH:mm'), t1.format('HH:mm'),
+ 'meridiem at ' + t1.format('HH:mm'));
+ }
+ }
+ });
+
+ test('date format correctness', function (assert) {
+ var data, tokens;
+ data = moment.localeData()._longDateFormat;
+ tokens = objectKeys(data);
+ each(tokens, function (srchToken) {
+ // Check each format string to make sure it does not contain any
+ // tokens that need to be expanded.
+ each(tokens, function (baseToken) {
+ // strip escaped sequences
+ var format = data[baseToken].replace(/(\[[^\]]*\])/g, '');
+ assert.equal(false, !!~format.indexOf(srchToken),
+ 'contains ' + srchToken + ' in ' + baseToken);
+ });
+ });
+ });
+
+ test('month parsing correctness', function (assert) {
+ var i, m;
+
+ if (locale === 'tr') {
+ // I can't fix it :(
+ expect(0);
+ return;
+ }
+ function tester(format) {
+ var r;
+ r = moment(m.format(format), format);
+ assert.equal(r.month(), m.month(), 'month ' + i + ' fmt ' + format);
+ r = moment(m.format(format).toLocaleUpperCase(), format);
+ assert.equal(r.month(), m.month(), 'month ' + i + ' fmt ' + format + ' upper');
+ r = moment(m.format(format).toLocaleLowerCase(), format);
+ assert.equal(r.month(), m.month(), 'month ' + i + ' fmt ' + format + ' lower');
+
+ r = moment(m.format(format), format, true);
+ assert.equal(r.month(), m.month(), 'month ' + i + ' fmt ' + format + ' strict');
+ r = moment(m.format(format).toLocaleUpperCase(), format, true);
+ assert.equal(r.month(), m.month(), 'month ' + i + ' fmt ' + format + ' upper strict');
+ r = moment(m.format(format).toLocaleLowerCase(), format, true);
+ assert.equal(r.month(), m.month(), 'month ' + i + ' fmt ' + format + ' lower strict');
+ }
+
+ for (i = 0; i < 12; ++i) {
+ m = moment([2015, i, 15, 18]);
+ tester('MMM');
+ tester('MMM.');
+ tester('MMMM');
+ tester('MMMM.');
+ }
+ });
+
+ test('weekday parsing correctness', function (assert) {
+ var i, m;
+
+ if (locale === 'tr' || locale === 'az') {
+ // There is a lower-case letter (ı), that converted to upper then
+ // lower changes to i
+ expect(0);
+ return;
+ }
+ function tester(format) {
+ var r, baseMsg = 'weekday ' + m.weekday() + ' fmt ' + format;
+ r = moment(m.format(format), format);
+ assert.equal(r.weekday(), m.weekday(), baseMsg);
+ r = moment(m.format(format).toLocaleUpperCase(), format);
+ assert.equal(r.weekday(), m.weekday(), baseMsg + ' upper');
+ r = moment(m.format(format).toLocaleLowerCase(), format);
+ assert.equal(r.weekday(), m.weekday(), baseMsg + ' lower');
+
+ r = moment(m.format(format), format, true);
+ assert.equal(r.weekday(), m.weekday(), baseMsg + ' strict');
+ r = moment(m.format(format).toLocaleUpperCase(), format, true);
+ assert.equal(r.weekday(), m.weekday(), baseMsg + ' upper strict');
+ r = moment(m.format(format).toLocaleLowerCase(), format, true);
+ assert.equal(r.weekday(), m.weekday(), baseMsg + ' lower strict');
+ }
+
+ for (i = 0; i < 7; ++i) {
+ m = moment.utc([2015, i, 15, 18]);
+ tester('dd');
+ tester('ddd');
+ tester('dddd');
+ }
+ });
+ }
+
+ function setupDeprecationHandler(test, moment, scope) {
+ test._expectedDeprecations = null;
+ test._observedDeprecations = null;
+ test._oldSupress = moment.suppressDeprecationWarnings;
+ moment.suppressDeprecationWarnings = true;
+ test.expectedDeprecations = function () {
+ test._expectedDeprecations = arguments;
+ test._observedDeprecations = [];
+ };
+ moment.deprecationHandler = function (name, msg) {
+ var deprecationId = matchedDeprecation(name, msg, test._expectedDeprecations);
+ if (deprecationId === -1) {
+ throw new Error('Unexpected deprecation thrown name=' +
+ name + ' msg=' + msg);
+ }
+ test._observedDeprecations[deprecationId] = 1;
+ };
+ }
+
+ function teardownDeprecationHandler(test, moment, scope) {
+ moment.suppressDeprecationWarnings = test._oldSupress;
+
+ if (test._expectedDeprecations != null) {
+ var missedDeprecations = [];
+ each(test._expectedDeprecations, function (deprecationPattern, id) {
+ if (test._observedDeprecations[id] !== 1) {
+ missedDeprecations.push(deprecationPattern);
+ }
+ });
+ if (missedDeprecations.length !== 0) {
+ throw new Error('Expected deprecation warnings did not happen: ' +
+ missedDeprecations.join(' '));
+ }
+ }
+ }
+
+ function matchedDeprecation(name, msg, deprecations) {
+ if (deprecations == null) {
+ return -1;
+ }
+ for (var i = 0; i < deprecations.length; ++i) {
+ if (name != null && name === deprecations[i]) {
+ return i;
+ }
+ if (msg != null && msg.substring(0, deprecations[i].length) === deprecations[i]) {
+ return i;
+ }
+ }
+ return -1;
+ }
/*global QUnit:false*/
@@ -26646,11 +37523,13 @@
moment.createFromInputFallback = function (config) {
throw new Error('input not handled by moment: ' + config._i);
};
+ setupDeprecationHandler(test, moment, 'core');
if (lifecycle && lifecycle.setup) {
lifecycle.setup();
}
},
teardown : function () {
+ teardownDeprecationHandler(test, moment, 'core');
if (lifecycle && lifecycle.teardown) {
lifecycle.teardown();
}
@@ -26665,23 +37544,26 @@
moment.createFromInputFallback = function (config) {
throw new Error('input not handled by moment: ' + config._i);
};
+ setupDeprecationHandler(test, moment, 'locale');
if (lifecycle && lifecycle.setup) {
lifecycle.setup();
}
},
teardown : function () {
moment.locale('en');
+ teardownDeprecationHandler(test, moment, 'locale');
if (lifecycle && lifecycle.teardown) {
lifecycle.teardown();
}
}
});
+ defineCommonLocaleTests(name, -1, -1);
}
localeModule('ru');
test('parse', function (assert) {
- var tests = 'Январь янв_Февраль фев_Март март_Апрель апр_Май май_Июнь июнь_Июль июль_Август авг_Сентябрь сен_Октябрь окт_Ноябрь ноя_Декабрь дек'.split('_'), i;
+ var tests = 'январь янв._февраль февр._март март_апрель апр._май май_июнь июнь_июль июль_август авг._сентябрь сент._октябрь окт._ноябрь нояб._декабрь дек.'.split('_'), i;
function equalTest(input, mmm, i) {
assert.equal(moment(input, mmm).month(), i, input + ' should be month ' + (i + 1));
}
@@ -26714,12 +37596,12 @@
test('format', function (assert) {
var a = [
- ['dddd, Do MMMM YYYY, HH:mm:ss', 'Воскресенье, 14-го Февраля 2010, 15:25:50'],
- ['ddd, h A', 'Вс, 3 дня'],
- ['M Mo MM MMMM MMM', '2 2-й 02 Февраль фев'],
+ ['dddd, Do MMMM YYYY, HH:mm:ss', 'воскресенье, 14-го февраля 2010, 15:25:50'],
+ ['ddd, h A', 'вс, 3 дня'],
+ ['M Mo MM MMMM MMM', '2 2-й 02 февраль февр.'],
['YYYY YY', '2010 10'],
['D Do DD', '14 14-го 14'],
- ['d do dddd ddd dd', '0 0-й Воскресенье Вс Вс'],
+ ['d do dddd ddd dd', '0 0-й воскресенье вс вс'],
['DDD DDDo DDDD', '45 45-й 045'],
['w wo ww', '7 7-я 07'],
['h hh', '3 03'],
@@ -26730,13 +37612,13 @@
['DDDo [день года]', '45-й день года'],
['LTS', '15:25:50'],
['L', '14.02.2010'],
- ['LL', '14 Февраля 2010 г.'],
- ['LLL', '14 Февраля 2010 г., 15:25'],
- ['LLLL', 'Воскресенье, 14 Февраля 2010 г., 15:25'],
+ ['LL', '14 февраля 2010 г.'],
+ ['LLL', '14 февраля 2010 г., 15:25'],
+ ['LLLL', 'воскресенье, 14 февраля 2010 г., 15:25'],
['l', '14.2.2010'],
- ['ll', '14 фев 2010 г.'],
- ['lll', '14 фев 2010 г., 15:25'],
- ['llll', 'Вс, 14 фев 2010 г., 15:25']
+ ['ll', '14 февр. 2010 г.'],
+ ['lll', '14 февр. 2010 г., 15:25'],
+ ['llll', 'вс, 14 февр. 2010 г., 15:25']
],
b = moment(new Date(2010, 1, 14, 15, 25, 50, 125)),
i;
@@ -26794,7 +37676,7 @@
});
test('format month', function (assert) {
- var expected = 'Январь янв_Февраль фев_Март март_Апрель апр_Май май_Июнь июнь_Июль июль_Август авг_Сентябрь сен_Октябрь окт_Ноябрь ноя_Декабрь дек'.split('_'), i;
+ var expected = 'январь янв._февраль февр._март март_апрель апр._май май_июнь июнь_июль июль_август авг._сентябрь сент._октябрь окт._ноябрь нояб._декабрь дек.'.split('_'), i;
for (i = 0; i < expected.length; i++) {
assert.equal(moment([2011, i, 1]).format('MMMM MMM'), expected[i], expected[i]);
}
@@ -26802,8 +37684,8 @@
test('format month case', function (assert) {
var months = {
- 'nominative': 'Январь_Февраль_Март_Апрель_Май_Июнь_Июль_Август_Сентябрь_Октябрь_Ноябрь_Декабрь'.split('_'),
- 'accusative': 'Января_Февраля_Марта_Апреля_Мая_Июня_Июля_Августа_Сентября_Октября_Ноября_Декабря'.split('_')
+ 'nominative': 'январь_февраль_март_апрель_май_июнь_июль_август_сентябрь_октябрь_ноябрь_декабрь'.split('_'),
+ 'accusative': 'января_февраля_марта_апреля_мая_июня_июля_августа_сентября_октября_ноября_декабря'.split('_')
}, i;
for (i = 0; i < 12; i++) {
assert.equal(moment([2011, i, 1]).format('D MMMM'), '1 ' + months.accusative[i], '1 ' + months.accusative[i]);
@@ -26813,8 +37695,8 @@
test('format month short case', function (assert) {
var monthsShort = {
- 'nominative': 'янв_фев_март_апр_май_июнь_июль_авг_сен_окт_ноя_дек'.split('_'),
- 'accusative': 'янв_фев_мар_апр_мая_июня_июля_авг_сен_окт_ноя_дек'.split('_')
+ 'nominative': 'янв._февр._март_апр._май_июнь_июль_авг._сент._окт._нояб._дек.'.split('_'),
+ 'accusative': 'янв._февр._мар._апр._мая_июня_июля_авг._сент._окт._нояб._дек.'.split('_')
}, i;
for (i = 0; i < 12; i++) {
assert.equal(moment([2011, i, 1]).format('D MMM'), '1 ' + monthsShort.accusative[i], '1 ' + monthsShort.accusative[i]);
@@ -26824,8 +37706,8 @@
test('format month case with escaped symbols', function (assert) {
var months = {
- 'nominative': 'Январь_Февраль_Март_Апрель_Май_Июнь_Июль_Август_Сентябрь_Октябрь_Ноябрь_Декабрь'.split('_'),
- 'accusative': 'Января_Февраля_Марта_Апреля_Мая_Июня_Июля_Августа_Сентября_Октября_Ноября_Декабря'.split('_')
+ 'nominative': 'январь_февраль_март_апрель_май_июнь_июль_август_сентябрь_октябрь_ноябрь_декабрь'.split('_'),
+ 'accusative': 'января_февраля_марта_апреля_мая_июня_июля_августа_сентября_октября_ноября_декабря'.split('_')
}, i;
for (i = 0; i < 12; i++) {
assert.equal(moment([2013, i, 1]).format('D[] MMMM'), '1 ' + months.accusative[i], '1 ' + months.accusative[i]);
@@ -26837,8 +37719,8 @@
test('format month short case with escaped symbols', function (assert) {
var monthsShort = {
- 'nominative': 'янв_фев_март_апр_май_июнь_июль_авг_сен_окт_ноя_дек'.split('_'),
- 'accusative': 'янв_фев_мар_апр_мая_июня_июля_авг_сен_окт_ноя_дек'.split('_')
+ 'nominative': 'янв._февр._март_апр._май_июнь_июль_авг._сент._окт._нояб._дек.'.split('_'),
+ 'accusative': 'янв._февр._мар._апр._мая_июня_июля_авг._сент._окт._нояб._дек.'.split('_')
}, i;
for (i = 0; i < 12; i++) {
assert.equal(moment([2013, i, 1]).format('D[] MMM'), '1 ' + monthsShort.accusative[i], '1 ' + monthsShort.accusative[i]);
@@ -26849,7 +37731,7 @@
});
test('format week', function (assert) {
- var expected = 'Воскресенье Вс Вс_Понедельник Пн Пн_Вторник Вт Вт_Среда Ср Ср_Четверг Чт Чт_Пятница Пт Пт_Суббота Сб Сб'.split('_'), i;
+ var expected = 'воскресенье вс вс_понедельник пн пн_вторник вт вт_среда ср ср_четверг чт чт_пятница пт пт_суббота сб сб'.split('_'), i;
for (i = 0; i < expected.length; i++) {
assert.equal(moment([2011, 0, 2 + i]).format('dddd ddd dd'), expected[i], expected[i]);
}
@@ -26903,14 +37785,14 @@
});
test('calendar day', function (assert) {
- var a = moment().hours(2).minutes(0).seconds(0);
-
- assert.equal(moment(a).calendar(), 'Сегодня в 02:00', 'today at the same time');
- assert.equal(moment(a).add({m: 25}).calendar(), 'Сегодня в 02:25', 'Now plus 25 min');
- assert.equal(moment(a).add({h: 1}).calendar(), 'Сегодня в 03:00', 'Now plus 1 hour');
- assert.equal(moment(a).add({d: 1}).calendar(), 'Завтра в 02:00', 'tomorrow at the same time');
- assert.equal(moment(a).subtract({h: 1}).calendar(), 'Сегодня в 01:00', 'Now minus 1 hour');
- assert.equal(moment(a).subtract({d: 1}).calendar(), 'Вчера в 02:00', 'yesterday at the same time');
+ var a = moment().hours(12).minutes(0).seconds(0);
+
+ assert.equal(moment(a).calendar(), 'Сегодня в 12:00', 'today at the same time');
+ assert.equal(moment(a).add({m: 25}).calendar(), 'Сегодня в 12:25', 'Now plus 25 min');
+ assert.equal(moment(a).add({h: 1}).calendar(), 'Сегодня в 13:00', 'Now plus 1 hour');
+ assert.equal(moment(a).add({d: 1}).calendar(), 'Завтра в 12:00', 'tomorrow at the same time');
+ assert.equal(moment(a).subtract({h: 1}).calendar(), 'Сегодня в 11:00', 'Now minus 1 hour');
+ assert.equal(moment(a).subtract({d: 1}).calendar(), 'Вчера в 12:00', 'yesterday at the same time');
});
test('calendar next week', function (assert) {
@@ -27023,67 +37905,6 @@
assert.equal(weeksFromNow.calendar(), weeksFromNow.format('L'), 'in 2 weeks');
});
- test('weeks year starting sunday', function (assert) {
- assert.equal(moment([2011, 11, 26]).week(), 1, 'Dec 26 2011 should be week 1');
- assert.equal(moment([2012, 0, 1]).week(), 1, 'Jan 1 2012 should be week 1');
- assert.equal(moment([2012, 0, 2]).week(), 2, 'Jan 2 2012 should be week 2');
- assert.equal(moment([2012, 0, 8]).week(), 2, 'Jan 8 2012 should be week 2');
- assert.equal(moment([2012, 0, 9]).week(), 3, 'Jan 9 2012 should be week 3');
- });
-
- test('weeks year starting monday', function (assert) {
- assert.equal(moment([2007, 0, 1]).week(), 1, 'Jan 1 2007 should be week 1');
- assert.equal(moment([2007, 0, 7]).week(), 1, 'Jan 7 2007 should be week 1');
- assert.equal(moment([2007, 0, 8]).week(), 2, 'Jan 8 2007 should be week 2');
- assert.equal(moment([2007, 0, 14]).week(), 2, 'Jan 14 2007 should be week 2');
- assert.equal(moment([2007, 0, 15]).week(), 3, 'Jan 15 2007 should be week 3');
- });
-
- test('weeks year starting tuesday', function (assert) {
- assert.equal(moment([2007, 11, 31]).week(), 1, 'Dec 31 2007 should be week 1');
- assert.equal(moment([2008, 0, 1]).week(), 1, 'Jan 1 2008 should be week 1');
- assert.equal(moment([2008, 0, 6]).week(), 1, 'Jan 6 2008 should be week 1');
- assert.equal(moment([2008, 0, 7]).week(), 2, 'Jan 7 2008 should be week 2');
- assert.equal(moment([2008, 0, 13]).week(), 2, 'Jan 13 2008 should be week 2');
- assert.equal(moment([2008, 0, 14]).week(), 3, 'Jan 14 2008 should be week 3');
- });
-
- test('weeks year starting wednesday', function (assert) {
- assert.equal(moment([2002, 11, 30]).week(), 1, 'Dec 30 2002 should be week 1');
- assert.equal(moment([2003, 0, 1]).week(), 1, 'Jan 1 2003 should be week 1');
- assert.equal(moment([2003, 0, 5]).week(), 1, 'Jan 5 2003 should be week 1');
- assert.equal(moment([2003, 0, 6]).week(), 2, 'Jan 6 2003 should be week 2');
- assert.equal(moment([2003, 0, 12]).week(), 2, 'Jan 12 2003 should be week 2');
- assert.equal(moment([2003, 0, 13]).week(), 3, 'Jan 13 2003 should be week 3');
- });
-
- test('weeks year starting thursday', function (assert) {
- assert.equal(moment([2008, 11, 29]).week(), 1, 'Dec 29 2008 should be week 1');
- assert.equal(moment([2009, 0, 1]).week(), 1, 'Jan 1 2009 should be week 1');
- assert.equal(moment([2009, 0, 4]).week(), 1, 'Jan 4 2009 should be week 1');
- assert.equal(moment([2009, 0, 5]).week(), 2, 'Jan 5 2009 should be week 2');
- assert.equal(moment([2009, 0, 11]).week(), 2, 'Jan 11 2009 should be week 2');
- assert.equal(moment([2009, 0, 12]).week(), 3, 'Jan 12 2009 should be week 3');
- });
-
- test('weeks year starting friday', function (assert) {
- assert.equal(moment([2009, 11, 28]).week(), 1, 'Dec 28 2009 should be week 1');
- assert.equal(moment([2010, 0, 1]).week(), 1, 'Jan 1 2010 should be week 1');
- assert.equal(moment([2010, 0, 3]).week(), 1, 'Jan 3 2010 should be week 1');
- assert.equal(moment([2010, 0, 4]).week(), 2, 'Jan 4 2010 should be week 2');
- assert.equal(moment([2010, 0, 10]).week(), 2, 'Jan 10 2010 should be week 2');
- assert.equal(moment([2010, 0, 11]).week(), 3, 'Jan 11 2010 should be week 3');
- });
-
- test('weeks year starting saturday', function (assert) {
- assert.equal(moment([2010, 11, 27]).week(), 1, 'Dec 27 2010 should be week 1');
- assert.equal(moment([2011, 0, 1]).week(), 1, 'Jan 1 2011 should be week 1');
- assert.equal(moment([2011, 0, 2]).week(), 1, 'Jan 2 2011 should be week 1');
- assert.equal(moment([2011, 0, 3]).week(), 2, 'Jan 3 2011 should be week 2');
- assert.equal(moment([2011, 0, 9]).week(), 2, 'Jan 9 2011 should be week 2');
- assert.equal(moment([2011, 0, 10]).week(), 3, 'Jan 10 2011 should be week 3');
- });
-
test('weeks year starting sunday formatted', function (assert) {
assert.equal(moment([2011, 11, 26]).format('w ww wo'), '1 01 1-я', 'Dec 26 2011 should be week 1');
assert.equal(moment([2012, 0, 1]).format('w ww wo'), '1 01 1-я', 'Jan 1 2012 should be week 1');
@@ -27092,42 +37913,6 @@
assert.equal(moment([2012, 0, 9]).format('w ww wo'), '3 03 3-я', 'Jan 9 2012 should be week 3');
});
- test('lenient ordinal parsing', function (assert) {
- var i, ordinalStr, testMoment;
- for (i = 1; i <= 31; ++i) {
- ordinalStr = moment([2014, 0, i]).format('YYYY MM Do');
- testMoment = moment(ordinalStr, 'YYYY MM Do');
- assert.equal(testMoment.year(), 2014,
- 'lenient ordinal parsing ' + i + ' year check');
- assert.equal(testMoment.month(), 0,
- 'lenient ordinal parsing ' + i + ' month check');
- assert.equal(testMoment.date(), i,
- 'lenient ordinal parsing ' + i + ' date check');
- }
- });
-
- test('lenient ordinal parsing of number', function (assert) {
- var i, testMoment;
- for (i = 1; i <= 31; ++i) {
- testMoment = moment('2014 01 ' + i, 'YYYY MM Do');
- assert.equal(testMoment.year(), 2014,
- 'lenient ordinal parsing of number ' + i + ' year check');
- assert.equal(testMoment.month(), 0,
- 'lenient ordinal parsing of number ' + i + ' month check');
- assert.equal(testMoment.date(), i,
- 'lenient ordinal parsing of number ' + i + ' date check');
- }
- });
-
- test('strict ordinal parsing', function (assert) {
- var i, ordinalStr, testMoment;
- for (i = 1; i <= 31; ++i) {
- ordinalStr = moment([2014, 0, i]).format('YYYY MM Do');
- testMoment = moment(ordinalStr, 'YYYY MM Do', true);
- assert.ok(testMoment.isValid(), 'strict ordinal parsing ' + i);
- }
- });
-
}));
;(function (global, factory) {
@@ -27136,6 +37921,224 @@
typeof define === 'function' && define.amd ? define(['../../moment'], factory) :
factory(global.moment)
}(this, function (moment) { 'use strict';
+
+ function each(array, callback) {
+ var i;
+ for (i = 0; i < array.length; i++) {
+ callback(array[i], i, array);
+ }
+ }
+
+ function objectKeys(obj) {
+ if (Object.keys) {
+ return Object.keys(obj);
+ } else {
+ // IE8
+ var res = [], i;
+ for (i in obj) {
+ if (obj.hasOwnProperty(i)) {
+ res.push(i);
+ }
+ }
+ return res;
+ }
+ }
+
+ // Pick the first defined of two or three arguments.
+ function defaults(a, b, c) {
+ if (a != null) {
+ return a;
+ }
+ if (b != null) {
+ return b;
+ }
+ return c;
+ }
+
+ function defineCommonLocaleTests(locale, options) {
+ test('lenient ordinal parsing', function (assert) {
+ var i, ordinalStr, testMoment;
+ for (i = 1; i <= 31; ++i) {
+ ordinalStr = moment([2014, 0, i]).format('YYYY MM Do');
+ testMoment = moment(ordinalStr, 'YYYY MM Do');
+ assert.equal(testMoment.year(), 2014,
+ 'lenient ordinal parsing ' + i + ' year check');
+ assert.equal(testMoment.month(), 0,
+ 'lenient ordinal parsing ' + i + ' month check');
+ assert.equal(testMoment.date(), i,
+ 'lenient ordinal parsing ' + i + ' date check');
+ }
+ });
+
+ test('lenient ordinal parsing of number', function (assert) {
+ var i, testMoment;
+ for (i = 1; i <= 31; ++i) {
+ testMoment = moment('2014 01 ' + i, 'YYYY MM Do');
+ assert.equal(testMoment.year(), 2014,
+ 'lenient ordinal parsing of number ' + i + ' year check');
+ assert.equal(testMoment.month(), 0,
+ 'lenient ordinal parsing of number ' + i + ' month check');
+ assert.equal(testMoment.date(), i,
+ 'lenient ordinal parsing of number ' + i + ' date check');
+ }
+ });
+
+ test('strict ordinal parsing', function (assert) {
+ var i, ordinalStr, testMoment;
+ for (i = 1; i <= 31; ++i) {
+ ordinalStr = moment([2014, 0, i]).format('YYYY MM Do');
+ testMoment = moment(ordinalStr, 'YYYY MM Do', true);
+ assert.ok(testMoment.isValid(), 'strict ordinal parsing ' + i);
+ }
+ });
+
+ test('meridiem invariant', function (assert) {
+ var h, m, t1, t2;
+ for (h = 0; h < 24; ++h) {
+ for (m = 0; m < 60; m += 15) {
+ t1 = moment.utc([2000, 0, 1, h, m]);
+ t2 = moment.utc(t1.format('A h:mm'), 'A h:mm');
+ assert.equal(t2.format('HH:mm'), t1.format('HH:mm'),
+ 'meridiem at ' + t1.format('HH:mm'));
+ }
+ }
+ });
+
+ test('date format correctness', function (assert) {
+ var data, tokens;
+ data = moment.localeData()._longDateFormat;
+ tokens = objectKeys(data);
+ each(tokens, function (srchToken) {
+ // Check each format string to make sure it does not contain any
+ // tokens that need to be expanded.
+ each(tokens, function (baseToken) {
+ // strip escaped sequences
+ var format = data[baseToken].replace(/(\[[^\]]*\])/g, '');
+ assert.equal(false, !!~format.indexOf(srchToken),
+ 'contains ' + srchToken + ' in ' + baseToken);
+ });
+ });
+ });
+
+ test('month parsing correctness', function (assert) {
+ var i, m;
+
+ if (locale === 'tr') {
+ // I can't fix it :(
+ expect(0);
+ return;
+ }
+ function tester(format) {
+ var r;
+ r = moment(m.format(format), format);
+ assert.equal(r.month(), m.month(), 'month ' + i + ' fmt ' + format);
+ r = moment(m.format(format).toLocaleUpperCase(), format);
+ assert.equal(r.month(), m.month(), 'month ' + i + ' fmt ' + format + ' upper');
+ r = moment(m.format(format).toLocaleLowerCase(), format);
+ assert.equal(r.month(), m.month(), 'month ' + i + ' fmt ' + format + ' lower');
+
+ r = moment(m.format(format), format, true);
+ assert.equal(r.month(), m.month(), 'month ' + i + ' fmt ' + format + ' strict');
+ r = moment(m.format(format).toLocaleUpperCase(), format, true);
+ assert.equal(r.month(), m.month(), 'month ' + i + ' fmt ' + format + ' upper strict');
+ r = moment(m.format(format).toLocaleLowerCase(), format, true);
+ assert.equal(r.month(), m.month(), 'month ' + i + ' fmt ' + format + ' lower strict');
+ }
+
+ for (i = 0; i < 12; ++i) {
+ m = moment([2015, i, 15, 18]);
+ tester('MMM');
+ tester('MMM.');
+ tester('MMMM');
+ tester('MMMM.');
+ }
+ });
+
+ test('weekday parsing correctness', function (assert) {
+ var i, m;
+
+ if (locale === 'tr' || locale === 'az') {
+ // There is a lower-case letter (ı), that converted to upper then
+ // lower changes to i
+ expect(0);
+ return;
+ }
+ function tester(format) {
+ var r, baseMsg = 'weekday ' + m.weekday() + ' fmt ' + format;
+ r = moment(m.format(format), format);
+ assert.equal(r.weekday(), m.weekday(), baseMsg);
+ r = moment(m.format(format).toLocaleUpperCase(), format);
+ assert.equal(r.weekday(), m.weekday(), baseMsg + ' upper');
+ r = moment(m.format(format).toLocaleLowerCase(), format);
+ assert.equal(r.weekday(), m.weekday(), baseMsg + ' lower');
+
+ r = moment(m.format(format), format, true);
+ assert.equal(r.weekday(), m.weekday(), baseMsg + ' strict');
+ r = moment(m.format(format).toLocaleUpperCase(), format, true);
+ assert.equal(r.weekday(), m.weekday(), baseMsg + ' upper strict');
+ r = moment(m.format(format).toLocaleLowerCase(), format, true);
+ assert.equal(r.weekday(), m.weekday(), baseMsg + ' lower strict');
+ }
+
+ for (i = 0; i < 7; ++i) {
+ m = moment.utc([2015, i, 15, 18]);
+ tester('dd');
+ tester('ddd');
+ tester('dddd');
+ }
+ });
+ }
+
+ function setupDeprecationHandler(test, moment, scope) {
+ test._expectedDeprecations = null;
+ test._observedDeprecations = null;
+ test._oldSupress = moment.suppressDeprecationWarnings;
+ moment.suppressDeprecationWarnings = true;
+ test.expectedDeprecations = function () {
+ test._expectedDeprecations = arguments;
+ test._observedDeprecations = [];
+ };
+ moment.deprecationHandler = function (name, msg) {
+ var deprecationId = matchedDeprecation(name, msg, test._expectedDeprecations);
+ if (deprecationId === -1) {
+ throw new Error('Unexpected deprecation thrown name=' +
+ name + ' msg=' + msg);
+ }
+ test._observedDeprecations[deprecationId] = 1;
+ };
+ }
+
+ function teardownDeprecationHandler(test, moment, scope) {
+ moment.suppressDeprecationWarnings = test._oldSupress;
+
+ if (test._expectedDeprecations != null) {
+ var missedDeprecations = [];
+ each(test._expectedDeprecations, function (deprecationPattern, id) {
+ if (test._observedDeprecations[id] !== 1) {
+ missedDeprecations.push(deprecationPattern);
+ }
+ });
+ if (missedDeprecations.length !== 0) {
+ throw new Error('Expected deprecation warnings did not happen: ' +
+ missedDeprecations.join(' '));
+ }
+ }
+ }
+
+ function matchedDeprecation(name, msg, deprecations) {
+ if (deprecations == null) {
+ return -1;
+ }
+ for (var i = 0; i < deprecations.length; ++i) {
+ if (name != null && name === deprecations[i]) {
+ return i;
+ }
+ if (msg != null && msg.substring(0, deprecations[i].length) === deprecations[i]) {
+ return i;
+ }
+ }
+ return -1;
+ }
/*global QUnit:false*/
@@ -27150,11 +38153,13 @@
moment.createFromInputFallback = function (config) {
throw new Error('input not handled by moment: ' + config._i);
};
+ setupDeprecationHandler(test, moment, 'core');
if (lifecycle && lifecycle.setup) {
lifecycle.setup();
}
},
teardown : function () {
+ teardownDeprecationHandler(test, moment, 'core');
if (lifecycle && lifecycle.teardown) {
lifecycle.teardown();
}
@@ -27169,17 +38174,20 @@
moment.createFromInputFallback = function (config) {
throw new Error('input not handled by moment: ' + config._i);
};
+ setupDeprecationHandler(test, moment, 'locale');
if (lifecycle && lifecycle.setup) {
lifecycle.setup();
}
},
teardown : function () {
moment.locale('en');
+ teardownDeprecationHandler(test, moment, 'locale');
if (lifecycle && lifecycle.teardown) {
lifecycle.teardown();
}
}
});
+ defineCommonLocaleTests(name, -1, -1);
}
localeModule('se');
@@ -27342,14 +38350,14 @@
});
test('calendar day', function (assert) {
- var a = moment().hours(2).minutes(0).seconds(0);
-
- assert.equal(moment(a).calendar(), 'otne ti 02:00', 'Today at the same time');
- assert.equal(moment(a).add({m: 25}).calendar(), 'otne ti 02:25', 'Now plus 25 min');
- assert.equal(moment(a).add({h: 1}).calendar(), 'otne ti 03:00', 'Now plus 1 hour');
- assert.equal(moment(a).add({d: 1}).calendar(), 'ihttin ti 02:00', 'Tomorrow at the same time');
- assert.equal(moment(a).subtract({h: 1}).calendar(), 'otne ti 01:00', 'Now minus 1 hour');
- assert.equal(moment(a).subtract({d: 1}).calendar(), 'ikte ti 02:00', 'yesterday at the same time');
+ var a = moment().hours(12).minutes(0).seconds(0);
+
+ assert.equal(moment(a).calendar(), 'otne ti 12:00', 'Today at the same time');
+ assert.equal(moment(a).add({m: 25}).calendar(), 'otne ti 12:25', 'Now plus 25 min');
+ assert.equal(moment(a).add({h: 1}).calendar(), 'otne ti 13:00', 'Now plus 1 hour');
+ assert.equal(moment(a).add({d: 1}).calendar(), 'ihttin ti 12:00', 'Tomorrow at the same time');
+ assert.equal(moment(a).subtract({h: 1}).calendar(), 'otne ti 11:00', 'Now minus 1 hour');
+ assert.equal(moment(a).subtract({d: 1}).calendar(), 'ikte ti 12:00', 'yesterday at the same time');
});
test('calendar next week', function (assert) {
@@ -27392,67 +38400,6 @@
assert.equal(weeksFromNow.calendar(), weeksFromNow.format('L'), 'in 2 weeks');
});
- test('weeks year starting sunday', function (assert) {
- assert.equal(moment([2012, 0, 1]).week(), 52, 'Jan 1 2012 should be week 52');
- assert.equal(moment([2012, 0, 2]).week(), 1, 'Jan 2 2012 should be week 1');
- assert.equal(moment([2012, 0, 8]).week(), 1, 'Jan 8 2012 should be week 1');
- assert.equal(moment([2012, 0, 9]).week(), 2, 'Jan 9 2012 should be week 2');
- assert.equal(moment([2012, 0, 15]).week(), 2, 'Jan 15 2012 should be week 2');
- });
-
- test('weeks year starting monday', function (assert) {
- assert.equal(moment([2007, 0, 1]).week(), 1, 'Jan 1 2007 should be week 1');
- assert.equal(moment([2007, 0, 7]).week(), 1, 'Jan 7 2007 should be week 1');
- assert.equal(moment([2007, 0, 8]).week(), 2, 'Jan 8 2007 should be week 2');
- assert.equal(moment([2007, 0, 14]).week(), 2, 'Jan 14 2007 should be week 2');
- assert.equal(moment([2007, 0, 15]).week(), 3, 'Jan 15 2007 should be week 3');
- });
-
- test('weeks year starting tuesday', function (assert) {
- assert.equal(moment([2007, 11, 31]).week(), 1, 'Dec 31 2007 should be week 1');
- assert.equal(moment([2008, 0, 1]).week(), 1, 'Jan 1 2008 should be week 1');
- assert.equal(moment([2008, 0, 6]).week(), 1, 'Jan 6 2008 should be week 1');
- assert.equal(moment([2008, 0, 7]).week(), 2, 'Jan 7 2008 should be week 2');
- assert.equal(moment([2008, 0, 13]).week(), 2, 'Jan 13 2008 should be week 2');
- assert.equal(moment([2008, 0, 14]).week(), 3, 'Jan 14 2008 should be week 3');
- });
-
- test('weeks year starting wednesday', function (assert) {
- assert.equal(moment([2002, 11, 30]).week(), 1, 'Dec 30 2002 should be week 1');
- assert.equal(moment([2003, 0, 1]).week(), 1, 'Jan 1 2003 should be week 1');
- assert.equal(moment([2003, 0, 5]).week(), 1, 'Jan 5 2003 should be week 1');
- assert.equal(moment([2003, 0, 6]).week(), 2, 'Jan 6 2003 should be week 2');
- assert.equal(moment([2003, 0, 12]).week(), 2, 'Jan 12 2003 should be week 2');
- assert.equal(moment([2003, 0, 13]).week(), 3, 'Jan 13 2003 should be week 3');
- });
-
- test('weeks year starting thursday', function (assert) {
- assert.equal(moment([2008, 11, 29]).week(), 1, 'Dec 29 2008 should be week 1');
- assert.equal(moment([2009, 0, 1]).week(), 1, 'Jan 1 2009 should be week 1');
- assert.equal(moment([2009, 0, 4]).week(), 1, 'Jan 4 2009 should be week 1');
- assert.equal(moment([2009, 0, 5]).week(), 2, 'Jan 5 2009 should be week 2');
- assert.equal(moment([2009, 0, 11]).week(), 2, 'Jan 11 2009 should be week 2');
- assert.equal(moment([2009, 0, 13]).week(), 3, 'Jan 12 2009 should be week 3');
- });
-
- test('weeks year starting friday', function (assert) {
- assert.equal(moment([2009, 11, 28]).week(), 53, 'Dec 28 2009 should be week 53');
- assert.equal(moment([2010, 0, 1]).week(), 53, 'Jan 1 2010 should be week 53');
- assert.equal(moment([2010, 0, 3]).week(), 53, 'Jan 3 2010 should be week 53');
- assert.equal(moment([2010, 0, 4]).week(), 1, 'Jan 4 2010 should be week 1');
- assert.equal(moment([2010, 0, 10]).week(), 1, 'Jan 10 2010 should be week 1');
- assert.equal(moment([2010, 0, 11]).week(), 2, 'Jan 11 2010 should be week 2');
- });
-
- test('weeks year starting saturday', function (assert) {
- assert.equal(moment([2010, 11, 27]).week(), 52, 'Dec 27 2010 should be week 52');
- assert.equal(moment([2011, 0, 1]).week(), 52, 'Jan 1 2011 should be week 52');
- assert.equal(moment([2011, 0, 2]).week(), 52, 'Jan 2 2011 should be week 52');
- assert.equal(moment([2011, 0, 3]).week(), 1, 'Jan 3 2011 should be week 1');
- assert.equal(moment([2011, 0, 9]).week(), 1, 'Jan 9 2011 should be week 1');
- assert.equal(moment([2011, 0, 10]).week(), 2, 'Jan 10 2011 should be week 2');
- });
-
test('weeks year starting sunday formatted', function (assert) {
assert.equal(moment([2012, 0, 1]).format('w ww wo'), '52 52 52.', 'Jan 1 2012 should be week 52');
assert.equal(moment([2012, 0, 2]).format('w ww wo'), '1 01 1.', 'Jan 2 2012 should be week 1');
@@ -27461,42 +38408,6 @@
assert.equal(moment([2012, 0, 15]).format('w ww wo'), '2 02 2.', 'Jan 15 2012 should be week 2');
});
- test('lenient ordinal parsing', function (assert) {
- var i, ordinalStr, testMoment;
- for (i = 1; i <= 31; ++i) {
- ordinalStr = moment([2014, 0, i]).format('YYYY MM Do');
- testMoment = moment(ordinalStr, 'YYYY MM Do');
- assert.equal(testMoment.year(), 2014,
- 'lenient ordinal parsing ' + i + ' year check');
- assert.equal(testMoment.month(), 0,
- 'lenient ordinal parsing ' + i + ' month check');
- assert.equal(testMoment.date(), i,
- 'lenient ordinal parsing ' + i + ' date check');
- }
- });
-
- test('lenient ordinal parsing of number', function (assert) {
- var i, testMoment;
- for (i = 1; i <= 31; ++i) {
- testMoment = moment('2014 01 ' + i, 'YYYY MM Do');
- assert.equal(testMoment.year(), 2014,
- 'lenient ordinal parsing of number ' + i + ' year check');
- assert.equal(testMoment.month(), 0,
- 'lenient ordinal parsing of number ' + i + ' month check');
- assert.equal(testMoment.date(), i,
- 'lenient ordinal parsing of number ' + i + ' date check');
- }
- });
-
- test('strict ordinal parsing', function (assert) {
- var i, ordinalStr, testMoment;
- for (i = 1; i <= 31; ++i) {
- ordinalStr = moment([2014, 0, i]).format('YYYY MM Do');
- testMoment = moment(ordinalStr, 'YYYY MM Do', true);
- assert.ok(testMoment.isValid(), 'strict ordinal parsing ' + i);
- }
- });
-
}));
;(function (global, factory) {
@@ -27505,6 +38416,224 @@
typeof define === 'function' && define.amd ? define(['../../moment'], factory) :
factory(global.moment)
}(this, function (moment) { 'use strict';
+
+ function each(array, callback) {
+ var i;
+ for (i = 0; i < array.length; i++) {
+ callback(array[i], i, array);
+ }
+ }
+
+ function objectKeys(obj) {
+ if (Object.keys) {
+ return Object.keys(obj);
+ } else {
+ // IE8
+ var res = [], i;
+ for (i in obj) {
+ if (obj.hasOwnProperty(i)) {
+ res.push(i);
+ }
+ }
+ return res;
+ }
+ }
+
+ // Pick the first defined of two or three arguments.
+ function defaults(a, b, c) {
+ if (a != null) {
+ return a;
+ }
+ if (b != null) {
+ return b;
+ }
+ return c;
+ }
+
+ function defineCommonLocaleTests(locale, options) {
+ test('lenient ordinal parsing', function (assert) {
+ var i, ordinalStr, testMoment;
+ for (i = 1; i <= 31; ++i) {
+ ordinalStr = moment([2014, 0, i]).format('YYYY MM Do');
+ testMoment = moment(ordinalStr, 'YYYY MM Do');
+ assert.equal(testMoment.year(), 2014,
+ 'lenient ordinal parsing ' + i + ' year check');
+ assert.equal(testMoment.month(), 0,
+ 'lenient ordinal parsing ' + i + ' month check');
+ assert.equal(testMoment.date(), i,
+ 'lenient ordinal parsing ' + i + ' date check');
+ }
+ });
+
+ test('lenient ordinal parsing of number', function (assert) {
+ var i, testMoment;
+ for (i = 1; i <= 31; ++i) {
+ testMoment = moment('2014 01 ' + i, 'YYYY MM Do');
+ assert.equal(testMoment.year(), 2014,
+ 'lenient ordinal parsing of number ' + i + ' year check');
+ assert.equal(testMoment.month(), 0,
+ 'lenient ordinal parsing of number ' + i + ' month check');
+ assert.equal(testMoment.date(), i,
+ 'lenient ordinal parsing of number ' + i + ' date check');
+ }
+ });
+
+ test('strict ordinal parsing', function (assert) {
+ var i, ordinalStr, testMoment;
+ for (i = 1; i <= 31; ++i) {
+ ordinalStr = moment([2014, 0, i]).format('YYYY MM Do');
+ testMoment = moment(ordinalStr, 'YYYY MM Do', true);
+ assert.ok(testMoment.isValid(), 'strict ordinal parsing ' + i);
+ }
+ });
+
+ test('meridiem invariant', function (assert) {
+ var h, m, t1, t2;
+ for (h = 0; h < 24; ++h) {
+ for (m = 0; m < 60; m += 15) {
+ t1 = moment.utc([2000, 0, 1, h, m]);
+ t2 = moment.utc(t1.format('A h:mm'), 'A h:mm');
+ assert.equal(t2.format('HH:mm'), t1.format('HH:mm'),
+ 'meridiem at ' + t1.format('HH:mm'));
+ }
+ }
+ });
+
+ test('date format correctness', function (assert) {
+ var data, tokens;
+ data = moment.localeData()._longDateFormat;
+ tokens = objectKeys(data);
+ each(tokens, function (srchToken) {
+ // Check each format string to make sure it does not contain any
+ // tokens that need to be expanded.
+ each(tokens, function (baseToken) {
+ // strip escaped sequences
+ var format = data[baseToken].replace(/(\[[^\]]*\])/g, '');
+ assert.equal(false, !!~format.indexOf(srchToken),
+ 'contains ' + srchToken + ' in ' + baseToken);
+ });
+ });
+ });
+
+ test('month parsing correctness', function (assert) {
+ var i, m;
+
+ if (locale === 'tr') {
+ // I can't fix it :(
+ expect(0);
+ return;
+ }
+ function tester(format) {
+ var r;
+ r = moment(m.format(format), format);
+ assert.equal(r.month(), m.month(), 'month ' + i + ' fmt ' + format);
+ r = moment(m.format(format).toLocaleUpperCase(), format);
+ assert.equal(r.month(), m.month(), 'month ' + i + ' fmt ' + format + ' upper');
+ r = moment(m.format(format).toLocaleLowerCase(), format);
+ assert.equal(r.month(), m.month(), 'month ' + i + ' fmt ' + format + ' lower');
+
+ r = moment(m.format(format), format, true);
+ assert.equal(r.month(), m.month(), 'month ' + i + ' fmt ' + format + ' strict');
+ r = moment(m.format(format).toLocaleUpperCase(), format, true);
+ assert.equal(r.month(), m.month(), 'month ' + i + ' fmt ' + format + ' upper strict');
+ r = moment(m.format(format).toLocaleLowerCase(), format, true);
+ assert.equal(r.month(), m.month(), 'month ' + i + ' fmt ' + format + ' lower strict');
+ }
+
+ for (i = 0; i < 12; ++i) {
+ m = moment([2015, i, 15, 18]);
+ tester('MMM');
+ tester('MMM.');
+ tester('MMMM');
+ tester('MMMM.');
+ }
+ });
+
+ test('weekday parsing correctness', function (assert) {
+ var i, m;
+
+ if (locale === 'tr' || locale === 'az') {
+ // There is a lower-case letter (ı), that converted to upper then
+ // lower changes to i
+ expect(0);
+ return;
+ }
+ function tester(format) {
+ var r, baseMsg = 'weekday ' + m.weekday() + ' fmt ' + format;
+ r = moment(m.format(format), format);
+ assert.equal(r.weekday(), m.weekday(), baseMsg);
+ r = moment(m.format(format).toLocaleUpperCase(), format);
+ assert.equal(r.weekday(), m.weekday(), baseMsg + ' upper');
+ r = moment(m.format(format).toLocaleLowerCase(), format);
+ assert.equal(r.weekday(), m.weekday(), baseMsg + ' lower');
+
+ r = moment(m.format(format), format, true);
+ assert.equal(r.weekday(), m.weekday(), baseMsg + ' strict');
+ r = moment(m.format(format).toLocaleUpperCase(), format, true);
+ assert.equal(r.weekday(), m.weekday(), baseMsg + ' upper strict');
+ r = moment(m.format(format).toLocaleLowerCase(), format, true);
+ assert.equal(r.weekday(), m.weekday(), baseMsg + ' lower strict');
+ }
+
+ for (i = 0; i < 7; ++i) {
+ m = moment.utc([2015, i, 15, 18]);
+ tester('dd');
+ tester('ddd');
+ tester('dddd');
+ }
+ });
+ }
+
+ function setupDeprecationHandler(test, moment, scope) {
+ test._expectedDeprecations = null;
+ test._observedDeprecations = null;
+ test._oldSupress = moment.suppressDeprecationWarnings;
+ moment.suppressDeprecationWarnings = true;
+ test.expectedDeprecations = function () {
+ test._expectedDeprecations = arguments;
+ test._observedDeprecations = [];
+ };
+ moment.deprecationHandler = function (name, msg) {
+ var deprecationId = matchedDeprecation(name, msg, test._expectedDeprecations);
+ if (deprecationId === -1) {
+ throw new Error('Unexpected deprecation thrown name=' +
+ name + ' msg=' + msg);
+ }
+ test._observedDeprecations[deprecationId] = 1;
+ };
+ }
+
+ function teardownDeprecationHandler(test, moment, scope) {
+ moment.suppressDeprecationWarnings = test._oldSupress;
+
+ if (test._expectedDeprecations != null) {
+ var missedDeprecations = [];
+ each(test._expectedDeprecations, function (deprecationPattern, id) {
+ if (test._observedDeprecations[id] !== 1) {
+ missedDeprecations.push(deprecationPattern);
+ }
+ });
+ if (missedDeprecations.length !== 0) {
+ throw new Error('Expected deprecation warnings did not happen: ' +
+ missedDeprecations.join(' '));
+ }
+ }
+ }
+
+ function matchedDeprecation(name, msg, deprecations) {
+ if (deprecations == null) {
+ return -1;
+ }
+ for (var i = 0; i < deprecations.length; ++i) {
+ if (name != null && name === deprecations[i]) {
+ return i;
+ }
+ if (msg != null && msg.substring(0, deprecations[i].length) === deprecations[i]) {
+ return i;
+ }
+ }
+ return -1;
+ }
/*global QUnit:false*/
@@ -27519,11 +38648,13 @@
moment.createFromInputFallback = function (config) {
throw new Error('input not handled by moment: ' + config._i);
};
+ setupDeprecationHandler(test, moment, 'core');
if (lifecycle && lifecycle.setup) {
lifecycle.setup();
}
},
teardown : function () {
+ teardownDeprecationHandler(test, moment, 'core');
if (lifecycle && lifecycle.teardown) {
lifecycle.teardown();
}
@@ -27538,17 +38669,20 @@
moment.createFromInputFallback = function (config) {
throw new Error('input not handled by moment: ' + config._i);
};
+ setupDeprecationHandler(test, moment, 'locale');
if (lifecycle && lifecycle.setup) {
lifecycle.setup();
}
},
teardown : function () {
moment.locale('en');
+ teardownDeprecationHandler(test, moment, 'locale');
if (lifecycle && lifecycle.teardown) {
lifecycle.teardown();
}
}
});
+ defineCommonLocaleTests(name, -1, -1);
}
localeModule('si');
@@ -27704,14 +38838,14 @@
});
test('calendar day', function (assert) {
- var a = moment().hours(2).minutes(0).seconds(0);
-
- assert.equal(moment(a).calendar(), 'අද පෙ.ව. 2:00ට', 'today at the same time');
- assert.equal(moment(a).add({m: 25}).calendar(), 'අද පෙ.ව. 2:25ට', 'Now plus 25 min');
- assert.equal(moment(a).add({h: 1}).calendar(), 'අද පෙ.ව. 3:00ට', 'Now plus 1 hour');
- assert.equal(moment(a).add({d: 1}).calendar(), 'හෙට පෙ.ව. 2:00ට', 'tomorrow at the same time');
- assert.equal(moment(a).subtract({h: 1}).calendar(), 'අද පෙ.ව. 1:00ට', 'Now minus 1 hour');
- assert.equal(moment(a).subtract({d: 1}).calendar(), 'ඊයේ පෙ.ව. 2:00ට', 'yesterday at the same time');
+ var a = moment().hours(12).minutes(0).seconds(0);
+
+ assert.equal(moment(a).calendar(), 'අද ප.ව. 12:00ට', 'today at the same time');
+ assert.equal(moment(a).add({m: 25}).calendar(), 'අද ප.ව. 12:25ට', 'Now plus 25 min');
+ assert.equal(moment(a).add({h: 1}).calendar(), 'අද ප.ව. 1:00ට', 'Now plus 1 hour');
+ assert.equal(moment(a).add({d: 1}).calendar(), 'හෙට ප.ව. 12:00ට', 'tomorrow at the same time');
+ assert.equal(moment(a).subtract({h: 1}).calendar(), 'අද පෙ.ව. 11:00ට', 'Now minus 1 hour');
+ assert.equal(moment(a).subtract({d: 1}).calendar(), 'ඊයේ ප.ව. 12:00ට', 'yesterday at the same time');
});
test('calendar next week', function (assert) {
@@ -27753,42 +38887,6 @@
assert.equal(weeksFromNow.calendar(), weeksFromNow.format('L'), 'in 2 weeks');
});
- test('lenient ordinal parsing', function (assert) {
- var i, ordinalStr, testMoment;
- for (i = 1; i <= 31; ++i) {
- ordinalStr = moment([2014, 0, i]).format('YYYY MM Do');
- testMoment = moment(ordinalStr, 'YYYY MM Do');
- assert.equal(testMoment.year(), 2014,
- 'lenient ordinal parsing ' + i + ' year check');
- assert.equal(testMoment.month(), 0,
- 'lenient ordinal parsing ' + i + ' month check');
- assert.equal(testMoment.date(), i,
- 'lenient ordinal parsing ' + i + ' date check');
- }
- });
-
- test('lenient ordinal parsing of number', function (assert) {
- var i, testMoment;
- for (i = 1; i <= 31; ++i) {
- testMoment = moment('2014 01 ' + i, 'YYYY MM Do');
- assert.equal(testMoment.year(), 2014,
- 'lenient ordinal parsing of number ' + i + ' year check');
- assert.equal(testMoment.month(), 0,
- 'lenient ordinal parsing of number ' + i + ' month check');
- assert.equal(testMoment.date(), i,
- 'lenient ordinal parsing of number ' + i + ' date check');
- }
- });
-
- test('strict ordinal parsing', function (assert) {
- var i, ordinalStr, testMoment;
- for (i = 1; i <= 31; ++i) {
- ordinalStr = moment([2014, 0, i]).format('YYYY MM Do');
- testMoment = moment(ordinalStr, 'YYYY MM Do', true);
- assert.ok(testMoment.isValid(), 'strict ordinal parsing ' + i);
- }
- });
-
}));
;(function (global, factory) {
@@ -27797,6 +38895,224 @@
typeof define === 'function' && define.amd ? define(['../../moment'], factory) :
factory(global.moment)
}(this, function (moment) { 'use strict';
+
+ function each(array, callback) {
+ var i;
+ for (i = 0; i < array.length; i++) {
+ callback(array[i], i, array);
+ }
+ }
+
+ function objectKeys(obj) {
+ if (Object.keys) {
+ return Object.keys(obj);
+ } else {
+ // IE8
+ var res = [], i;
+ for (i in obj) {
+ if (obj.hasOwnProperty(i)) {
+ res.push(i);
+ }
+ }
+ return res;
+ }
+ }
+
+ // Pick the first defined of two or three arguments.
+ function defaults(a, b, c) {
+ if (a != null) {
+ return a;
+ }
+ if (b != null) {
+ return b;
+ }
+ return c;
+ }
+
+ function defineCommonLocaleTests(locale, options) {
+ test('lenient ordinal parsing', function (assert) {
+ var i, ordinalStr, testMoment;
+ for (i = 1; i <= 31; ++i) {
+ ordinalStr = moment([2014, 0, i]).format('YYYY MM Do');
+ testMoment = moment(ordinalStr, 'YYYY MM Do');
+ assert.equal(testMoment.year(), 2014,
+ 'lenient ordinal parsing ' + i + ' year check');
+ assert.equal(testMoment.month(), 0,
+ 'lenient ordinal parsing ' + i + ' month check');
+ assert.equal(testMoment.date(), i,
+ 'lenient ordinal parsing ' + i + ' date check');
+ }
+ });
+
+ test('lenient ordinal parsing of number', function (assert) {
+ var i, testMoment;
+ for (i = 1; i <= 31; ++i) {
+ testMoment = moment('2014 01 ' + i, 'YYYY MM Do');
+ assert.equal(testMoment.year(), 2014,
+ 'lenient ordinal parsing of number ' + i + ' year check');
+ assert.equal(testMoment.month(), 0,
+ 'lenient ordinal parsing of number ' + i + ' month check');
+ assert.equal(testMoment.date(), i,
+ 'lenient ordinal parsing of number ' + i + ' date check');
+ }
+ });
+
+ test('strict ordinal parsing', function (assert) {
+ var i, ordinalStr, testMoment;
+ for (i = 1; i <= 31; ++i) {
+ ordinalStr = moment([2014, 0, i]).format('YYYY MM Do');
+ testMoment = moment(ordinalStr, 'YYYY MM Do', true);
+ assert.ok(testMoment.isValid(), 'strict ordinal parsing ' + i);
+ }
+ });
+
+ test('meridiem invariant', function (assert) {
+ var h, m, t1, t2;
+ for (h = 0; h < 24; ++h) {
+ for (m = 0; m < 60; m += 15) {
+ t1 = moment.utc([2000, 0, 1, h, m]);
+ t2 = moment.utc(t1.format('A h:mm'), 'A h:mm');
+ assert.equal(t2.format('HH:mm'), t1.format('HH:mm'),
+ 'meridiem at ' + t1.format('HH:mm'));
+ }
+ }
+ });
+
+ test('date format correctness', function (assert) {
+ var data, tokens;
+ data = moment.localeData()._longDateFormat;
+ tokens = objectKeys(data);
+ each(tokens, function (srchToken) {
+ // Check each format string to make sure it does not contain any
+ // tokens that need to be expanded.
+ each(tokens, function (baseToken) {
+ // strip escaped sequences
+ var format = data[baseToken].replace(/(\[[^\]]*\])/g, '');
+ assert.equal(false, !!~format.indexOf(srchToken),
+ 'contains ' + srchToken + ' in ' + baseToken);
+ });
+ });
+ });
+
+ test('month parsing correctness', function (assert) {
+ var i, m;
+
+ if (locale === 'tr') {
+ // I can't fix it :(
+ expect(0);
+ return;
+ }
+ function tester(format) {
+ var r;
+ r = moment(m.format(format), format);
+ assert.equal(r.month(), m.month(), 'month ' + i + ' fmt ' + format);
+ r = moment(m.format(format).toLocaleUpperCase(), format);
+ assert.equal(r.month(), m.month(), 'month ' + i + ' fmt ' + format + ' upper');
+ r = moment(m.format(format).toLocaleLowerCase(), format);
+ assert.equal(r.month(), m.month(), 'month ' + i + ' fmt ' + format + ' lower');
+
+ r = moment(m.format(format), format, true);
+ assert.equal(r.month(), m.month(), 'month ' + i + ' fmt ' + format + ' strict');
+ r = moment(m.format(format).toLocaleUpperCase(), format, true);
+ assert.equal(r.month(), m.month(), 'month ' + i + ' fmt ' + format + ' upper strict');
+ r = moment(m.format(format).toLocaleLowerCase(), format, true);
+ assert.equal(r.month(), m.month(), 'month ' + i + ' fmt ' + format + ' lower strict');
+ }
+
+ for (i = 0; i < 12; ++i) {
+ m = moment([2015, i, 15, 18]);
+ tester('MMM');
+ tester('MMM.');
+ tester('MMMM');
+ tester('MMMM.');
+ }
+ });
+
+ test('weekday parsing correctness', function (assert) {
+ var i, m;
+
+ if (locale === 'tr' || locale === 'az') {
+ // There is a lower-case letter (ı), that converted to upper then
+ // lower changes to i
+ expect(0);
+ return;
+ }
+ function tester(format) {
+ var r, baseMsg = 'weekday ' + m.weekday() + ' fmt ' + format;
+ r = moment(m.format(format), format);
+ assert.equal(r.weekday(), m.weekday(), baseMsg);
+ r = moment(m.format(format).toLocaleUpperCase(), format);
+ assert.equal(r.weekday(), m.weekday(), baseMsg + ' upper');
+ r = moment(m.format(format).toLocaleLowerCase(), format);
+ assert.equal(r.weekday(), m.weekday(), baseMsg + ' lower');
+
+ r = moment(m.format(format), format, true);
+ assert.equal(r.weekday(), m.weekday(), baseMsg + ' strict');
+ r = moment(m.format(format).toLocaleUpperCase(), format, true);
+ assert.equal(r.weekday(), m.weekday(), baseMsg + ' upper strict');
+ r = moment(m.format(format).toLocaleLowerCase(), format, true);
+ assert.equal(r.weekday(), m.weekday(), baseMsg + ' lower strict');
+ }
+
+ for (i = 0; i < 7; ++i) {
+ m = moment.utc([2015, i, 15, 18]);
+ tester('dd');
+ tester('ddd');
+ tester('dddd');
+ }
+ });
+ }
+
+ function setupDeprecationHandler(test, moment, scope) {
+ test._expectedDeprecations = null;
+ test._observedDeprecations = null;
+ test._oldSupress = moment.suppressDeprecationWarnings;
+ moment.suppressDeprecationWarnings = true;
+ test.expectedDeprecations = function () {
+ test._expectedDeprecations = arguments;
+ test._observedDeprecations = [];
+ };
+ moment.deprecationHandler = function (name, msg) {
+ var deprecationId = matchedDeprecation(name, msg, test._expectedDeprecations);
+ if (deprecationId === -1) {
+ throw new Error('Unexpected deprecation thrown name=' +
+ name + ' msg=' + msg);
+ }
+ test._observedDeprecations[deprecationId] = 1;
+ };
+ }
+
+ function teardownDeprecationHandler(test, moment, scope) {
+ moment.suppressDeprecationWarnings = test._oldSupress;
+
+ if (test._expectedDeprecations != null) {
+ var missedDeprecations = [];
+ each(test._expectedDeprecations, function (deprecationPattern, id) {
+ if (test._observedDeprecations[id] !== 1) {
+ missedDeprecations.push(deprecationPattern);
+ }
+ });
+ if (missedDeprecations.length !== 0) {
+ throw new Error('Expected deprecation warnings did not happen: ' +
+ missedDeprecations.join(' '));
+ }
+ }
+ }
+
+ function matchedDeprecation(name, msg, deprecations) {
+ if (deprecations == null) {
+ return -1;
+ }
+ for (var i = 0; i < deprecations.length; ++i) {
+ if (name != null && name === deprecations[i]) {
+ return i;
+ }
+ if (msg != null && msg.substring(0, deprecations[i].length) === deprecations[i]) {
+ return i;
+ }
+ }
+ return -1;
+ }
/*global QUnit:false*/
@@ -27811,11 +39127,13 @@
moment.createFromInputFallback = function (config) {
throw new Error('input not handled by moment: ' + config._i);
};
+ setupDeprecationHandler(test, moment, 'core');
if (lifecycle && lifecycle.setup) {
lifecycle.setup();
}
},
teardown : function () {
+ teardownDeprecationHandler(test, moment, 'core');
if (lifecycle && lifecycle.teardown) {
lifecycle.teardown();
}
@@ -27830,17 +39148,20 @@
moment.createFromInputFallback = function (config) {
throw new Error('input not handled by moment: ' + config._i);
};
+ setupDeprecationHandler(test, moment, 'locale');
if (lifecycle && lifecycle.setup) {
lifecycle.setup();
}
},
teardown : function () {
moment.locale('en');
+ teardownDeprecationHandler(test, moment, 'locale');
if (lifecycle && lifecycle.teardown) {
lifecycle.teardown();
}
}
});
+ defineCommonLocaleTests(name, -1, -1);
}
localeModule('sk');
@@ -28027,14 +39348,14 @@
});
test('calendar day', function (assert) {
- var a = moment().hours(2).minutes(0).seconds(0);
-
- assert.equal(moment(a).calendar(), 'dnes o 2:00', 'today at the same time');
- assert.equal(moment(a).add({m: 25}).calendar(), 'dnes o 2:25', 'Now plus 25 min');
- assert.equal(moment(a).add({h: 1}).calendar(), 'dnes o 3:00', 'Now plus 1 hour');
- assert.equal(moment(a).add({d: 1}).calendar(), 'zajtra o 2:00', 'tomorrow at the same time');
- assert.equal(moment(a).subtract({h: 1}).calendar(), 'dnes o 1:00', 'Now minus 1 hour');
- assert.equal(moment(a).subtract({d: 1}).calendar(), 'včera o 2:00', 'yesterday at the same time');
+ var a = moment().hours(12).minutes(0).seconds(0);
+
+ assert.equal(moment(a).calendar(), 'dnes o 12:00', 'today at the same time');
+ assert.equal(moment(a).add({m: 25}).calendar(), 'dnes o 12:25', 'Now plus 25 min');
+ assert.equal(moment(a).add({h: 1}).calendar(), 'dnes o 13:00', 'Now plus 1 hour');
+ assert.equal(moment(a).add({d: 1}).calendar(), 'zajtra o 12:00', 'tomorrow at the same time');
+ assert.equal(moment(a).subtract({h: 1}).calendar(), 'dnes o 11:00', 'Now minus 1 hour');
+ assert.equal(moment(a).subtract({d: 1}).calendar(), 'včera o 12:00', 'yesterday at the same time');
});
test('calendar next week', function (assert) {
@@ -28130,67 +39451,6 @@
assert.equal(moment.duration(-1, 'minutes').humanize(true), 'pred minútou', 'a minute ago');
});
- test('weeks year starting sunday', function (assert) {
- assert.equal(moment([2012, 0, 1]).week(), 52, 'Jan 1 2012 should be week 52');
- assert.equal(moment([2012, 0, 2]).week(), 1, 'Jan 2 2012 should be week 1');
- assert.equal(moment([2012, 0, 8]).week(), 1, 'Jan 8 2012 should be week 1');
- assert.equal(moment([2012, 0, 9]).week(), 2, 'Jan 9 2012 should be week 2');
- assert.equal(moment([2012, 0, 15]).week(), 2, 'Jan 15 2012 should be week 2');
- });
-
- test('weeks year starting monday', function (assert) {
- assert.equal(moment([2007, 0, 1]).week(), 1, 'Jan 1 2007 should be week 1');
- assert.equal(moment([2007, 0, 7]).week(), 1, 'Jan 7 2007 should be week 1');
- assert.equal(moment([2007, 0, 8]).week(), 2, 'Jan 8 2007 should be week 2');
- assert.equal(moment([2007, 0, 14]).week(), 2, 'Jan 14 2007 should be week 2');
- assert.equal(moment([2007, 0, 15]).week(), 3, 'Jan 15 2007 should be week 3');
- });
-
- test('weeks year starting tuesday', function (assert) {
- assert.equal(moment([2007, 11, 31]).week(), 1, 'Dec 31 2007 should be week 1');
- assert.equal(moment([2008, 0, 1]).week(), 1, 'Jan 1 2008 should be week 1');
- assert.equal(moment([2008, 0, 6]).week(), 1, 'Jan 6 2008 should be week 1');
- assert.equal(moment([2008, 0, 7]).week(), 2, 'Jan 7 2008 should be week 2');
- assert.equal(moment([2008, 0, 13]).week(), 2, 'Jan 13 2008 should be week 2');
- assert.equal(moment([2008, 0, 14]).week(), 3, 'Jan 14 2008 should be week 3');
- });
-
- test('weeks year starting wednesday', function (assert) {
- assert.equal(moment([2002, 11, 30]).week(), 1, 'Dec 30 2002 should be week 1');
- assert.equal(moment([2003, 0, 1]).week(), 1, 'Jan 1 2003 should be week 1');
- assert.equal(moment([2003, 0, 5]).week(), 1, 'Jan 5 2003 should be week 1');
- assert.equal(moment([2003, 0, 6]).week(), 2, 'Jan 6 2003 should be week 2');
- assert.equal(moment([2003, 0, 12]).week(), 2, 'Jan 12 2003 should be week 2');
- assert.equal(moment([2003, 0, 13]).week(), 3, 'Jan 13 2003 should be week 3');
- });
-
- test('weeks year starting thursday', function (assert) {
- assert.equal(moment([2008, 11, 29]).week(), 1, 'Dec 29 2008 should be week 1');
- assert.equal(moment([2009, 0, 1]).week(), 1, 'Jan 1 2009 should be week 1');
- assert.equal(moment([2009, 0, 4]).week(), 1, 'Jan 4 2009 should be week 1');
- assert.equal(moment([2009, 0, 5]).week(), 2, 'Jan 5 2009 should be week 2');
- assert.equal(moment([2009, 0, 11]).week(), 2, 'Jan 11 2009 should be week 2');
- assert.equal(moment([2009, 0, 13]).week(), 3, 'Jan 12 2009 should be week 3');
- });
-
- test('weeks year starting friday', function (assert) {
- assert.equal(moment([2009, 11, 28]).week(), 53, 'Dec 28 2009 should be week 53');
- assert.equal(moment([2010, 0, 1]).week(), 53, 'Jan 1 2010 should be week 53');
- assert.equal(moment([2010, 0, 3]).week(), 53, 'Jan 3 2010 should be week 53');
- assert.equal(moment([2010, 0, 4]).week(), 1, 'Jan 4 2010 should be week 1');
- assert.equal(moment([2010, 0, 10]).week(), 1, 'Jan 10 2010 should be week 1');
- assert.equal(moment([2010, 0, 11]).week(), 2, 'Jan 11 2010 should be week 2');
- });
-
- test('weeks year starting saturday', function (assert) {
- assert.equal(moment([2010, 11, 27]).week(), 52, 'Dec 27 2010 should be week 52');
- assert.equal(moment([2011, 0, 1]).week(), 52, 'Jan 1 2011 should be week 52');
- assert.equal(moment([2011, 0, 2]).week(), 52, 'Jan 2 2011 should be week 52');
- assert.equal(moment([2011, 0, 3]).week(), 1, 'Jan 3 2011 should be week 1');
- assert.equal(moment([2011, 0, 9]).week(), 1, 'Jan 9 2011 should be week 1');
- assert.equal(moment([2011, 0, 10]).week(), 2, 'Jan 10 2011 should be week 2');
- });
-
test('weeks year starting sunday formatted', function (assert) {
assert.equal(moment([2012, 0, 1]).format('w ww wo'), '52 52 52.', 'Jan 1 2012 should be week 52');
assert.equal(moment([2012, 0, 2]).format('w ww wo'), '1 01 1.', 'Jan 2 2012 should be week 1');
@@ -28199,42 +39459,6 @@
assert.equal(moment([2012, 0, 15]).format('w ww wo'), '2 02 2.', 'Jan 15 2012 should be week 2');
});
- test('lenient ordinal parsing', function (assert) {
- var i, ordinalStr, testMoment;
- for (i = 1; i <= 31; ++i) {
- ordinalStr = moment([2014, 0, i]).format('YYYY MM Do');
- testMoment = moment(ordinalStr, 'YYYY MM Do');
- assert.equal(testMoment.year(), 2014,
- 'lenient ordinal parsing ' + i + ' year check');
- assert.equal(testMoment.month(), 0,
- 'lenient ordinal parsing ' + i + ' month check');
- assert.equal(testMoment.date(), i,
- 'lenient ordinal parsing ' + i + ' date check');
- }
- });
-
- test('lenient ordinal parsing of number', function (assert) {
- var i, testMoment;
- for (i = 1; i <= 31; ++i) {
- testMoment = moment('2014 01 ' + i, 'YYYY MM Do');
- assert.equal(testMoment.year(), 2014,
- 'lenient ordinal parsing of number ' + i + ' year check');
- assert.equal(testMoment.month(), 0,
- 'lenient ordinal parsing of number ' + i + ' month check');
- assert.equal(testMoment.date(), i,
- 'lenient ordinal parsing of number ' + i + ' date check');
- }
- });
-
- test('strict ordinal parsing', function (assert) {
- var i, ordinalStr, testMoment;
- for (i = 1; i <= 31; ++i) {
- ordinalStr = moment([2014, 0, i]).format('YYYY MM Do');
- testMoment = moment(ordinalStr, 'YYYY MM Do', true);
- assert.ok(testMoment.isValid(), 'strict ordinal parsing ' + i);
- }
- });
-
}));
;(function (global, factory) {
@@ -28243,6 +39467,224 @@
typeof define === 'function' && define.amd ? define(['../../moment'], factory) :
factory(global.moment)
}(this, function (moment) { 'use strict';
+
+ function each(array, callback) {
+ var i;
+ for (i = 0; i < array.length; i++) {
+ callback(array[i], i, array);
+ }
+ }
+
+ function objectKeys(obj) {
+ if (Object.keys) {
+ return Object.keys(obj);
+ } else {
+ // IE8
+ var res = [], i;
+ for (i in obj) {
+ if (obj.hasOwnProperty(i)) {
+ res.push(i);
+ }
+ }
+ return res;
+ }
+ }
+
+ // Pick the first defined of two or three arguments.
+ function defaults(a, b, c) {
+ if (a != null) {
+ return a;
+ }
+ if (b != null) {
+ return b;
+ }
+ return c;
+ }
+
+ function defineCommonLocaleTests(locale, options) {
+ test('lenient ordinal parsing', function (assert) {
+ var i, ordinalStr, testMoment;
+ for (i = 1; i <= 31; ++i) {
+ ordinalStr = moment([2014, 0, i]).format('YYYY MM Do');
+ testMoment = moment(ordinalStr, 'YYYY MM Do');
+ assert.equal(testMoment.year(), 2014,
+ 'lenient ordinal parsing ' + i + ' year check');
+ assert.equal(testMoment.month(), 0,
+ 'lenient ordinal parsing ' + i + ' month check');
+ assert.equal(testMoment.date(), i,
+ 'lenient ordinal parsing ' + i + ' date check');
+ }
+ });
+
+ test('lenient ordinal parsing of number', function (assert) {
+ var i, testMoment;
+ for (i = 1; i <= 31; ++i) {
+ testMoment = moment('2014 01 ' + i, 'YYYY MM Do');
+ assert.equal(testMoment.year(), 2014,
+ 'lenient ordinal parsing of number ' + i + ' year check');
+ assert.equal(testMoment.month(), 0,
+ 'lenient ordinal parsing of number ' + i + ' month check');
+ assert.equal(testMoment.date(), i,
+ 'lenient ordinal parsing of number ' + i + ' date check');
+ }
+ });
+
+ test('strict ordinal parsing', function (assert) {
+ var i, ordinalStr, testMoment;
+ for (i = 1; i <= 31; ++i) {
+ ordinalStr = moment([2014, 0, i]).format('YYYY MM Do');
+ testMoment = moment(ordinalStr, 'YYYY MM Do', true);
+ assert.ok(testMoment.isValid(), 'strict ordinal parsing ' + i);
+ }
+ });
+
+ test('meridiem invariant', function (assert) {
+ var h, m, t1, t2;
+ for (h = 0; h < 24; ++h) {
+ for (m = 0; m < 60; m += 15) {
+ t1 = moment.utc([2000, 0, 1, h, m]);
+ t2 = moment.utc(t1.format('A h:mm'), 'A h:mm');
+ assert.equal(t2.format('HH:mm'), t1.format('HH:mm'),
+ 'meridiem at ' + t1.format('HH:mm'));
+ }
+ }
+ });
+
+ test('date format correctness', function (assert) {
+ var data, tokens;
+ data = moment.localeData()._longDateFormat;
+ tokens = objectKeys(data);
+ each(tokens, function (srchToken) {
+ // Check each format string to make sure it does not contain any
+ // tokens that need to be expanded.
+ each(tokens, function (baseToken) {
+ // strip escaped sequences
+ var format = data[baseToken].replace(/(\[[^\]]*\])/g, '');
+ assert.equal(false, !!~format.indexOf(srchToken),
+ 'contains ' + srchToken + ' in ' + baseToken);
+ });
+ });
+ });
+
+ test('month parsing correctness', function (assert) {
+ var i, m;
+
+ if (locale === 'tr') {
+ // I can't fix it :(
+ expect(0);
+ return;
+ }
+ function tester(format) {
+ var r;
+ r = moment(m.format(format), format);
+ assert.equal(r.month(), m.month(), 'month ' + i + ' fmt ' + format);
+ r = moment(m.format(format).toLocaleUpperCase(), format);
+ assert.equal(r.month(), m.month(), 'month ' + i + ' fmt ' + format + ' upper');
+ r = moment(m.format(format).toLocaleLowerCase(), format);
+ assert.equal(r.month(), m.month(), 'month ' + i + ' fmt ' + format + ' lower');
+
+ r = moment(m.format(format), format, true);
+ assert.equal(r.month(), m.month(), 'month ' + i + ' fmt ' + format + ' strict');
+ r = moment(m.format(format).toLocaleUpperCase(), format, true);
+ assert.equal(r.month(), m.month(), 'month ' + i + ' fmt ' + format + ' upper strict');
+ r = moment(m.format(format).toLocaleLowerCase(), format, true);
+ assert.equal(r.month(), m.month(), 'month ' + i + ' fmt ' + format + ' lower strict');
+ }
+
+ for (i = 0; i < 12; ++i) {
+ m = moment([2015, i, 15, 18]);
+ tester('MMM');
+ tester('MMM.');
+ tester('MMMM');
+ tester('MMMM.');
+ }
+ });
+
+ test('weekday parsing correctness', function (assert) {
+ var i, m;
+
+ if (locale === 'tr' || locale === 'az') {
+ // There is a lower-case letter (ı), that converted to upper then
+ // lower changes to i
+ expect(0);
+ return;
+ }
+ function tester(format) {
+ var r, baseMsg = 'weekday ' + m.weekday() + ' fmt ' + format;
+ r = moment(m.format(format), format);
+ assert.equal(r.weekday(), m.weekday(), baseMsg);
+ r = moment(m.format(format).toLocaleUpperCase(), format);
+ assert.equal(r.weekday(), m.weekday(), baseMsg + ' upper');
+ r = moment(m.format(format).toLocaleLowerCase(), format);
+ assert.equal(r.weekday(), m.weekday(), baseMsg + ' lower');
+
+ r = moment(m.format(format), format, true);
+ assert.equal(r.weekday(), m.weekday(), baseMsg + ' strict');
+ r = moment(m.format(format).toLocaleUpperCase(), format, true);
+ assert.equal(r.weekday(), m.weekday(), baseMsg + ' upper strict');
+ r = moment(m.format(format).toLocaleLowerCase(), format, true);
+ assert.equal(r.weekday(), m.weekday(), baseMsg + ' lower strict');
+ }
+
+ for (i = 0; i < 7; ++i) {
+ m = moment.utc([2015, i, 15, 18]);
+ tester('dd');
+ tester('ddd');
+ tester('dddd');
+ }
+ });
+ }
+
+ function setupDeprecationHandler(test, moment, scope) {
+ test._expectedDeprecations = null;
+ test._observedDeprecations = null;
+ test._oldSupress = moment.suppressDeprecationWarnings;
+ moment.suppressDeprecationWarnings = true;
+ test.expectedDeprecations = function () {
+ test._expectedDeprecations = arguments;
+ test._observedDeprecations = [];
+ };
+ moment.deprecationHandler = function (name, msg) {
+ var deprecationId = matchedDeprecation(name, msg, test._expectedDeprecations);
+ if (deprecationId === -1) {
+ throw new Error('Unexpected deprecation thrown name=' +
+ name + ' msg=' + msg);
+ }
+ test._observedDeprecations[deprecationId] = 1;
+ };
+ }
+
+ function teardownDeprecationHandler(test, moment, scope) {
+ moment.suppressDeprecationWarnings = test._oldSupress;
+
+ if (test._expectedDeprecations != null) {
+ var missedDeprecations = [];
+ each(test._expectedDeprecations, function (deprecationPattern, id) {
+ if (test._observedDeprecations[id] !== 1) {
+ missedDeprecations.push(deprecationPattern);
+ }
+ });
+ if (missedDeprecations.length !== 0) {
+ throw new Error('Expected deprecation warnings did not happen: ' +
+ missedDeprecations.join(' '));
+ }
+ }
+ }
+
+ function matchedDeprecation(name, msg, deprecations) {
+ if (deprecations == null) {
+ return -1;
+ }
+ for (var i = 0; i < deprecations.length; ++i) {
+ if (name != null && name === deprecations[i]) {
+ return i;
+ }
+ if (msg != null && msg.substring(0, deprecations[i].length) === deprecations[i]) {
+ return i;
+ }
+ }
+ return -1;
+ }
/*global QUnit:false*/
@@ -28257,11 +39699,13 @@
moment.createFromInputFallback = function (config) {
throw new Error('input not handled by moment: ' + config._i);
};
+ setupDeprecationHandler(test, moment, 'core');
if (lifecycle && lifecycle.setup) {
lifecycle.setup();
}
},
teardown : function () {
+ teardownDeprecationHandler(test, moment, 'core');
if (lifecycle && lifecycle.teardown) {
lifecycle.teardown();
}
@@ -28276,17 +39720,20 @@
moment.createFromInputFallback = function (config) {
throw new Error('input not handled by moment: ' + config._i);
};
+ setupDeprecationHandler(test, moment, 'locale');
if (lifecycle && lifecycle.setup) {
lifecycle.setup();
}
},
teardown : function () {
moment.locale('en');
+ teardownDeprecationHandler(test, moment, 'locale');
if (lifecycle && lifecycle.teardown) {
lifecycle.teardown();
}
}
});
+ defineCommonLocaleTests(name, -1, -1);
}
localeModule('sl');
@@ -28530,14 +39977,14 @@
});
test('calendar day', function (assert) {
- var a = moment().hours(2).minutes(0).seconds(0);
-
- assert.equal(moment(a).calendar(), 'danes ob 2:00', 'today at the same time');
- assert.equal(moment(a).add({m: 25}).calendar(), 'danes ob 2:25', 'Now plus 25 min');
- assert.equal(moment(a).add({h: 1}).calendar(), 'danes ob 3:00', 'Now plus 1 hour');
- assert.equal(moment(a).add({d: 1}).calendar(), 'jutri ob 2:00', 'tomorrow at the same time');
- assert.equal(moment(a).subtract({h: 1}).calendar(), 'danes ob 1:00', 'Now minus 1 hour');
- assert.equal(moment(a).subtract({d: 1}).calendar(), 'včeraj ob 2:00', 'yesterday at the same time');
+ var a = moment().hours(12).minutes(0).seconds(0);
+
+ assert.equal(moment(a).calendar(), 'danes ob 12:00', 'today at the same time');
+ assert.equal(moment(a).add({m: 25}).calendar(), 'danes ob 12:25', 'Now plus 25 min');
+ assert.equal(moment(a).add({h: 1}).calendar(), 'danes ob 13:00', 'Now plus 1 hour');
+ assert.equal(moment(a).add({d: 1}).calendar(), 'jutri ob 12:00', 'tomorrow at the same time');
+ assert.equal(moment(a).subtract({h: 1}).calendar(), 'danes ob 11:00', 'Now minus 1 hour');
+ assert.equal(moment(a).subtract({d: 1}).calendar(), 'včeraj ob 12:00', 'yesterday at the same time');
});
test('calendar next week', function (assert) {
@@ -28612,67 +40059,6 @@
assert.equal(weeksFromNow.calendar(), weeksFromNow.format('L'), 'in 2 weeks');
});
- test('weeks year starting sunday', function (assert) {
- assert.equal(moment([2011, 11, 26]).week(), 1, 'Dec 26 2011 should be week 1');
- assert.equal(moment([2012, 0, 1]).week(), 1, 'Jan 1 2012 should be week 1');
- assert.equal(moment([2012, 0, 2]).week(), 2, 'Jan 2 2012 should be week 2');
- assert.equal(moment([2012, 0, 8]).week(), 2, 'Jan 8 2012 should be week 2');
- assert.equal(moment([2012, 0, 9]).week(), 3, 'Jan 9 2012 should be week 3');
- });
-
- test('weeks year starting monday', function (assert) {
- assert.equal(moment([2007, 0, 1]).week(), 1, 'Jan 1 2007 should be week 1');
- assert.equal(moment([2007, 0, 7]).week(), 1, 'Jan 7 2007 should be week 1');
- assert.equal(moment([2007, 0, 8]).week(), 2, 'Jan 8 2007 should be week 2');
- assert.equal(moment([2007, 0, 14]).week(), 2, 'Jan 14 2007 should be week 2');
- assert.equal(moment([2007, 0, 15]).week(), 3, 'Jan 15 2007 should be week 3');
- });
-
- test('weeks year starting tuesday', function (assert) {
- assert.equal(moment([2007, 11, 31]).week(), 1, 'Dec 31 2007 should be week 1');
- assert.equal(moment([2008, 0, 1]).week(), 1, 'Jan 1 2008 should be week 1');
- assert.equal(moment([2008, 0, 6]).week(), 1, 'Jan 6 2008 should be week 1');
- assert.equal(moment([2008, 0, 7]).week(), 2, 'Jan 7 2008 should be week 2');
- assert.equal(moment([2008, 0, 13]).week(), 2, 'Jan 13 2008 should be week 2');
- assert.equal(moment([2008, 0, 14]).week(), 3, 'Jan 14 2008 should be week 3');
- });
-
- test('weeks year starting wednesday', function (assert) {
- assert.equal(moment([2002, 11, 30]).week(), 1, 'Dec 30 2002 should be week 1');
- assert.equal(moment([2003, 0, 1]).week(), 1, 'Jan 1 2003 should be week 1');
- assert.equal(moment([2003, 0, 5]).week(), 1, 'Jan 5 2003 should be week 1');
- assert.equal(moment([2003, 0, 6]).week(), 2, 'Jan 6 2003 should be week 2');
- assert.equal(moment([2003, 0, 12]).week(), 2, 'Jan 12 2003 should be week 2');
- assert.equal(moment([2003, 0, 13]).week(), 3, 'Jan 13 2003 should be week 3');
- });
-
- test('weeks year starting thursday', function (assert) {
- assert.equal(moment([2008, 11, 29]).week(), 1, 'Dec 29 2008 should be week 1');
- assert.equal(moment([2009, 0, 1]).week(), 1, 'Jan 1 2009 should be week 1');
- assert.equal(moment([2009, 0, 4]).week(), 1, 'Jan 4 2009 should be week 1');
- assert.equal(moment([2009, 0, 5]).week(), 2, 'Jan 5 2009 should be week 2');
- assert.equal(moment([2009, 0, 11]).week(), 2, 'Jan 11 2009 should be week 2');
- assert.equal(moment([2009, 0, 12]).week(), 3, 'Jan 12 2009 should be week 3');
- });
-
- test('weeks year starting friday', function (assert) {
- assert.equal(moment([2009, 11, 28]).week(), 1, 'Dec 28 2009 should be week 1');
- assert.equal(moment([2010, 0, 1]).week(), 1, 'Jan 1 2010 should be week 1');
- assert.equal(moment([2010, 0, 3]).week(), 1, 'Jan 3 2010 should be week 1');
- assert.equal(moment([2010, 0, 4]).week(), 2, 'Jan 4 2010 should be week 2');
- assert.equal(moment([2010, 0, 10]).week(), 2, 'Jan 10 2010 should be week 2');
- assert.equal(moment([2010, 0, 11]).week(), 3, 'Jan 11 2010 should be week 3');
- });
-
- test('weeks year starting saturday', function (assert) {
- assert.equal(moment([2010, 11, 27]).week(), 1, 'Dec 27 2010 should be week 1');
- assert.equal(moment([2011, 0, 1]).week(), 1, 'Jan 1 2011 should be week 1');
- assert.equal(moment([2011, 0, 2]).week(), 1, 'Jan 2 2011 should be week 1');
- assert.equal(moment([2011, 0, 3]).week(), 2, 'Jan 3 2011 should be week 2');
- assert.equal(moment([2011, 0, 9]).week(), 2, 'Jan 9 2011 should be week 2');
- assert.equal(moment([2011, 0, 10]).week(), 3, 'Jan 10 2011 should be week 3');
- });
-
test('weeks year starting sunday formatted', function (assert) {
assert.equal(moment([2011, 11, 26]).format('w ww wo'), '1 01 1.', 'Dec 26 2011 should be week 1');
assert.equal(moment([2012, 0, 1]).format('w ww wo'), '1 01 1.', 'Jan 1 2012 should be week 1');
@@ -28681,42 +40067,6 @@
assert.equal(moment([2012, 0, 9]).format('w ww wo'), '3 03 3.', 'Jan 9 2012 should be week 3');
});
- test('lenient ordinal parsing', function (assert) {
- var i, ordinalStr, testMoment;
- for (i = 1; i <= 31; ++i) {
- ordinalStr = moment([2014, 0, i]).format('YYYY MM Do');
- testMoment = moment(ordinalStr, 'YYYY MM Do');
- assert.equal(testMoment.year(), 2014,
- 'lenient ordinal parsing ' + i + ' year check');
- assert.equal(testMoment.month(), 0,
- 'lenient ordinal parsing ' + i + ' month check');
- assert.equal(testMoment.date(), i,
- 'lenient ordinal parsing ' + i + ' date check');
- }
- });
-
- test('lenient ordinal parsing of number', function (assert) {
- var i, testMoment;
- for (i = 1; i <= 31; ++i) {
- testMoment = moment('2014 01 ' + i, 'YYYY MM Do');
- assert.equal(testMoment.year(), 2014,
- 'lenient ordinal parsing of number ' + i + ' year check');
- assert.equal(testMoment.month(), 0,
- 'lenient ordinal parsing of number ' + i + ' month check');
- assert.equal(testMoment.date(), i,
- 'lenient ordinal parsing of number ' + i + ' date check');
- }
- });
-
- test('strict ordinal parsing', function (assert) {
- var i, ordinalStr, testMoment;
- for (i = 1; i <= 31; ++i) {
- ordinalStr = moment([2014, 0, i]).format('YYYY MM Do');
- testMoment = moment(ordinalStr, 'YYYY MM Do', true);
- assert.ok(testMoment.isValid(), 'strict ordinal parsing ' + i);
- }
- });
-
}));
;(function (global, factory) {
@@ -28725,6 +40075,224 @@
typeof define === 'function' && define.amd ? define(['../../moment'], factory) :
factory(global.moment)
}(this, function (moment) { 'use strict';
+
+ function each(array, callback) {
+ var i;
+ for (i = 0; i < array.length; i++) {
+ callback(array[i], i, array);
+ }
+ }
+
+ function objectKeys(obj) {
+ if (Object.keys) {
+ return Object.keys(obj);
+ } else {
+ // IE8
+ var res = [], i;
+ for (i in obj) {
+ if (obj.hasOwnProperty(i)) {
+ res.push(i);
+ }
+ }
+ return res;
+ }
+ }
+
+ // Pick the first defined of two or three arguments.
+ function defaults(a, b, c) {
+ if (a != null) {
+ return a;
+ }
+ if (b != null) {
+ return b;
+ }
+ return c;
+ }
+
+ function defineCommonLocaleTests(locale, options) {
+ test('lenient ordinal parsing', function (assert) {
+ var i, ordinalStr, testMoment;
+ for (i = 1; i <= 31; ++i) {
+ ordinalStr = moment([2014, 0, i]).format('YYYY MM Do');
+ testMoment = moment(ordinalStr, 'YYYY MM Do');
+ assert.equal(testMoment.year(), 2014,
+ 'lenient ordinal parsing ' + i + ' year check');
+ assert.equal(testMoment.month(), 0,
+ 'lenient ordinal parsing ' + i + ' month check');
+ assert.equal(testMoment.date(), i,
+ 'lenient ordinal parsing ' + i + ' date check');
+ }
+ });
+
+ test('lenient ordinal parsing of number', function (assert) {
+ var i, testMoment;
+ for (i = 1; i <= 31; ++i) {
+ testMoment = moment('2014 01 ' + i, 'YYYY MM Do');
+ assert.equal(testMoment.year(), 2014,
+ 'lenient ordinal parsing of number ' + i + ' year check');
+ assert.equal(testMoment.month(), 0,
+ 'lenient ordinal parsing of number ' + i + ' month check');
+ assert.equal(testMoment.date(), i,
+ 'lenient ordinal parsing of number ' + i + ' date check');
+ }
+ });
+
+ test('strict ordinal parsing', function (assert) {
+ var i, ordinalStr, testMoment;
+ for (i = 1; i <= 31; ++i) {
+ ordinalStr = moment([2014, 0, i]).format('YYYY MM Do');
+ testMoment = moment(ordinalStr, 'YYYY MM Do', true);
+ assert.ok(testMoment.isValid(), 'strict ordinal parsing ' + i);
+ }
+ });
+
+ test('meridiem invariant', function (assert) {
+ var h, m, t1, t2;
+ for (h = 0; h < 24; ++h) {
+ for (m = 0; m < 60; m += 15) {
+ t1 = moment.utc([2000, 0, 1, h, m]);
+ t2 = moment.utc(t1.format('A h:mm'), 'A h:mm');
+ assert.equal(t2.format('HH:mm'), t1.format('HH:mm'),
+ 'meridiem at ' + t1.format('HH:mm'));
+ }
+ }
+ });
+
+ test('date format correctness', function (assert) {
+ var data, tokens;
+ data = moment.localeData()._longDateFormat;
+ tokens = objectKeys(data);
+ each(tokens, function (srchToken) {
+ // Check each format string to make sure it does not contain any
+ // tokens that need to be expanded.
+ each(tokens, function (baseToken) {
+ // strip escaped sequences
+ var format = data[baseToken].replace(/(\[[^\]]*\])/g, '');
+ assert.equal(false, !!~format.indexOf(srchToken),
+ 'contains ' + srchToken + ' in ' + baseToken);
+ });
+ });
+ });
+
+ test('month parsing correctness', function (assert) {
+ var i, m;
+
+ if (locale === 'tr') {
+ // I can't fix it :(
+ expect(0);
+ return;
+ }
+ function tester(format) {
+ var r;
+ r = moment(m.format(format), format);
+ assert.equal(r.month(), m.month(), 'month ' + i + ' fmt ' + format);
+ r = moment(m.format(format).toLocaleUpperCase(), format);
+ assert.equal(r.month(), m.month(), 'month ' + i + ' fmt ' + format + ' upper');
+ r = moment(m.format(format).toLocaleLowerCase(), format);
+ assert.equal(r.month(), m.month(), 'month ' + i + ' fmt ' + format + ' lower');
+
+ r = moment(m.format(format), format, true);
+ assert.equal(r.month(), m.month(), 'month ' + i + ' fmt ' + format + ' strict');
+ r = moment(m.format(format).toLocaleUpperCase(), format, true);
+ assert.equal(r.month(), m.month(), 'month ' + i + ' fmt ' + format + ' upper strict');
+ r = moment(m.format(format).toLocaleLowerCase(), format, true);
+ assert.equal(r.month(), m.month(), 'month ' + i + ' fmt ' + format + ' lower strict');
+ }
+
+ for (i = 0; i < 12; ++i) {
+ m = moment([2015, i, 15, 18]);
+ tester('MMM');
+ tester('MMM.');
+ tester('MMMM');
+ tester('MMMM.');
+ }
+ });
+
+ test('weekday parsing correctness', function (assert) {
+ var i, m;
+
+ if (locale === 'tr' || locale === 'az') {
+ // There is a lower-case letter (ı), that converted to upper then
+ // lower changes to i
+ expect(0);
+ return;
+ }
+ function tester(format) {
+ var r, baseMsg = 'weekday ' + m.weekday() + ' fmt ' + format;
+ r = moment(m.format(format), format);
+ assert.equal(r.weekday(), m.weekday(), baseMsg);
+ r = moment(m.format(format).toLocaleUpperCase(), format);
+ assert.equal(r.weekday(), m.weekday(), baseMsg + ' upper');
+ r = moment(m.format(format).toLocaleLowerCase(), format);
+ assert.equal(r.weekday(), m.weekday(), baseMsg + ' lower');
+
+ r = moment(m.format(format), format, true);
+ assert.equal(r.weekday(), m.weekday(), baseMsg + ' strict');
+ r = moment(m.format(format).toLocaleUpperCase(), format, true);
+ assert.equal(r.weekday(), m.weekday(), baseMsg + ' upper strict');
+ r = moment(m.format(format).toLocaleLowerCase(), format, true);
+ assert.equal(r.weekday(), m.weekday(), baseMsg + ' lower strict');
+ }
+
+ for (i = 0; i < 7; ++i) {
+ m = moment.utc([2015, i, 15, 18]);
+ tester('dd');
+ tester('ddd');
+ tester('dddd');
+ }
+ });
+ }
+
+ function setupDeprecationHandler(test, moment, scope) {
+ test._expectedDeprecations = null;
+ test._observedDeprecations = null;
+ test._oldSupress = moment.suppressDeprecationWarnings;
+ moment.suppressDeprecationWarnings = true;
+ test.expectedDeprecations = function () {
+ test._expectedDeprecations = arguments;
+ test._observedDeprecations = [];
+ };
+ moment.deprecationHandler = function (name, msg) {
+ var deprecationId = matchedDeprecation(name, msg, test._expectedDeprecations);
+ if (deprecationId === -1) {
+ throw new Error('Unexpected deprecation thrown name=' +
+ name + ' msg=' + msg);
+ }
+ test._observedDeprecations[deprecationId] = 1;
+ };
+ }
+
+ function teardownDeprecationHandler(test, moment, scope) {
+ moment.suppressDeprecationWarnings = test._oldSupress;
+
+ if (test._expectedDeprecations != null) {
+ var missedDeprecations = [];
+ each(test._expectedDeprecations, function (deprecationPattern, id) {
+ if (test._observedDeprecations[id] !== 1) {
+ missedDeprecations.push(deprecationPattern);
+ }
+ });
+ if (missedDeprecations.length !== 0) {
+ throw new Error('Expected deprecation warnings did not happen: ' +
+ missedDeprecations.join(' '));
+ }
+ }
+ }
+
+ function matchedDeprecation(name, msg, deprecations) {
+ if (deprecations == null) {
+ return -1;
+ }
+ for (var i = 0; i < deprecations.length; ++i) {
+ if (name != null && name === deprecations[i]) {
+ return i;
+ }
+ if (msg != null && msg.substring(0, deprecations[i].length) === deprecations[i]) {
+ return i;
+ }
+ }
+ return -1;
+ }
/*global QUnit:false*/
@@ -28739,11 +40307,13 @@
moment.createFromInputFallback = function (config) {
throw new Error('input not handled by moment: ' + config._i);
};
+ setupDeprecationHandler(test, moment, 'core');
if (lifecycle && lifecycle.setup) {
lifecycle.setup();
}
},
teardown : function () {
+ teardownDeprecationHandler(test, moment, 'core');
if (lifecycle && lifecycle.teardown) {
lifecycle.teardown();
}
@@ -28758,17 +40328,20 @@
moment.createFromInputFallback = function (config) {
throw new Error('input not handled by moment: ' + config._i);
};
+ setupDeprecationHandler(test, moment, 'locale');
if (lifecycle && lifecycle.setup) {
lifecycle.setup();
}
},
teardown : function () {
moment.locale('en');
+ teardownDeprecationHandler(test, moment, 'locale');
if (lifecycle && lifecycle.teardown) {
lifecycle.teardown();
}
}
});
+ defineCommonLocaleTests(name, -1, -1);
}
localeModule('sq');
@@ -28936,14 +40509,14 @@
});
test('calendar day', function (assert) {
- var a = moment().hours(2).minutes(0).seconds(0);
-
- assert.equal(moment(a).calendar(), 'Sot në 02:00', 'today at the same time');
- assert.equal(moment(a).add({m: 25}).calendar(), 'Sot në 02:25', 'Now plus 25 min');
- assert.equal(moment(a).add({h: 1}).calendar(), 'Sot në 03:00', 'Now plus 1 hour');
- assert.equal(moment(a).add({d: 1}).calendar(), 'Nesër në 02:00', 'tomorrow at the same time');
- assert.equal(moment(a).subtract({h: 1}).calendar(), 'Sot në 01:00', 'Now minus 1 hour');
- assert.equal(moment(a).subtract({d: 1}).calendar(), 'Dje në 02:00', 'yesterday at the same time');
+ var a = moment().hours(12).minutes(0).seconds(0);
+
+ assert.equal(moment(a).calendar(), 'Sot në 12:00', 'today at the same time');
+ assert.equal(moment(a).add({m: 25}).calendar(), 'Sot në 12:25', 'Now plus 25 min');
+ assert.equal(moment(a).add({h: 1}).calendar(), 'Sot në 13:00', 'Now plus 1 hour');
+ assert.equal(moment(a).add({d: 1}).calendar(), 'Nesër në 12:00', 'tomorrow at the same time');
+ assert.equal(moment(a).subtract({h: 1}).calendar(), 'Sot në 11:00', 'Now minus 1 hour');
+ assert.equal(moment(a).subtract({d: 1}).calendar(), 'Dje në 12:00', 'yesterday at the same time');
});
test('calendar next week', function (assert) {
@@ -28986,67 +40559,6 @@
assert.equal(weeksFromNow.calendar(), weeksFromNow.format('L'), 'in 2 weeks');
});
- test('weeks year starting sunday', function (assert) {
- assert.equal(moment([2012, 0, 1]).week(), 52, 'Jan 1 2012 should be week 52');
- assert.equal(moment([2012, 0, 2]).week(), 1, 'Jan 2 2012 should be week 1');
- assert.equal(moment([2012, 0, 8]).week(), 1, 'Jan 8 2012 should be week 1');
- assert.equal(moment([2012, 0, 9]).week(), 2, 'Jan 9 2012 should be week 2');
- assert.equal(moment([2012, 0, 15]).week(), 2, 'Jan 15 2012 should be week 2');
- });
-
- test('weeks year starting monday', function (assert) {
- assert.equal(moment([2007, 0, 1]).week(), 1, 'Jan 1 2007 should be week 1');
- assert.equal(moment([2007, 0, 7]).week(), 1, 'Jan 7 2007 should be week 1');
- assert.equal(moment([2007, 0, 8]).week(), 2, 'Jan 8 2007 should be week 2');
- assert.equal(moment([2007, 0, 14]).week(), 2, 'Jan 14 2007 should be week 2');
- assert.equal(moment([2007, 0, 15]).week(), 3, 'Jan 15 2007 should be week 3');
- });
-
- test('weeks year starting tuesday', function (assert) {
- assert.equal(moment([2007, 11, 31]).week(), 1, 'Dec 31 2007 should be week 1');
- assert.equal(moment([2008, 0, 1]).week(), 1, 'Jan 1 2008 should be week 1');
- assert.equal(moment([2008, 0, 6]).week(), 1, 'Jan 6 2008 should be week 1');
- assert.equal(moment([2008, 0, 7]).week(), 2, 'Jan 7 2008 should be week 2');
- assert.equal(moment([2008, 0, 13]).week(), 2, 'Jan 13 2008 should be week 2');
- assert.equal(moment([2008, 0, 14]).week(), 3, 'Jan 14 2008 should be week 3');
- });
-
- test('weeks year starting wednesday', function (assert) {
- assert.equal(moment([2002, 11, 30]).week(), 1, 'Dec 30 2002 should be week 1');
- assert.equal(moment([2003, 0, 1]).week(), 1, 'Jan 1 2003 should be week 1');
- assert.equal(moment([2003, 0, 5]).week(), 1, 'Jan 5 2003 should be week 1');
- assert.equal(moment([2003, 0, 6]).week(), 2, 'Jan 6 2003 should be week 2');
- assert.equal(moment([2003, 0, 12]).week(), 2, 'Jan 12 2003 should be week 2');
- assert.equal(moment([2003, 0, 13]).week(), 3, 'Jan 13 2003 should be week 3');
- });
-
- test('weeks year starting thursday', function (assert) {
- assert.equal(moment([2008, 11, 29]).week(), 1, 'Dec 29 2008 should be week 1');
- assert.equal(moment([2009, 0, 1]).week(), 1, 'Jan 1 2009 should be week 1');
- assert.equal(moment([2009, 0, 4]).week(), 1, 'Jan 4 2009 should be week 1');
- assert.equal(moment([2009, 0, 5]).week(), 2, 'Jan 5 2009 should be week 2');
- assert.equal(moment([2009, 0, 11]).week(), 2, 'Jan 11 2009 should be week 2');
- assert.equal(moment([2009, 0, 13]).week(), 3, 'Jan 12 2009 should be week 3');
- });
-
- test('weeks year starting friday', function (assert) {
- assert.equal(moment([2009, 11, 28]).week(), 53, 'Dec 28 2009 should be week 53');
- assert.equal(moment([2010, 0, 1]).week(), 53, 'Jan 1 2010 should be week 53');
- assert.equal(moment([2010, 0, 3]).week(), 53, 'Jan 3 2010 should be week 53');
- assert.equal(moment([2010, 0, 4]).week(), 1, 'Jan 4 2010 should be week 1');
- assert.equal(moment([2010, 0, 10]).week(), 1, 'Jan 10 2010 should be week 1');
- assert.equal(moment([2010, 0, 11]).week(), 2, 'Jan 11 2010 should be week 2');
- });
-
- test('weeks year starting saturday', function (assert) {
- assert.equal(moment([2010, 11, 27]).week(), 52, 'Dec 27 2010 should be week 52');
- assert.equal(moment([2011, 0, 1]).week(), 52, 'Jan 1 2011 should be week 52');
- assert.equal(moment([2011, 0, 2]).week(), 52, 'Jan 2 2011 should be week 52');
- assert.equal(moment([2011, 0, 3]).week(), 1, 'Jan 3 2011 should be week 1');
- assert.equal(moment([2011, 0, 9]).week(), 1, 'Jan 9 2011 should be week 1');
- assert.equal(moment([2011, 0, 10]).week(), 2, 'Jan 10 2011 should be week 2');
- });
-
test('weeks year starting sunday formatted', function (assert) {
assert.equal(moment([2012, 0, 1]).format('w ww wo'), '52 52 52.', 'Jan 1 2012 should be week 52');
assert.equal(moment([2012, 0, 2]).format('w ww wo'), '1 01 1.', 'Jan 2 2012 should be week 1');
@@ -29055,42 +40567,6 @@
assert.equal(moment([2012, 0, 15]).format('w ww wo'), '2 02 2.', 'Jan 15 2012 should be week 2');
});
- test('lenient ordinal parsing', function (assert) {
- var i, ordinalStr, testMoment;
- for (i = 1; i <= 31; ++i) {
- ordinalStr = moment([2014, 0, i]).format('YYYY MM Do');
- testMoment = moment(ordinalStr, 'YYYY MM Do');
- assert.equal(testMoment.year(), 2014,
- 'lenient ordinal parsing ' + i + ' year check');
- assert.equal(testMoment.month(), 0,
- 'lenient ordinal parsing ' + i + ' month check');
- assert.equal(testMoment.date(), i,
- 'lenient ordinal parsing ' + i + ' date check');
- }
- });
-
- test('lenient ordinal parsing of number', function (assert) {
- var i, testMoment;
- for (i = 1; i <= 31; ++i) {
- testMoment = moment('2014 01 ' + i, 'YYYY MM Do');
- assert.equal(testMoment.year(), 2014,
- 'lenient ordinal parsing of number ' + i + ' year check');
- assert.equal(testMoment.month(), 0,
- 'lenient ordinal parsing of number ' + i + ' month check');
- assert.equal(testMoment.date(), i,
- 'lenient ordinal parsing of number ' + i + ' date check');
- }
- });
-
- test('strict ordinal parsing', function (assert) {
- var i, ordinalStr, testMoment;
- for (i = 1; i <= 31; ++i) {
- ordinalStr = moment([2014, 0, i]).format('YYYY MM Do');
- testMoment = moment(ordinalStr, 'YYYY MM Do', true);
- assert.ok(testMoment.isValid(), 'strict ordinal parsing ' + i);
- }
- });
-
}));
;(function (global, factory) {
@@ -29099,6 +40575,224 @@
typeof define === 'function' && define.amd ? define(['../../moment'], factory) :
factory(global.moment)
}(this, function (moment) { 'use strict';
+
+ function each(array, callback) {
+ var i;
+ for (i = 0; i < array.length; i++) {
+ callback(array[i], i, array);
+ }
+ }
+
+ function objectKeys(obj) {
+ if (Object.keys) {
+ return Object.keys(obj);
+ } else {
+ // IE8
+ var res = [], i;
+ for (i in obj) {
+ if (obj.hasOwnProperty(i)) {
+ res.push(i);
+ }
+ }
+ return res;
+ }
+ }
+
+ // Pick the first defined of two or three arguments.
+ function defaults(a, b, c) {
+ if (a != null) {
+ return a;
+ }
+ if (b != null) {
+ return b;
+ }
+ return c;
+ }
+
+ function defineCommonLocaleTests(locale, options) {
+ test('lenient ordinal parsing', function (assert) {
+ var i, ordinalStr, testMoment;
+ for (i = 1; i <= 31; ++i) {
+ ordinalStr = moment([2014, 0, i]).format('YYYY MM Do');
+ testMoment = moment(ordinalStr, 'YYYY MM Do');
+ assert.equal(testMoment.year(), 2014,
+ 'lenient ordinal parsing ' + i + ' year check');
+ assert.equal(testMoment.month(), 0,
+ 'lenient ordinal parsing ' + i + ' month check');
+ assert.equal(testMoment.date(), i,
+ 'lenient ordinal parsing ' + i + ' date check');
+ }
+ });
+
+ test('lenient ordinal parsing of number', function (assert) {
+ var i, testMoment;
+ for (i = 1; i <= 31; ++i) {
+ testMoment = moment('2014 01 ' + i, 'YYYY MM Do');
+ assert.equal(testMoment.year(), 2014,
+ 'lenient ordinal parsing of number ' + i + ' year check');
+ assert.equal(testMoment.month(), 0,
+ 'lenient ordinal parsing of number ' + i + ' month check');
+ assert.equal(testMoment.date(), i,
+ 'lenient ordinal parsing of number ' + i + ' date check');
+ }
+ });
+
+ test('strict ordinal parsing', function (assert) {
+ var i, ordinalStr, testMoment;
+ for (i = 1; i <= 31; ++i) {
+ ordinalStr = moment([2014, 0, i]).format('YYYY MM Do');
+ testMoment = moment(ordinalStr, 'YYYY MM Do', true);
+ assert.ok(testMoment.isValid(), 'strict ordinal parsing ' + i);
+ }
+ });
+
+ test('meridiem invariant', function (assert) {
+ var h, m, t1, t2;
+ for (h = 0; h < 24; ++h) {
+ for (m = 0; m < 60; m += 15) {
+ t1 = moment.utc([2000, 0, 1, h, m]);
+ t2 = moment.utc(t1.format('A h:mm'), 'A h:mm');
+ assert.equal(t2.format('HH:mm'), t1.format('HH:mm'),
+ 'meridiem at ' + t1.format('HH:mm'));
+ }
+ }
+ });
+
+ test('date format correctness', function (assert) {
+ var data, tokens;
+ data = moment.localeData()._longDateFormat;
+ tokens = objectKeys(data);
+ each(tokens, function (srchToken) {
+ // Check each format string to make sure it does not contain any
+ // tokens that need to be expanded.
+ each(tokens, function (baseToken) {
+ // strip escaped sequences
+ var format = data[baseToken].replace(/(\[[^\]]*\])/g, '');
+ assert.equal(false, !!~format.indexOf(srchToken),
+ 'contains ' + srchToken + ' in ' + baseToken);
+ });
+ });
+ });
+
+ test('month parsing correctness', function (assert) {
+ var i, m;
+
+ if (locale === 'tr') {
+ // I can't fix it :(
+ expect(0);
+ return;
+ }
+ function tester(format) {
+ var r;
+ r = moment(m.format(format), format);
+ assert.equal(r.month(), m.month(), 'month ' + i + ' fmt ' + format);
+ r = moment(m.format(format).toLocaleUpperCase(), format);
+ assert.equal(r.month(), m.month(), 'month ' + i + ' fmt ' + format + ' upper');
+ r = moment(m.format(format).toLocaleLowerCase(), format);
+ assert.equal(r.month(), m.month(), 'month ' + i + ' fmt ' + format + ' lower');
+
+ r = moment(m.format(format), format, true);
+ assert.equal(r.month(), m.month(), 'month ' + i + ' fmt ' + format + ' strict');
+ r = moment(m.format(format).toLocaleUpperCase(), format, true);
+ assert.equal(r.month(), m.month(), 'month ' + i + ' fmt ' + format + ' upper strict');
+ r = moment(m.format(format).toLocaleLowerCase(), format, true);
+ assert.equal(r.month(), m.month(), 'month ' + i + ' fmt ' + format + ' lower strict');
+ }
+
+ for (i = 0; i < 12; ++i) {
+ m = moment([2015, i, 15, 18]);
+ tester('MMM');
+ tester('MMM.');
+ tester('MMMM');
+ tester('MMMM.');
+ }
+ });
+
+ test('weekday parsing correctness', function (assert) {
+ var i, m;
+
+ if (locale === 'tr' || locale === 'az') {
+ // There is a lower-case letter (ı), that converted to upper then
+ // lower changes to i
+ expect(0);
+ return;
+ }
+ function tester(format) {
+ var r, baseMsg = 'weekday ' + m.weekday() + ' fmt ' + format;
+ r = moment(m.format(format), format);
+ assert.equal(r.weekday(), m.weekday(), baseMsg);
+ r = moment(m.format(format).toLocaleUpperCase(), format);
+ assert.equal(r.weekday(), m.weekday(), baseMsg + ' upper');
+ r = moment(m.format(format).toLocaleLowerCase(), format);
+ assert.equal(r.weekday(), m.weekday(), baseMsg + ' lower');
+
+ r = moment(m.format(format), format, true);
+ assert.equal(r.weekday(), m.weekday(), baseMsg + ' strict');
+ r = moment(m.format(format).toLocaleUpperCase(), format, true);
+ assert.equal(r.weekday(), m.weekday(), baseMsg + ' upper strict');
+ r = moment(m.format(format).toLocaleLowerCase(), format, true);
+ assert.equal(r.weekday(), m.weekday(), baseMsg + ' lower strict');
+ }
+
+ for (i = 0; i < 7; ++i) {
+ m = moment.utc([2015, i, 15, 18]);
+ tester('dd');
+ tester('ddd');
+ tester('dddd');
+ }
+ });
+ }
+
+ function setupDeprecationHandler(test, moment, scope) {
+ test._expectedDeprecations = null;
+ test._observedDeprecations = null;
+ test._oldSupress = moment.suppressDeprecationWarnings;
+ moment.suppressDeprecationWarnings = true;
+ test.expectedDeprecations = function () {
+ test._expectedDeprecations = arguments;
+ test._observedDeprecations = [];
+ };
+ moment.deprecationHandler = function (name, msg) {
+ var deprecationId = matchedDeprecation(name, msg, test._expectedDeprecations);
+ if (deprecationId === -1) {
+ throw new Error('Unexpected deprecation thrown name=' +
+ name + ' msg=' + msg);
+ }
+ test._observedDeprecations[deprecationId] = 1;
+ };
+ }
+
+ function teardownDeprecationHandler(test, moment, scope) {
+ moment.suppressDeprecationWarnings = test._oldSupress;
+
+ if (test._expectedDeprecations != null) {
+ var missedDeprecations = [];
+ each(test._expectedDeprecations, function (deprecationPattern, id) {
+ if (test._observedDeprecations[id] !== 1) {
+ missedDeprecations.push(deprecationPattern);
+ }
+ });
+ if (missedDeprecations.length !== 0) {
+ throw new Error('Expected deprecation warnings did not happen: ' +
+ missedDeprecations.join(' '));
+ }
+ }
+ }
+
+ function matchedDeprecation(name, msg, deprecations) {
+ if (deprecations == null) {
+ return -1;
+ }
+ for (var i = 0; i < deprecations.length; ++i) {
+ if (name != null && name === deprecations[i]) {
+ return i;
+ }
+ if (msg != null && msg.substring(0, deprecations[i].length) === deprecations[i]) {
+ return i;
+ }
+ }
+ return -1;
+ }
/*global QUnit:false*/
@@ -29113,11 +40807,13 @@
moment.createFromInputFallback = function (config) {
throw new Error('input not handled by moment: ' + config._i);
};
+ setupDeprecationHandler(test, moment, 'core');
if (lifecycle && lifecycle.setup) {
lifecycle.setup();
}
},
teardown : function () {
+ teardownDeprecationHandler(test, moment, 'core');
if (lifecycle && lifecycle.teardown) {
lifecycle.teardown();
}
@@ -29132,17 +40828,20 @@
moment.createFromInputFallback = function (config) {
throw new Error('input not handled by moment: ' + config._i);
};
+ setupDeprecationHandler(test, moment, 'locale');
if (lifecycle && lifecycle.setup) {
lifecycle.setup();
}
},
teardown : function () {
moment.locale('en');
+ teardownDeprecationHandler(test, moment, 'locale');
if (lifecycle && lifecycle.teardown) {
lifecycle.teardown();
}
}
});
+ defineCommonLocaleTests(name, -1, -1);
}
localeModule('sr-cyrl');
@@ -29299,14 +40998,14 @@
});
test('calendar day', function (assert) {
- var a = moment().hours(2).minutes(0).seconds(0);
-
- assert.equal(moment(a).calendar(), 'данас у 2:00', 'today at the same time');
- assert.equal(moment(a).add({m: 25}).calendar(), 'данас у 2:25', 'Now plus 25 min');
- assert.equal(moment(a).add({h: 1}).calendar(), 'данас у 3:00', 'Now plus 1 hour');
- assert.equal(moment(a).add({d: 1}).calendar(), 'сутра у 2:00', 'tomorrow at the same time');
- assert.equal(moment(a).subtract({h: 1}).calendar(), 'данас у 1:00', 'Now minus 1 hour');
- assert.equal(moment(a).subtract({d: 1}).calendar(), 'јуче у 2:00', 'yesterday at the same time');
+ var a = moment().hours(12).minutes(0).seconds(0);
+
+ assert.equal(moment(a).calendar(), 'данас у 12:00', 'today at the same time');
+ assert.equal(moment(a).add({m: 25}).calendar(), 'данас у 12:25', 'Now plus 25 min');
+ assert.equal(moment(a).add({h: 1}).calendar(), 'данас у 13:00', 'Now plus 1 hour');
+ assert.equal(moment(a).add({d: 1}).calendar(), 'сутра у 12:00', 'tomorrow at the same time');
+ assert.equal(moment(a).subtract({h: 1}).calendar(), 'данас у 11:00', 'Now minus 1 hour');
+ assert.equal(moment(a).subtract({d: 1}).calendar(), 'јуче у 12:00', 'yesterday at the same time');
});
test('calendar next week', function (assert) {
@@ -29379,67 +41078,6 @@
assert.equal(weeksFromNow.calendar(), weeksFromNow.format('L'), 'in 2 weeks');
});
- test('weeks year starting sunday', function (assert) {
- assert.equal(moment([2011, 11, 26]).week(), 1, 'Dec 26 2011 should be week 1');
- assert.equal(moment([2012, 0, 1]).week(), 1, 'Jan 1 2012 should be week 1');
- assert.equal(moment([2012, 0, 2]).week(), 2, 'Jan 2 2012 should be week 2');
- assert.equal(moment([2012, 0, 8]).week(), 2, 'Jan 8 2012 should be week 2');
- assert.equal(moment([2012, 0, 9]).week(), 3, 'Jan 9 2012 should be week 3');
- });
-
- test('weeks year starting monday', function (assert) {
- assert.equal(moment([2007, 0, 1]).week(), 1, 'Jan 1 2007 should be week 1');
- assert.equal(moment([2007, 0, 7]).week(), 1, 'Jan 7 2007 should be week 1');
- assert.equal(moment([2007, 0, 8]).week(), 2, 'Jan 8 2007 should be week 2');
- assert.equal(moment([2007, 0, 14]).week(), 2, 'Jan 14 2007 should be week 2');
- assert.equal(moment([2007, 0, 15]).week(), 3, 'Jan 15 2007 should be week 3');
- });
-
- test('weeks year starting tuesday', function (assert) {
- assert.equal(moment([2007, 11, 31]).week(), 1, 'Dec 31 2007 should be week 1');
- assert.equal(moment([2008, 0, 1]).week(), 1, 'Jan 1 2008 should be week 1');
- assert.equal(moment([2008, 0, 6]).week(), 1, 'Jan 6 2008 should be week 1');
- assert.equal(moment([2008, 0, 7]).week(), 2, 'Jan 7 2008 should be week 2');
- assert.equal(moment([2008, 0, 13]).week(), 2, 'Jan 13 2008 should be week 2');
- assert.equal(moment([2008, 0, 14]).week(), 3, 'Jan 14 2008 should be week 3');
- });
-
- test('weeks year starting wednesday', function (assert) {
- assert.equal(moment([2002, 11, 30]).week(), 1, 'Dec 30 2002 should be week 1');
- assert.equal(moment([2003, 0, 1]).week(), 1, 'Jan 1 2003 should be week 1');
- assert.equal(moment([2003, 0, 5]).week(), 1, 'Jan 5 2003 should be week 1');
- assert.equal(moment([2003, 0, 6]).week(), 2, 'Jan 6 2003 should be week 2');
- assert.equal(moment([2003, 0, 12]).week(), 2, 'Jan 12 2003 should be week 2');
- assert.equal(moment([2003, 0, 13]).week(), 3, 'Jan 13 2003 should be week 3');
- });
-
- test('weeks year starting thursday', function (assert) {
- assert.equal(moment([2008, 11, 29]).week(), 1, 'Dec 29 2008 should be week 1');
- assert.equal(moment([2009, 0, 1]).week(), 1, 'Jan 1 2009 should be week 1');
- assert.equal(moment([2009, 0, 4]).week(), 1, 'Jan 4 2009 should be week 1');
- assert.equal(moment([2009, 0, 5]).week(), 2, 'Jan 5 2009 should be week 2');
- assert.equal(moment([2009, 0, 11]).week(), 2, 'Jan 11 2009 should be week 2');
- assert.equal(moment([2009, 0, 12]).week(), 3, 'Jan 12 2009 should be week 3');
- });
-
- test('weeks year starting friday', function (assert) {
- assert.equal(moment([2009, 11, 28]).week(), 1, 'Dec 28 2009 should be week 1');
- assert.equal(moment([2010, 0, 1]).week(), 1, 'Jan 1 2010 should be week 1');
- assert.equal(moment([2010, 0, 3]).week(), 1, 'Jan 3 2010 should be week 1');
- assert.equal(moment([2010, 0, 4]).week(), 2, 'Jan 4 2010 should be week 2');
- assert.equal(moment([2010, 0, 10]).week(), 2, 'Jan 10 2010 should be week 2');
- assert.equal(moment([2010, 0, 11]).week(), 3, 'Jan 11 2010 should be week 3');
- });
-
- test('weeks year starting saturday', function (assert) {
- assert.equal(moment([2010, 11, 27]).week(), 1, 'Dec 27 2010 should be week 1');
- assert.equal(moment([2011, 0, 1]).week(), 1, 'Jan 1 2011 should be week 1');
- assert.equal(moment([2011, 0, 2]).week(), 1, 'Jan 2 2011 should be week 1');
- assert.equal(moment([2011, 0, 3]).week(), 2, 'Jan 3 2011 should be week 2');
- assert.equal(moment([2011, 0, 9]).week(), 2, 'Jan 9 2011 should be week 2');
- assert.equal(moment([2011, 0, 10]).week(), 3, 'Jan 10 2011 should be week 3');
- });
-
test('weeks year starting sunday formatted', function (assert) {
assert.equal(moment([2011, 11, 26]).format('w ww wo'), '1 01 1.', 'Dec 26 2011 should be week 1');
assert.equal(moment([2012, 0, 1]).format('w ww wo'), '1 01 1.', 'Jan 1 2012 should be week 1');
@@ -29448,42 +41086,6 @@
assert.equal(moment([2012, 0, 9]).format('w ww wo'), '3 03 3.', 'Jan 9 2012 should be week 3');
});
- test('lenient ordinal parsing', function (assert) {
- var i, ordinalStr, testMoment;
- for (i = 1; i <= 31; ++i) {
- ordinalStr = moment([2014, 0, i]).format('YYYY MM Do');
- testMoment = moment(ordinalStr, 'YYYY MM Do');
- assert.equal(testMoment.year(), 2014,
- 'lenient ordinal parsing ' + i + ' year check');
- assert.equal(testMoment.month(), 0,
- 'lenient ordinal parsing ' + i + ' month check');
- assert.equal(testMoment.date(), i,
- 'lenient ordinal parsing ' + i + ' date check');
- }
- });
-
- test('lenient ordinal parsing of number', function (assert) {
- var i, testMoment;
- for (i = 1; i <= 31; ++i) {
- testMoment = moment('2014 01 ' + i, 'YYYY MM Do');
- assert.equal(testMoment.year(), 2014,
- 'lenient ordinal parsing of number ' + i + ' year check');
- assert.equal(testMoment.month(), 0,
- 'lenient ordinal parsing of number ' + i + ' month check');
- assert.equal(testMoment.date(), i,
- 'lenient ordinal parsing of number ' + i + ' date check');
- }
- });
-
- test('strict ordinal parsing', function (assert) {
- var i, ordinalStr, testMoment;
- for (i = 1; i <= 31; ++i) {
- ordinalStr = moment([2014, 0, i]).format('YYYY MM Do');
- testMoment = moment(ordinalStr, 'YYYY MM Do', true);
- assert.ok(testMoment.isValid(), 'strict ordinal parsing ' + i);
- }
- });
-
}));
;(function (global, factory) {
@@ -29492,6 +41094,224 @@
typeof define === 'function' && define.amd ? define(['../../moment'], factory) :
factory(global.moment)
}(this, function (moment) { 'use strict';
+
+ function each(array, callback) {
+ var i;
+ for (i = 0; i < array.length; i++) {
+ callback(array[i], i, array);
+ }
+ }
+
+ function objectKeys(obj) {
+ if (Object.keys) {
+ return Object.keys(obj);
+ } else {
+ // IE8
+ var res = [], i;
+ for (i in obj) {
+ if (obj.hasOwnProperty(i)) {
+ res.push(i);
+ }
+ }
+ return res;
+ }
+ }
+
+ // Pick the first defined of two or three arguments.
+ function defaults(a, b, c) {
+ if (a != null) {
+ return a;
+ }
+ if (b != null) {
+ return b;
+ }
+ return c;
+ }
+
+ function defineCommonLocaleTests(locale, options) {
+ test('lenient ordinal parsing', function (assert) {
+ var i, ordinalStr, testMoment;
+ for (i = 1; i <= 31; ++i) {
+ ordinalStr = moment([2014, 0, i]).format('YYYY MM Do');
+ testMoment = moment(ordinalStr, 'YYYY MM Do');
+ assert.equal(testMoment.year(), 2014,
+ 'lenient ordinal parsing ' + i + ' year check');
+ assert.equal(testMoment.month(), 0,
+ 'lenient ordinal parsing ' + i + ' month check');
+ assert.equal(testMoment.date(), i,
+ 'lenient ordinal parsing ' + i + ' date check');
+ }
+ });
+
+ test('lenient ordinal parsing of number', function (assert) {
+ var i, testMoment;
+ for (i = 1; i <= 31; ++i) {
+ testMoment = moment('2014 01 ' + i, 'YYYY MM Do');
+ assert.equal(testMoment.year(), 2014,
+ 'lenient ordinal parsing of number ' + i + ' year check');
+ assert.equal(testMoment.month(), 0,
+ 'lenient ordinal parsing of number ' + i + ' month check');
+ assert.equal(testMoment.date(), i,
+ 'lenient ordinal parsing of number ' + i + ' date check');
+ }
+ });
+
+ test('strict ordinal parsing', function (assert) {
+ var i, ordinalStr, testMoment;
+ for (i = 1; i <= 31; ++i) {
+ ordinalStr = moment([2014, 0, i]).format('YYYY MM Do');
+ testMoment = moment(ordinalStr, 'YYYY MM Do', true);
+ assert.ok(testMoment.isValid(), 'strict ordinal parsing ' + i);
+ }
+ });
+
+ test('meridiem invariant', function (assert) {
+ var h, m, t1, t2;
+ for (h = 0; h < 24; ++h) {
+ for (m = 0; m < 60; m += 15) {
+ t1 = moment.utc([2000, 0, 1, h, m]);
+ t2 = moment.utc(t1.format('A h:mm'), 'A h:mm');
+ assert.equal(t2.format('HH:mm'), t1.format('HH:mm'),
+ 'meridiem at ' + t1.format('HH:mm'));
+ }
+ }
+ });
+
+ test('date format correctness', function (assert) {
+ var data, tokens;
+ data = moment.localeData()._longDateFormat;
+ tokens = objectKeys(data);
+ each(tokens, function (srchToken) {
+ // Check each format string to make sure it does not contain any
+ // tokens that need to be expanded.
+ each(tokens, function (baseToken) {
+ // strip escaped sequences
+ var format = data[baseToken].replace(/(\[[^\]]*\])/g, '');
+ assert.equal(false, !!~format.indexOf(srchToken),
+ 'contains ' + srchToken + ' in ' + baseToken);
+ });
+ });
+ });
+
+ test('month parsing correctness', function (assert) {
+ var i, m;
+
+ if (locale === 'tr') {
+ // I can't fix it :(
+ expect(0);
+ return;
+ }
+ function tester(format) {
+ var r;
+ r = moment(m.format(format), format);
+ assert.equal(r.month(), m.month(), 'month ' + i + ' fmt ' + format);
+ r = moment(m.format(format).toLocaleUpperCase(), format);
+ assert.equal(r.month(), m.month(), 'month ' + i + ' fmt ' + format + ' upper');
+ r = moment(m.format(format).toLocaleLowerCase(), format);
+ assert.equal(r.month(), m.month(), 'month ' + i + ' fmt ' + format + ' lower');
+
+ r = moment(m.format(format), format, true);
+ assert.equal(r.month(), m.month(), 'month ' + i + ' fmt ' + format + ' strict');
+ r = moment(m.format(format).toLocaleUpperCase(), format, true);
+ assert.equal(r.month(), m.month(), 'month ' + i + ' fmt ' + format + ' upper strict');
+ r = moment(m.format(format).toLocaleLowerCase(), format, true);
+ assert.equal(r.month(), m.month(), 'month ' + i + ' fmt ' + format + ' lower strict');
+ }
+
+ for (i = 0; i < 12; ++i) {
+ m = moment([2015, i, 15, 18]);
+ tester('MMM');
+ tester('MMM.');
+ tester('MMMM');
+ tester('MMMM.');
+ }
+ });
+
+ test('weekday parsing correctness', function (assert) {
+ var i, m;
+
+ if (locale === 'tr' || locale === 'az') {
+ // There is a lower-case letter (ı), that converted to upper then
+ // lower changes to i
+ expect(0);
+ return;
+ }
+ function tester(format) {
+ var r, baseMsg = 'weekday ' + m.weekday() + ' fmt ' + format;
+ r = moment(m.format(format), format);
+ assert.equal(r.weekday(), m.weekday(), baseMsg);
+ r = moment(m.format(format).toLocaleUpperCase(), format);
+ assert.equal(r.weekday(), m.weekday(), baseMsg + ' upper');
+ r = moment(m.format(format).toLocaleLowerCase(), format);
+ assert.equal(r.weekday(), m.weekday(), baseMsg + ' lower');
+
+ r = moment(m.format(format), format, true);
+ assert.equal(r.weekday(), m.weekday(), baseMsg + ' strict');
+ r = moment(m.format(format).toLocaleUpperCase(), format, true);
+ assert.equal(r.weekday(), m.weekday(), baseMsg + ' upper strict');
+ r = moment(m.format(format).toLocaleLowerCase(), format, true);
+ assert.equal(r.weekday(), m.weekday(), baseMsg + ' lower strict');
+ }
+
+ for (i = 0; i < 7; ++i) {
+ m = moment.utc([2015, i, 15, 18]);
+ tester('dd');
+ tester('ddd');
+ tester('dddd');
+ }
+ });
+ }
+
+ function setupDeprecationHandler(test, moment, scope) {
+ test._expectedDeprecations = null;
+ test._observedDeprecations = null;
+ test._oldSupress = moment.suppressDeprecationWarnings;
+ moment.suppressDeprecationWarnings = true;
+ test.expectedDeprecations = function () {
+ test._expectedDeprecations = arguments;
+ test._observedDeprecations = [];
+ };
+ moment.deprecationHandler = function (name, msg) {
+ var deprecationId = matchedDeprecation(name, msg, test._expectedDeprecations);
+ if (deprecationId === -1) {
+ throw new Error('Unexpected deprecation thrown name=' +
+ name + ' msg=' + msg);
+ }
+ test._observedDeprecations[deprecationId] = 1;
+ };
+ }
+
+ function teardownDeprecationHandler(test, moment, scope) {
+ moment.suppressDeprecationWarnings = test._oldSupress;
+
+ if (test._expectedDeprecations != null) {
+ var missedDeprecations = [];
+ each(test._expectedDeprecations, function (deprecationPattern, id) {
+ if (test._observedDeprecations[id] !== 1) {
+ missedDeprecations.push(deprecationPattern);
+ }
+ });
+ if (missedDeprecations.length !== 0) {
+ throw new Error('Expected deprecation warnings did not happen: ' +
+ missedDeprecations.join(' '));
+ }
+ }
+ }
+
+ function matchedDeprecation(name, msg, deprecations) {
+ if (deprecations == null) {
+ return -1;
+ }
+ for (var i = 0; i < deprecations.length; ++i) {
+ if (name != null && name === deprecations[i]) {
+ return i;
+ }
+ if (msg != null && msg.substring(0, deprecations[i].length) === deprecations[i]) {
+ return i;
+ }
+ }
+ return -1;
+ }
/*global QUnit:false*/
@@ -29506,11 +41326,13 @@
moment.createFromInputFallback = function (config) {
throw new Error('input not handled by moment: ' + config._i);
};
+ setupDeprecationHandler(test, moment, 'core');
if (lifecycle && lifecycle.setup) {
lifecycle.setup();
}
},
teardown : function () {
+ teardownDeprecationHandler(test, moment, 'core');
if (lifecycle && lifecycle.teardown) {
lifecycle.teardown();
}
@@ -29525,17 +41347,20 @@
moment.createFromInputFallback = function (config) {
throw new Error('input not handled by moment: ' + config._i);
};
+ setupDeprecationHandler(test, moment, 'locale');
if (lifecycle && lifecycle.setup) {
lifecycle.setup();
}
},
teardown : function () {
moment.locale('en');
+ teardownDeprecationHandler(test, moment, 'locale');
if (lifecycle && lifecycle.teardown) {
lifecycle.teardown();
}
}
});
+ defineCommonLocaleTests(name, -1, -1);
}
localeModule('sr');
@@ -29692,14 +41517,14 @@
});
test('calendar day', function (assert) {
- var a = moment().hours(2).minutes(0).seconds(0);
-
- assert.equal(moment(a).calendar(), 'danas u 2:00', 'today at the same time');
- assert.equal(moment(a).add({m: 25}).calendar(), 'danas u 2:25', 'Now plus 25 min');
- assert.equal(moment(a).add({h: 1}).calendar(), 'danas u 3:00', 'Now plus 1 hour');
- assert.equal(moment(a).add({d: 1}).calendar(), 'sutra u 2:00', 'tomorrow at the same time');
- assert.equal(moment(a).subtract({h: 1}).calendar(), 'danas u 1:00', 'Now minus 1 hour');
- assert.equal(moment(a).subtract({d: 1}).calendar(), 'juče u 2:00', 'yesterday at the same time');
+ var a = moment().hours(12).minutes(0).seconds(0);
+
+ assert.equal(moment(a).calendar(), 'danas u 12:00', 'today at the same time');
+ assert.equal(moment(a).add({m: 25}).calendar(), 'danas u 12:25', 'Now plus 25 min');
+ assert.equal(moment(a).add({h: 1}).calendar(), 'danas u 13:00', 'Now plus 1 hour');
+ assert.equal(moment(a).add({d: 1}).calendar(), 'sutra u 12:00', 'tomorrow at the same time');
+ assert.equal(moment(a).subtract({h: 1}).calendar(), 'danas u 11:00', 'Now minus 1 hour');
+ assert.equal(moment(a).subtract({d: 1}).calendar(), 'juče u 12:00', 'yesterday at the same time');
});
test('calendar next week', function (assert) {
@@ -29772,67 +41597,6 @@
assert.equal(weeksFromNow.calendar(), weeksFromNow.format('L'), 'in 2 weeks');
});
- test('weeks year starting sunday', function (assert) {
- assert.equal(moment([2011, 11, 26]).week(), 1, 'Dec 26 2011 should be week 1');
- assert.equal(moment([2012, 0, 1]).week(), 1, 'Jan 1 2012 should be week 1');
- assert.equal(moment([2012, 0, 2]).week(), 2, 'Jan 2 2012 should be week 2');
- assert.equal(moment([2012, 0, 8]).week(), 2, 'Jan 8 2012 should be week 2');
- assert.equal(moment([2012, 0, 9]).week(), 3, 'Jan 9 2012 should be week 3');
- });
-
- test('weeks year starting monday', function (assert) {
- assert.equal(moment([2007, 0, 1]).week(), 1, 'Jan 1 2007 should be week 1');
- assert.equal(moment([2007, 0, 7]).week(), 1, 'Jan 7 2007 should be week 1');
- assert.equal(moment([2007, 0, 8]).week(), 2, 'Jan 8 2007 should be week 2');
- assert.equal(moment([2007, 0, 14]).week(), 2, 'Jan 14 2007 should be week 2');
- assert.equal(moment([2007, 0, 15]).week(), 3, 'Jan 15 2007 should be week 3');
- });
-
- test('weeks year starting tuesday', function (assert) {
- assert.equal(moment([2007, 11, 31]).week(), 1, 'Dec 31 2007 should be week 1');
- assert.equal(moment([2008, 0, 1]).week(), 1, 'Jan 1 2008 should be week 1');
- assert.equal(moment([2008, 0, 6]).week(), 1, 'Jan 6 2008 should be week 1');
- assert.equal(moment([2008, 0, 7]).week(), 2, 'Jan 7 2008 should be week 2');
- assert.equal(moment([2008, 0, 13]).week(), 2, 'Jan 13 2008 should be week 2');
- assert.equal(moment([2008, 0, 14]).week(), 3, 'Jan 14 2008 should be week 3');
- });
-
- test('weeks year starting wednesday', function (assert) {
- assert.equal(moment([2002, 11, 30]).week(), 1, 'Dec 30 2002 should be week 1');
- assert.equal(moment([2003, 0, 1]).week(), 1, 'Jan 1 2003 should be week 1');
- assert.equal(moment([2003, 0, 5]).week(), 1, 'Jan 5 2003 should be week 1');
- assert.equal(moment([2003, 0, 6]).week(), 2, 'Jan 6 2003 should be week 2');
- assert.equal(moment([2003, 0, 12]).week(), 2, 'Jan 12 2003 should be week 2');
- assert.equal(moment([2003, 0, 13]).week(), 3, 'Jan 13 2003 should be week 3');
- });
-
- test('weeks year starting thursday', function (assert) {
- assert.equal(moment([2008, 11, 29]).week(), 1, 'Dec 29 2008 should be week 1');
- assert.equal(moment([2009, 0, 1]).week(), 1, 'Jan 1 2009 should be week 1');
- assert.equal(moment([2009, 0, 4]).week(), 1, 'Jan 4 2009 should be week 1');
- assert.equal(moment([2009, 0, 5]).week(), 2, 'Jan 5 2009 should be week 2');
- assert.equal(moment([2009, 0, 11]).week(), 2, 'Jan 11 2009 should be week 2');
- assert.equal(moment([2009, 0, 12]).week(), 3, 'Jan 12 2009 should be week 3');
- });
-
- test('weeks year starting friday', function (assert) {
- assert.equal(moment([2009, 11, 28]).week(), 1, 'Dec 28 2009 should be week 1');
- assert.equal(moment([2010, 0, 1]).week(), 1, 'Jan 1 2010 should be week 1');
- assert.equal(moment([2010, 0, 3]).week(), 1, 'Jan 3 2010 should be week 1');
- assert.equal(moment([2010, 0, 4]).week(), 2, 'Jan 4 2010 should be week 2');
- assert.equal(moment([2010, 0, 10]).week(), 2, 'Jan 10 2010 should be week 2');
- assert.equal(moment([2010, 0, 11]).week(), 3, 'Jan 11 2010 should be week 3');
- });
-
- test('weeks year starting saturday', function (assert) {
- assert.equal(moment([2010, 11, 27]).week(), 1, 'Dec 27 2010 should be week 1');
- assert.equal(moment([2011, 0, 1]).week(), 1, 'Jan 1 2011 should be week 1');
- assert.equal(moment([2011, 0, 2]).week(), 1, 'Jan 2 2011 should be week 1');
- assert.equal(moment([2011, 0, 3]).week(), 2, 'Jan 3 2011 should be week 2');
- assert.equal(moment([2011, 0, 9]).week(), 2, 'Jan 9 2011 should be week 2');
- assert.equal(moment([2011, 0, 10]).week(), 3, 'Jan 10 2011 should be week 3');
- });
-
test('weeks year starting sunday formatted', function (assert) {
assert.equal(moment([2011, 11, 26]).format('w ww wo'), '1 01 1.', 'Dec 26 2011 should be week 1');
assert.equal(moment([2012, 0, 1]).format('w ww wo'), '1 01 1.', 'Jan 1 2012 should be week 1');
@@ -29841,42 +41605,6 @@
assert.equal(moment([2012, 0, 9]).format('w ww wo'), '3 03 3.', 'Jan 9 2012 should be week 3');
});
- test('lenient ordinal parsing', function (assert) {
- var i, ordinalStr, testMoment;
- for (i = 1; i <= 31; ++i) {
- ordinalStr = moment([2014, 0, i]).format('YYYY MM Do');
- testMoment = moment(ordinalStr, 'YYYY MM Do');
- assert.equal(testMoment.year(), 2014,
- 'lenient ordinal parsing ' + i + ' year check');
- assert.equal(testMoment.month(), 0,
- 'lenient ordinal parsing ' + i + ' month check');
- assert.equal(testMoment.date(), i,
- 'lenient ordinal parsing ' + i + ' date check');
- }
- });
-
- test('lenient ordinal parsing of number', function (assert) {
- var i, testMoment;
- for (i = 1; i <= 31; ++i) {
- testMoment = moment('2014 01 ' + i, 'YYYY MM Do');
- assert.equal(testMoment.year(), 2014,
- 'lenient ordinal parsing of number ' + i + ' year check');
- assert.equal(testMoment.month(), 0,
- 'lenient ordinal parsing of number ' + i + ' month check');
- assert.equal(testMoment.date(), i,
- 'lenient ordinal parsing of number ' + i + ' date check');
- }
- });
-
- test('strict ordinal parsing', function (assert) {
- var i, ordinalStr, testMoment;
- for (i = 1; i <= 31; ++i) {
- ordinalStr = moment([2014, 0, i]).format('YYYY MM Do');
- testMoment = moment(ordinalStr, 'YYYY MM Do', true);
- assert.ok(testMoment.isValid(), 'strict ordinal parsing ' + i);
- }
- });
-
}));
;(function (global, factory) {
@@ -29885,6 +41613,224 @@
typeof define === 'function' && define.amd ? define(['../../moment'], factory) :
factory(global.moment)
}(this, function (moment) { 'use strict';
+
+ function each(array, callback) {
+ var i;
+ for (i = 0; i < array.length; i++) {
+ callback(array[i], i, array);
+ }
+ }
+
+ function objectKeys(obj) {
+ if (Object.keys) {
+ return Object.keys(obj);
+ } else {
+ // IE8
+ var res = [], i;
+ for (i in obj) {
+ if (obj.hasOwnProperty(i)) {
+ res.push(i);
+ }
+ }
+ return res;
+ }
+ }
+
+ // Pick the first defined of two or three arguments.
+ function defaults(a, b, c) {
+ if (a != null) {
+ return a;
+ }
+ if (b != null) {
+ return b;
+ }
+ return c;
+ }
+
+ function defineCommonLocaleTests(locale, options) {
+ test('lenient ordinal parsing', function (assert) {
+ var i, ordinalStr, testMoment;
+ for (i = 1; i <= 31; ++i) {
+ ordinalStr = moment([2014, 0, i]).format('YYYY MM Do');
+ testMoment = moment(ordinalStr, 'YYYY MM Do');
+ assert.equal(testMoment.year(), 2014,
+ 'lenient ordinal parsing ' + i + ' year check');
+ assert.equal(testMoment.month(), 0,
+ 'lenient ordinal parsing ' + i + ' month check');
+ assert.equal(testMoment.date(), i,
+ 'lenient ordinal parsing ' + i + ' date check');
+ }
+ });
+
+ test('lenient ordinal parsing of number', function (assert) {
+ var i, testMoment;
+ for (i = 1; i <= 31; ++i) {
+ testMoment = moment('2014 01 ' + i, 'YYYY MM Do');
+ assert.equal(testMoment.year(), 2014,
+ 'lenient ordinal parsing of number ' + i + ' year check');
+ assert.equal(testMoment.month(), 0,
+ 'lenient ordinal parsing of number ' + i + ' month check');
+ assert.equal(testMoment.date(), i,
+ 'lenient ordinal parsing of number ' + i + ' date check');
+ }
+ });
+
+ test('strict ordinal parsing', function (assert) {
+ var i, ordinalStr, testMoment;
+ for (i = 1; i <= 31; ++i) {
+ ordinalStr = moment([2014, 0, i]).format('YYYY MM Do');
+ testMoment = moment(ordinalStr, 'YYYY MM Do', true);
+ assert.ok(testMoment.isValid(), 'strict ordinal parsing ' + i);
+ }
+ });
+
+ test('meridiem invariant', function (assert) {
+ var h, m, t1, t2;
+ for (h = 0; h < 24; ++h) {
+ for (m = 0; m < 60; m += 15) {
+ t1 = moment.utc([2000, 0, 1, h, m]);
+ t2 = moment.utc(t1.format('A h:mm'), 'A h:mm');
+ assert.equal(t2.format('HH:mm'), t1.format('HH:mm'),
+ 'meridiem at ' + t1.format('HH:mm'));
+ }
+ }
+ });
+
+ test('date format correctness', function (assert) {
+ var data, tokens;
+ data = moment.localeData()._longDateFormat;
+ tokens = objectKeys(data);
+ each(tokens, function (srchToken) {
+ // Check each format string to make sure it does not contain any
+ // tokens that need to be expanded.
+ each(tokens, function (baseToken) {
+ // strip escaped sequences
+ var format = data[baseToken].replace(/(\[[^\]]*\])/g, '');
+ assert.equal(false, !!~format.indexOf(srchToken),
+ 'contains ' + srchToken + ' in ' + baseToken);
+ });
+ });
+ });
+
+ test('month parsing correctness', function (assert) {
+ var i, m;
+
+ if (locale === 'tr') {
+ // I can't fix it :(
+ expect(0);
+ return;
+ }
+ function tester(format) {
+ var r;
+ r = moment(m.format(format), format);
+ assert.equal(r.month(), m.month(), 'month ' + i + ' fmt ' + format);
+ r = moment(m.format(format).toLocaleUpperCase(), format);
+ assert.equal(r.month(), m.month(), 'month ' + i + ' fmt ' + format + ' upper');
+ r = moment(m.format(format).toLocaleLowerCase(), format);
+ assert.equal(r.month(), m.month(), 'month ' + i + ' fmt ' + format + ' lower');
+
+ r = moment(m.format(format), format, true);
+ assert.equal(r.month(), m.month(), 'month ' + i + ' fmt ' + format + ' strict');
+ r = moment(m.format(format).toLocaleUpperCase(), format, true);
+ assert.equal(r.month(), m.month(), 'month ' + i + ' fmt ' + format + ' upper strict');
+ r = moment(m.format(format).toLocaleLowerCase(), format, true);
+ assert.equal(r.month(), m.month(), 'month ' + i + ' fmt ' + format + ' lower strict');
+ }
+
+ for (i = 0; i < 12; ++i) {
+ m = moment([2015, i, 15, 18]);
+ tester('MMM');
+ tester('MMM.');
+ tester('MMMM');
+ tester('MMMM.');
+ }
+ });
+
+ test('weekday parsing correctness', function (assert) {
+ var i, m;
+
+ if (locale === 'tr' || locale === 'az') {
+ // There is a lower-case letter (ı), that converted to upper then
+ // lower changes to i
+ expect(0);
+ return;
+ }
+ function tester(format) {
+ var r, baseMsg = 'weekday ' + m.weekday() + ' fmt ' + format;
+ r = moment(m.format(format), format);
+ assert.equal(r.weekday(), m.weekday(), baseMsg);
+ r = moment(m.format(format).toLocaleUpperCase(), format);
+ assert.equal(r.weekday(), m.weekday(), baseMsg + ' upper');
+ r = moment(m.format(format).toLocaleLowerCase(), format);
+ assert.equal(r.weekday(), m.weekday(), baseMsg + ' lower');
+
+ r = moment(m.format(format), format, true);
+ assert.equal(r.weekday(), m.weekday(), baseMsg + ' strict');
+ r = moment(m.format(format).toLocaleUpperCase(), format, true);
+ assert.equal(r.weekday(), m.weekday(), baseMsg + ' upper strict');
+ r = moment(m.format(format).toLocaleLowerCase(), format, true);
+ assert.equal(r.weekday(), m.weekday(), baseMsg + ' lower strict');
+ }
+
+ for (i = 0; i < 7; ++i) {
+ m = moment.utc([2015, i, 15, 18]);
+ tester('dd');
+ tester('ddd');
+ tester('dddd');
+ }
+ });
+ }
+
+ function setupDeprecationHandler(test, moment, scope) {
+ test._expectedDeprecations = null;
+ test._observedDeprecations = null;
+ test._oldSupress = moment.suppressDeprecationWarnings;
+ moment.suppressDeprecationWarnings = true;
+ test.expectedDeprecations = function () {
+ test._expectedDeprecations = arguments;
+ test._observedDeprecations = [];
+ };
+ moment.deprecationHandler = function (name, msg) {
+ var deprecationId = matchedDeprecation(name, msg, test._expectedDeprecations);
+ if (deprecationId === -1) {
+ throw new Error('Unexpected deprecation thrown name=' +
+ name + ' msg=' + msg);
+ }
+ test._observedDeprecations[deprecationId] = 1;
+ };
+ }
+
+ function teardownDeprecationHandler(test, moment, scope) {
+ moment.suppressDeprecationWarnings = test._oldSupress;
+
+ if (test._expectedDeprecations != null) {
+ var missedDeprecations = [];
+ each(test._expectedDeprecations, function (deprecationPattern, id) {
+ if (test._observedDeprecations[id] !== 1) {
+ missedDeprecations.push(deprecationPattern);
+ }
+ });
+ if (missedDeprecations.length !== 0) {
+ throw new Error('Expected deprecation warnings did not happen: ' +
+ missedDeprecations.join(' '));
+ }
+ }
+ }
+
+ function matchedDeprecation(name, msg, deprecations) {
+ if (deprecations == null) {
+ return -1;
+ }
+ for (var i = 0; i < deprecations.length; ++i) {
+ if (name != null && name === deprecations[i]) {
+ return i;
+ }
+ if (msg != null && msg.substring(0, deprecations[i].length) === deprecations[i]) {
+ return i;
+ }
+ }
+ return -1;
+ }
/*global QUnit:false*/
@@ -29899,11 +41845,13 @@
moment.createFromInputFallback = function (config) {
throw new Error('input not handled by moment: ' + config._i);
};
+ setupDeprecationHandler(test, moment, 'core');
if (lifecycle && lifecycle.setup) {
lifecycle.setup();
}
},
teardown : function () {
+ teardownDeprecationHandler(test, moment, 'core');
if (lifecycle && lifecycle.teardown) {
lifecycle.teardown();
}
@@ -29918,17 +41866,537 @@
moment.createFromInputFallback = function (config) {
throw new Error('input not handled by moment: ' + config._i);
};
+ setupDeprecationHandler(test, moment, 'locale');
if (lifecycle && lifecycle.setup) {
lifecycle.setup();
}
},
teardown : function () {
moment.locale('en');
+ teardownDeprecationHandler(test, moment, 'locale');
if (lifecycle && lifecycle.teardown) {
lifecycle.teardown();
}
}
});
+ defineCommonLocaleTests(name, -1, -1);
+ }
+
+ localeModule('ss');
+
+ test('parse', function (assert) {
+ var tests = "Bhimbidvwane Bhi_Indlovana Ina_Indlov'lenkhulu Inu_Mabasa Mab_Inkhwekhweti Ink_Inhlaba Inh_Kholwane Kho_Ingci Igc_Inyoni Iny_Imphala Imp_Lweti lwe_Ingongoni Igo".split('_'), i;
+ function equalTest(input, mmm, i) {
+ assert.equal(moment(input, mmm).month(), i, input + ' should be month ' + (i + 1));
+ }
+ for (i = 0; i < 12; i++) {
+ tests[i] = tests[i].split(' ');
+ equalTest(tests[i][0], 'MMM', i);
+ equalTest(tests[i][1], 'MMM', i);
+ equalTest(tests[i][0], 'MMMM', i);
+ equalTest(tests[i][1], 'MMMM', i);
+ equalTest(tests[i][0].toLocaleLowerCase(), 'MMMM', i);
+ equalTest(tests[i][1].toLocaleLowerCase(), 'MMMM', i);
+ equalTest(tests[i][0].toLocaleUpperCase(), 'MMMM', i);
+ equalTest(tests[i][1].toLocaleUpperCase(), 'MMMM', i);
+ }
+ });
+
+ test('parse meridiem', function (assert) {
+ var i,
+ b = moment(),
+ meridiemTests = [
+ // h a patterns, expected hours, isValid
+ ['10 ekuseni', 10, true],
+ ['11 emini', 11, true],
+ ['3 entsambama', 15, true],
+ ['4 entsambama', 16, true],
+ ['6 entsambama', 18, true],
+ ['7 ebusuku', 19, true],
+ ['12 ebusuku', 0, true],
+ ['10 am', 10, false],
+ ['10 pm', 10, false]
+ ],
+ parsed;
+
+ // test that a formatted moment including meridiem string can be parsed back to the same moment
+ assert.ok(b.isSame(moment(b.format('h:mm:ss a'), 'h:mm:ss a', 'ss', true), 'seconds'), b.format('h:mm:ss a') + ' should be equal to ' + moment(b.format('h:mm:ss a'), 'h:mm:ss a', 'ss', true).format('h:mm:ss a'));
+
+ // test that a formatted moment having a meridiem string can be parsed with strict flag
+ assert.ok(moment(b.format('h:mm:ss a'), 'h:mm:ss a', 'ss', true).isValid(), b.format('h:mm:ss a') + ' should be parsed as valid');
+
+ for (i = 0; i < meridiemTests.length; i++) {
+ parsed = moment(meridiemTests[i][0], 'h a', 'ss', true);
+ assert.equal(parsed.isValid(), meridiemTests[i][2], 'validity for ' + meridiemTests[i][0]);
+ if (parsed.isValid()) {
+ assert.equal(parsed.hours(), meridiemTests[i][1], 'hours for ' + meridiemTests[i][0]);
+ }
+ }
+ });
+
+ test('format', function (assert) {
+ var a = [
+ ['dddd, MMMM Do YYYY, h:mm:ss a', 'Lisontfo, Indlovana 14 2010, 3:25:50 entsambama'],
+ ['ddd, h A', 'Lis, 3 entsambama'],
+ ['M Mo MM MMMM MMM', '2 2 02 Indlovana Ina'],
+ ['YYYY YY', '2010 10'],
+ ['D Do DD', '14 14 14'],
+ ['d do dddd ddd dd', '0 0 Lisontfo Lis Li'],
+ ['DDD DDDo DDDD', '45 45 045'],
+ ['w wo ww', '6 6 06'],
+ ['h hh', '3 03'],
+ ['H HH', '15 15'],
+ ['m mm', '25 25'],
+ ['s ss', '50 50'],
+ ['a A', 'entsambama entsambama'],
+ ['[Lilanga] DDDo [lilanga lelinyaka]', 'Lilanga 45 lilanga lelinyaka'],
+ ['LTS', '3:25:50 entsambama'],
+ ['L', '14/02/2010'],
+ ['LL', '14 Indlovana 2010'],
+ ['LLL', '14 Indlovana 2010 3:25 entsambama'],
+ ['LLLL', 'Lisontfo, 14 Indlovana 2010 3:25 entsambama'],
+ ['l', '14/2/2010'],
+ ['ll', '14 Ina 2010'],
+ ['lll', '14 Ina 2010 3:25 entsambama'],
+ ['llll', 'Lis, 14 Ina 2010 3:25 entsambama']
+ ],
+ b = moment(new Date(2010, 1, 14, 15, 25, 50, 125)),
+ i;
+ for (i = 0; i < a.length; i++) {
+ assert.equal(b.format(a[i][0]), a[i][1], a[i][0] + ' ---> ' + a[i][1]);
+ }
+ });
+
+ test('format ordinal', function (assert) {
+ assert.equal(moment([2011, 0, 1]).format('DDDo'), '1', '1');
+ assert.equal(moment([2011, 0, 2]).format('DDDo'), '2', '2');
+ assert.equal(moment([2011, 0, 3]).format('DDDo'), '3', '3');
+ assert.equal(moment([2011, 0, 4]).format('DDDo'), '4', '4');
+ assert.equal(moment([2011, 0, 5]).format('DDDo'), '5', '5');
+ assert.equal(moment([2011, 0, 6]).format('DDDo'), '6', '6');
+ assert.equal(moment([2011, 0, 7]).format('DDDo'), '7', '7');
+ assert.equal(moment([2011, 0, 8]).format('DDDo'), '8', '8');
+ assert.equal(moment([2011, 0, 9]).format('DDDo'), '9', '9');
+ assert.equal(moment([2011, 0, 10]).format('DDDo'), '10', '10');
+
+ assert.equal(moment([2011, 0, 11]).format('DDDo'), '11', '11');
+ assert.equal(moment([2011, 0, 12]).format('DDDo'), '12', '12');
+ assert.equal(moment([2011, 0, 13]).format('DDDo'), '13', '13');
+ assert.equal(moment([2011, 0, 14]).format('DDDo'), '14', '14');
+ assert.equal(moment([2011, 0, 15]).format('DDDo'), '15', '15');
+ assert.equal(moment([2011, 0, 16]).format('DDDo'), '16', '16');
+ assert.equal(moment([2011, 0, 17]).format('DDDo'), '17', '17');
+ assert.equal(moment([2011, 0, 18]).format('DDDo'), '18', '18');
+ assert.equal(moment([2011, 0, 19]).format('DDDo'), '19', '19');
+ assert.equal(moment([2011, 0, 20]).format('DDDo'), '20', '20');
+
+ assert.equal(moment([2011, 0, 21]).format('DDDo'), '21', '21');
+ assert.equal(moment([2011, 0, 22]).format('DDDo'), '22', '22');
+ assert.equal(moment([2011, 0, 23]).format('DDDo'), '23', '23');
+ assert.equal(moment([2011, 0, 24]).format('DDDo'), '24', '24');
+ assert.equal(moment([2011, 0, 25]).format('DDDo'), '25', '25');
+ assert.equal(moment([2011, 0, 26]).format('DDDo'), '26', '26');
+ assert.equal(moment([2011, 0, 27]).format('DDDo'), '27', '27');
+ assert.equal(moment([2011, 0, 28]).format('DDDo'), '28', '28');
+ assert.equal(moment([2011, 0, 29]).format('DDDo'), '29', '29');
+ assert.equal(moment([2011, 0, 30]).format('DDDo'), '30', '30');
+
+ assert.equal(moment([2011, 0, 31]).format('DDDo'), '31', '31');
+ });
+
+ test('format month', function (assert) {
+ var expected = "Bhimbidvwane Bhi_Indlovana Ina_Indlov'lenkhulu Inu_Mabasa Mab_Inkhwekhweti Ink_Inhlaba Inh_Kholwane Kho_Ingci Igc_Inyoni Iny_Imphala Imp_Lweti Lwe_Ingongoni Igo".split('_'), i;
+ for (i = 0; i < expected.length; i++) {
+ assert.equal(moment([2011, i, 1]).format('MMMM MMM'), expected[i], expected[i]);
+ }
+ });
+
+ test('format week', function (assert) {
+ var expected = 'Lisontfo Lis Li_Umsombuluko Umb Us_Lesibili Lsb Lb_Lesitsatfu Les Lt_Lesine Lsi Ls_Lesihlanu Lsh Lh_Umgcibelo Umg Ug'.split('_'), i;
+ for (i = 0; i < expected.length; i++) {
+ assert.equal(moment([2011, 0, 2 + i]).format('dddd ddd dd'), expected[i], expected[i]);
+ }
+ });
+
+ test('from', function (assert) {
+ var start = moment([2007, 1, 28]);
+ assert.equal(start.from(moment([2007, 1, 28]).add({s: 44}), true), 'emizuzwana lomcane', '44 seconds = a few seconds');
+ assert.equal(start.from(moment([2007, 1, 28]).add({s: 45}), true), 'umzuzu', '45 seconds = a minute');
+ assert.equal(start.from(moment([2007, 1, 28]).add({s: 89}), true), 'umzuzu', '89 seconds = a minute');
+ assert.equal(start.from(moment([2007, 1, 28]).add({s: 90}), true), '2 emizuzu', '90 seconds = 2 minutes');
+ assert.equal(start.from(moment([2007, 1, 28]).add({m: 44}), true), '44 emizuzu', '44 minutes = 44 minutes');
+ assert.equal(start.from(moment([2007, 1, 28]).add({m: 45}), true), 'lihora', '45 minutes = an hour');
+ assert.equal(start.from(moment([2007, 1, 28]).add({m: 89}), true), 'lihora', '89 minutes = an hour');
+ assert.equal(start.from(moment([2007, 1, 28]).add({m: 90}), true), '2 emahora', '90 minutes = 2 hours');
+ assert.equal(start.from(moment([2007, 1, 28]).add({h: 5}), true), '5 emahora', '5 hours = 5 hours');
+ assert.equal(start.from(moment([2007, 1, 28]).add({h: 21}), true), '21 emahora', '21 hours = 21 hours');
+ assert.equal(start.from(moment([2007, 1, 28]).add({h: 22}), true), 'lilanga', '22 hours = a day');
+ assert.equal(start.from(moment([2007, 1, 28]).add({h: 35}), true), 'lilanga', '35 hours = a day');
+ assert.equal(start.from(moment([2007, 1, 28]).add({h: 36}), true), '2 emalanga', '36 hours = 2 days');
+ assert.equal(start.from(moment([2007, 1, 28]).add({d: 1}), true), 'lilanga', '1 day = a day');
+ assert.equal(start.from(moment([2007, 1, 28]).add({d: 5}), true), '5 emalanga', '5 days = 5 days');
+ assert.equal(start.from(moment([2007, 1, 28]).add({d: 25}), true), '25 emalanga', '25 days = 25 days');
+ assert.equal(start.from(moment([2007, 1, 28]).add({d: 26}), true), 'inyanga', '26 days = a month');
+ assert.equal(start.from(moment([2007, 1, 28]).add({d: 30}), true), 'inyanga', '30 days = a month');
+ assert.equal(start.from(moment([2007, 1, 28]).add({d: 43}), true), 'inyanga', '43 days = a month');
+ assert.equal(start.from(moment([2007, 1, 28]).add({d: 46}), true), '2 tinyanga', '46 days = 2 months');
+ assert.equal(start.from(moment([2007, 1, 28]).add({d: 74}), true), '2 tinyanga', '75 days = 2 months');
+ assert.equal(start.from(moment([2007, 1, 28]).add({d: 76}), true), '3 tinyanga', '76 days = 3 months');
+ assert.equal(start.from(moment([2007, 1, 28]).add({M: 1}), true), 'inyanga', '1 month = a month');
+ assert.equal(start.from(moment([2007, 1, 28]).add({M: 5}), true), '5 tinyanga', '5 months = 5 months');
+ assert.equal(start.from(moment([2007, 1, 28]).add({d: 345}), true), 'umnyaka', '345 days = a year');
+ assert.equal(start.from(moment([2007, 1, 28]).add({d: 548}), true), '2 iminyaka', '548 days = 2 years');
+ assert.equal(start.from(moment([2007, 1, 28]).add({y: 1}), true), 'umnyaka', '1 year = a year');
+ assert.equal(start.from(moment([2007, 1, 28]).add({y: 5}), true), '5 iminyaka', '5 years = 5 years');
+ });
+
+ test('suffix', function (assert) {
+ assert.equal(moment(30000).from(0), 'nga emizuzwana lomcane', 'prefix');
+ assert.equal(moment(0).from(30000), 'wenteka nga emizuzwana lomcane', 'suffix');
+ });
+
+ test('now from now', function (assert) {
+ assert.equal(moment().fromNow(), 'wenteka nga emizuzwana lomcane', 'now from now should display as in the past');
+ });
+
+ test('fromNow', function (assert) {
+ assert.equal(moment().add({s: 30}).fromNow(), 'nga emizuzwana lomcane', 'in a few seconds');
+ assert.equal(moment().add({d: 5}).fromNow(), 'nga 5 emalanga', 'in 5 days');
+ });
+
+ test('calendar day', function (assert) {
+ var a = moment().hours(12).minutes(0).seconds(0);
+
+ assert.equal(moment(a).calendar(), 'Namuhla nga 12:00 emini', 'Today at the same time');
+ assert.equal(moment(a).add({m: 25}).calendar(), 'Namuhla nga 12:25 emini', 'Now plus 25 min');
+ assert.equal(moment(a).add({h: 1}).calendar(), 'Namuhla nga 1:00 emini', 'Now plus 1 hour');
+ assert.equal(moment(a).add({d: 1}).calendar(), 'Kusasa nga 12:00 emini', 'tomorrow at the same time');
+ assert.equal(moment(a).subtract({h: 1}).calendar(), 'Namuhla nga 11:00 emini', 'Now minus 1 hour');
+ assert.equal(moment(a).subtract({d: 1}).calendar(), 'Itolo nga 12:00 emini', 'yesterday at the same time');
+ });
+
+ test('calendar next week', function (assert) {
+ var i, m;
+ for (i = 2; i < 7; i++) {
+ m = moment().add({d: i});
+ assert.equal(m.calendar(), m.format('dddd [nga] LT'), 'Today + ' + i + ' days current time');
+ m.hours(0).minutes(0).seconds(0).milliseconds(0);
+ assert.equal(m.calendar(), m.format('dddd [nga] LT'), 'Today + ' + i + ' days beginning of day');
+ m.hours(23).minutes(59).seconds(59).milliseconds(999);
+ assert.equal(m.calendar(), m.format('dddd [nga] LT'), 'Today + ' + i + ' days end of day');
+ }
+ });
+
+ test('calendar last week', function (assert) {
+ var i, m;
+
+ for (i = 2; i < 7; i++) {
+ m = moment().subtract({d: i});
+ assert.equal(m.calendar(), m.format('dddd [leliphelile] [nga] LT'), 'Today - ' + i + ' days current time');
+ m.hours(0).minutes(0).seconds(0).milliseconds(0);
+ assert.equal(m.calendar(), m.format('dddd [leliphelile] [nga] LT'), 'Today - ' + i + ' days beginning of day');
+ m.hours(23).minutes(59).seconds(59).milliseconds(999);
+ assert.equal(m.calendar(), m.format('dddd [leliphelile] [nga] LT'), 'Today - ' + i + ' days end of day');
+ }
+ });
+
+ test('calendar all else', function (assert) {
+ var weeksAgo = moment().subtract({w: 1}),
+ weeksFromNow = moment().add({w: 1});
+
+ assert.equal(weeksAgo.calendar(), weeksAgo.format('L'), '1 week ago');
+ assert.equal(weeksFromNow.calendar(), weeksFromNow.format('L'), 'in 1 week');
+
+ weeksAgo = moment().subtract({w: 2});
+ weeksFromNow = moment().add({w: 2});
+
+ assert.equal(weeksAgo.calendar(), weeksAgo.format('L'), '2 weeks ago');
+ assert.equal(weeksFromNow.calendar(), weeksFromNow.format('L'), 'in 2 weeks');
+ });
+
+ test('weeks year starting sunday formatted', function (assert) {
+ assert.equal(moment([2012, 0, 1]).format('w ww wo'), '52 52 52', 'Jan 1 2012 should be week 52');
+ assert.equal(moment([2012, 0, 2]).format('w ww wo'), '1 01 1', 'Jan 4 2012 should be week 1');
+ assert.equal(moment([2012, 0, 8]).format('w ww wo'), '1 01 1', 'Jan 8 2012 should be week 1');
+ assert.equal(moment([2012, 0, 9]).format('w ww wo'), '2 02 2', 'Jan 9 2012 should be week 2');
+ assert.equal(moment([2012, 0, 15]).format('w ww wo'), '2 02 2', 'Jan 15 2012 should be week 2');
+ });
+
+}));
+
+;(function (global, factory) {
+ typeof exports === 'object' && typeof module !== 'undefined'
+ && typeof require === 'function' ? factory(require('../../moment')) :
+ typeof define === 'function' && define.amd ? define(['../../moment'], factory) :
+ factory(global.moment)
+}(this, function (moment) { 'use strict';
+
+ function each(array, callback) {
+ var i;
+ for (i = 0; i < array.length; i++) {
+ callback(array[i], i, array);
+ }
+ }
+
+ function objectKeys(obj) {
+ if (Object.keys) {
+ return Object.keys(obj);
+ } else {
+ // IE8
+ var res = [], i;
+ for (i in obj) {
+ if (obj.hasOwnProperty(i)) {
+ res.push(i);
+ }
+ }
+ return res;
+ }
+ }
+
+ // Pick the first defined of two or three arguments.
+ function defaults(a, b, c) {
+ if (a != null) {
+ return a;
+ }
+ if (b != null) {
+ return b;
+ }
+ return c;
+ }
+
+ function defineCommonLocaleTests(locale, options) {
+ test('lenient ordinal parsing', function (assert) {
+ var i, ordinalStr, testMoment;
+ for (i = 1; i <= 31; ++i) {
+ ordinalStr = moment([2014, 0, i]).format('YYYY MM Do');
+ testMoment = moment(ordinalStr, 'YYYY MM Do');
+ assert.equal(testMoment.year(), 2014,
+ 'lenient ordinal parsing ' + i + ' year check');
+ assert.equal(testMoment.month(), 0,
+ 'lenient ordinal parsing ' + i + ' month check');
+ assert.equal(testMoment.date(), i,
+ 'lenient ordinal parsing ' + i + ' date check');
+ }
+ });
+
+ test('lenient ordinal parsing of number', function (assert) {
+ var i, testMoment;
+ for (i = 1; i <= 31; ++i) {
+ testMoment = moment('2014 01 ' + i, 'YYYY MM Do');
+ assert.equal(testMoment.year(), 2014,
+ 'lenient ordinal parsing of number ' + i + ' year check');
+ assert.equal(testMoment.month(), 0,
+ 'lenient ordinal parsing of number ' + i + ' month check');
+ assert.equal(testMoment.date(), i,
+ 'lenient ordinal parsing of number ' + i + ' date check');
+ }
+ });
+
+ test('strict ordinal parsing', function (assert) {
+ var i, ordinalStr, testMoment;
+ for (i = 1; i <= 31; ++i) {
+ ordinalStr = moment([2014, 0, i]).format('YYYY MM Do');
+ testMoment = moment(ordinalStr, 'YYYY MM Do', true);
+ assert.ok(testMoment.isValid(), 'strict ordinal parsing ' + i);
+ }
+ });
+
+ test('meridiem invariant', function (assert) {
+ var h, m, t1, t2;
+ for (h = 0; h < 24; ++h) {
+ for (m = 0; m < 60; m += 15) {
+ t1 = moment.utc([2000, 0, 1, h, m]);
+ t2 = moment.utc(t1.format('A h:mm'), 'A h:mm');
+ assert.equal(t2.format('HH:mm'), t1.format('HH:mm'),
+ 'meridiem at ' + t1.format('HH:mm'));
+ }
+ }
+ });
+
+ test('date format correctness', function (assert) {
+ var data, tokens;
+ data = moment.localeData()._longDateFormat;
+ tokens = objectKeys(data);
+ each(tokens, function (srchToken) {
+ // Check each format string to make sure it does not contain any
+ // tokens that need to be expanded.
+ each(tokens, function (baseToken) {
+ // strip escaped sequences
+ var format = data[baseToken].replace(/(\[[^\]]*\])/g, '');
+ assert.equal(false, !!~format.indexOf(srchToken),
+ 'contains ' + srchToken + ' in ' + baseToken);
+ });
+ });
+ });
+
+ test('month parsing correctness', function (assert) {
+ var i, m;
+
+ if (locale === 'tr') {
+ // I can't fix it :(
+ expect(0);
+ return;
+ }
+ function tester(format) {
+ var r;
+ r = moment(m.format(format), format);
+ assert.equal(r.month(), m.month(), 'month ' + i + ' fmt ' + format);
+ r = moment(m.format(format).toLocaleUpperCase(), format);
+ assert.equal(r.month(), m.month(), 'month ' + i + ' fmt ' + format + ' upper');
+ r = moment(m.format(format).toLocaleLowerCase(), format);
+ assert.equal(r.month(), m.month(), 'month ' + i + ' fmt ' + format + ' lower');
+
+ r = moment(m.format(format), format, true);
+ assert.equal(r.month(), m.month(), 'month ' + i + ' fmt ' + format + ' strict');
+ r = moment(m.format(format).toLocaleUpperCase(), format, true);
+ assert.equal(r.month(), m.month(), 'month ' + i + ' fmt ' + format + ' upper strict');
+ r = moment(m.format(format).toLocaleLowerCase(), format, true);
+ assert.equal(r.month(), m.month(), 'month ' + i + ' fmt ' + format + ' lower strict');
+ }
+
+ for (i = 0; i < 12; ++i) {
+ m = moment([2015, i, 15, 18]);
+ tester('MMM');
+ tester('MMM.');
+ tester('MMMM');
+ tester('MMMM.');
+ }
+ });
+
+ test('weekday parsing correctness', function (assert) {
+ var i, m;
+
+ if (locale === 'tr' || locale === 'az') {
+ // There is a lower-case letter (ı), that converted to upper then
+ // lower changes to i
+ expect(0);
+ return;
+ }
+ function tester(format) {
+ var r, baseMsg = 'weekday ' + m.weekday() + ' fmt ' + format;
+ r = moment(m.format(format), format);
+ assert.equal(r.weekday(), m.weekday(), baseMsg);
+ r = moment(m.format(format).toLocaleUpperCase(), format);
+ assert.equal(r.weekday(), m.weekday(), baseMsg + ' upper');
+ r = moment(m.format(format).toLocaleLowerCase(), format);
+ assert.equal(r.weekday(), m.weekday(), baseMsg + ' lower');
+
+ r = moment(m.format(format), format, true);
+ assert.equal(r.weekday(), m.weekday(), baseMsg + ' strict');
+ r = moment(m.format(format).toLocaleUpperCase(), format, true);
+ assert.equal(r.weekday(), m.weekday(), baseMsg + ' upper strict');
+ r = moment(m.format(format).toLocaleLowerCase(), format, true);
+ assert.equal(r.weekday(), m.weekday(), baseMsg + ' lower strict');
+ }
+
+ for (i = 0; i < 7; ++i) {
+ m = moment.utc([2015, i, 15, 18]);
+ tester('dd');
+ tester('ddd');
+ tester('dddd');
+ }
+ });
+ }
+
+ function setupDeprecationHandler(test, moment, scope) {
+ test._expectedDeprecations = null;
+ test._observedDeprecations = null;
+ test._oldSupress = moment.suppressDeprecationWarnings;
+ moment.suppressDeprecationWarnings = true;
+ test.expectedDeprecations = function () {
+ test._expectedDeprecations = arguments;
+ test._observedDeprecations = [];
+ };
+ moment.deprecationHandler = function (name, msg) {
+ var deprecationId = matchedDeprecation(name, msg, test._expectedDeprecations);
+ if (deprecationId === -1) {
+ throw new Error('Unexpected deprecation thrown name=' +
+ name + ' msg=' + msg);
+ }
+ test._observedDeprecations[deprecationId] = 1;
+ };
+ }
+
+ function teardownDeprecationHandler(test, moment, scope) {
+ moment.suppressDeprecationWarnings = test._oldSupress;
+
+ if (test._expectedDeprecations != null) {
+ var missedDeprecations = [];
+ each(test._expectedDeprecations, function (deprecationPattern, id) {
+ if (test._observedDeprecations[id] !== 1) {
+ missedDeprecations.push(deprecationPattern);
+ }
+ });
+ if (missedDeprecations.length !== 0) {
+ throw new Error('Expected deprecation warnings did not happen: ' +
+ missedDeprecations.join(' '));
+ }
+ }
+ }
+
+ function matchedDeprecation(name, msg, deprecations) {
+ if (deprecations == null) {
+ return -1;
+ }
+ for (var i = 0; i < deprecations.length; ++i) {
+ if (name != null && name === deprecations[i]) {
+ return i;
+ }
+ if (msg != null && msg.substring(0, deprecations[i].length) === deprecations[i]) {
+ return i;
+ }
+ }
+ return -1;
+ }
+
+ /*global QUnit:false*/
+
+ var test = QUnit.test;
+
+ var expect = QUnit.expect;
+
+ function module (name, lifecycle) {
+ QUnit.module(name, {
+ setup : function () {
+ moment.locale('en');
+ moment.createFromInputFallback = function (config) {
+ throw new Error('input not handled by moment: ' + config._i);
+ };
+ setupDeprecationHandler(test, moment, 'core');
+ if (lifecycle && lifecycle.setup) {
+ lifecycle.setup();
+ }
+ },
+ teardown : function () {
+ teardownDeprecationHandler(test, moment, 'core');
+ if (lifecycle && lifecycle.teardown) {
+ lifecycle.teardown();
+ }
+ }
+ });
+ }
+
+ function localeModule (name, lifecycle) {
+ QUnit.module('locale:' + name, {
+ setup : function () {
+ moment.locale(name);
+ moment.createFromInputFallback = function (config) {
+ throw new Error('input not handled by moment: ' + config._i);
+ };
+ setupDeprecationHandler(test, moment, 'locale');
+ if (lifecycle && lifecycle.setup) {
+ lifecycle.setup();
+ }
+ },
+ teardown : function () {
+ moment.locale('en');
+ teardownDeprecationHandler(test, moment, 'locale');
+ if (lifecycle && lifecycle.teardown) {
+ lifecycle.teardown();
+ }
+ }
+ });
+ defineCommonLocaleTests(name, -1, -1);
}
localeModule('sv');
@@ -29970,8 +42438,8 @@
['LTS', '15:25:50'],
['L', '2010-02-14'],
['LL', '14 februari 2010'],
- ['LLL', '14 februari 2010 15:25'],
- ['LLLL', 'söndag 14 februari 2010 15:25'],
+ ['LLL', '14 februari 2010 kl. 15:25'],
+ ['LLLL', 'söndag 14 februari 2010 kl. 15:25'],
['l', '2010-2-14'],
['ll', '14 feb 2010'],
['lll', '14 feb 2010 15:25'],
@@ -30082,14 +42550,14 @@
});
test('calendar day', function (assert) {
- var a = moment().hours(2).minutes(0).seconds(0);
-
- assert.equal(moment(a).calendar(), 'Idag 02:00', 'today at the same time');
- assert.equal(moment(a).add({m: 25}).calendar(), 'Idag 02:25', 'Now plus 25 min');
- assert.equal(moment(a).add({h: 1}).calendar(), 'Idag 03:00', 'Now plus 1 hour');
- assert.equal(moment(a).add({d: 1}).calendar(), 'Imorgon 02:00', 'tomorrow at the same time');
- assert.equal(moment(a).subtract({h: 1}).calendar(), 'Idag 01:00', 'Now minus 1 hour');
- assert.equal(moment(a).subtract({d: 1}).calendar(), 'Igår 02:00', 'yesterday at the same time');
+ var a = moment().hours(12).minutes(0).seconds(0);
+
+ assert.equal(moment(a).calendar(), 'Idag 12:00', 'today at the same time');
+ assert.equal(moment(a).add({m: 25}).calendar(), 'Idag 12:25', 'Now plus 25 min');
+ assert.equal(moment(a).add({h: 1}).calendar(), 'Idag 13:00', 'Now plus 1 hour');
+ assert.equal(moment(a).add({d: 1}).calendar(), 'Imorgon 12:00', 'tomorrow at the same time');
+ assert.equal(moment(a).subtract({h: 1}).calendar(), 'Idag 11:00', 'Now minus 1 hour');
+ assert.equal(moment(a).subtract({d: 1}).calendar(), 'Igår 12:00', 'yesterday at the same time');
});
test('calendar next week', function (assert) {
@@ -30130,67 +42598,6 @@
assert.equal(weeksFromNow.calendar(), weeksFromNow.format('L'), 'in 2 weeks');
});
- test('weeks year starting sunday', function (assert) {
- assert.equal(moment([2012, 0, 1]).week(), 52, 'Jan 1 2012 should be week 52');
- assert.equal(moment([2012, 0, 2]).week(), 1, 'Jan 2 2012 should be week 1');
- assert.equal(moment([2012, 0, 8]).week(), 1, 'Jan 8 2012 should be week 1');
- assert.equal(moment([2012, 0, 9]).week(), 2, 'Jan 9 2012 should be week 2');
- assert.equal(moment([2012, 0, 15]).week(), 2, 'Jan 15 2012 should be week 2');
- });
-
- test('weeks year starting monday', function (assert) {
- assert.equal(moment([2007, 0, 1]).week(), 1, 'Jan 1 2007 should be week 1');
- assert.equal(moment([2007, 0, 7]).week(), 1, 'Jan 7 2007 should be week 1');
- assert.equal(moment([2007, 0, 8]).week(), 2, 'Jan 8 2007 should be week 2');
- assert.equal(moment([2007, 0, 14]).week(), 2, 'Jan 14 2007 should be week 2');
- assert.equal(moment([2007, 0, 15]).week(), 3, 'Jan 15 2007 should be week 3');
- });
-
- test('weeks year starting tuesday', function (assert) {
- assert.equal(moment([2007, 11, 31]).week(), 1, 'Dec 31 2007 should be week 1');
- assert.equal(moment([2008, 0, 1]).week(), 1, 'Jan 1 2008 should be week 1');
- assert.equal(moment([2008, 0, 6]).week(), 1, 'Jan 6 2008 should be week 1');
- assert.equal(moment([2008, 0, 7]).week(), 2, 'Jan 7 2008 should be week 2');
- assert.equal(moment([2008, 0, 13]).week(), 2, 'Jan 13 2008 should be week 2');
- assert.equal(moment([2008, 0, 14]).week(), 3, 'Jan 14 2008 should be week 3');
- });
-
- test('weeks year starting wednesday', function (assert) {
- assert.equal(moment([2002, 11, 30]).week(), 1, 'Dec 30 2002 should be week 1');
- assert.equal(moment([2003, 0, 1]).week(), 1, 'Jan 1 2003 should be week 1');
- assert.equal(moment([2003, 0, 5]).week(), 1, 'Jan 5 2003 should be week 1');
- assert.equal(moment([2003, 0, 6]).week(), 2, 'Jan 6 2003 should be week 2');
- assert.equal(moment([2003, 0, 12]).week(), 2, 'Jan 12 2003 should be week 2');
- assert.equal(moment([2003, 0, 13]).week(), 3, 'Jan 13 2003 should be week 3');
- });
-
- test('weeks year starting thursday', function (assert) {
- assert.equal(moment([2008, 11, 29]).week(), 1, 'Dec 29 2008 should be week 1');
- assert.equal(moment([2009, 0, 1]).week(), 1, 'Jan 1 2009 should be week 1');
- assert.equal(moment([2009, 0, 4]).week(), 1, 'Jan 4 2009 should be week 1');
- assert.equal(moment([2009, 0, 5]).week(), 2, 'Jan 5 2009 should be week 2');
- assert.equal(moment([2009, 0, 11]).week(), 2, 'Jan 11 2009 should be week 2');
- assert.equal(moment([2009, 0, 13]).week(), 3, 'Jan 12 2009 should be week 3');
- });
-
- test('weeks year starting friday', function (assert) {
- assert.equal(moment([2009, 11, 28]).week(), 53, 'Dec 28 2009 should be week 53');
- assert.equal(moment([2010, 0, 1]).week(), 53, 'Jan 1 2010 should be week 53');
- assert.equal(moment([2010, 0, 3]).week(), 53, 'Jan 3 2010 should be week 53');
- assert.equal(moment([2010, 0, 4]).week(), 1, 'Jan 4 2010 should be week 1');
- assert.equal(moment([2010, 0, 10]).week(), 1, 'Jan 10 2010 should be week 1');
- assert.equal(moment([2010, 0, 11]).week(), 2, 'Jan 11 2010 should be week 2');
- });
-
- test('weeks year starting saturday', function (assert) {
- assert.equal(moment([2010, 11, 27]).week(), 52, 'Dec 27 2010 should be week 52');
- assert.equal(moment([2011, 0, 1]).week(), 52, 'Jan 1 2011 should be week 52');
- assert.equal(moment([2011, 0, 2]).week(), 52, 'Jan 2 2011 should be week 52');
- assert.equal(moment([2011, 0, 3]).week(), 1, 'Jan 3 2011 should be week 1');
- assert.equal(moment([2011, 0, 9]).week(), 1, 'Jan 9 2011 should be week 1');
- assert.equal(moment([2011, 0, 10]).week(), 2, 'Jan 10 2011 should be week 2');
- });
-
test('weeks year starting sunday formatted', function (assert) {
assert.equal(moment([2012, 0, 1]).format('w ww wo'), '52 52 52a', 'Jan 1 2012 should be week 52');
assert.equal(moment([2012, 0, 2]).format('w ww wo'), '1 01 1a', 'Jan 2 2012 should be week 1');
@@ -30199,42 +42606,6 @@
assert.equal(moment([2012, 0, 15]).format('w ww wo'), '2 02 2a', 'Jan 15 2012 should be week 2');
});
- test('lenient ordinal parsing', function (assert) {
- var i, ordinalStr, testMoment;
- for (i = 1; i <= 31; ++i) {
- ordinalStr = moment([2014, 0, i]).format('YYYY MM Do');
- testMoment = moment(ordinalStr, 'YYYY MM Do');
- assert.equal(testMoment.year(), 2014,
- 'lenient ordinal parsing ' + i + ' year check');
- assert.equal(testMoment.month(), 0,
- 'lenient ordinal parsing ' + i + ' month check');
- assert.equal(testMoment.date(), i,
- 'lenient ordinal parsing ' + i + ' date check');
- }
- });
-
- test('lenient ordinal parsing of number', function (assert) {
- var i, testMoment;
- for (i = 1; i <= 31; ++i) {
- testMoment = moment('2014 01 ' + i, 'YYYY MM Do');
- assert.equal(testMoment.year(), 2014,
- 'lenient ordinal parsing of number ' + i + ' year check');
- assert.equal(testMoment.month(), 0,
- 'lenient ordinal parsing of number ' + i + ' month check');
- assert.equal(testMoment.date(), i,
- 'lenient ordinal parsing of number ' + i + ' date check');
- }
- });
-
- test('strict ordinal parsing', function (assert) {
- var i, ordinalStr, testMoment;
- for (i = 1; i <= 31; ++i) {
- ordinalStr = moment([2014, 0, i]).format('YYYY MM Do');
- testMoment = moment(ordinalStr, 'YYYY MM Do', true);
- assert.ok(testMoment.isValid(), 'strict ordinal parsing ' + i);
- }
- });
-
}));
;(function (global, factory) {
@@ -30243,6 +42614,224 @@
typeof define === 'function' && define.amd ? define(['../../moment'], factory) :
factory(global.moment)
}(this, function (moment) { 'use strict';
+
+ function each(array, callback) {
+ var i;
+ for (i = 0; i < array.length; i++) {
+ callback(array[i], i, array);
+ }
+ }
+
+ function objectKeys(obj) {
+ if (Object.keys) {
+ return Object.keys(obj);
+ } else {
+ // IE8
+ var res = [], i;
+ for (i in obj) {
+ if (obj.hasOwnProperty(i)) {
+ res.push(i);
+ }
+ }
+ return res;
+ }
+ }
+
+ // Pick the first defined of two or three arguments.
+ function defaults(a, b, c) {
+ if (a != null) {
+ return a;
+ }
+ if (b != null) {
+ return b;
+ }
+ return c;
+ }
+
+ function defineCommonLocaleTests(locale, options) {
+ test('lenient ordinal parsing', function (assert) {
+ var i, ordinalStr, testMoment;
+ for (i = 1; i <= 31; ++i) {
+ ordinalStr = moment([2014, 0, i]).format('YYYY MM Do');
+ testMoment = moment(ordinalStr, 'YYYY MM Do');
+ assert.equal(testMoment.year(), 2014,
+ 'lenient ordinal parsing ' + i + ' year check');
+ assert.equal(testMoment.month(), 0,
+ 'lenient ordinal parsing ' + i + ' month check');
+ assert.equal(testMoment.date(), i,
+ 'lenient ordinal parsing ' + i + ' date check');
+ }
+ });
+
+ test('lenient ordinal parsing of number', function (assert) {
+ var i, testMoment;
+ for (i = 1; i <= 31; ++i) {
+ testMoment = moment('2014 01 ' + i, 'YYYY MM Do');
+ assert.equal(testMoment.year(), 2014,
+ 'lenient ordinal parsing of number ' + i + ' year check');
+ assert.equal(testMoment.month(), 0,
+ 'lenient ordinal parsing of number ' + i + ' month check');
+ assert.equal(testMoment.date(), i,
+ 'lenient ordinal parsing of number ' + i + ' date check');
+ }
+ });
+
+ test('strict ordinal parsing', function (assert) {
+ var i, ordinalStr, testMoment;
+ for (i = 1; i <= 31; ++i) {
+ ordinalStr = moment([2014, 0, i]).format('YYYY MM Do');
+ testMoment = moment(ordinalStr, 'YYYY MM Do', true);
+ assert.ok(testMoment.isValid(), 'strict ordinal parsing ' + i);
+ }
+ });
+
+ test('meridiem invariant', function (assert) {
+ var h, m, t1, t2;
+ for (h = 0; h < 24; ++h) {
+ for (m = 0; m < 60; m += 15) {
+ t1 = moment.utc([2000, 0, 1, h, m]);
+ t2 = moment.utc(t1.format('A h:mm'), 'A h:mm');
+ assert.equal(t2.format('HH:mm'), t1.format('HH:mm'),
+ 'meridiem at ' + t1.format('HH:mm'));
+ }
+ }
+ });
+
+ test('date format correctness', function (assert) {
+ var data, tokens;
+ data = moment.localeData()._longDateFormat;
+ tokens = objectKeys(data);
+ each(tokens, function (srchToken) {
+ // Check each format string to make sure it does not contain any
+ // tokens that need to be expanded.
+ each(tokens, function (baseToken) {
+ // strip escaped sequences
+ var format = data[baseToken].replace(/(\[[^\]]*\])/g, '');
+ assert.equal(false, !!~format.indexOf(srchToken),
+ 'contains ' + srchToken + ' in ' + baseToken);
+ });
+ });
+ });
+
+ test('month parsing correctness', function (assert) {
+ var i, m;
+
+ if (locale === 'tr') {
+ // I can't fix it :(
+ expect(0);
+ return;
+ }
+ function tester(format) {
+ var r;
+ r = moment(m.format(format), format);
+ assert.equal(r.month(), m.month(), 'month ' + i + ' fmt ' + format);
+ r = moment(m.format(format).toLocaleUpperCase(), format);
+ assert.equal(r.month(), m.month(), 'month ' + i + ' fmt ' + format + ' upper');
+ r = moment(m.format(format).toLocaleLowerCase(), format);
+ assert.equal(r.month(), m.month(), 'month ' + i + ' fmt ' + format + ' lower');
+
+ r = moment(m.format(format), format, true);
+ assert.equal(r.month(), m.month(), 'month ' + i + ' fmt ' + format + ' strict');
+ r = moment(m.format(format).toLocaleUpperCase(), format, true);
+ assert.equal(r.month(), m.month(), 'month ' + i + ' fmt ' + format + ' upper strict');
+ r = moment(m.format(format).toLocaleLowerCase(), format, true);
+ assert.equal(r.month(), m.month(), 'month ' + i + ' fmt ' + format + ' lower strict');
+ }
+
+ for (i = 0; i < 12; ++i) {
+ m = moment([2015, i, 15, 18]);
+ tester('MMM');
+ tester('MMM.');
+ tester('MMMM');
+ tester('MMMM.');
+ }
+ });
+
+ test('weekday parsing correctness', function (assert) {
+ var i, m;
+
+ if (locale === 'tr' || locale === 'az') {
+ // There is a lower-case letter (ı), that converted to upper then
+ // lower changes to i
+ expect(0);
+ return;
+ }
+ function tester(format) {
+ var r, baseMsg = 'weekday ' + m.weekday() + ' fmt ' + format;
+ r = moment(m.format(format), format);
+ assert.equal(r.weekday(), m.weekday(), baseMsg);
+ r = moment(m.format(format).toLocaleUpperCase(), format);
+ assert.equal(r.weekday(), m.weekday(), baseMsg + ' upper');
+ r = moment(m.format(format).toLocaleLowerCase(), format);
+ assert.equal(r.weekday(), m.weekday(), baseMsg + ' lower');
+
+ r = moment(m.format(format), format, true);
+ assert.equal(r.weekday(), m.weekday(), baseMsg + ' strict');
+ r = moment(m.format(format).toLocaleUpperCase(), format, true);
+ assert.equal(r.weekday(), m.weekday(), baseMsg + ' upper strict');
+ r = moment(m.format(format).toLocaleLowerCase(), format, true);
+ assert.equal(r.weekday(), m.weekday(), baseMsg + ' lower strict');
+ }
+
+ for (i = 0; i < 7; ++i) {
+ m = moment.utc([2015, i, 15, 18]);
+ tester('dd');
+ tester('ddd');
+ tester('dddd');
+ }
+ });
+ }
+
+ function setupDeprecationHandler(test, moment, scope) {
+ test._expectedDeprecations = null;
+ test._observedDeprecations = null;
+ test._oldSupress = moment.suppressDeprecationWarnings;
+ moment.suppressDeprecationWarnings = true;
+ test.expectedDeprecations = function () {
+ test._expectedDeprecations = arguments;
+ test._observedDeprecations = [];
+ };
+ moment.deprecationHandler = function (name, msg) {
+ var deprecationId = matchedDeprecation(name, msg, test._expectedDeprecations);
+ if (deprecationId === -1) {
+ throw new Error('Unexpected deprecation thrown name=' +
+ name + ' msg=' + msg);
+ }
+ test._observedDeprecations[deprecationId] = 1;
+ };
+ }
+
+ function teardownDeprecationHandler(test, moment, scope) {
+ moment.suppressDeprecationWarnings = test._oldSupress;
+
+ if (test._expectedDeprecations != null) {
+ var missedDeprecations = [];
+ each(test._expectedDeprecations, function (deprecationPattern, id) {
+ if (test._observedDeprecations[id] !== 1) {
+ missedDeprecations.push(deprecationPattern);
+ }
+ });
+ if (missedDeprecations.length !== 0) {
+ throw new Error('Expected deprecation warnings did not happen: ' +
+ missedDeprecations.join(' '));
+ }
+ }
+ }
+
+ function matchedDeprecation(name, msg, deprecations) {
+ if (deprecations == null) {
+ return -1;
+ }
+ for (var i = 0; i < deprecations.length; ++i) {
+ if (name != null && name === deprecations[i]) {
+ return i;
+ }
+ if (msg != null && msg.substring(0, deprecations[i].length) === deprecations[i]) {
+ return i;
+ }
+ }
+ return -1;
+ }
/*global QUnit:false*/
@@ -30257,11 +42846,13 @@
moment.createFromInputFallback = function (config) {
throw new Error('input not handled by moment: ' + config._i);
};
+ setupDeprecationHandler(test, moment, 'core');
if (lifecycle && lifecycle.setup) {
lifecycle.setup();
}
},
teardown : function () {
+ teardownDeprecationHandler(test, moment, 'core');
if (lifecycle && lifecycle.teardown) {
lifecycle.teardown();
}
@@ -30276,17 +42867,20 @@
moment.createFromInputFallback = function (config) {
throw new Error('input not handled by moment: ' + config._i);
};
+ setupDeprecationHandler(test, moment, 'locale');
if (lifecycle && lifecycle.setup) {
lifecycle.setup();
}
},
teardown : function () {
moment.locale('en');
+ teardownDeprecationHandler(test, moment, 'locale');
if (lifecycle && lifecycle.teardown) {
lifecycle.teardown();
}
}
});
+ defineCommonLocaleTests(name, -1, -1);
}
localeModule('sw');
@@ -30440,13 +43034,13 @@
});
test('calendar day', function (assert) {
- var a = moment().hours(2).minutes(0).seconds(0);
- assert.equal(moment(a).calendar(), 'leo saa 02:00', 'today at the same time');
- assert.equal(moment(a).add({m: 25}).calendar(), 'leo saa 02:25', 'Now plus 25 min');
- assert.equal(moment(a).add({h: 1}).calendar(), 'leo saa 03:00', 'Now plus 1 hour');
- assert.equal(moment(a).add({d: 1}).calendar(), 'kesho saa 02:00', 'tomorrow at the same time');
- assert.equal(moment(a).subtract({h: 1}).calendar(), 'leo saa 01:00', 'Now minus 1 hour');
- assert.equal(moment(a).subtract({d: 1}).calendar(), 'jana 02:00', 'yesterday at the same time');
+ var a = moment().hours(12).minutes(0).seconds(0);
+ assert.equal(moment(a).calendar(), 'leo saa 12:00', 'today at the same time');
+ assert.equal(moment(a).add({m: 25}).calendar(), 'leo saa 12:25', 'Now plus 25 min');
+ assert.equal(moment(a).add({h: 1}).calendar(), 'leo saa 13:00', 'Now plus 1 hour');
+ assert.equal(moment(a).add({d: 1}).calendar(), 'kesho saa 12:00', 'tomorrow at the same time');
+ assert.equal(moment(a).subtract({h: 1}).calendar(), 'leo saa 11:00', 'Now minus 1 hour');
+ assert.equal(moment(a).subtract({d: 1}).calendar(), 'jana 12:00', 'yesterday at the same time');
});
test('calendar next week', function (assert) {
@@ -30488,67 +43082,6 @@
assert.equal(weeksFromNow.calendar(), weeksFromNow.format('L'), 'in 2 weeks');
});
- test('weeks year starting sunday', function (assert) {
- assert.equal(moment([2011, 11, 26]).week(), 1, 'Dec 26 2011 should be week 1');
- assert.equal(moment([2012, 0, 1]).week(), 1, 'Jan 1 2012 should be week 1');
- assert.equal(moment([2012, 0, 2]).week(), 2, 'Jan 2 2012 should be week 2');
- assert.equal(moment([2012, 0, 8]).week(), 2, 'Jan 8 2012 should be week 2');
- assert.equal(moment([2012, 0, 9]).week(), 3, 'Jan 9 2012 should be week 3');
- });
-
- test('weeks year starting monday', function (assert) {
- assert.equal(moment([2007, 0, 1]).week(), 1, 'Jan 1 2007 should be week 1');
- assert.equal(moment([2007, 0, 7]).week(), 1, 'Jan 7 2007 should be week 1');
- assert.equal(moment([2007, 0, 8]).week(), 2, 'Jan 8 2007 should be week 2');
- assert.equal(moment([2007, 0, 14]).week(), 2, 'Jan 14 2007 should be week 2');
- assert.equal(moment([2007, 0, 15]).week(), 3, 'Jan 15 2007 should be week 3');
- });
-
- test('weeks year starting tuesday', function (assert) {
- assert.equal(moment([2007, 11, 31]).week(), 1, 'Dec 31 2007 should be week 1');
- assert.equal(moment([2008, 0, 1]).week(), 1, 'Jan 1 2008 should be week 1');
- assert.equal(moment([2008, 0, 6]).week(), 1, 'Jan 6 2008 should be week 1');
- assert.equal(moment([2008, 0, 7]).week(), 2, 'Jan 7 2008 should be week 2');
- assert.equal(moment([2008, 0, 13]).week(), 2, 'Jan 13 2008 should be week 2');
- assert.equal(moment([2008, 0, 14]).week(), 3, 'Jan 14 2008 should be week 3');
- });
-
- test('weeks year starting wednesday', function (assert) {
- assert.equal(moment([2002, 11, 30]).week(), 1, 'Dec 30 2002 should be week 1');
- assert.equal(moment([2003, 0, 1]).week(), 1, 'Jan 1 2003 should be week 1');
- assert.equal(moment([2003, 0, 5]).week(), 1, 'Jan 5 2003 should be week 1');
- assert.equal(moment([2003, 0, 6]).week(), 2, 'Jan 6 2003 should be week 2');
- assert.equal(moment([2003, 0, 12]).week(), 2, 'Jan 12 2003 should be week 2');
- assert.equal(moment([2003, 0, 13]).week(), 3, 'Jan 13 2003 should be week 3');
- });
-
- test('weeks year starting thursday', function (assert) {
- assert.equal(moment([2008, 11, 29]).week(), 1, 'Dec 29 2008 should be week 1');
- assert.equal(moment([2009, 0, 1]).week(), 1, 'Jan 1 2009 should be week 1');
- assert.equal(moment([2009, 0, 4]).week(), 1, 'Jan 4 2009 should be week 1');
- assert.equal(moment([2009, 0, 5]).week(), 2, 'Jan 5 2009 should be week 2');
- assert.equal(moment([2009, 0, 11]).week(), 2, 'Jan 11 2009 should be week 2');
- assert.equal(moment([2009, 0, 12]).week(), 3, 'Jan 12 2009 should be week 3');
- });
-
- test('weeks year starting friday', function (assert) {
- assert.equal(moment([2009, 11, 28]).week(), 1, 'Dec 28 2009 should be week 1');
- assert.equal(moment([2010, 0, 1]).week(), 1, 'Jan 1 2010 should be week 1');
- assert.equal(moment([2010, 0, 3]).week(), 1, 'Jan 3 2010 should be week 1');
- assert.equal(moment([2010, 0, 4]).week(), 2, 'Jan 4 2010 should be week 2');
- assert.equal(moment([2010, 0, 10]).week(), 2, 'Jan 10 2010 should be week 2');
- assert.equal(moment([2010, 0, 11]).week(), 3, 'Jan 11 2010 should be week 3');
- });
-
- test('weeks year starting saturday', function (assert) {
- assert.equal(moment([2010, 11, 27]).week(), 1, 'Dec 27 2010 should be week 1');
- assert.equal(moment([2011, 0, 1]).week(), 1, 'Jan 1 2011 should be week 1');
- assert.equal(moment([2011, 0, 2]).week(), 1, 'Jan 2 2011 should be week 1');
- assert.equal(moment([2011, 0, 3]).week(), 2, 'Jan 3 2011 should be week 2');
- assert.equal(moment([2011, 0, 9]).week(), 2, 'Jan 9 2011 should be week 2');
- assert.equal(moment([2011, 0, 10]).week(), 3, 'Jan 10 2011 should be week 3');
- });
-
test('weeks year starting sunday format', function (assert) {
assert.equal(moment([2011, 11, 26]).format('w ww wo'), '1 01 1', 'Dec 26 2011 should be week 1');
assert.equal(moment([2012, 0, 1]).format('w ww wo'), '1 01 1', 'Jan 1 2012 should be week 1');
@@ -30557,42 +43090,6 @@
assert.equal(moment([2012, 0, 9]).format('w ww wo'), '3 03 3', 'Jan 9 2012 should be week 3');
});
- test('lenient ordinal parsing', function (assert) {
- var i, ordinalStr, testMoment;
- for (i = 1; i <= 31; ++i) {
- ordinalStr = moment([2014, 0, i]).format('YYYY MM Do');
- testMoment = moment(ordinalStr, 'YYYY MM Do');
- assert.equal(testMoment.year(), 2014,
- 'lenient ordinal parsing ' + i + ' year check');
- assert.equal(testMoment.month(), 0,
- 'lenient ordinal parsing ' + i + ' month check');
- assert.equal(testMoment.date(), i,
- 'lenient ordinal parsing ' + i + ' date check');
- }
- });
-
- test('lenient ordinal parsing of number', function (assert) {
- var i, testMoment;
- for (i = 1; i <= 31; ++i) {
- testMoment = moment('2014 01 ' + i, 'YYYY MM Do');
- assert.equal(testMoment.year(), 2014,
- 'lenient ordinal parsing of number ' + i + ' year check');
- assert.equal(testMoment.month(), 0,
- 'lenient ordinal parsing of number ' + i + ' month check');
- assert.equal(testMoment.date(), i,
- 'lenient ordinal parsing of number ' + i + ' date check');
- }
- });
-
- test('strict ordinal parsing', function (assert) {
- var i, ordinalStr, testMoment;
- for (i = 1; i <= 31; ++i) {
- ordinalStr = moment([2014, 0, i]).format('YYYY MM Do');
- testMoment = moment(ordinalStr, 'YYYY MM Do', true);
- assert.ok(testMoment.isValid(), 'strict ordinal parsing ' + i);
- }
- });
-
}));
;(function (global, factory) {
@@ -30601,6 +43098,224 @@
typeof define === 'function' && define.amd ? define(['../../moment'], factory) :
factory(global.moment)
}(this, function (moment) { 'use strict';
+
+ function each(array, callback) {
+ var i;
+ for (i = 0; i < array.length; i++) {
+ callback(array[i], i, array);
+ }
+ }
+
+ function objectKeys(obj) {
+ if (Object.keys) {
+ return Object.keys(obj);
+ } else {
+ // IE8
+ var res = [], i;
+ for (i in obj) {
+ if (obj.hasOwnProperty(i)) {
+ res.push(i);
+ }
+ }
+ return res;
+ }
+ }
+
+ // Pick the first defined of two or three arguments.
+ function defaults(a, b, c) {
+ if (a != null) {
+ return a;
+ }
+ if (b != null) {
+ return b;
+ }
+ return c;
+ }
+
+ function defineCommonLocaleTests(locale, options) {
+ test('lenient ordinal parsing', function (assert) {
+ var i, ordinalStr, testMoment;
+ for (i = 1; i <= 31; ++i) {
+ ordinalStr = moment([2014, 0, i]).format('YYYY MM Do');
+ testMoment = moment(ordinalStr, 'YYYY MM Do');
+ assert.equal(testMoment.year(), 2014,
+ 'lenient ordinal parsing ' + i + ' year check');
+ assert.equal(testMoment.month(), 0,
+ 'lenient ordinal parsing ' + i + ' month check');
+ assert.equal(testMoment.date(), i,
+ 'lenient ordinal parsing ' + i + ' date check');
+ }
+ });
+
+ test('lenient ordinal parsing of number', function (assert) {
+ var i, testMoment;
+ for (i = 1; i <= 31; ++i) {
+ testMoment = moment('2014 01 ' + i, 'YYYY MM Do');
+ assert.equal(testMoment.year(), 2014,
+ 'lenient ordinal parsing of number ' + i + ' year check');
+ assert.equal(testMoment.month(), 0,
+ 'lenient ordinal parsing of number ' + i + ' month check');
+ assert.equal(testMoment.date(), i,
+ 'lenient ordinal parsing of number ' + i + ' date check');
+ }
+ });
+
+ test('strict ordinal parsing', function (assert) {
+ var i, ordinalStr, testMoment;
+ for (i = 1; i <= 31; ++i) {
+ ordinalStr = moment([2014, 0, i]).format('YYYY MM Do');
+ testMoment = moment(ordinalStr, 'YYYY MM Do', true);
+ assert.ok(testMoment.isValid(), 'strict ordinal parsing ' + i);
+ }
+ });
+
+ test('meridiem invariant', function (assert) {
+ var h, m, t1, t2;
+ for (h = 0; h < 24; ++h) {
+ for (m = 0; m < 60; m += 15) {
+ t1 = moment.utc([2000, 0, 1, h, m]);
+ t2 = moment.utc(t1.format('A h:mm'), 'A h:mm');
+ assert.equal(t2.format('HH:mm'), t1.format('HH:mm'),
+ 'meridiem at ' + t1.format('HH:mm'));
+ }
+ }
+ });
+
+ test('date format correctness', function (assert) {
+ var data, tokens;
+ data = moment.localeData()._longDateFormat;
+ tokens = objectKeys(data);
+ each(tokens, function (srchToken) {
+ // Check each format string to make sure it does not contain any
+ // tokens that need to be expanded.
+ each(tokens, function (baseToken) {
+ // strip escaped sequences
+ var format = data[baseToken].replace(/(\[[^\]]*\])/g, '');
+ assert.equal(false, !!~format.indexOf(srchToken),
+ 'contains ' + srchToken + ' in ' + baseToken);
+ });
+ });
+ });
+
+ test('month parsing correctness', function (assert) {
+ var i, m;
+
+ if (locale === 'tr') {
+ // I can't fix it :(
+ expect(0);
+ return;
+ }
+ function tester(format) {
+ var r;
+ r = moment(m.format(format), format);
+ assert.equal(r.month(), m.month(), 'month ' + i + ' fmt ' + format);
+ r = moment(m.format(format).toLocaleUpperCase(), format);
+ assert.equal(r.month(), m.month(), 'month ' + i + ' fmt ' + format + ' upper');
+ r = moment(m.format(format).toLocaleLowerCase(), format);
+ assert.equal(r.month(), m.month(), 'month ' + i + ' fmt ' + format + ' lower');
+
+ r = moment(m.format(format), format, true);
+ assert.equal(r.month(), m.month(), 'month ' + i + ' fmt ' + format + ' strict');
+ r = moment(m.format(format).toLocaleUpperCase(), format, true);
+ assert.equal(r.month(), m.month(), 'month ' + i + ' fmt ' + format + ' upper strict');
+ r = moment(m.format(format).toLocaleLowerCase(), format, true);
+ assert.equal(r.month(), m.month(), 'month ' + i + ' fmt ' + format + ' lower strict');
+ }
+
+ for (i = 0; i < 12; ++i) {
+ m = moment([2015, i, 15, 18]);
+ tester('MMM');
+ tester('MMM.');
+ tester('MMMM');
+ tester('MMMM.');
+ }
+ });
+
+ test('weekday parsing correctness', function (assert) {
+ var i, m;
+
+ if (locale === 'tr' || locale === 'az') {
+ // There is a lower-case letter (ı), that converted to upper then
+ // lower changes to i
+ expect(0);
+ return;
+ }
+ function tester(format) {
+ var r, baseMsg = 'weekday ' + m.weekday() + ' fmt ' + format;
+ r = moment(m.format(format), format);
+ assert.equal(r.weekday(), m.weekday(), baseMsg);
+ r = moment(m.format(format).toLocaleUpperCase(), format);
+ assert.equal(r.weekday(), m.weekday(), baseMsg + ' upper');
+ r = moment(m.format(format).toLocaleLowerCase(), format);
+ assert.equal(r.weekday(), m.weekday(), baseMsg + ' lower');
+
+ r = moment(m.format(format), format, true);
+ assert.equal(r.weekday(), m.weekday(), baseMsg + ' strict');
+ r = moment(m.format(format).toLocaleUpperCase(), format, true);
+ assert.equal(r.weekday(), m.weekday(), baseMsg + ' upper strict');
+ r = moment(m.format(format).toLocaleLowerCase(), format, true);
+ assert.equal(r.weekday(), m.weekday(), baseMsg + ' lower strict');
+ }
+
+ for (i = 0; i < 7; ++i) {
+ m = moment.utc([2015, i, 15, 18]);
+ tester('dd');
+ tester('ddd');
+ tester('dddd');
+ }
+ });
+ }
+
+ function setupDeprecationHandler(test, moment, scope) {
+ test._expectedDeprecations = null;
+ test._observedDeprecations = null;
+ test._oldSupress = moment.suppressDeprecationWarnings;
+ moment.suppressDeprecationWarnings = true;
+ test.expectedDeprecations = function () {
+ test._expectedDeprecations = arguments;
+ test._observedDeprecations = [];
+ };
+ moment.deprecationHandler = function (name, msg) {
+ var deprecationId = matchedDeprecation(name, msg, test._expectedDeprecations);
+ if (deprecationId === -1) {
+ throw new Error('Unexpected deprecation thrown name=' +
+ name + ' msg=' + msg);
+ }
+ test._observedDeprecations[deprecationId] = 1;
+ };
+ }
+
+ function teardownDeprecationHandler(test, moment, scope) {
+ moment.suppressDeprecationWarnings = test._oldSupress;
+
+ if (test._expectedDeprecations != null) {
+ var missedDeprecations = [];
+ each(test._expectedDeprecations, function (deprecationPattern, id) {
+ if (test._observedDeprecations[id] !== 1) {
+ missedDeprecations.push(deprecationPattern);
+ }
+ });
+ if (missedDeprecations.length !== 0) {
+ throw new Error('Expected deprecation warnings did not happen: ' +
+ missedDeprecations.join(' '));
+ }
+ }
+ }
+
+ function matchedDeprecation(name, msg, deprecations) {
+ if (deprecations == null) {
+ return -1;
+ }
+ for (var i = 0; i < deprecations.length; ++i) {
+ if (name != null && name === deprecations[i]) {
+ return i;
+ }
+ if (msg != null && msg.substring(0, deprecations[i].length) === deprecations[i]) {
+ return i;
+ }
+ }
+ return -1;
+ }
/*global QUnit:false*/
@@ -30615,11 +43330,13 @@
moment.createFromInputFallback = function (config) {
throw new Error('input not handled by moment: ' + config._i);
};
+ setupDeprecationHandler(test, moment, 'core');
if (lifecycle && lifecycle.setup) {
lifecycle.setup();
}
},
teardown : function () {
+ teardownDeprecationHandler(test, moment, 'core');
if (lifecycle && lifecycle.teardown) {
lifecycle.teardown();
}
@@ -30634,17 +43351,20 @@
moment.createFromInputFallback = function (config) {
throw new Error('input not handled by moment: ' + config._i);
};
+ setupDeprecationHandler(test, moment, 'locale');
if (lifecycle && lifecycle.setup) {
lifecycle.setup();
}
},
teardown : function () {
moment.locale('en');
+ teardownDeprecationHandler(test, moment, 'locale');
if (lifecycle && lifecycle.teardown) {
lifecycle.teardown();
}
}
});
+ defineCommonLocaleTests(name, -1, -1);
}
localeModule('ta');
@@ -30798,14 +43518,14 @@
});
test('calendar day', function (assert) {
- var a = moment().hours(2).minutes(0).seconds(0);
-
- assert.equal(moment(a).calendar(), 'இன்று ௦௨:௦௦', 'இன்று 02:00');
- assert.equal(moment(a).add({m: 25}).calendar(), 'இன்று ௦௨:௨௫', 'இன்று 02:25');
- assert.equal(moment(a).add({h: 1}).calendar(), 'இன்று ௦௩:௦௦', 'இன்று 03:00');
- assert.equal(moment(a).add({d: 1}).calendar(), 'நாளை ௦௨:௦௦', 'நாளை 02:00');
- assert.equal(moment(a).subtract({h: 1}).calendar(), 'இன்று ௦௧:௦௦', 'இன்று 0௧:00');
- assert.equal(moment(a).subtract({d: 1}).calendar(), 'நேற்று ௦௨:௦௦', 'நேற்று 02:00');
+ var a = moment().hours(12).minutes(0).seconds(0);
+
+ assert.equal(moment(a).calendar(), 'இன்று ௧௨:௦௦', 'இன்று 12:00');
+ assert.equal(moment(a).add({m: 25}).calendar(), 'இன்று ௧௨:௨௫', 'இன்று 12:25');
+ assert.equal(moment(a).add({h: 1}).calendar(), 'இன்று ௧௩:௦௦', 'இன்று 13:00');
+ assert.equal(moment(a).add({d: 1}).calendar(), 'நாளை ௧௨:௦௦', 'நாளை 12:00');
+ assert.equal(moment(a).subtract({h: 1}).calendar(), 'இன்று ௧௧:௦௦', 'இன்று 11:00');
+ assert.equal(moment(a).subtract({d: 1}).calendar(), 'நேற்று ௧௨:௦௦', 'நேற்று 12:00');
});
test('calendar next week', function (assert) {
@@ -30847,67 +43567,6 @@
assert.equal(weeksFromNow.calendar(), weeksFromNow.format('L'), 'in 2 weeks');
});
- test('weeks year starting sunday', function (assert) {
- assert.equal(moment([2012, 0, 1]).week(), 1, 'Jan 1 2012 should be week 1');
- assert.equal(moment([2012, 0, 7]).week(), 1, 'Jan 7 2012 should be week 1');
- assert.equal(moment([2012, 0, 8]).week(), 2, 'Jan 8 2012 should be week 2');
- assert.equal(moment([2012, 0, 14]).week(), 2, 'Jan 14 2012 should be week 2');
- assert.equal(moment([2012, 0, 15]).week(), 3, 'Jan 15 2012 should be week 3');
- });
-
- test('weeks year starting monday', function (assert) {
- assert.equal(moment([2006, 11, 31]).week(), 1, 'Dec 31 2006 should be week 1');
- assert.equal(moment([2007, 0, 1]).week(), 1, 'Jan 1 2007 should be week 1');
- assert.equal(moment([2007, 0, 6]).week(), 1, 'Jan 6 2007 should be week 1');
- assert.equal(moment([2007, 0, 7]).week(), 2, 'Jan 7 2007 should be week 2');
- assert.equal(moment([2007, 0, 13]).week(), 2, 'Jan 13 2007 should be week 2');
- assert.equal(moment([2007, 0, 14]).week(), 3, 'Jan 14 2007 should be week 3');
- });
-
- test('weeks year starting tuesday', function (assert) {
- assert.equal(moment([2007, 11, 29]).week(), 52, 'Dec 29 2007 should be week 52');
- assert.equal(moment([2008, 0, 1]).week(), 1, 'Jan 1 2008 should be week 1');
- assert.equal(moment([2008, 0, 5]).week(), 1, 'Jan 5 2008 should be week 1');
- assert.equal(moment([2008, 0, 6]).week(), 2, 'Jan 6 2008 should be week 2');
- assert.equal(moment([2008, 0, 12]).week(), 2, 'Jan 12 2008 should be week 2');
- assert.equal(moment([2008, 0, 13]).week(), 3, 'Jan 13 2008 should be week 3');
- });
-
- test('weeks year starting wednesday', function (assert) {
- assert.equal(moment([2002, 11, 29]).week(), 1, 'Dec 29 2002 should be week 1');
- assert.equal(moment([2003, 0, 1]).week(), 1, 'Jan 1 2003 should be week 1');
- assert.equal(moment([2003, 0, 4]).week(), 1, 'Jan 4 2003 should be week 1');
- assert.equal(moment([2003, 0, 5]).week(), 2, 'Jan 5 2003 should be week 2');
- assert.equal(moment([2003, 0, 11]).week(), 2, 'Jan 11 2003 should be week 2');
- assert.equal(moment([2003, 0, 12]).week(), 3, 'Jan 12 2003 should be week 3');
- });
-
- test('weeks year starting thursday', function (assert) {
- assert.equal(moment([2008, 11, 28]).week(), 1, 'Dec 28 2008 should be week 1');
- assert.equal(moment([2009, 0, 1]).week(), 1, 'Jan 1 2009 should be week 1');
- assert.equal(moment([2009, 0, 3]).week(), 1, 'Jan 3 2009 should be week 1');
- assert.equal(moment([2009, 0, 4]).week(), 2, 'Jan 4 2009 should be week 2');
- assert.equal(moment([2009, 0, 10]).week(), 2, 'Jan 10 2009 should be week 2');
- assert.equal(moment([2009, 0, 11]).week(), 3, 'Jan 11 2009 should be week 3');
- });
-
- test('weeks year starting friday', function (assert) {
- assert.equal(moment([2009, 11, 27]).week(), 1, 'Dec 27 2009 should be week 1');
- assert.equal(moment([2010, 0, 1]).week(), 1, 'Jan 1 2010 should be week 1');
- assert.equal(moment([2010, 0, 2]).week(), 1, 'Jan 2 2010 should be week 1');
- assert.equal(moment([2010, 0, 3]).week(), 2, 'Jan 3 2010 should be week 2');
- assert.equal(moment([2010, 0, 9]).week(), 2, 'Jan 9 2010 should be week 2');
- assert.equal(moment([2010, 0, 10]).week(), 3, 'Jan 10 2010 should be week 3');
- });
-
- test('weeks year starting saturday', function (assert) {
- assert.equal(moment([2010, 11, 26]).week(), 1, 'Dec 26 2010 should be week 1');
- assert.equal(moment([2011, 0, 1]).week(), 1, 'Jan 1 2011 should be week 1');
- assert.equal(moment([2011, 0, 2]).week(), 2, 'Jan 2 2011 should be week 2');
- assert.equal(moment([2011, 0, 8]).week(), 2, 'Jan 8 2011 should be week 2');
- assert.equal(moment([2011, 0, 9]).week(), 3, 'Jan 9 2011 should be week 3');
- });
-
test('meridiem', function (assert) {
assert.equal(moment([2011, 2, 23, 0, 30]).format('a'), ' யாமம்', '(after) midnight');
assert.equal(moment([2011, 2, 23, 2, 30]).format('a'), ' வைகறை', 'before dawn');
@@ -30918,54 +43577,6 @@
assert.equal(moment([2011, 2, 23, 23, 30]).format('a'), ' யாமம்', '(before) midnight');
});
- test('lenient ordinal parsing', function (assert) {
- var i, ordinalStr, testMoment;
- for (i = 1; i <= 31; ++i) {
- ordinalStr = moment([2014, 0, i]).format('YYYY MM Do');
- testMoment = moment(ordinalStr, 'YYYY MM Do');
- assert.equal(testMoment.year(), 2014,
- 'lenient ordinal parsing ' + i + ' year check');
- assert.equal(testMoment.month(), 0,
- 'lenient ordinal parsing ' + i + ' month check');
- assert.equal(testMoment.date(), i,
- 'lenient ordinal parsing ' + i + ' date check');
- }
- });
-
- test('lenient ordinal parsing of number', function (assert) {
- var i, testMoment;
- for (i = 1; i <= 31; ++i) {
- testMoment = moment('2014 01 ' + i, 'YYYY MM Do');
- assert.equal(testMoment.year(), 2014,
- 'lenient ordinal parsing of number ' + i + ' year check');
- assert.equal(testMoment.month(), 0,
- 'lenient ordinal parsing of number ' + i + ' month check');
- assert.equal(testMoment.date(), i,
- 'lenient ordinal parsing of number ' + i + ' date check');
- }
- });
-
- test('meridiem invariant', function (assert) {
- var h, m, t1, t2;
- for (h = 0; h < 24; ++h) {
- for (m = 0; m < 60; m += 15) {
- t1 = moment.utc([2000, 0, 1, h, m]);
- t2 = moment(t1.format('A h:mm'), 'A h:mm');
- assert.equal(t2.format('HH:mm'), t1.format('HH:mm'),
- 'meridiem at ' + t1.format('HH:mm'));
- }
- }
- });
-
- test('strict ordinal parsing', function (assert) {
- var i, ordinalStr, testMoment;
- for (i = 1; i <= 31; ++i) {
- ordinalStr = moment([2014, 0, i]).format('YYYY MM Do');
- testMoment = moment(ordinalStr, 'YYYY MM Do', true);
- assert.ok(testMoment.isValid(), 'strict ordinal parsing ' + i);
- }
- });
-
}));
;(function (global, factory) {
@@ -30974,6 +43585,224 @@
typeof define === 'function' && define.amd ? define(['../../moment'], factory) :
factory(global.moment)
}(this, function (moment) { 'use strict';
+
+ function each(array, callback) {
+ var i;
+ for (i = 0; i < array.length; i++) {
+ callback(array[i], i, array);
+ }
+ }
+
+ function objectKeys(obj) {
+ if (Object.keys) {
+ return Object.keys(obj);
+ } else {
+ // IE8
+ var res = [], i;
+ for (i in obj) {
+ if (obj.hasOwnProperty(i)) {
+ res.push(i);
+ }
+ }
+ return res;
+ }
+ }
+
+ // Pick the first defined of two or three arguments.
+ function defaults(a, b, c) {
+ if (a != null) {
+ return a;
+ }
+ if (b != null) {
+ return b;
+ }
+ return c;
+ }
+
+ function defineCommonLocaleTests(locale, options) {
+ test('lenient ordinal parsing', function (assert) {
+ var i, ordinalStr, testMoment;
+ for (i = 1; i <= 31; ++i) {
+ ordinalStr = moment([2014, 0, i]).format('YYYY MM Do');
+ testMoment = moment(ordinalStr, 'YYYY MM Do');
+ assert.equal(testMoment.year(), 2014,
+ 'lenient ordinal parsing ' + i + ' year check');
+ assert.equal(testMoment.month(), 0,
+ 'lenient ordinal parsing ' + i + ' month check');
+ assert.equal(testMoment.date(), i,
+ 'lenient ordinal parsing ' + i + ' date check');
+ }
+ });
+
+ test('lenient ordinal parsing of number', function (assert) {
+ var i, testMoment;
+ for (i = 1; i <= 31; ++i) {
+ testMoment = moment('2014 01 ' + i, 'YYYY MM Do');
+ assert.equal(testMoment.year(), 2014,
+ 'lenient ordinal parsing of number ' + i + ' year check');
+ assert.equal(testMoment.month(), 0,
+ 'lenient ordinal parsing of number ' + i + ' month check');
+ assert.equal(testMoment.date(), i,
+ 'lenient ordinal parsing of number ' + i + ' date check');
+ }
+ });
+
+ test('strict ordinal parsing', function (assert) {
+ var i, ordinalStr, testMoment;
+ for (i = 1; i <= 31; ++i) {
+ ordinalStr = moment([2014, 0, i]).format('YYYY MM Do');
+ testMoment = moment(ordinalStr, 'YYYY MM Do', true);
+ assert.ok(testMoment.isValid(), 'strict ordinal parsing ' + i);
+ }
+ });
+
+ test('meridiem invariant', function (assert) {
+ var h, m, t1, t2;
+ for (h = 0; h < 24; ++h) {
+ for (m = 0; m < 60; m += 15) {
+ t1 = moment.utc([2000, 0, 1, h, m]);
+ t2 = moment.utc(t1.format('A h:mm'), 'A h:mm');
+ assert.equal(t2.format('HH:mm'), t1.format('HH:mm'),
+ 'meridiem at ' + t1.format('HH:mm'));
+ }
+ }
+ });
+
+ test('date format correctness', function (assert) {
+ var data, tokens;
+ data = moment.localeData()._longDateFormat;
+ tokens = objectKeys(data);
+ each(tokens, function (srchToken) {
+ // Check each format string to make sure it does not contain any
+ // tokens that need to be expanded.
+ each(tokens, function (baseToken) {
+ // strip escaped sequences
+ var format = data[baseToken].replace(/(\[[^\]]*\])/g, '');
+ assert.equal(false, !!~format.indexOf(srchToken),
+ 'contains ' + srchToken + ' in ' + baseToken);
+ });
+ });
+ });
+
+ test('month parsing correctness', function (assert) {
+ var i, m;
+
+ if (locale === 'tr') {
+ // I can't fix it :(
+ expect(0);
+ return;
+ }
+ function tester(format) {
+ var r;
+ r = moment(m.format(format), format);
+ assert.equal(r.month(), m.month(), 'month ' + i + ' fmt ' + format);
+ r = moment(m.format(format).toLocaleUpperCase(), format);
+ assert.equal(r.month(), m.month(), 'month ' + i + ' fmt ' + format + ' upper');
+ r = moment(m.format(format).toLocaleLowerCase(), format);
+ assert.equal(r.month(), m.month(), 'month ' + i + ' fmt ' + format + ' lower');
+
+ r = moment(m.format(format), format, true);
+ assert.equal(r.month(), m.month(), 'month ' + i + ' fmt ' + format + ' strict');
+ r = moment(m.format(format).toLocaleUpperCase(), format, true);
+ assert.equal(r.month(), m.month(), 'month ' + i + ' fmt ' + format + ' upper strict');
+ r = moment(m.format(format).toLocaleLowerCase(), format, true);
+ assert.equal(r.month(), m.month(), 'month ' + i + ' fmt ' + format + ' lower strict');
+ }
+
+ for (i = 0; i < 12; ++i) {
+ m = moment([2015, i, 15, 18]);
+ tester('MMM');
+ tester('MMM.');
+ tester('MMMM');
+ tester('MMMM.');
+ }
+ });
+
+ test('weekday parsing correctness', function (assert) {
+ var i, m;
+
+ if (locale === 'tr' || locale === 'az') {
+ // There is a lower-case letter (ı), that converted to upper then
+ // lower changes to i
+ expect(0);
+ return;
+ }
+ function tester(format) {
+ var r, baseMsg = 'weekday ' + m.weekday() + ' fmt ' + format;
+ r = moment(m.format(format), format);
+ assert.equal(r.weekday(), m.weekday(), baseMsg);
+ r = moment(m.format(format).toLocaleUpperCase(), format);
+ assert.equal(r.weekday(), m.weekday(), baseMsg + ' upper');
+ r = moment(m.format(format).toLocaleLowerCase(), format);
+ assert.equal(r.weekday(), m.weekday(), baseMsg + ' lower');
+
+ r = moment(m.format(format), format, true);
+ assert.equal(r.weekday(), m.weekday(), baseMsg + ' strict');
+ r = moment(m.format(format).toLocaleUpperCase(), format, true);
+ assert.equal(r.weekday(), m.weekday(), baseMsg + ' upper strict');
+ r = moment(m.format(format).toLocaleLowerCase(), format, true);
+ assert.equal(r.weekday(), m.weekday(), baseMsg + ' lower strict');
+ }
+
+ for (i = 0; i < 7; ++i) {
+ m = moment.utc([2015, i, 15, 18]);
+ tester('dd');
+ tester('ddd');
+ tester('dddd');
+ }
+ });
+ }
+
+ function setupDeprecationHandler(test, moment, scope) {
+ test._expectedDeprecations = null;
+ test._observedDeprecations = null;
+ test._oldSupress = moment.suppressDeprecationWarnings;
+ moment.suppressDeprecationWarnings = true;
+ test.expectedDeprecations = function () {
+ test._expectedDeprecations = arguments;
+ test._observedDeprecations = [];
+ };
+ moment.deprecationHandler = function (name, msg) {
+ var deprecationId = matchedDeprecation(name, msg, test._expectedDeprecations);
+ if (deprecationId === -1) {
+ throw new Error('Unexpected deprecation thrown name=' +
+ name + ' msg=' + msg);
+ }
+ test._observedDeprecations[deprecationId] = 1;
+ };
+ }
+
+ function teardownDeprecationHandler(test, moment, scope) {
+ moment.suppressDeprecationWarnings = test._oldSupress;
+
+ if (test._expectedDeprecations != null) {
+ var missedDeprecations = [];
+ each(test._expectedDeprecations, function (deprecationPattern, id) {
+ if (test._observedDeprecations[id] !== 1) {
+ missedDeprecations.push(deprecationPattern);
+ }
+ });
+ if (missedDeprecations.length !== 0) {
+ throw new Error('Expected deprecation warnings did not happen: ' +
+ missedDeprecations.join(' '));
+ }
+ }
+ }
+
+ function matchedDeprecation(name, msg, deprecations) {
+ if (deprecations == null) {
+ return -1;
+ }
+ for (var i = 0; i < deprecations.length; ++i) {
+ if (name != null && name === deprecations[i]) {
+ return i;
+ }
+ if (msg != null && msg.substring(0, deprecations[i].length) === deprecations[i]) {
+ return i;
+ }
+ }
+ return -1;
+ }
/*global QUnit:false*/
@@ -30988,11 +43817,13 @@
moment.createFromInputFallback = function (config) {
throw new Error('input not handled by moment: ' + config._i);
};
+ setupDeprecationHandler(test, moment, 'core');
if (lifecycle && lifecycle.setup) {
lifecycle.setup();
}
},
teardown : function () {
+ teardownDeprecationHandler(test, moment, 'core');
if (lifecycle && lifecycle.teardown) {
lifecycle.teardown();
}
@@ -31007,17 +43838,20 @@
moment.createFromInputFallback = function (config) {
throw new Error('input not handled by moment: ' + config._i);
};
+ setupDeprecationHandler(test, moment, 'locale');
if (lifecycle && lifecycle.setup) {
lifecycle.setup();
}
},
teardown : function () {
moment.locale('en');
+ teardownDeprecationHandler(test, moment, 'locale');
if (lifecycle && lifecycle.teardown) {
lifecycle.teardown();
}
}
});
+ defineCommonLocaleTests(name, -1, -1);
}
localeModule('te');
@@ -31170,14 +44004,14 @@
});
test('calendar day', function (assert) {
- var a = moment().hours(2).minutes(0).seconds(0);
-
- assert.equal(moment(a).calendar(), 'నేడు రాత్రి 2:00', 'today at the same time');
- assert.equal(moment(a).add({m: 25}).calendar(), 'నేడు రాత్రి 2:25', 'Now plus 25 min');
- assert.equal(moment(a).add({h: 3}).calendar(), 'నేడు ఉదయం 5:00', 'Now plus 3 hour');
- assert.equal(moment(a).add({d: 1}).calendar(), 'రేపు రాత్రి 2:00', 'tomorrow at the same time');
- assert.equal(moment(a).subtract({h: 1}).calendar(), 'నేడు రాత్రి 1:00', 'Now minus 1 hour');
- assert.equal(moment(a).subtract({d: 1}).calendar(), 'నిన్న రాత్రి 2:00', 'yesterday at the same time');
+ var a = moment().hours(12).minutes(0).seconds(0);
+
+ assert.equal(moment(a).calendar(), 'నేడు మధ్యాహ్నం 12:00', 'today at the same time');
+ assert.equal(moment(a).add({m: 25}).calendar(), 'నేడు మధ్యాహ్నం 12:25', 'Now plus 25 min');
+ assert.equal(moment(a).add({h: 3}).calendar(), 'నేడు మధ్యాహ్నం 3:00', 'Now plus 3 hours');
+ assert.equal(moment(a).add({d: 1}).calendar(), 'రేపు మధ్యాహ్నం 12:00', 'tomorrow at the same time');
+ assert.equal(moment(a).subtract({h: 1}).calendar(), 'నేడు మధ్యాహ్నం 11:00', 'Now minus 1 hour');
+ assert.equal(moment(a).subtract({d: 1}).calendar(), 'నిన్న మధ్యాహ్నం 12:00', 'yesterday at the same time');
});
test('calendar next week', function (assert) {
@@ -31219,7 +44053,7 @@
assert.equal(weeksFromNow.calendar(), weeksFromNow.format('L'), 'in 2 weeks');
});
- test('meridiem invariant', function (assert) {
+ test('meridiem', function (assert) {
assert.equal(moment([2011, 2, 23, 2, 30]).format('a'), 'రాత్రి', 'before dawn');
assert.equal(moment([2011, 2, 23, 9, 30]).format('a'), 'ఉదయం', 'morning');
assert.equal(moment([2011, 2, 23, 14, 30]).format('a'), 'మధ్యాహ్నం', 'during day');
@@ -31235,67 +44069,6 @@
assert.equal(moment([2011, 2, 23, 21, 20]).format('A'), 'రాత్రి', 'night');
});
- test('weeks year starting sunday', function (assert) {
- assert.equal(moment([2012, 0, 1]).week(), 1, 'Jan 1 2012 should be week 1');
- assert.equal(moment([2012, 0, 7]).week(), 1, 'Jan 7 2012 should be week 1');
- assert.equal(moment([2012, 0, 8]).week(), 2, 'Jan 8 2012 should be week 2');
- assert.equal(moment([2012, 0, 14]).week(), 2, 'Jan 14 2012 should be week 2');
- assert.equal(moment([2012, 0, 15]).week(), 3, 'Jan 15 2012 should be week 3');
- });
-
- test('weeks year starting monday', function (assert) {
- assert.equal(moment([2006, 11, 31]).week(), 1, 'Dec 31 2006 should be week 1');
- assert.equal(moment([2007, 0, 1]).week(), 1, 'Jan 1 2007 should be week 1');
- assert.equal(moment([2007, 0, 6]).week(), 1, 'Jan 6 2007 should be week 1');
- assert.equal(moment([2007, 0, 7]).week(), 2, 'Jan 7 2007 should be week 2');
- assert.equal(moment([2007, 0, 13]).week(), 2, 'Jan 13 2007 should be week 2');
- assert.equal(moment([2007, 0, 14]).week(), 3, 'Jan 14 2007 should be week 3');
- });
-
- test('weeks year starting tuesday', function (assert) {
- assert.equal(moment([2007, 11, 29]).week(), 52, 'Dec 29 2007 should be week 52');
- assert.equal(moment([2008, 0, 1]).week(), 1, 'Jan 1 2008 should be week 1');
- assert.equal(moment([2008, 0, 5]).week(), 1, 'Jan 5 2008 should be week 1');
- assert.equal(moment([2008, 0, 6]).week(), 2, 'Jan 6 2008 should be week 2');
- assert.equal(moment([2008, 0, 12]).week(), 2, 'Jan 12 2008 should be week 2');
- assert.equal(moment([2008, 0, 13]).week(), 3, 'Jan 13 2008 should be week 3');
- });
-
- test('weeks year starting wednesday', function (assert) {
- assert.equal(moment([2002, 11, 29]).week(), 1, 'Dec 29 2002 should be week 1');
- assert.equal(moment([2003, 0, 1]).week(), 1, 'Jan 1 2003 should be week 1');
- assert.equal(moment([2003, 0, 4]).week(), 1, 'Jan 4 2003 should be week 1');
- assert.equal(moment([2003, 0, 5]).week(), 2, 'Jan 5 2003 should be week 2');
- assert.equal(moment([2003, 0, 11]).week(), 2, 'Jan 11 2003 should be week 2');
- assert.equal(moment([2003, 0, 12]).week(), 3, 'Jan 12 2003 should be week 3');
- });
-
- test('weeks year starting thursday', function (assert) {
- assert.equal(moment([2008, 11, 28]).week(), 1, 'Dec 28 2008 should be week 1');
- assert.equal(moment([2009, 0, 1]).week(), 1, 'Jan 1 2009 should be week 1');
- assert.equal(moment([2009, 0, 3]).week(), 1, 'Jan 3 2009 should be week 1');
- assert.equal(moment([2009, 0, 4]).week(), 2, 'Jan 4 2009 should be week 2');
- assert.equal(moment([2009, 0, 10]).week(), 2, 'Jan 10 2009 should be week 2');
- assert.equal(moment([2009, 0, 11]).week(), 3, 'Jan 11 2009 should be week 3');
- });
-
- test('weeks year starting friday', function (assert) {
- assert.equal(moment([2009, 11, 27]).week(), 1, 'Dec 27 2009 should be week 1');
- assert.equal(moment([2010, 0, 1]).week(), 1, 'Jan 1 2010 should be week 1');
- assert.equal(moment([2010, 0, 2]).week(), 1, 'Jan 2 2010 should be week 1');
- assert.equal(moment([2010, 0, 3]).week(), 2, 'Jan 3 2010 should be week 2');
- assert.equal(moment([2010, 0, 9]).week(), 2, 'Jan 9 2010 should be week 2');
- assert.equal(moment([2010, 0, 10]).week(), 3, 'Jan 10 2010 should be week 3');
- });
-
- test('weeks year starting saturday', function (assert) {
- assert.equal(moment([2010, 11, 26]).week(), 1, 'Dec 26 2010 should be week 1');
- assert.equal(moment([2011, 0, 1]).week(), 1, 'Jan 1 2011 should be week 1');
- assert.equal(moment([2011, 0, 2]).week(), 2, 'Jan 2 2011 should be week 2');
- assert.equal(moment([2011, 0, 8]).week(), 2, 'Jan 8 2011 should be week 2');
- assert.equal(moment([2011, 0, 9]).week(), 3, 'Jan 9 2011 should be week 3');
- });
-
test('weeks year starting sunday formatted', function (assert) {
assert.equal(moment([2012, 0, 1]).format('w ww wo'), '1 01 1వ', 'Jan 1 2012 should be week 1');
assert.equal(moment([2012, 0, 7]).format('w ww wo'), '1 01 1వ', 'Jan 7 2012 should be week 1');
@@ -31304,54 +44077,6 @@
assert.equal(moment([2012, 0, 15]).format('w ww wo'), '3 03 3వ', 'Jan 15 2012 should be week 3');
});
- test('lenient ordinal parsing', function (assert) {
- var i, ordinalStr, testMoment;
- for (i = 1; i <= 31; ++i) {
- ordinalStr = moment([2014, 0, i]).format('YYYY MM Do');
- testMoment = moment(ordinalStr, 'YYYY MM Do');
- assert.equal(testMoment.year(), 2014,
- 'lenient ordinal parsing ' + i + ' year check');
- assert.equal(testMoment.month(), 0,
- 'lenient ordinal parsing ' + i + ' month check');
- assert.equal(testMoment.date(), i,
- 'lenient ordinal parsing ' + i + ' date check');
- }
- });
-
- test('lenient ordinal parsing of number', function (assert) {
- var i, testMoment;
- for (i = 1; i <= 31; ++i) {
- testMoment = moment('2014 01 ' + i, 'YYYY MM Do');
- assert.equal(testMoment.year(), 2014,
- 'lenient ordinal parsing of number ' + i + ' year check');
- assert.equal(testMoment.month(), 0,
- 'lenient ordinal parsing of number ' + i + ' month check');
- assert.equal(testMoment.date(), i,
- 'lenient ordinal parsing of number ' + i + ' date check');
- }
- });
-
- test('meridiem', function (assert) {
- var h, m, t1, t2;
- for (h = 0; h < 24; ++h) {
- for (m = 0; m < 60; m += 15) {
- t1 = moment.utc([2000, 0, 1, h, m]);
- t2 = moment(t1.format('A h:mm'), 'A h:mm');
- assert.equal(t2.format('HH:mm'), t1.format('HH:mm'),
- 'meridiem at ' + t1.format('HH:mm'));
- }
- }
- });
-
- test('strict ordinal parsing', function (assert) {
- var i, ordinalStr, testMoment;
- for (i = 1; i <= 31; ++i) {
- ordinalStr = moment([2014, 0, i]).format('YYYY MM Do');
- testMoment = moment(ordinalStr, 'YYYY MM Do', true);
- assert.ok(testMoment.isValid(), 'strict ordinal parsing ' + i);
- }
- });
-
}));
;(function (global, factory) {
@@ -31360,6 +44085,224 @@
typeof define === 'function' && define.amd ? define(['../../moment'], factory) :
factory(global.moment)
}(this, function (moment) { 'use strict';
+
+ function each(array, callback) {
+ var i;
+ for (i = 0; i < array.length; i++) {
+ callback(array[i], i, array);
+ }
+ }
+
+ function objectKeys(obj) {
+ if (Object.keys) {
+ return Object.keys(obj);
+ } else {
+ // IE8
+ var res = [], i;
+ for (i in obj) {
+ if (obj.hasOwnProperty(i)) {
+ res.push(i);
+ }
+ }
+ return res;
+ }
+ }
+
+ // Pick the first defined of two or three arguments.
+ function defaults(a, b, c) {
+ if (a != null) {
+ return a;
+ }
+ if (b != null) {
+ return b;
+ }
+ return c;
+ }
+
+ function defineCommonLocaleTests(locale, options) {
+ test('lenient ordinal parsing', function (assert) {
+ var i, ordinalStr, testMoment;
+ for (i = 1; i <= 31; ++i) {
+ ordinalStr = moment([2014, 0, i]).format('YYYY MM Do');
+ testMoment = moment(ordinalStr, 'YYYY MM Do');
+ assert.equal(testMoment.year(), 2014,
+ 'lenient ordinal parsing ' + i + ' year check');
+ assert.equal(testMoment.month(), 0,
+ 'lenient ordinal parsing ' + i + ' month check');
+ assert.equal(testMoment.date(), i,
+ 'lenient ordinal parsing ' + i + ' date check');
+ }
+ });
+
+ test('lenient ordinal parsing of number', function (assert) {
+ var i, testMoment;
+ for (i = 1; i <= 31; ++i) {
+ testMoment = moment('2014 01 ' + i, 'YYYY MM Do');
+ assert.equal(testMoment.year(), 2014,
+ 'lenient ordinal parsing of number ' + i + ' year check');
+ assert.equal(testMoment.month(), 0,
+ 'lenient ordinal parsing of number ' + i + ' month check');
+ assert.equal(testMoment.date(), i,
+ 'lenient ordinal parsing of number ' + i + ' date check');
+ }
+ });
+
+ test('strict ordinal parsing', function (assert) {
+ var i, ordinalStr, testMoment;
+ for (i = 1; i <= 31; ++i) {
+ ordinalStr = moment([2014, 0, i]).format('YYYY MM Do');
+ testMoment = moment(ordinalStr, 'YYYY MM Do', true);
+ assert.ok(testMoment.isValid(), 'strict ordinal parsing ' + i);
+ }
+ });
+
+ test('meridiem invariant', function (assert) {
+ var h, m, t1, t2;
+ for (h = 0; h < 24; ++h) {
+ for (m = 0; m < 60; m += 15) {
+ t1 = moment.utc([2000, 0, 1, h, m]);
+ t2 = moment.utc(t1.format('A h:mm'), 'A h:mm');
+ assert.equal(t2.format('HH:mm'), t1.format('HH:mm'),
+ 'meridiem at ' + t1.format('HH:mm'));
+ }
+ }
+ });
+
+ test('date format correctness', function (assert) {
+ var data, tokens;
+ data = moment.localeData()._longDateFormat;
+ tokens = objectKeys(data);
+ each(tokens, function (srchToken) {
+ // Check each format string to make sure it does not contain any
+ // tokens that need to be expanded.
+ each(tokens, function (baseToken) {
+ // strip escaped sequences
+ var format = data[baseToken].replace(/(\[[^\]]*\])/g, '');
+ assert.equal(false, !!~format.indexOf(srchToken),
+ 'contains ' + srchToken + ' in ' + baseToken);
+ });
+ });
+ });
+
+ test('month parsing correctness', function (assert) {
+ var i, m;
+
+ if (locale === 'tr') {
+ // I can't fix it :(
+ expect(0);
+ return;
+ }
+ function tester(format) {
+ var r;
+ r = moment(m.format(format), format);
+ assert.equal(r.month(), m.month(), 'month ' + i + ' fmt ' + format);
+ r = moment(m.format(format).toLocaleUpperCase(), format);
+ assert.equal(r.month(), m.month(), 'month ' + i + ' fmt ' + format + ' upper');
+ r = moment(m.format(format).toLocaleLowerCase(), format);
+ assert.equal(r.month(), m.month(), 'month ' + i + ' fmt ' + format + ' lower');
+
+ r = moment(m.format(format), format, true);
+ assert.equal(r.month(), m.month(), 'month ' + i + ' fmt ' + format + ' strict');
+ r = moment(m.format(format).toLocaleUpperCase(), format, true);
+ assert.equal(r.month(), m.month(), 'month ' + i + ' fmt ' + format + ' upper strict');
+ r = moment(m.format(format).toLocaleLowerCase(), format, true);
+ assert.equal(r.month(), m.month(), 'month ' + i + ' fmt ' + format + ' lower strict');
+ }
+
+ for (i = 0; i < 12; ++i) {
+ m = moment([2015, i, 15, 18]);
+ tester('MMM');
+ tester('MMM.');
+ tester('MMMM');
+ tester('MMMM.');
+ }
+ });
+
+ test('weekday parsing correctness', function (assert) {
+ var i, m;
+
+ if (locale === 'tr' || locale === 'az') {
+ // There is a lower-case letter (ı), that converted to upper then
+ // lower changes to i
+ expect(0);
+ return;
+ }
+ function tester(format) {
+ var r, baseMsg = 'weekday ' + m.weekday() + ' fmt ' + format;
+ r = moment(m.format(format), format);
+ assert.equal(r.weekday(), m.weekday(), baseMsg);
+ r = moment(m.format(format).toLocaleUpperCase(), format);
+ assert.equal(r.weekday(), m.weekday(), baseMsg + ' upper');
+ r = moment(m.format(format).toLocaleLowerCase(), format);
+ assert.equal(r.weekday(), m.weekday(), baseMsg + ' lower');
+
+ r = moment(m.format(format), format, true);
+ assert.equal(r.weekday(), m.weekday(), baseMsg + ' strict');
+ r = moment(m.format(format).toLocaleUpperCase(), format, true);
+ assert.equal(r.weekday(), m.weekday(), baseMsg + ' upper strict');
+ r = moment(m.format(format).toLocaleLowerCase(), format, true);
+ assert.equal(r.weekday(), m.weekday(), baseMsg + ' lower strict');
+ }
+
+ for (i = 0; i < 7; ++i) {
+ m = moment.utc([2015, i, 15, 18]);
+ tester('dd');
+ tester('ddd');
+ tester('dddd');
+ }
+ });
+ }
+
+ function setupDeprecationHandler(test, moment, scope) {
+ test._expectedDeprecations = null;
+ test._observedDeprecations = null;
+ test._oldSupress = moment.suppressDeprecationWarnings;
+ moment.suppressDeprecationWarnings = true;
+ test.expectedDeprecations = function () {
+ test._expectedDeprecations = arguments;
+ test._observedDeprecations = [];
+ };
+ moment.deprecationHandler = function (name, msg) {
+ var deprecationId = matchedDeprecation(name, msg, test._expectedDeprecations);
+ if (deprecationId === -1) {
+ throw new Error('Unexpected deprecation thrown name=' +
+ name + ' msg=' + msg);
+ }
+ test._observedDeprecations[deprecationId] = 1;
+ };
+ }
+
+ function teardownDeprecationHandler(test, moment, scope) {
+ moment.suppressDeprecationWarnings = test._oldSupress;
+
+ if (test._expectedDeprecations != null) {
+ var missedDeprecations = [];
+ each(test._expectedDeprecations, function (deprecationPattern, id) {
+ if (test._observedDeprecations[id] !== 1) {
+ missedDeprecations.push(deprecationPattern);
+ }
+ });
+ if (missedDeprecations.length !== 0) {
+ throw new Error('Expected deprecation warnings did not happen: ' +
+ missedDeprecations.join(' '));
+ }
+ }
+ }
+
+ function matchedDeprecation(name, msg, deprecations) {
+ if (deprecations == null) {
+ return -1;
+ }
+ for (var i = 0; i < deprecations.length; ++i) {
+ if (name != null && name === deprecations[i]) {
+ return i;
+ }
+ if (msg != null && msg.substring(0, deprecations[i].length) === deprecations[i]) {
+ return i;
+ }
+ }
+ return -1;
+ }
/*global QUnit:false*/
@@ -31374,11 +44317,13 @@
moment.createFromInputFallback = function (config) {
throw new Error('input not handled by moment: ' + config._i);
};
+ setupDeprecationHandler(test, moment, 'core');
if (lifecycle && lifecycle.setup) {
lifecycle.setup();
}
},
teardown : function () {
+ teardownDeprecationHandler(test, moment, 'core');
if (lifecycle && lifecycle.teardown) {
lifecycle.teardown();
}
@@ -31393,17 +44338,20 @@
moment.createFromInputFallback = function (config) {
throw new Error('input not handled by moment: ' + config._i);
};
+ setupDeprecationHandler(test, moment, 'locale');
if (lifecycle && lifecycle.setup) {
lifecycle.setup();
}
},
teardown : function () {
moment.locale('en');
+ teardownDeprecationHandler(test, moment, 'locale');
if (lifecycle && lifecycle.teardown) {
lifecycle.teardown();
}
}
});
+ defineCommonLocaleTests(name, -1, -1);
}
localeModule('th');
@@ -31520,14 +44468,14 @@
});
test('calendar day', function (assert) {
- var a = moment().hours(2).minutes(0).seconds(0);
-
- assert.equal(moment(a).calendar(), 'วันนี้ เวลา 2 นาฬิกา 0 นาที', 'today at the same time');
- assert.equal(moment(a).add({m: 25}).calendar(), 'วันนี้ เวลา 2 นาฬิกา 25 นาที', 'Now plus 25 min');
- assert.equal(moment(a).add({h: 1}).calendar(), 'วันนี้ เวลา 3 นาฬิกา 0 นาที', 'Now plus 1 hour');
- assert.equal(moment(a).add({d: 1}).calendar(), 'พรุ่งนี้ เวลา 2 นาฬิกา 0 นาที', 'tomorrow at the same time');
- assert.equal(moment(a).subtract({h: 1}).calendar(), 'วันนี้ เวลา 1 นาฬิกา 0 นาที', 'Now minus 1 hour');
- assert.equal(moment(a).subtract({d: 1}).calendar(), 'เมื่อวานนี้ เวลา 2 นาฬิกา 0 นาที', 'yesterday at the same time');
+ var a = moment().hours(12).minutes(0).seconds(0);
+
+ assert.equal(moment(a).calendar(), 'วันนี้ เวลา 12 นาฬิกา 0 นาที', 'today at the same time');
+ assert.equal(moment(a).add({m: 25}).calendar(), 'วันนี้ เวลา 12 นาฬิกา 25 นาที', 'Now plus 25 min');
+ assert.equal(moment(a).add({h: 1}).calendar(), 'วันนี้ เวลา 13 นาฬิกา 0 นาที', 'Now plus 1 hour');
+ assert.equal(moment(a).add({d: 1}).calendar(), 'พรุ่งนี้ เวลา 12 นาฬิกา 0 นาที', 'tomorrow at the same time');
+ assert.equal(moment(a).subtract({h: 1}).calendar(), 'วันนี้ เวลา 11 นาฬิกา 0 นาที', 'Now minus 1 hour');
+ assert.equal(moment(a).subtract({d: 1}).calendar(), 'เมื่อวานนี้ เวลา 12 นาฬิกา 0 นาที', 'yesterday at the same time');
});
test('calendar next week', function (assert) {
@@ -31568,67 +44516,6 @@
assert.equal(weeksFromNow.calendar(), weeksFromNow.format('L'), 'in 2 weeks');
});
- test('weeks year starting sunday', function (assert) {
- assert.equal(moment([2012, 0, 1]).week(), 1, 'Jan 1 2012 should be week 1');
- assert.equal(moment([2012, 0, 7]).week(), 1, 'Jan 7 2012 should be week 1');
- assert.equal(moment([2012, 0, 8]).week(), 2, 'Jan 8 2012 should be week 2');
- assert.equal(moment([2012, 0, 14]).week(), 2, 'Jan 14 2012 should be week 2');
- assert.equal(moment([2012, 0, 15]).week(), 3, 'Jan 15 2012 should be week 3');
- });
-
- test('weeks year starting monday', function (assert) {
- assert.equal(moment([2006, 11, 31]).week(), 1, 'Dec 31 2006 should be week 1');
- assert.equal(moment([2007, 0, 1]).week(), 1, 'Jan 1 2007 should be week 1');
- assert.equal(moment([2007, 0, 6]).week(), 1, 'Jan 6 2007 should be week 1');
- assert.equal(moment([2007, 0, 7]).week(), 2, 'Jan 7 2007 should be week 2');
- assert.equal(moment([2007, 0, 13]).week(), 2, 'Jan 13 2007 should be week 2');
- assert.equal(moment([2007, 0, 14]).week(), 3, 'Jan 14 2007 should be week 3');
- });
-
- test('weeks year starting tuesday', function (assert) {
- assert.equal(moment([2007, 11, 29]).week(), 52, 'Dec 29 2007 should be week 52');
- assert.equal(moment([2008, 0, 1]).week(), 1, 'Jan 1 2008 should be week 1');
- assert.equal(moment([2008, 0, 5]).week(), 1, 'Jan 5 2008 should be week 1');
- assert.equal(moment([2008, 0, 6]).week(), 2, 'Jan 6 2008 should be week 2');
- assert.equal(moment([2008, 0, 12]).week(), 2, 'Jan 12 2008 should be week 2');
- assert.equal(moment([2008, 0, 13]).week(), 3, 'Jan 13 2008 should be week 3');
- });
-
- test('weeks year starting wednesday', function (assert) {
- assert.equal(moment([2002, 11, 29]).week(), 1, 'Dec 29 2002 should be week 1');
- assert.equal(moment([2003, 0, 1]).week(), 1, 'Jan 1 2003 should be week 1');
- assert.equal(moment([2003, 0, 4]).week(), 1, 'Jan 4 2003 should be week 1');
- assert.equal(moment([2003, 0, 5]).week(), 2, 'Jan 5 2003 should be week 2');
- assert.equal(moment([2003, 0, 11]).week(), 2, 'Jan 11 2003 should be week 2');
- assert.equal(moment([2003, 0, 12]).week(), 3, 'Jan 12 2003 should be week 3');
- });
-
- test('weeks year starting thursday', function (assert) {
- assert.equal(moment([2008, 11, 28]).week(), 1, 'Dec 28 2008 should be week 1');
- assert.equal(moment([2009, 0, 1]).week(), 1, 'Jan 1 2009 should be week 1');
- assert.equal(moment([2009, 0, 3]).week(), 1, 'Jan 3 2009 should be week 1');
- assert.equal(moment([2009, 0, 4]).week(), 2, 'Jan 4 2009 should be week 2');
- assert.equal(moment([2009, 0, 10]).week(), 2, 'Jan 10 2009 should be week 2');
- assert.equal(moment([2009, 0, 11]).week(), 3, 'Jan 11 2009 should be week 3');
- });
-
- test('weeks year starting friday', function (assert) {
- assert.equal(moment([2009, 11, 27]).week(), 1, 'Dec 27 2009 should be week 1');
- assert.equal(moment([2010, 0, 1]).week(), 1, 'Jan 1 2010 should be week 1');
- assert.equal(moment([2010, 0, 2]).week(), 1, 'Jan 2 2010 should be week 1');
- assert.equal(moment([2010, 0, 3]).week(), 2, 'Jan 3 2010 should be week 2');
- assert.equal(moment([2010, 0, 9]).week(), 2, 'Jan 9 2010 should be week 2');
- assert.equal(moment([2010, 0, 10]).week(), 3, 'Jan 10 2010 should be week 3');
- });
-
- test('weeks year starting saturday', function (assert) {
- assert.equal(moment([2010, 11, 26]).week(), 1, 'Dec 26 2010 should be week 1');
- assert.equal(moment([2011, 0, 1]).week(), 1, 'Jan 1 2011 should be week 1');
- assert.equal(moment([2011, 0, 2]).week(), 2, 'Jan 2 2011 should be week 2');
- assert.equal(moment([2011, 0, 8]).week(), 2, 'Jan 8 2011 should be week 2');
- assert.equal(moment([2011, 0, 9]).week(), 3, 'Jan 9 2011 should be week 3');
- });
-
test('weeks year starting sunday format', function (assert) {
assert.equal(moment([2012, 0, 1]).format('w ww wo'), '1 01 1', 'Jan 1 2012 should be week 1');
assert.equal(moment([2012, 0, 7]).format('w ww wo'), '1 01 1', 'Jan 7 2012 should be week 1');
@@ -31637,42 +44524,6 @@
assert.equal(moment([2012, 0, 15]).format('w ww wo'), '3 03 3', 'Jan 15 2012 should be week 3');
});
- test('lenient ordinal parsing', function (assert) {
- var i, ordinalStr, testMoment;
- for (i = 1; i <= 31; ++i) {
- ordinalStr = moment([2014, 0, i]).format('YYYY MM Do');
- testMoment = moment(ordinalStr, 'YYYY MM Do');
- assert.equal(testMoment.year(), 2014,
- 'lenient ordinal parsing ' + i + ' year check');
- assert.equal(testMoment.month(), 0,
- 'lenient ordinal parsing ' + i + ' month check');
- assert.equal(testMoment.date(), i,
- 'lenient ordinal parsing ' + i + ' date check');
- }
- });
-
- test('lenient ordinal parsing of number', function (assert) {
- var i, testMoment;
- for (i = 1; i <= 31; ++i) {
- testMoment = moment('2014 01 ' + i, 'YYYY MM Do');
- assert.equal(testMoment.year(), 2014,
- 'lenient ordinal parsing of number ' + i + ' year check');
- assert.equal(testMoment.month(), 0,
- 'lenient ordinal parsing of number ' + i + ' month check');
- assert.equal(testMoment.date(), i,
- 'lenient ordinal parsing of number ' + i + ' date check');
- }
- });
-
- test('strict ordinal parsing', function (assert) {
- var i, ordinalStr, testMoment;
- for (i = 1; i <= 31; ++i) {
- ordinalStr = moment([2014, 0, i]).format('YYYY MM Do');
- testMoment = moment(ordinalStr, 'YYYY MM Do', true);
- assert.ok(testMoment.isValid(), 'strict ordinal parsing ' + i);
- }
- });
-
}));
;(function (global, factory) {
@@ -31681,6 +44532,224 @@
typeof define === 'function' && define.amd ? define(['../../moment'], factory) :
factory(global.moment)
}(this, function (moment) { 'use strict';
+
+ function each(array, callback) {
+ var i;
+ for (i = 0; i < array.length; i++) {
+ callback(array[i], i, array);
+ }
+ }
+
+ function objectKeys(obj) {
+ if (Object.keys) {
+ return Object.keys(obj);
+ } else {
+ // IE8
+ var res = [], i;
+ for (i in obj) {
+ if (obj.hasOwnProperty(i)) {
+ res.push(i);
+ }
+ }
+ return res;
+ }
+ }
+
+ // Pick the first defined of two or three arguments.
+ function defaults(a, b, c) {
+ if (a != null) {
+ return a;
+ }
+ if (b != null) {
+ return b;
+ }
+ return c;
+ }
+
+ function defineCommonLocaleTests(locale, options) {
+ test('lenient ordinal parsing', function (assert) {
+ var i, ordinalStr, testMoment;
+ for (i = 1; i <= 31; ++i) {
+ ordinalStr = moment([2014, 0, i]).format('YYYY MM Do');
+ testMoment = moment(ordinalStr, 'YYYY MM Do');
+ assert.equal(testMoment.year(), 2014,
+ 'lenient ordinal parsing ' + i + ' year check');
+ assert.equal(testMoment.month(), 0,
+ 'lenient ordinal parsing ' + i + ' month check');
+ assert.equal(testMoment.date(), i,
+ 'lenient ordinal parsing ' + i + ' date check');
+ }
+ });
+
+ test('lenient ordinal parsing of number', function (assert) {
+ var i, testMoment;
+ for (i = 1; i <= 31; ++i) {
+ testMoment = moment('2014 01 ' + i, 'YYYY MM Do');
+ assert.equal(testMoment.year(), 2014,
+ 'lenient ordinal parsing of number ' + i + ' year check');
+ assert.equal(testMoment.month(), 0,
+ 'lenient ordinal parsing of number ' + i + ' month check');
+ assert.equal(testMoment.date(), i,
+ 'lenient ordinal parsing of number ' + i + ' date check');
+ }
+ });
+
+ test('strict ordinal parsing', function (assert) {
+ var i, ordinalStr, testMoment;
+ for (i = 1; i <= 31; ++i) {
+ ordinalStr = moment([2014, 0, i]).format('YYYY MM Do');
+ testMoment = moment(ordinalStr, 'YYYY MM Do', true);
+ assert.ok(testMoment.isValid(), 'strict ordinal parsing ' + i);
+ }
+ });
+
+ test('meridiem invariant', function (assert) {
+ var h, m, t1, t2;
+ for (h = 0; h < 24; ++h) {
+ for (m = 0; m < 60; m += 15) {
+ t1 = moment.utc([2000, 0, 1, h, m]);
+ t2 = moment.utc(t1.format('A h:mm'), 'A h:mm');
+ assert.equal(t2.format('HH:mm'), t1.format('HH:mm'),
+ 'meridiem at ' + t1.format('HH:mm'));
+ }
+ }
+ });
+
+ test('date format correctness', function (assert) {
+ var data, tokens;
+ data = moment.localeData()._longDateFormat;
+ tokens = objectKeys(data);
+ each(tokens, function (srchToken) {
+ // Check each format string to make sure it does not contain any
+ // tokens that need to be expanded.
+ each(tokens, function (baseToken) {
+ // strip escaped sequences
+ var format = data[baseToken].replace(/(\[[^\]]*\])/g, '');
+ assert.equal(false, !!~format.indexOf(srchToken),
+ 'contains ' + srchToken + ' in ' + baseToken);
+ });
+ });
+ });
+
+ test('month parsing correctness', function (assert) {
+ var i, m;
+
+ if (locale === 'tr') {
+ // I can't fix it :(
+ expect(0);
+ return;
+ }
+ function tester(format) {
+ var r;
+ r = moment(m.format(format), format);
+ assert.equal(r.month(), m.month(), 'month ' + i + ' fmt ' + format);
+ r = moment(m.format(format).toLocaleUpperCase(), format);
+ assert.equal(r.month(), m.month(), 'month ' + i + ' fmt ' + format + ' upper');
+ r = moment(m.format(format).toLocaleLowerCase(), format);
+ assert.equal(r.month(), m.month(), 'month ' + i + ' fmt ' + format + ' lower');
+
+ r = moment(m.format(format), format, true);
+ assert.equal(r.month(), m.month(), 'month ' + i + ' fmt ' + format + ' strict');
+ r = moment(m.format(format).toLocaleUpperCase(), format, true);
+ assert.equal(r.month(), m.month(), 'month ' + i + ' fmt ' + format + ' upper strict');
+ r = moment(m.format(format).toLocaleLowerCase(), format, true);
+ assert.equal(r.month(), m.month(), 'month ' + i + ' fmt ' + format + ' lower strict');
+ }
+
+ for (i = 0; i < 12; ++i) {
+ m = moment([2015, i, 15, 18]);
+ tester('MMM');
+ tester('MMM.');
+ tester('MMMM');
+ tester('MMMM.');
+ }
+ });
+
+ test('weekday parsing correctness', function (assert) {
+ var i, m;
+
+ if (locale === 'tr' || locale === 'az') {
+ // There is a lower-case letter (ı), that converted to upper then
+ // lower changes to i
+ expect(0);
+ return;
+ }
+ function tester(format) {
+ var r, baseMsg = 'weekday ' + m.weekday() + ' fmt ' + format;
+ r = moment(m.format(format), format);
+ assert.equal(r.weekday(), m.weekday(), baseMsg);
+ r = moment(m.format(format).toLocaleUpperCase(), format);
+ assert.equal(r.weekday(), m.weekday(), baseMsg + ' upper');
+ r = moment(m.format(format).toLocaleLowerCase(), format);
+ assert.equal(r.weekday(), m.weekday(), baseMsg + ' lower');
+
+ r = moment(m.format(format), format, true);
+ assert.equal(r.weekday(), m.weekday(), baseMsg + ' strict');
+ r = moment(m.format(format).toLocaleUpperCase(), format, true);
+ assert.equal(r.weekday(), m.weekday(), baseMsg + ' upper strict');
+ r = moment(m.format(format).toLocaleLowerCase(), format, true);
+ assert.equal(r.weekday(), m.weekday(), baseMsg + ' lower strict');
+ }
+
+ for (i = 0; i < 7; ++i) {
+ m = moment.utc([2015, i, 15, 18]);
+ tester('dd');
+ tester('ddd');
+ tester('dddd');
+ }
+ });
+ }
+
+ function setupDeprecationHandler(test, moment, scope) {
+ test._expectedDeprecations = null;
+ test._observedDeprecations = null;
+ test._oldSupress = moment.suppressDeprecationWarnings;
+ moment.suppressDeprecationWarnings = true;
+ test.expectedDeprecations = function () {
+ test._expectedDeprecations = arguments;
+ test._observedDeprecations = [];
+ };
+ moment.deprecationHandler = function (name, msg) {
+ var deprecationId = matchedDeprecation(name, msg, test._expectedDeprecations);
+ if (deprecationId === -1) {
+ throw new Error('Unexpected deprecation thrown name=' +
+ name + ' msg=' + msg);
+ }
+ test._observedDeprecations[deprecationId] = 1;
+ };
+ }
+
+ function teardownDeprecationHandler(test, moment, scope) {
+ moment.suppressDeprecationWarnings = test._oldSupress;
+
+ if (test._expectedDeprecations != null) {
+ var missedDeprecations = [];
+ each(test._expectedDeprecations, function (deprecationPattern, id) {
+ if (test._observedDeprecations[id] !== 1) {
+ missedDeprecations.push(deprecationPattern);
+ }
+ });
+ if (missedDeprecations.length !== 0) {
+ throw new Error('Expected deprecation warnings did not happen: ' +
+ missedDeprecations.join(' '));
+ }
+ }
+ }
+
+ function matchedDeprecation(name, msg, deprecations) {
+ if (deprecations == null) {
+ return -1;
+ }
+ for (var i = 0; i < deprecations.length; ++i) {
+ if (name != null && name === deprecations[i]) {
+ return i;
+ }
+ if (msg != null && msg.substring(0, deprecations[i].length) === deprecations[i]) {
+ return i;
+ }
+ }
+ return -1;
+ }
/*global QUnit:false*/
@@ -31695,11 +44764,13 @@
moment.createFromInputFallback = function (config) {
throw new Error('input not handled by moment: ' + config._i);
};
+ setupDeprecationHandler(test, moment, 'core');
if (lifecycle && lifecycle.setup) {
lifecycle.setup();
}
},
teardown : function () {
+ teardownDeprecationHandler(test, moment, 'core');
if (lifecycle && lifecycle.teardown) {
lifecycle.teardown();
}
@@ -31714,17 +44785,20 @@
moment.createFromInputFallback = function (config) {
throw new Error('input not handled by moment: ' + config._i);
};
+ setupDeprecationHandler(test, moment, 'locale');
if (lifecycle && lifecycle.setup) {
lifecycle.setup();
}
},
teardown : function () {
moment.locale('en');
+ teardownDeprecationHandler(test, moment, 'locale');
if (lifecycle && lifecycle.teardown) {
lifecycle.teardown();
}
}
});
+ defineCommonLocaleTests(name, -1, -1);
}
localeModule('tl-ph');
@@ -31875,14 +44949,14 @@
});
test('same day', function (assert) {
- var a = moment().hours(2).minutes(0).seconds(0);
-
- assert.equal(moment(a).calendar(), 'Ngayon sa 02:00', 'today at the same time');
- assert.equal(moment(a).add({m: 25}).calendar(), 'Ngayon sa 02:25', 'Now plus 25 min');
- assert.equal(moment(a).add({h: 1}).calendar(), 'Ngayon sa 03:00', 'Now plus 1 hour');
- assert.equal(moment(a).add({d: 1}).calendar(), 'Bukas sa 02:00', 'tomorrow at the same time');
- assert.equal(moment(a).subtract({h: 1}).calendar(), 'Ngayon sa 01:00', 'Now minus 1 hour');
- assert.equal(moment(a).subtract({d: 1}).calendar(), 'Kahapon sa 02:00', 'yesterday at the same time');
+ var a = moment().hours(12).minutes(0).seconds(0);
+
+ assert.equal(moment(a).calendar(), 'Ngayon sa 12:00', 'today at the same time');
+ assert.equal(moment(a).add({m: 25}).calendar(), 'Ngayon sa 12:25', 'Now plus 25 min');
+ assert.equal(moment(a).add({h: 1}).calendar(), 'Ngayon sa 13:00', 'Now plus 1 hour');
+ assert.equal(moment(a).add({d: 1}).calendar(), 'Bukas sa 12:00', 'tomorrow at the same time');
+ assert.equal(moment(a).subtract({h: 1}).calendar(), 'Ngayon sa 11:00', 'Now minus 1 hour');
+ assert.equal(moment(a).subtract({d: 1}).calendar(), 'Kahapon sa 12:00', 'yesterday at the same time');
});
test('same next week', function (assert) {
@@ -31925,67 +44999,6 @@
assert.equal(weeksFromNow.calendar(), weeksFromNow.format('L'), 'in 2 weeks');
});
- test('weeks year starting sunday', function (assert) {
- assert.equal(moment([2012, 0, 1]).week(), 52, 'Jan 1 2012 should be week 52');
- assert.equal(moment([2012, 0, 2]).week(), 1, 'Jan 2 2012 should be week 1');
- assert.equal(moment([2012, 0, 8]).week(), 1, 'Jan 8 2012 should be week 1');
- assert.equal(moment([2012, 0, 9]).week(), 2, 'Jan 9 2012 should be week 2');
- assert.equal(moment([2012, 0, 15]).week(), 2, 'Jan 15 2012 should be week 2');
- });
-
- test('weeks year starting monday', function (assert) {
- assert.equal(moment([2007, 0, 1]).week(), 1, 'Jan 1 2007 should be week 1');
- assert.equal(moment([2007, 0, 7]).week(), 1, 'Jan 7 2007 should be week 1');
- assert.equal(moment([2007, 0, 8]).week(), 2, 'Jan 8 2007 should be week 2');
- assert.equal(moment([2007, 0, 14]).week(), 2, 'Jan 14 2007 should be week 2');
- assert.equal(moment([2007, 0, 15]).week(), 3, 'Jan 15 2007 should be week 3');
- });
-
- test('weeks year starting tuesday', function (assert) {
- assert.equal(moment([2007, 11, 31]).week(), 1, 'Dec 31 2007 should be week 1');
- assert.equal(moment([2008, 0, 1]).week(), 1, 'Jan 1 2008 should be week 1');
- assert.equal(moment([2008, 0, 6]).week(), 1, 'Jan 6 2008 should be week 1');
- assert.equal(moment([2008, 0, 7]).week(), 2, 'Jan 7 2008 should be week 2');
- assert.equal(moment([2008, 0, 13]).week(), 2, 'Jan 13 2008 should be week 2');
- assert.equal(moment([2008, 0, 14]).week(), 3, 'Jan 14 2008 should be week 3');
- });
-
- test('weeks year starting wednesday', function (assert) {
- assert.equal(moment([2002, 11, 30]).week(), 1, 'Dec 30 2002 should be week 1');
- assert.equal(moment([2003, 0, 1]).week(), 1, 'Jan 1 2003 should be week 1');
- assert.equal(moment([2003, 0, 5]).week(), 1, 'Jan 5 2003 should be week 1');
- assert.equal(moment([2003, 0, 6]).week(), 2, 'Jan 6 2003 should be week 2');
- assert.equal(moment([2003, 0, 12]).week(), 2, 'Jan 12 2003 should be week 2');
- assert.equal(moment([2003, 0, 13]).week(), 3, 'Jan 13 2003 should be week 3');
- });
-
- test('weeks year starting thursday', function (assert) {
- assert.equal(moment([2008, 11, 29]).week(), 1, 'Dec 29 2008 should be week 1');
- assert.equal(moment([2009, 0, 1]).week(), 1, 'Jan 1 2009 should be week 1');
- assert.equal(moment([2009, 0, 4]).week(), 1, 'Jan 4 2009 should be week 1');
- assert.equal(moment([2009, 0, 5]).week(), 2, 'Jan 5 2009 should be week 2');
- assert.equal(moment([2009, 0, 11]).week(), 2, 'Jan 11 2009 should be week 2');
- assert.equal(moment([2009, 0, 13]).week(), 3, 'Jan 12 2009 should be week 3');
- });
-
- test('weeks year starting friday', function (assert) {
- assert.equal(moment([2009, 11, 28]).week(), 53, 'Dec 28 2009 should be week 53');
- assert.equal(moment([2010, 0, 1]).week(), 53, 'Jan 1 2010 should be week 53');
- assert.equal(moment([2010, 0, 3]).week(), 53, 'Jan 3 2010 should be week 53');
- assert.equal(moment([2010, 0, 4]).week(), 1, 'Jan 4 2010 should be week 1');
- assert.equal(moment([2010, 0, 10]).week(), 1, 'Jan 10 2010 should be week 1');
- assert.equal(moment([2010, 0, 11]).week(), 2, 'Jan 11 2010 should be week 2');
- });
-
- test('weeks year starting saturday', function (assert) {
- assert.equal(moment([2010, 11, 27]).week(), 52, 'Dec 27 2010 should be week 52');
- assert.equal(moment([2011, 0, 1]).week(), 52, 'Jan 1 2011 should be week 52');
- assert.equal(moment([2011, 0, 2]).week(), 52, 'Jan 2 2011 should be week 52');
- assert.equal(moment([2011, 0, 3]).week(), 1, 'Jan 3 2011 should be week 1');
- assert.equal(moment([2011, 0, 9]).week(), 1, 'Jan 9 2011 should be week 1');
- assert.equal(moment([2011, 0, 10]).week(), 2, 'Jan 10 2011 should be week 2');
- });
-
test('weeks year starting sunday formatted', function (assert) {
assert.equal(moment([2012, 0, 1]).format('w ww wo'), '52 52 52', 'Jan 1 2012 should be week 52');
assert.equal(moment([2012, 0, 2]).format('w ww wo'), '1 01 1', 'Jan 2 2012 should be week 1');
@@ -31994,42 +45007,6 @@
assert.equal(moment([2012, 0, 15]).format('w ww wo'), '2 02 2', 'Jan 15 2012 should be week 2');
});
- test('lenient ordinal parsing', function (assert) {
- var i, ordinalStr, testMoment;
- for (i = 1; i <= 31; ++i) {
- ordinalStr = moment([2014, 0, i]).format('YYYY MM Do');
- testMoment = moment(ordinalStr, 'YYYY MM Do');
- assert.equal(testMoment.year(), 2014,
- 'lenient ordinal parsing ' + i + ' year check');
- assert.equal(testMoment.month(), 0,
- 'lenient ordinal parsing ' + i + ' month check');
- assert.equal(testMoment.date(), i,
- 'lenient ordinal parsing ' + i + ' date check');
- }
- });
-
- test('lenient ordinal parsing of number', function (assert) {
- var i, testMoment;
- for (i = 1; i <= 31; ++i) {
- testMoment = moment('2014 01 ' + i, 'YYYY MM Do');
- assert.equal(testMoment.year(), 2014,
- 'lenient ordinal parsing of number ' + i + ' year check');
- assert.equal(testMoment.month(), 0,
- 'lenient ordinal parsing of number ' + i + ' month check');
- assert.equal(testMoment.date(), i,
- 'lenient ordinal parsing of number ' + i + ' date check');
- }
- });
-
- test('strict ordinal parsing', function (assert) {
- var i, ordinalStr, testMoment;
- for (i = 1; i <= 31; ++i) {
- ordinalStr = moment([2014, 0, i]).format('YYYY MM Do');
- testMoment = moment(ordinalStr, 'YYYY MM Do', true);
- assert.ok(testMoment.isValid(), 'strict ordinal parsing ' + i);
- }
- });
-
}));
;(function (global, factory) {
@@ -32038,6 +45015,224 @@
typeof define === 'function' && define.amd ? define(['../../moment'], factory) :
factory(global.moment)
}(this, function (moment) { 'use strict';
+
+ function each(array, callback) {
+ var i;
+ for (i = 0; i < array.length; i++) {
+ callback(array[i], i, array);
+ }
+ }
+
+ function objectKeys(obj) {
+ if (Object.keys) {
+ return Object.keys(obj);
+ } else {
+ // IE8
+ var res = [], i;
+ for (i in obj) {
+ if (obj.hasOwnProperty(i)) {
+ res.push(i);
+ }
+ }
+ return res;
+ }
+ }
+
+ // Pick the first defined of two or three arguments.
+ function defaults(a, b, c) {
+ if (a != null) {
+ return a;
+ }
+ if (b != null) {
+ return b;
+ }
+ return c;
+ }
+
+ function defineCommonLocaleTests(locale, options) {
+ test('lenient ordinal parsing', function (assert) {
+ var i, ordinalStr, testMoment;
+ for (i = 1; i <= 31; ++i) {
+ ordinalStr = moment([2014, 0, i]).format('YYYY MM Do');
+ testMoment = moment(ordinalStr, 'YYYY MM Do');
+ assert.equal(testMoment.year(), 2014,
+ 'lenient ordinal parsing ' + i + ' year check');
+ assert.equal(testMoment.month(), 0,
+ 'lenient ordinal parsing ' + i + ' month check');
+ assert.equal(testMoment.date(), i,
+ 'lenient ordinal parsing ' + i + ' date check');
+ }
+ });
+
+ test('lenient ordinal parsing of number', function (assert) {
+ var i, testMoment;
+ for (i = 1; i <= 31; ++i) {
+ testMoment = moment('2014 01 ' + i, 'YYYY MM Do');
+ assert.equal(testMoment.year(), 2014,
+ 'lenient ordinal parsing of number ' + i + ' year check');
+ assert.equal(testMoment.month(), 0,
+ 'lenient ordinal parsing of number ' + i + ' month check');
+ assert.equal(testMoment.date(), i,
+ 'lenient ordinal parsing of number ' + i + ' date check');
+ }
+ });
+
+ test('strict ordinal parsing', function (assert) {
+ var i, ordinalStr, testMoment;
+ for (i = 1; i <= 31; ++i) {
+ ordinalStr = moment([2014, 0, i]).format('YYYY MM Do');
+ testMoment = moment(ordinalStr, 'YYYY MM Do', true);
+ assert.ok(testMoment.isValid(), 'strict ordinal parsing ' + i);
+ }
+ });
+
+ test('meridiem invariant', function (assert) {
+ var h, m, t1, t2;
+ for (h = 0; h < 24; ++h) {
+ for (m = 0; m < 60; m += 15) {
+ t1 = moment.utc([2000, 0, 1, h, m]);
+ t2 = moment.utc(t1.format('A h:mm'), 'A h:mm');
+ assert.equal(t2.format('HH:mm'), t1.format('HH:mm'),
+ 'meridiem at ' + t1.format('HH:mm'));
+ }
+ }
+ });
+
+ test('date format correctness', function (assert) {
+ var data, tokens;
+ data = moment.localeData()._longDateFormat;
+ tokens = objectKeys(data);
+ each(tokens, function (srchToken) {
+ // Check each format string to make sure it does not contain any
+ // tokens that need to be expanded.
+ each(tokens, function (baseToken) {
+ // strip escaped sequences
+ var format = data[baseToken].replace(/(\[[^\]]*\])/g, '');
+ assert.equal(false, !!~format.indexOf(srchToken),
+ 'contains ' + srchToken + ' in ' + baseToken);
+ });
+ });
+ });
+
+ test('month parsing correctness', function (assert) {
+ var i, m;
+
+ if (locale === 'tr') {
+ // I can't fix it :(
+ expect(0);
+ return;
+ }
+ function tester(format) {
+ var r;
+ r = moment(m.format(format), format);
+ assert.equal(r.month(), m.month(), 'month ' + i + ' fmt ' + format);
+ r = moment(m.format(format).toLocaleUpperCase(), format);
+ assert.equal(r.month(), m.month(), 'month ' + i + ' fmt ' + format + ' upper');
+ r = moment(m.format(format).toLocaleLowerCase(), format);
+ assert.equal(r.month(), m.month(), 'month ' + i + ' fmt ' + format + ' lower');
+
+ r = moment(m.format(format), format, true);
+ assert.equal(r.month(), m.month(), 'month ' + i + ' fmt ' + format + ' strict');
+ r = moment(m.format(format).toLocaleUpperCase(), format, true);
+ assert.equal(r.month(), m.month(), 'month ' + i + ' fmt ' + format + ' upper strict');
+ r = moment(m.format(format).toLocaleLowerCase(), format, true);
+ assert.equal(r.month(), m.month(), 'month ' + i + ' fmt ' + format + ' lower strict');
+ }
+
+ for (i = 0; i < 12; ++i) {
+ m = moment([2015, i, 15, 18]);
+ tester('MMM');
+ tester('MMM.');
+ tester('MMMM');
+ tester('MMMM.');
+ }
+ });
+
+ test('weekday parsing correctness', function (assert) {
+ var i, m;
+
+ if (locale === 'tr' || locale === 'az') {
+ // There is a lower-case letter (ı), that converted to upper then
+ // lower changes to i
+ expect(0);
+ return;
+ }
+ function tester(format) {
+ var r, baseMsg = 'weekday ' + m.weekday() + ' fmt ' + format;
+ r = moment(m.format(format), format);
+ assert.equal(r.weekday(), m.weekday(), baseMsg);
+ r = moment(m.format(format).toLocaleUpperCase(), format);
+ assert.equal(r.weekday(), m.weekday(), baseMsg + ' upper');
+ r = moment(m.format(format).toLocaleLowerCase(), format);
+ assert.equal(r.weekday(), m.weekday(), baseMsg + ' lower');
+
+ r = moment(m.format(format), format, true);
+ assert.equal(r.weekday(), m.weekday(), baseMsg + ' strict');
+ r = moment(m.format(format).toLocaleUpperCase(), format, true);
+ assert.equal(r.weekday(), m.weekday(), baseMsg + ' upper strict');
+ r = moment(m.format(format).toLocaleLowerCase(), format, true);
+ assert.equal(r.weekday(), m.weekday(), baseMsg + ' lower strict');
+ }
+
+ for (i = 0; i < 7; ++i) {
+ m = moment.utc([2015, i, 15, 18]);
+ tester('dd');
+ tester('ddd');
+ tester('dddd');
+ }
+ });
+ }
+
+ function setupDeprecationHandler(test, moment, scope) {
+ test._expectedDeprecations = null;
+ test._observedDeprecations = null;
+ test._oldSupress = moment.suppressDeprecationWarnings;
+ moment.suppressDeprecationWarnings = true;
+ test.expectedDeprecations = function () {
+ test._expectedDeprecations = arguments;
+ test._observedDeprecations = [];
+ };
+ moment.deprecationHandler = function (name, msg) {
+ var deprecationId = matchedDeprecation(name, msg, test._expectedDeprecations);
+ if (deprecationId === -1) {
+ throw new Error('Unexpected deprecation thrown name=' +
+ name + ' msg=' + msg);
+ }
+ test._observedDeprecations[deprecationId] = 1;
+ };
+ }
+
+ function teardownDeprecationHandler(test, moment, scope) {
+ moment.suppressDeprecationWarnings = test._oldSupress;
+
+ if (test._expectedDeprecations != null) {
+ var missedDeprecations = [];
+ each(test._expectedDeprecations, function (deprecationPattern, id) {
+ if (test._observedDeprecations[id] !== 1) {
+ missedDeprecations.push(deprecationPattern);
+ }
+ });
+ if (missedDeprecations.length !== 0) {
+ throw new Error('Expected deprecation warnings did not happen: ' +
+ missedDeprecations.join(' '));
+ }
+ }
+ }
+
+ function matchedDeprecation(name, msg, deprecations) {
+ if (deprecations == null) {
+ return -1;
+ }
+ for (var i = 0; i < deprecations.length; ++i) {
+ if (name != null && name === deprecations[i]) {
+ return i;
+ }
+ if (msg != null && msg.substring(0, deprecations[i].length) === deprecations[i]) {
+ return i;
+ }
+ }
+ return -1;
+ }
/*global QUnit:false*/
@@ -32052,11 +45247,13 @@
moment.createFromInputFallback = function (config) {
throw new Error('input not handled by moment: ' + config._i);
};
+ setupDeprecationHandler(test, moment, 'core');
if (lifecycle && lifecycle.setup) {
lifecycle.setup();
}
},
teardown : function () {
+ teardownDeprecationHandler(test, moment, 'core');
if (lifecycle && lifecycle.teardown) {
lifecycle.teardown();
}
@@ -32071,17 +45268,20 @@
moment.createFromInputFallback = function (config) {
throw new Error('input not handled by moment: ' + config._i);
};
+ setupDeprecationHandler(test, moment, 'locale');
if (lifecycle && lifecycle.setup) {
lifecycle.setup();
}
},
teardown : function () {
moment.locale('en');
+ teardownDeprecationHandler(test, moment, 'locale');
if (lifecycle && lifecycle.teardown) {
lifecycle.teardown();
}
}
});
+ defineCommonLocaleTests(name, -1, -1);
}
localeModule('tlh');
@@ -32249,14 +45449,14 @@
});
test('calendar day', function (assert) {
- var a = moment().hours(2).minutes(0).seconds(0);
-
- assert.equal(moment(a).calendar(), 'DaHjaj 02:00', 'today at the same time');
- assert.equal(moment(a).add({m: 25}).calendar(), 'DaHjaj 02:25', 'Now plus 25 min');
- assert.equal(moment(a).add({h: 1}).calendar(), 'DaHjaj 03:00', 'Now plus 1 hour');
- assert.equal(moment(a).add({d: 1}).calendar(), 'wa’leS 02:00', 'tomorrow at the same time');
- assert.equal(moment(a).subtract({h: 1}).calendar(), 'DaHjaj 01:00', 'Now minus 1 hour');
- assert.equal(moment(a).subtract({d: 1}).calendar(), 'wa’Hu’ 02:00', 'yesterday at the same time');
+ var a = moment().hours(12).minutes(0).seconds(0);
+
+ assert.equal(moment(a).calendar(), 'DaHjaj 12:00', 'today at the same time');
+ assert.equal(moment(a).add({m: 25}).calendar(), 'DaHjaj 12:25', 'Now plus 25 min');
+ assert.equal(moment(a).add({h: 1}).calendar(), 'DaHjaj 13:00', 'Now plus 1 hour');
+ assert.equal(moment(a).add({d: 1}).calendar(), 'wa’leS 12:00', 'tomorrow at the same time');
+ assert.equal(moment(a).subtract({h: 1}).calendar(), 'DaHjaj 11:00', 'Now minus 1 hour');
+ assert.equal(moment(a).subtract({d: 1}).calendar(), 'wa’Hu’ 12:00', 'yesterday at the same time');
});
test('calendar next week', function (assert) {
@@ -32299,67 +45499,6 @@
assert.equal(weeksFromNow.calendar(), weeksFromNow.format('L'), 'in 2 weeks');
});
- test('weeks year starting sunday', function (assert) {
- assert.equal(moment([2012, 0, 1]).week(), 52, 'Jan 1 2012 should be week 52');
- assert.equal(moment([2012, 0, 2]).week(), 1, 'Jan 2 2012 should be week 1');
- assert.equal(moment([2012, 0, 8]).week(), 1, 'Jan 8 2012 should be week 1');
- assert.equal(moment([2012, 0, 9]).week(), 2, 'Jan 9 2012 should be week 2');
- assert.equal(moment([2012, 0, 15]).week(), 2, 'Jan 15 2012 should be week 2');
- });
-
- test('weeks year starting monday', function (assert) {
- assert.equal(moment([2007, 0, 1]).week(), 1, 'Jan 1 2007 should be week 1');
- assert.equal(moment([2007, 0, 7]).week(), 1, 'Jan 7 2007 should be week 1');
- assert.equal(moment([2007, 0, 8]).week(), 2, 'Jan 8 2007 should be week 2');
- assert.equal(moment([2007, 0, 14]).week(), 2, 'Jan 14 2007 should be week 2');
- assert.equal(moment([2007, 0, 15]).week(), 3, 'Jan 15 2007 should be week 3');
- });
-
- test('weeks year starting tuesday', function (assert) {
- assert.equal(moment([2007, 11, 31]).week(), 1, 'Dec 31 2007 should be week 1');
- assert.equal(moment([2008, 0, 1]).week(), 1, 'Jan 1 2008 should be week 1');
- assert.equal(moment([2008, 0, 6]).week(), 1, 'Jan 6 2008 should be week 1');
- assert.equal(moment([2008, 0, 7]).week(), 2, 'Jan 7 2008 should be week 2');
- assert.equal(moment([2008, 0, 13]).week(), 2, 'Jan 13 2008 should be week 2');
- assert.equal(moment([2008, 0, 14]).week(), 3, 'Jan 14 2008 should be week 3');
- });
-
- test('weeks year starting wednesday', function (assert) {
- assert.equal(moment([2002, 11, 30]).week(), 1, 'Dec 30 2002 should be week 1');
- assert.equal(moment([2003, 0, 1]).week(), 1, 'Jan 1 2003 should be week 1');
- assert.equal(moment([2003, 0, 5]).week(), 1, 'Jan 5 2003 should be week 1');
- assert.equal(moment([2003, 0, 6]).week(), 2, 'Jan 6 2003 should be week 2');
- assert.equal(moment([2003, 0, 12]).week(), 2, 'Jan 12 2003 should be week 2');
- assert.equal(moment([2003, 0, 13]).week(), 3, 'Jan 13 2003 should be week 3');
- });
-
- test('weeks year starting thursday', function (assert) {
- assert.equal(moment([2008, 11, 29]).week(), 1, 'Dec 29 2008 should be week 1');
- assert.equal(moment([2009, 0, 1]).week(), 1, 'Jan 1 2009 should be week 1');
- assert.equal(moment([2009, 0, 4]).week(), 1, 'Jan 4 2009 should be week 1');
- assert.equal(moment([2009, 0, 5]).week(), 2, 'Jan 5 2009 should be week 2');
- assert.equal(moment([2009, 0, 11]).week(), 2, 'Jan 11 2009 should be week 2');
- assert.equal(moment([2009, 0, 13]).week(), 3, 'Jan 12 2009 should be week 3');
- });
-
- test('weeks year starting friday', function (assert) {
- assert.equal(moment([2009, 11, 28]).week(), 53, 'Dec 28 2009 should be week 53');
- assert.equal(moment([2010, 0, 1]).week(), 53, 'Jan 1 2010 should be week 53');
- assert.equal(moment([2010, 0, 3]).week(), 53, 'Jan 3 2010 should be week 53');
- assert.equal(moment([2010, 0, 4]).week(), 1, 'Jan 4 2010 should be week 1');
- assert.equal(moment([2010, 0, 10]).week(), 1, 'Jan 10 2010 should be week 1');
- assert.equal(moment([2010, 0, 11]).week(), 2, 'Jan 11 2010 should be week 2');
- });
-
- test('weeks year starting saturday', function (assert) {
- assert.equal(moment([2010, 11, 27]).week(), 52, 'Dec 27 2010 should be week 52');
- assert.equal(moment([2011, 0, 1]).week(), 52, 'Jan 1 2011 should be week 52');
- assert.equal(moment([2011, 0, 2]).week(), 52, 'Jan 2 2011 should be week 52');
- assert.equal(moment([2011, 0, 3]).week(), 1, 'Jan 3 2011 should be week 1');
- assert.equal(moment([2011, 0, 9]).week(), 1, 'Jan 9 2011 should be week 1');
- assert.equal(moment([2011, 0, 10]).week(), 2, 'Jan 10 2011 should be week 2');
- });
-
test('weeks year starting sunday formatted', function (assert) {
assert.equal(moment([2012, 0, 1]).format('w ww wo'), '52 52 52.', 'Jan 1 2012 should be week 52');
assert.equal(moment([2012, 0, 2]).format('w ww wo'), '1 01 1.', 'Jan 2 2012 should be week 1');
@@ -32368,42 +45507,6 @@
assert.equal(moment([2012, 0, 15]).format('w ww wo'), '2 02 2.', 'Jan 15 2012 should be week 2');
});
- test('lenient ordinal parsing', function (assert) {
- var i, ordinalStr, testMoment;
- for (i = 1; i <= 31; ++i) {
- ordinalStr = moment([2014, 0, i]).format('YYYY MM Do');
- testMoment = moment(ordinalStr, 'YYYY MM Do');
- assert.equal(testMoment.year(), 2014,
- 'lenient ordinal parsing ' + i + ' year check');
- assert.equal(testMoment.month(), 0,
- 'lenient ordinal parsing ' + i + ' month check');
- assert.equal(testMoment.date(), i,
- 'lenient ordinal parsing ' + i + ' date check');
- }
- });
-
- test('lenient ordinal parsing of number', function (assert) {
- var i, testMoment;
- for (i = 1; i <= 31; ++i) {
- testMoment = moment('2014 01 ' + i, 'YYYY MM Do');
- assert.equal(testMoment.year(), 2014,
- 'lenient ordinal parsing of number ' + i + ' year check');
- assert.equal(testMoment.month(), 0,
- 'lenient ordinal parsing of number ' + i + ' month check');
- assert.equal(testMoment.date(), i,
- 'lenient ordinal parsing of number ' + i + ' date check');
- }
- });
-
- test('strict ordinal parsing', function (assert) {
- var i, ordinalStr, testMoment;
- for (i = 1; i <= 31; ++i) {
- ordinalStr = moment([2014, 0, i]).format('YYYY MM Do');
- testMoment = moment(ordinalStr, 'YYYY MM Do', true);
- assert.ok(testMoment.isValid(), 'strict ordinal parsing ' + i);
- }
- });
-
}));
;(function (global, factory) {
@@ -32412,6 +45515,224 @@
typeof define === 'function' && define.amd ? define(['../../moment'], factory) :
factory(global.moment)
}(this, function (moment) { 'use strict';
+
+ function each(array, callback) {
+ var i;
+ for (i = 0; i < array.length; i++) {
+ callback(array[i], i, array);
+ }
+ }
+
+ function objectKeys(obj) {
+ if (Object.keys) {
+ return Object.keys(obj);
+ } else {
+ // IE8
+ var res = [], i;
+ for (i in obj) {
+ if (obj.hasOwnProperty(i)) {
+ res.push(i);
+ }
+ }
+ return res;
+ }
+ }
+
+ // Pick the first defined of two or three arguments.
+ function defaults(a, b, c) {
+ if (a != null) {
+ return a;
+ }
+ if (b != null) {
+ return b;
+ }
+ return c;
+ }
+
+ function defineCommonLocaleTests(locale, options) {
+ test('lenient ordinal parsing', function (assert) {
+ var i, ordinalStr, testMoment;
+ for (i = 1; i <= 31; ++i) {
+ ordinalStr = moment([2014, 0, i]).format('YYYY MM Do');
+ testMoment = moment(ordinalStr, 'YYYY MM Do');
+ assert.equal(testMoment.year(), 2014,
+ 'lenient ordinal parsing ' + i + ' year check');
+ assert.equal(testMoment.month(), 0,
+ 'lenient ordinal parsing ' + i + ' month check');
+ assert.equal(testMoment.date(), i,
+ 'lenient ordinal parsing ' + i + ' date check');
+ }
+ });
+
+ test('lenient ordinal parsing of number', function (assert) {
+ var i, testMoment;
+ for (i = 1; i <= 31; ++i) {
+ testMoment = moment('2014 01 ' + i, 'YYYY MM Do');
+ assert.equal(testMoment.year(), 2014,
+ 'lenient ordinal parsing of number ' + i + ' year check');
+ assert.equal(testMoment.month(), 0,
+ 'lenient ordinal parsing of number ' + i + ' month check');
+ assert.equal(testMoment.date(), i,
+ 'lenient ordinal parsing of number ' + i + ' date check');
+ }
+ });
+
+ test('strict ordinal parsing', function (assert) {
+ var i, ordinalStr, testMoment;
+ for (i = 1; i <= 31; ++i) {
+ ordinalStr = moment([2014, 0, i]).format('YYYY MM Do');
+ testMoment = moment(ordinalStr, 'YYYY MM Do', true);
+ assert.ok(testMoment.isValid(), 'strict ordinal parsing ' + i);
+ }
+ });
+
+ test('meridiem invariant', function (assert) {
+ var h, m, t1, t2;
+ for (h = 0; h < 24; ++h) {
+ for (m = 0; m < 60; m += 15) {
+ t1 = moment.utc([2000, 0, 1, h, m]);
+ t2 = moment.utc(t1.format('A h:mm'), 'A h:mm');
+ assert.equal(t2.format('HH:mm'), t1.format('HH:mm'),
+ 'meridiem at ' + t1.format('HH:mm'));
+ }
+ }
+ });
+
+ test('date format correctness', function (assert) {
+ var data, tokens;
+ data = moment.localeData()._longDateFormat;
+ tokens = objectKeys(data);
+ each(tokens, function (srchToken) {
+ // Check each format string to make sure it does not contain any
+ // tokens that need to be expanded.
+ each(tokens, function (baseToken) {
+ // strip escaped sequences
+ var format = data[baseToken].replace(/(\[[^\]]*\])/g, '');
+ assert.equal(false, !!~format.indexOf(srchToken),
+ 'contains ' + srchToken + ' in ' + baseToken);
+ });
+ });
+ });
+
+ test('month parsing correctness', function (assert) {
+ var i, m;
+
+ if (locale === 'tr') {
+ // I can't fix it :(
+ expect(0);
+ return;
+ }
+ function tester(format) {
+ var r;
+ r = moment(m.format(format), format);
+ assert.equal(r.month(), m.month(), 'month ' + i + ' fmt ' + format);
+ r = moment(m.format(format).toLocaleUpperCase(), format);
+ assert.equal(r.month(), m.month(), 'month ' + i + ' fmt ' + format + ' upper');
+ r = moment(m.format(format).toLocaleLowerCase(), format);
+ assert.equal(r.month(), m.month(), 'month ' + i + ' fmt ' + format + ' lower');
+
+ r = moment(m.format(format), format, true);
+ assert.equal(r.month(), m.month(), 'month ' + i + ' fmt ' + format + ' strict');
+ r = moment(m.format(format).toLocaleUpperCase(), format, true);
+ assert.equal(r.month(), m.month(), 'month ' + i + ' fmt ' + format + ' upper strict');
+ r = moment(m.format(format).toLocaleLowerCase(), format, true);
+ assert.equal(r.month(), m.month(), 'month ' + i + ' fmt ' + format + ' lower strict');
+ }
+
+ for (i = 0; i < 12; ++i) {
+ m = moment([2015, i, 15, 18]);
+ tester('MMM');
+ tester('MMM.');
+ tester('MMMM');
+ tester('MMMM.');
+ }
+ });
+
+ test('weekday parsing correctness', function (assert) {
+ var i, m;
+
+ if (locale === 'tr' || locale === 'az') {
+ // There is a lower-case letter (ı), that converted to upper then
+ // lower changes to i
+ expect(0);
+ return;
+ }
+ function tester(format) {
+ var r, baseMsg = 'weekday ' + m.weekday() + ' fmt ' + format;
+ r = moment(m.format(format), format);
+ assert.equal(r.weekday(), m.weekday(), baseMsg);
+ r = moment(m.format(format).toLocaleUpperCase(), format);
+ assert.equal(r.weekday(), m.weekday(), baseMsg + ' upper');
+ r = moment(m.format(format).toLocaleLowerCase(), format);
+ assert.equal(r.weekday(), m.weekday(), baseMsg + ' lower');
+
+ r = moment(m.format(format), format, true);
+ assert.equal(r.weekday(), m.weekday(), baseMsg + ' strict');
+ r = moment(m.format(format).toLocaleUpperCase(), format, true);
+ assert.equal(r.weekday(), m.weekday(), baseMsg + ' upper strict');
+ r = moment(m.format(format).toLocaleLowerCase(), format, true);
+ assert.equal(r.weekday(), m.weekday(), baseMsg + ' lower strict');
+ }
+
+ for (i = 0; i < 7; ++i) {
+ m = moment.utc([2015, i, 15, 18]);
+ tester('dd');
+ tester('ddd');
+ tester('dddd');
+ }
+ });
+ }
+
+ function setupDeprecationHandler(test, moment, scope) {
+ test._expectedDeprecations = null;
+ test._observedDeprecations = null;
+ test._oldSupress = moment.suppressDeprecationWarnings;
+ moment.suppressDeprecationWarnings = true;
+ test.expectedDeprecations = function () {
+ test._expectedDeprecations = arguments;
+ test._observedDeprecations = [];
+ };
+ moment.deprecationHandler = function (name, msg) {
+ var deprecationId = matchedDeprecation(name, msg, test._expectedDeprecations);
+ if (deprecationId === -1) {
+ throw new Error('Unexpected deprecation thrown name=' +
+ name + ' msg=' + msg);
+ }
+ test._observedDeprecations[deprecationId] = 1;
+ };
+ }
+
+ function teardownDeprecationHandler(test, moment, scope) {
+ moment.suppressDeprecationWarnings = test._oldSupress;
+
+ if (test._expectedDeprecations != null) {
+ var missedDeprecations = [];
+ each(test._expectedDeprecations, function (deprecationPattern, id) {
+ if (test._observedDeprecations[id] !== 1) {
+ missedDeprecations.push(deprecationPattern);
+ }
+ });
+ if (missedDeprecations.length !== 0) {
+ throw new Error('Expected deprecation warnings did not happen: ' +
+ missedDeprecations.join(' '));
+ }
+ }
+ }
+
+ function matchedDeprecation(name, msg, deprecations) {
+ if (deprecations == null) {
+ return -1;
+ }
+ for (var i = 0; i < deprecations.length; ++i) {
+ if (name != null && name === deprecations[i]) {
+ return i;
+ }
+ if (msg != null && msg.substring(0, deprecations[i].length) === deprecations[i]) {
+ return i;
+ }
+ }
+ return -1;
+ }
/*global QUnit:false*/
@@ -32426,11 +45747,13 @@
moment.createFromInputFallback = function (config) {
throw new Error('input not handled by moment: ' + config._i);
};
+ setupDeprecationHandler(test, moment, 'core');
if (lifecycle && lifecycle.setup) {
lifecycle.setup();
}
},
teardown : function () {
+ teardownDeprecationHandler(test, moment, 'core');
if (lifecycle && lifecycle.teardown) {
lifecycle.teardown();
}
@@ -32445,17 +45768,20 @@
moment.createFromInputFallback = function (config) {
throw new Error('input not handled by moment: ' + config._i);
};
+ setupDeprecationHandler(test, moment, 'locale');
if (lifecycle && lifecycle.setup) {
lifecycle.setup();
}
},
teardown : function () {
moment.locale('en');
+ teardownDeprecationHandler(test, moment, 'locale');
if (lifecycle && lifecycle.teardown) {
lifecycle.teardown();
}
}
});
+ defineCommonLocaleTests(name, -1, -1);
}
localeModule('tr');
@@ -32620,14 +45946,14 @@
});
test('calendar day', function (assert) {
- var a = moment().hours(2).minutes(0).seconds(0);
-
- assert.equal(moment(a).calendar(), 'bugün saat 02:00', 'today at the same time');
- assert.equal(moment(a).add({m: 25}).calendar(), 'bugün saat 02:25', 'Now plus 25 min');
- assert.equal(moment(a).add({h: 1}).calendar(), 'bugün saat 03:00', 'Now plus 1 hour');
- assert.equal(moment(a).add({d: 1}).calendar(), 'yarın saat 02:00', 'tomorrow at the same time');
- assert.equal(moment(a).subtract({h: 1}).calendar(), 'bugün saat 01:00', 'Now minus 1 hour');
- assert.equal(moment(a).subtract({d: 1}).calendar(), 'dün 02:00', 'yesterday at the same time');
+ var a = moment().hours(12).minutes(0).seconds(0);
+
+ assert.equal(moment(a).calendar(), 'bugün saat 12:00', 'today at the same time');
+ assert.equal(moment(a).add({m: 25}).calendar(), 'bugün saat 12:25', 'Now plus 25 min');
+ assert.equal(moment(a).add({h: 1}).calendar(), 'bugün saat 13:00', 'Now plus 1 hour');
+ assert.equal(moment(a).add({d: 1}).calendar(), 'yarın saat 12:00', 'tomorrow at the same time');
+ assert.equal(moment(a).subtract({h: 1}).calendar(), 'bugün saat 11:00', 'Now minus 1 hour');
+ assert.equal(moment(a).subtract({d: 1}).calendar(), 'dün 12:00', 'yesterday at the same time');
});
test('calendar next week', function (assert) {
@@ -32668,67 +45994,6 @@
assert.equal(weeksFromNow.calendar(), weeksFromNow.format('L'), 'in 2 weeks');
});
- test('weeks year starting sunday', function (assert) {
- assert.equal(moment([2011, 11, 26]).week(), 1, 'Dec 26 2011 should be week 1');
- assert.equal(moment([2012, 0, 1]).week(), 1, 'Jan 1 2012 should be week 1');
- assert.equal(moment([2012, 0, 2]).week(), 2, 'Jan 2 2012 should be week 2');
- assert.equal(moment([2012, 0, 8]).week(), 2, 'Jan 8 2012 should be week 2');
- assert.equal(moment([2012, 0, 9]).week(), 3, 'Jan 9 2012 should be week 3');
- });
-
- test('weeks year starting monday', function (assert) {
- assert.equal(moment([2007, 0, 1]).week(), 1, 'Jan 1 2007 should be week 1');
- assert.equal(moment([2007, 0, 7]).week(), 1, 'Jan 7 2007 should be week 1');
- assert.equal(moment([2007, 0, 8]).week(), 2, 'Jan 8 2007 should be week 2');
- assert.equal(moment([2007, 0, 14]).week(), 2, 'Jan 14 2007 should be week 2');
- assert.equal(moment([2007, 0, 15]).week(), 3, 'Jan 15 2007 should be week 3');
- });
-
- test('weeks year starting tuesday', function (assert) {
- assert.equal(moment([2007, 11, 31]).week(), 1, 'Dec 31 2007 should be week 1');
- assert.equal(moment([2008, 0, 1]).week(), 1, 'Jan 1 2008 should be week 1');
- assert.equal(moment([2008, 0, 6]).week(), 1, 'Jan 6 2008 should be week 1');
- assert.equal(moment([2008, 0, 7]).week(), 2, 'Jan 7 2008 should be week 2');
- assert.equal(moment([2008, 0, 13]).week(), 2, 'Jan 13 2008 should be week 2');
- assert.equal(moment([2008, 0, 14]).week(), 3, 'Jan 14 2008 should be week 3');
- });
-
- test('weeks year starting wednesday', function (assert) {
- assert.equal(moment([2002, 11, 30]).week(), 1, 'Dec 30 2002 should be week 1');
- assert.equal(moment([2003, 0, 1]).week(), 1, 'Jan 1 2003 should be week 1');
- assert.equal(moment([2003, 0, 5]).week(), 1, 'Jan 5 2003 should be week 1');
- assert.equal(moment([2003, 0, 6]).week(), 2, 'Jan 6 2003 should be week 2');
- assert.equal(moment([2003, 0, 12]).week(), 2, 'Jan 12 2003 should be week 2');
- assert.equal(moment([2003, 0, 13]).week(), 3, 'Jan 13 2003 should be week 3');
- });
-
- test('weeks year starting thursday', function (assert) {
- assert.equal(moment([2008, 11, 29]).week(), 1, 'Dec 29 2008 should be week 1');
- assert.equal(moment([2009, 0, 1]).week(), 1, 'Jan 1 2009 should be week 1');
- assert.equal(moment([2009, 0, 4]).week(), 1, 'Jan 4 2009 should be week 1');
- assert.equal(moment([2009, 0, 5]).week(), 2, 'Jan 5 2009 should be week 2');
- assert.equal(moment([2009, 0, 11]).week(), 2, 'Jan 11 2009 should be week 2');
- assert.equal(moment([2009, 0, 12]).week(), 3, 'Jan 12 2009 should be week 3');
- });
-
- test('weeks year starting friday', function (assert) {
- assert.equal(moment([2009, 11, 28]).week(), 1, 'Dec 28 2009 should be week 1');
- assert.equal(moment([2010, 0, 1]).week(), 1, 'Jan 1 2010 should be week 1');
- assert.equal(moment([2010, 0, 3]).week(), 1, 'Jan 3 2010 should be week 1');
- assert.equal(moment([2010, 0, 4]).week(), 2, 'Jan 4 2010 should be week 2');
- assert.equal(moment([2010, 0, 10]).week(), 2, 'Jan 10 2010 should be week 2');
- assert.equal(moment([2010, 0, 11]).week(), 3, 'Jan 11 2010 should be week 3');
- });
-
- test('weeks year starting saturday', function (assert) {
- assert.equal(moment([2010, 11, 27]).week(), 1, 'Dec 27 2010 should be week 1');
- assert.equal(moment([2011, 0, 1]).week(), 1, 'Jan 1 2011 should be week 1');
- assert.equal(moment([2011, 0, 2]).week(), 1, 'Jan 2 2011 should be week 1');
- assert.equal(moment([2011, 0, 3]).week(), 2, 'Jan 3 2011 should be week 2');
- assert.equal(moment([2011, 0, 9]).week(), 2, 'Jan 9 2011 should be week 2');
- assert.equal(moment([2011, 0, 10]).week(), 3, 'Jan 10 2011 should be week 3');
- });
-
test('weeks year starting sunday formatted', function (assert) {
assert.equal(moment([2011, 11, 26]).format('w ww wo'), '1 01 1\'inci', 'Dec 26 2011 should be week 1');
assert.equal(moment([2012, 0, 1]).format('w ww wo'), '1 01 1\'inci', 'Jan 1 2012 should be week 1');
@@ -32737,42 +46002,6 @@
assert.equal(moment([2012, 0, 9]).format('w ww wo'), '3 03 3\'üncü', 'Jan 9 2012 should be week 3');
});
- test('lenient ordinal parsing', function (assert) {
- var i, ordinalStr, testMoment;
- for (i = 1; i <= 31; ++i) {
- ordinalStr = moment([2014, 0, i]).format('YYYY MM Do');
- testMoment = moment(ordinalStr, 'YYYY MM Do');
- assert.equal(testMoment.year(), 2014,
- 'lenient ordinal parsing ' + i + ' year check');
- assert.equal(testMoment.month(), 0,
- 'lenient ordinal parsing ' + i + ' month check');
- assert.equal(testMoment.date(), i,
- 'lenient ordinal parsing ' + i + ' date check');
- }
- });
-
- test('lenient ordinal parsing of number', function (assert) {
- var i, testMoment;
- for (i = 1; i <= 31; ++i) {
- testMoment = moment('2014 01 ' + i, 'YYYY MM Do');
- assert.equal(testMoment.year(), 2014,
- 'lenient ordinal parsing of number ' + i + ' year check');
- assert.equal(testMoment.month(), 0,
- 'lenient ordinal parsing of number ' + i + ' month check');
- assert.equal(testMoment.date(), i,
- 'lenient ordinal parsing of number ' + i + ' date check');
- }
- });
-
- test('strict ordinal parsing', function (assert) {
- var i, ordinalStr, testMoment;
- for (i = 1; i <= 31; ++i) {
- ordinalStr = moment([2014, 0, i]).format('YYYY MM Do');
- testMoment = moment(ordinalStr, 'YYYY MM Do', true);
- assert.ok(testMoment.isValid(), 'strict ordinal parsing ' + i);
- }
- });
-
}));
;(function (global, factory) {
@@ -32781,6 +46010,224 @@
typeof define === 'function' && define.amd ? define(['../../moment'], factory) :
factory(global.moment)
}(this, function (moment) { 'use strict';
+
+ function each(array, callback) {
+ var i;
+ for (i = 0; i < array.length; i++) {
+ callback(array[i], i, array);
+ }
+ }
+
+ function objectKeys(obj) {
+ if (Object.keys) {
+ return Object.keys(obj);
+ } else {
+ // IE8
+ var res = [], i;
+ for (i in obj) {
+ if (obj.hasOwnProperty(i)) {
+ res.push(i);
+ }
+ }
+ return res;
+ }
+ }
+
+ // Pick the first defined of two or three arguments.
+ function defaults(a, b, c) {
+ if (a != null) {
+ return a;
+ }
+ if (b != null) {
+ return b;
+ }
+ return c;
+ }
+
+ function defineCommonLocaleTests(locale, options) {
+ test('lenient ordinal parsing', function (assert) {
+ var i, ordinalStr, testMoment;
+ for (i = 1; i <= 31; ++i) {
+ ordinalStr = moment([2014, 0, i]).format('YYYY MM Do');
+ testMoment = moment(ordinalStr, 'YYYY MM Do');
+ assert.equal(testMoment.year(), 2014,
+ 'lenient ordinal parsing ' + i + ' year check');
+ assert.equal(testMoment.month(), 0,
+ 'lenient ordinal parsing ' + i + ' month check');
+ assert.equal(testMoment.date(), i,
+ 'lenient ordinal parsing ' + i + ' date check');
+ }
+ });
+
+ test('lenient ordinal parsing of number', function (assert) {
+ var i, testMoment;
+ for (i = 1; i <= 31; ++i) {
+ testMoment = moment('2014 01 ' + i, 'YYYY MM Do');
+ assert.equal(testMoment.year(), 2014,
+ 'lenient ordinal parsing of number ' + i + ' year check');
+ assert.equal(testMoment.month(), 0,
+ 'lenient ordinal parsing of number ' + i + ' month check');
+ assert.equal(testMoment.date(), i,
+ 'lenient ordinal parsing of number ' + i + ' date check');
+ }
+ });
+
+ test('strict ordinal parsing', function (assert) {
+ var i, ordinalStr, testMoment;
+ for (i = 1; i <= 31; ++i) {
+ ordinalStr = moment([2014, 0, i]).format('YYYY MM Do');
+ testMoment = moment(ordinalStr, 'YYYY MM Do', true);
+ assert.ok(testMoment.isValid(), 'strict ordinal parsing ' + i);
+ }
+ });
+
+ test('meridiem invariant', function (assert) {
+ var h, m, t1, t2;
+ for (h = 0; h < 24; ++h) {
+ for (m = 0; m < 60; m += 15) {
+ t1 = moment.utc([2000, 0, 1, h, m]);
+ t2 = moment.utc(t1.format('A h:mm'), 'A h:mm');
+ assert.equal(t2.format('HH:mm'), t1.format('HH:mm'),
+ 'meridiem at ' + t1.format('HH:mm'));
+ }
+ }
+ });
+
+ test('date format correctness', function (assert) {
+ var data, tokens;
+ data = moment.localeData()._longDateFormat;
+ tokens = objectKeys(data);
+ each(tokens, function (srchToken) {
+ // Check each format string to make sure it does not contain any
+ // tokens that need to be expanded.
+ each(tokens, function (baseToken) {
+ // strip escaped sequences
+ var format = data[baseToken].replace(/(\[[^\]]*\])/g, '');
+ assert.equal(false, !!~format.indexOf(srchToken),
+ 'contains ' + srchToken + ' in ' + baseToken);
+ });
+ });
+ });
+
+ test('month parsing correctness', function (assert) {
+ var i, m;
+
+ if (locale === 'tr') {
+ // I can't fix it :(
+ expect(0);
+ return;
+ }
+ function tester(format) {
+ var r;
+ r = moment(m.format(format), format);
+ assert.equal(r.month(), m.month(), 'month ' + i + ' fmt ' + format);
+ r = moment(m.format(format).toLocaleUpperCase(), format);
+ assert.equal(r.month(), m.month(), 'month ' + i + ' fmt ' + format + ' upper');
+ r = moment(m.format(format).toLocaleLowerCase(), format);
+ assert.equal(r.month(), m.month(), 'month ' + i + ' fmt ' + format + ' lower');
+
+ r = moment(m.format(format), format, true);
+ assert.equal(r.month(), m.month(), 'month ' + i + ' fmt ' + format + ' strict');
+ r = moment(m.format(format).toLocaleUpperCase(), format, true);
+ assert.equal(r.month(), m.month(), 'month ' + i + ' fmt ' + format + ' upper strict');
+ r = moment(m.format(format).toLocaleLowerCase(), format, true);
+ assert.equal(r.month(), m.month(), 'month ' + i + ' fmt ' + format + ' lower strict');
+ }
+
+ for (i = 0; i < 12; ++i) {
+ m = moment([2015, i, 15, 18]);
+ tester('MMM');
+ tester('MMM.');
+ tester('MMMM');
+ tester('MMMM.');
+ }
+ });
+
+ test('weekday parsing correctness', function (assert) {
+ var i, m;
+
+ if (locale === 'tr' || locale === 'az') {
+ // There is a lower-case letter (ı), that converted to upper then
+ // lower changes to i
+ expect(0);
+ return;
+ }
+ function tester(format) {
+ var r, baseMsg = 'weekday ' + m.weekday() + ' fmt ' + format;
+ r = moment(m.format(format), format);
+ assert.equal(r.weekday(), m.weekday(), baseMsg);
+ r = moment(m.format(format).toLocaleUpperCase(), format);
+ assert.equal(r.weekday(), m.weekday(), baseMsg + ' upper');
+ r = moment(m.format(format).toLocaleLowerCase(), format);
+ assert.equal(r.weekday(), m.weekday(), baseMsg + ' lower');
+
+ r = moment(m.format(format), format, true);
+ assert.equal(r.weekday(), m.weekday(), baseMsg + ' strict');
+ r = moment(m.format(format).toLocaleUpperCase(), format, true);
+ assert.equal(r.weekday(), m.weekday(), baseMsg + ' upper strict');
+ r = moment(m.format(format).toLocaleLowerCase(), format, true);
+ assert.equal(r.weekday(), m.weekday(), baseMsg + ' lower strict');
+ }
+
+ for (i = 0; i < 7; ++i) {
+ m = moment.utc([2015, i, 15, 18]);
+ tester('dd');
+ tester('ddd');
+ tester('dddd');
+ }
+ });
+ }
+
+ function setupDeprecationHandler(test, moment, scope) {
+ test._expectedDeprecations = null;
+ test._observedDeprecations = null;
+ test._oldSupress = moment.suppressDeprecationWarnings;
+ moment.suppressDeprecationWarnings = true;
+ test.expectedDeprecations = function () {
+ test._expectedDeprecations = arguments;
+ test._observedDeprecations = [];
+ };
+ moment.deprecationHandler = function (name, msg) {
+ var deprecationId = matchedDeprecation(name, msg, test._expectedDeprecations);
+ if (deprecationId === -1) {
+ throw new Error('Unexpected deprecation thrown name=' +
+ name + ' msg=' + msg);
+ }
+ test._observedDeprecations[deprecationId] = 1;
+ };
+ }
+
+ function teardownDeprecationHandler(test, moment, scope) {
+ moment.suppressDeprecationWarnings = test._oldSupress;
+
+ if (test._expectedDeprecations != null) {
+ var missedDeprecations = [];
+ each(test._expectedDeprecations, function (deprecationPattern, id) {
+ if (test._observedDeprecations[id] !== 1) {
+ missedDeprecations.push(deprecationPattern);
+ }
+ });
+ if (missedDeprecations.length !== 0) {
+ throw new Error('Expected deprecation warnings did not happen: ' +
+ missedDeprecations.join(' '));
+ }
+ }
+ }
+
+ function matchedDeprecation(name, msg, deprecations) {
+ if (deprecations == null) {
+ return -1;
+ }
+ for (var i = 0; i < deprecations.length; ++i) {
+ if (name != null && name === deprecations[i]) {
+ return i;
+ }
+ if (msg != null && msg.substring(0, deprecations[i].length) === deprecations[i]) {
+ return i;
+ }
+ }
+ return -1;
+ }
/*global QUnit:false*/
@@ -32795,11 +46242,13 @@
moment.createFromInputFallback = function (config) {
throw new Error('input not handled by moment: ' + config._i);
};
+ setupDeprecationHandler(test, moment, 'core');
if (lifecycle && lifecycle.setup) {
lifecycle.setup();
}
},
teardown : function () {
+ teardownDeprecationHandler(test, moment, 'core');
if (lifecycle && lifecycle.teardown) {
lifecycle.teardown();
}
@@ -32814,17 +46263,20 @@
moment.createFromInputFallback = function (config) {
throw new Error('input not handled by moment: ' + config._i);
};
+ setupDeprecationHandler(test, moment, 'locale');
if (lifecycle && lifecycle.setup) {
lifecycle.setup();
}
},
teardown : function () {
moment.locale('en');
+ teardownDeprecationHandler(test, moment, 'locale');
if (lifecycle && lifecycle.teardown) {
lifecycle.teardown();
}
}
});
+ defineCommonLocaleTests(name, -1, -1);
}
localeModule('tzl');
@@ -32978,14 +46430,14 @@
});
test('calendar day', function (assert) {
- var a = moment().hours(2).minutes(0).seconds(0);
-
- assert.equal(moment(a).calendar(), 'oxhi à 02.00', 'today at the same time');
- assert.equal(moment(a).add({m: 25}).calendar(), 'oxhi à 02.25', 'Now plus 25 min');
- assert.equal(moment(a).add({h: 1}).calendar(), 'oxhi à 03.00', 'Now plus 1 hour');
- assert.equal(moment(a).add({d: 1}).calendar(), 'demà à 02.00', 'tomorrow at the same time');
- assert.equal(moment(a).subtract({h: 1}).calendar(), 'oxhi à 01.00', 'Now minus 1 hour');
- assert.equal(moment(a).subtract({d: 1}).calendar(), 'ieiri à 02.00', 'yesterday at the same time');
+ var a = moment().hours(12).minutes(0).seconds(0);
+
+ assert.equal(moment(a).calendar(), 'oxhi à 12.00', 'today at the same time');
+ assert.equal(moment(a).add({m: 25}).calendar(), 'oxhi à 12.25', 'Now plus 25 min');
+ assert.equal(moment(a).add({h: 1}).calendar(), 'oxhi à 13.00', 'Now plus 1 hour');
+ assert.equal(moment(a).add({d: 1}).calendar(), 'demà à 12.00', 'tomorrow at the same time');
+ assert.equal(moment(a).subtract({h: 1}).calendar(), 'oxhi à 11.00', 'Now minus 1 hour');
+ assert.equal(moment(a).subtract({d: 1}).calendar(), 'ieiri à 12.00', 'yesterday at the same time');
});
test('calendar next week', function (assert) {
@@ -33030,67 +46482,6 @@
// Monday is the first day of the week.
// The week that contains Jan 4th is the first week of the year.
- test('weeks year starting sunday', function (assert) {
- assert.equal(moment([2012, 0, 1]).week(), 52, 'Jan 1 2012 should be week 52');
- assert.equal(moment([2012, 0, 2]).week(), 1, 'Jan 2 2012 should be week 1');
- assert.equal(moment([2012, 0, 8]).week(), 1, 'Jan 8 2012 should be week 1');
- assert.equal(moment([2012, 0, 9]).week(), 2, 'Jan 9 2012 should be week 2');
- assert.equal(moment([2012, 0, 15]).week(), 2, 'Jan 15 2012 should be week 2');
- });
-
- test('weeks year starting monday', function (assert) {
- assert.equal(moment([2007, 0, 1]).week(), 1, 'Jan 1 2007 should be week 1');
- assert.equal(moment([2007, 0, 7]).week(), 1, 'Jan 7 2007 should be week 1');
- assert.equal(moment([2007, 0, 8]).week(), 2, 'Jan 8 2007 should be week 2');
- assert.equal(moment([2007, 0, 14]).week(), 2, 'Jan 14 2007 should be week 2');
- assert.equal(moment([2007, 0, 15]).week(), 3, 'Jan 15 2007 should be week 3');
- });
-
- test('weeks year starting tuesday', function (assert) {
- assert.equal(moment([2007, 11, 31]).week(), 1, 'Dec 31 2007 should be week 1');
- assert.equal(moment([2008, 0, 1]).week(), 1, 'Jan 1 2008 should be week 1');
- assert.equal(moment([2008, 0, 6]).week(), 1, 'Jan 6 2008 should be week 1');
- assert.equal(moment([2008, 0, 7]).week(), 2, 'Jan 7 2008 should be week 2');
- assert.equal(moment([2008, 0, 13]).week(), 2, 'Jan 13 2008 should be week 2');
- assert.equal(moment([2008, 0, 14]).week(), 3, 'Jan 14 2008 should be week 3');
- });
-
- test('weeks year starting wednesday', function (assert) {
- assert.equal(moment([2002, 11, 30]).week(), 1, 'Dec 30 2002 should be week 1');
- assert.equal(moment([2003, 0, 1]).week(), 1, 'Jan 1 2003 should be week 1');
- assert.equal(moment([2003, 0, 5]).week(), 1, 'Jan 5 2003 should be week 1');
- assert.equal(moment([2003, 0, 6]).week(), 2, 'Jan 6 2003 should be week 2');
- assert.equal(moment([2003, 0, 12]).week(), 2, 'Jan 12 2003 should be week 2');
- assert.equal(moment([2003, 0, 13]).week(), 3, 'Jan 13 2003 should be week 3');
- });
-
- test('weeks year starting thursday', function (assert) {
- assert.equal(moment([2008, 11, 29]).week(), 1, 'Dec 29 2008 should be week 1');
- assert.equal(moment([2009, 0, 1]).week(), 1, 'Jan 1 2009 should be week 1');
- assert.equal(moment([2009, 0, 4]).week(), 1, 'Jan 4 2009 should be week 1');
- assert.equal(moment([2009, 0, 5]).week(), 2, 'Jan 5 2009 should be week 2');
- assert.equal(moment([2009, 0, 11]).week(), 2, 'Jan 11 2009 should be week 2');
- assert.equal(moment([2009, 0, 13]).week(), 3, 'Jan 12 2009 should be week 3');
- });
-
- test('weeks year starting friday', function (assert) {
- assert.equal(moment([2009, 11, 28]).week(), 53, 'Dec 28 2009 should be week 53');
- assert.equal(moment([2010, 0, 1]).week(), 53, 'Jan 1 2010 should be week 53');
- assert.equal(moment([2010, 0, 3]).week(), 53, 'Jan 3 2010 should be week 53');
- assert.equal(moment([2010, 0, 4]).week(), 1, 'Jan 4 2010 should be week 1');
- assert.equal(moment([2010, 0, 10]).week(), 1, 'Jan 10 2010 should be week 1');
- assert.equal(moment([2010, 0, 11]).week(), 2, 'Jan 11 2010 should be week 2');
- });
-
- test('weeks year starting saturday', function (assert) {
- assert.equal(moment([2010, 11, 27]).week(), 52, 'Dec 27 2010 should be week 52');
- assert.equal(moment([2011, 0, 1]).week(), 52, 'Jan 1 2011 should be week 52');
- assert.equal(moment([2011, 0, 2]).week(), 52, 'Jan 2 2011 should be week 52');
- assert.equal(moment([2011, 0, 3]).week(), 1, 'Jan 3 2011 should be week 1');
- assert.equal(moment([2011, 0, 9]).week(), 1, 'Jan 9 2011 should be week 1');
- assert.equal(moment([2011, 0, 10]).week(), 2, 'Jan 10 2011 should be week 2');
- });
-
test('weeks year starting sunday formatted', function (assert) {
assert.equal(moment([2012, 0, 1]).format('w ww wo'), '52 52 52.', 'Jan 1 2012 should be week 52');
assert.equal(moment([2012, 0, 2]).format('w ww wo'), '1 01 1.', 'Jan 2 2012 should be week 1');
@@ -33099,42 +46490,6 @@
assert.equal(moment([2012, 0, 15]).format('w ww wo'), '2 02 2.', 'Jan 15 2012 should be week 2');
});
- test('lenient ordinal parsing', function (assert) {
- var i, ordinalStr, testMoment;
- for (i = 1; i <= 31; ++i) {
- ordinalStr = moment([2014, 0, i]).format('YYYY MM Do');
- testMoment = moment(ordinalStr, 'YYYY MM Do');
- assert.equal(testMoment.year(), 2014,
- 'lenient ordinal parsing ' + i + ' year check');
- assert.equal(testMoment.month(), 0,
- 'lenient ordinal parsing ' + i + ' month check');
- assert.equal(testMoment.date(), i,
- 'lenient ordinal parsing ' + i + ' date check');
- }
- });
-
- test('lenient ordinal parsing of number', function (assert) {
- var i, testMoment;
- for (i = 1; i <= 31; ++i) {
- testMoment = moment('2014 01 ' + i, 'YYYY MM Do');
- assert.equal(testMoment.year(), 2014,
- 'lenient ordinal parsing of number ' + i + ' year check');
- assert.equal(testMoment.month(), 0,
- 'lenient ordinal parsing of number ' + i + ' month check');
- assert.equal(testMoment.date(), i,
- 'lenient ordinal parsing of number ' + i + ' date check');
- }
- });
-
- test('strict ordinal parsing', function (assert) {
- var i, ordinalStr, testMoment;
- for (i = 1; i <= 31; ++i) {
- ordinalStr = moment([2014, 0, i]).format('YYYY MM Do');
- testMoment = moment(ordinalStr, 'YYYY MM Do', true);
- assert.ok(testMoment.isValid(), 'strict ordinal parsing ' + i);
- }
- });
-
}));
;(function (global, factory) {
@@ -33143,6 +46498,224 @@
typeof define === 'function' && define.amd ? define(['../../moment'], factory) :
factory(global.moment)
}(this, function (moment) { 'use strict';
+
+ function each(array, callback) {
+ var i;
+ for (i = 0; i < array.length; i++) {
+ callback(array[i], i, array);
+ }
+ }
+
+ function objectKeys(obj) {
+ if (Object.keys) {
+ return Object.keys(obj);
+ } else {
+ // IE8
+ var res = [], i;
+ for (i in obj) {
+ if (obj.hasOwnProperty(i)) {
+ res.push(i);
+ }
+ }
+ return res;
+ }
+ }
+
+ // Pick the first defined of two or three arguments.
+ function defaults(a, b, c) {
+ if (a != null) {
+ return a;
+ }
+ if (b != null) {
+ return b;
+ }
+ return c;
+ }
+
+ function defineCommonLocaleTests(locale, options) {
+ test('lenient ordinal parsing', function (assert) {
+ var i, ordinalStr, testMoment;
+ for (i = 1; i <= 31; ++i) {
+ ordinalStr = moment([2014, 0, i]).format('YYYY MM Do');
+ testMoment = moment(ordinalStr, 'YYYY MM Do');
+ assert.equal(testMoment.year(), 2014,
+ 'lenient ordinal parsing ' + i + ' year check');
+ assert.equal(testMoment.month(), 0,
+ 'lenient ordinal parsing ' + i + ' month check');
+ assert.equal(testMoment.date(), i,
+ 'lenient ordinal parsing ' + i + ' date check');
+ }
+ });
+
+ test('lenient ordinal parsing of number', function (assert) {
+ var i, testMoment;
+ for (i = 1; i <= 31; ++i) {
+ testMoment = moment('2014 01 ' + i, 'YYYY MM Do');
+ assert.equal(testMoment.year(), 2014,
+ 'lenient ordinal parsing of number ' + i + ' year check');
+ assert.equal(testMoment.month(), 0,
+ 'lenient ordinal parsing of number ' + i + ' month check');
+ assert.equal(testMoment.date(), i,
+ 'lenient ordinal parsing of number ' + i + ' date check');
+ }
+ });
+
+ test('strict ordinal parsing', function (assert) {
+ var i, ordinalStr, testMoment;
+ for (i = 1; i <= 31; ++i) {
+ ordinalStr = moment([2014, 0, i]).format('YYYY MM Do');
+ testMoment = moment(ordinalStr, 'YYYY MM Do', true);
+ assert.ok(testMoment.isValid(), 'strict ordinal parsing ' + i);
+ }
+ });
+
+ test('meridiem invariant', function (assert) {
+ var h, m, t1, t2;
+ for (h = 0; h < 24; ++h) {
+ for (m = 0; m < 60; m += 15) {
+ t1 = moment.utc([2000, 0, 1, h, m]);
+ t2 = moment.utc(t1.format('A h:mm'), 'A h:mm');
+ assert.equal(t2.format('HH:mm'), t1.format('HH:mm'),
+ 'meridiem at ' + t1.format('HH:mm'));
+ }
+ }
+ });
+
+ test('date format correctness', function (assert) {
+ var data, tokens;
+ data = moment.localeData()._longDateFormat;
+ tokens = objectKeys(data);
+ each(tokens, function (srchToken) {
+ // Check each format string to make sure it does not contain any
+ // tokens that need to be expanded.
+ each(tokens, function (baseToken) {
+ // strip escaped sequences
+ var format = data[baseToken].replace(/(\[[^\]]*\])/g, '');
+ assert.equal(false, !!~format.indexOf(srchToken),
+ 'contains ' + srchToken + ' in ' + baseToken);
+ });
+ });
+ });
+
+ test('month parsing correctness', function (assert) {
+ var i, m;
+
+ if (locale === 'tr') {
+ // I can't fix it :(
+ expect(0);
+ return;
+ }
+ function tester(format) {
+ var r;
+ r = moment(m.format(format), format);
+ assert.equal(r.month(), m.month(), 'month ' + i + ' fmt ' + format);
+ r = moment(m.format(format).toLocaleUpperCase(), format);
+ assert.equal(r.month(), m.month(), 'month ' + i + ' fmt ' + format + ' upper');
+ r = moment(m.format(format).toLocaleLowerCase(), format);
+ assert.equal(r.month(), m.month(), 'month ' + i + ' fmt ' + format + ' lower');
+
+ r = moment(m.format(format), format, true);
+ assert.equal(r.month(), m.month(), 'month ' + i + ' fmt ' + format + ' strict');
+ r = moment(m.format(format).toLocaleUpperCase(), format, true);
+ assert.equal(r.month(), m.month(), 'month ' + i + ' fmt ' + format + ' upper strict');
+ r = moment(m.format(format).toLocaleLowerCase(), format, true);
+ assert.equal(r.month(), m.month(), 'month ' + i + ' fmt ' + format + ' lower strict');
+ }
+
+ for (i = 0; i < 12; ++i) {
+ m = moment([2015, i, 15, 18]);
+ tester('MMM');
+ tester('MMM.');
+ tester('MMMM');
+ tester('MMMM.');
+ }
+ });
+
+ test('weekday parsing correctness', function (assert) {
+ var i, m;
+
+ if (locale === 'tr' || locale === 'az') {
+ // There is a lower-case letter (ı), that converted to upper then
+ // lower changes to i
+ expect(0);
+ return;
+ }
+ function tester(format) {
+ var r, baseMsg = 'weekday ' + m.weekday() + ' fmt ' + format;
+ r = moment(m.format(format), format);
+ assert.equal(r.weekday(), m.weekday(), baseMsg);
+ r = moment(m.format(format).toLocaleUpperCase(), format);
+ assert.equal(r.weekday(), m.weekday(), baseMsg + ' upper');
+ r = moment(m.format(format).toLocaleLowerCase(), format);
+ assert.equal(r.weekday(), m.weekday(), baseMsg + ' lower');
+
+ r = moment(m.format(format), format, true);
+ assert.equal(r.weekday(), m.weekday(), baseMsg + ' strict');
+ r = moment(m.format(format).toLocaleUpperCase(), format, true);
+ assert.equal(r.weekday(), m.weekday(), baseMsg + ' upper strict');
+ r = moment(m.format(format).toLocaleLowerCase(), format, true);
+ assert.equal(r.weekday(), m.weekday(), baseMsg + ' lower strict');
+ }
+
+ for (i = 0; i < 7; ++i) {
+ m = moment.utc([2015, i, 15, 18]);
+ tester('dd');
+ tester('ddd');
+ tester('dddd');
+ }
+ });
+ }
+
+ function setupDeprecationHandler(test, moment, scope) {
+ test._expectedDeprecations = null;
+ test._observedDeprecations = null;
+ test._oldSupress = moment.suppressDeprecationWarnings;
+ moment.suppressDeprecationWarnings = true;
+ test.expectedDeprecations = function () {
+ test._expectedDeprecations = arguments;
+ test._observedDeprecations = [];
+ };
+ moment.deprecationHandler = function (name, msg) {
+ var deprecationId = matchedDeprecation(name, msg, test._expectedDeprecations);
+ if (deprecationId === -1) {
+ throw new Error('Unexpected deprecation thrown name=' +
+ name + ' msg=' + msg);
+ }
+ test._observedDeprecations[deprecationId] = 1;
+ };
+ }
+
+ function teardownDeprecationHandler(test, moment, scope) {
+ moment.suppressDeprecationWarnings = test._oldSupress;
+
+ if (test._expectedDeprecations != null) {
+ var missedDeprecations = [];
+ each(test._expectedDeprecations, function (deprecationPattern, id) {
+ if (test._observedDeprecations[id] !== 1) {
+ missedDeprecations.push(deprecationPattern);
+ }
+ });
+ if (missedDeprecations.length !== 0) {
+ throw new Error('Expected deprecation warnings did not happen: ' +
+ missedDeprecations.join(' '));
+ }
+ }
+ }
+
+ function matchedDeprecation(name, msg, deprecations) {
+ if (deprecations == null) {
+ return -1;
+ }
+ for (var i = 0; i < deprecations.length; ++i) {
+ if (name != null && name === deprecations[i]) {
+ return i;
+ }
+ if (msg != null && msg.substring(0, deprecations[i].length) === deprecations[i]) {
+ return i;
+ }
+ }
+ return -1;
+ }
/*global QUnit:false*/
@@ -33157,11 +46730,13 @@
moment.createFromInputFallback = function (config) {
throw new Error('input not handled by moment: ' + config._i);
};
+ setupDeprecationHandler(test, moment, 'core');
if (lifecycle && lifecycle.setup) {
lifecycle.setup();
}
},
teardown : function () {
+ teardownDeprecationHandler(test, moment, 'core');
if (lifecycle && lifecycle.teardown) {
lifecycle.teardown();
}
@@ -33176,17 +46751,20 @@
moment.createFromInputFallback = function (config) {
throw new Error('input not handled by moment: ' + config._i);
};
+ setupDeprecationHandler(test, moment, 'locale');
if (lifecycle && lifecycle.setup) {
lifecycle.setup();
}
},
teardown : function () {
moment.locale('en');
+ teardownDeprecationHandler(test, moment, 'locale');
if (lifecycle && lifecycle.teardown) {
lifecycle.teardown();
}
}
});
+ defineCommonLocaleTests(name, -1, -1);
}
localeModule('tzm-latn');
@@ -33340,14 +46918,14 @@
});
test('calendar day', function (assert) {
- var a = moment().hours(2).minutes(0).seconds(0);
-
- assert.equal(moment(a).calendar(), 'asdkh g 02:00', 'today at the same time');
- assert.equal(moment(a).add({m: 25}).calendar(), 'asdkh g 02:25', 'Now plus 25 min');
- assert.equal(moment(a).add({h: 1}).calendar(), 'asdkh g 03:00', 'Now plus 1 hour');
- assert.equal(moment(a).add({d: 1}).calendar(), 'aska g 02:00', 'tomorrow at the same time');
- assert.equal(moment(a).subtract({h: 1}).calendar(), 'asdkh g 01:00', 'Now minus 1 hour');
- assert.equal(moment(a).subtract({d: 1}).calendar(), 'assant g 02:00', 'yesterday at the same time');
+ var a = moment().hours(12).minutes(0).seconds(0);
+
+ assert.equal(moment(a).calendar(), 'asdkh g 12:00', 'today at the same time');
+ assert.equal(moment(a).add({m: 25}).calendar(), 'asdkh g 12:25', 'Now plus 25 min');
+ assert.equal(moment(a).add({h: 1}).calendar(), 'asdkh g 13:00', 'Now plus 1 hour');
+ assert.equal(moment(a).add({d: 1}).calendar(), 'aska g 12:00', 'tomorrow at the same time');
+ assert.equal(moment(a).subtract({h: 1}).calendar(), 'asdkh g 11:00', 'Now minus 1 hour');
+ assert.equal(moment(a).subtract({d: 1}).calendar(), 'assant g 12:00', 'yesterday at the same time');
});
test('calendar next week', function (assert) {
@@ -33388,65 +46966,6 @@
assert.equal(weeksFromNow.calendar(), weeksFromNow.format('L'), 'in 2 weeks');
});
- test('weeks year starting sunday', function (assert) {
- assert.equal(moment([2011, 11, 31]).week(), 1, 'Dec 31 2011 should be week 1');
- assert.equal(moment([2012, 0, 6]).week(), 1, 'Jan 6 2012 should be week 1');
- assert.equal(moment([2012, 0, 7]).week(), 2, 'Jan 7 2012 should be week 2');
- assert.equal(moment([2012, 0, 13]).week(), 2, 'Jan 13 2012 should be week 2');
- assert.equal(moment([2012, 0, 14]).week(), 3, 'Jan 14 2012 should be week 3');
- });
-
- test('weeks year starting monday', function (assert) {
- assert.equal(moment([2006, 11, 30]).week(), 1, 'Dec 30 2006 should be week 1');
- assert.equal(moment([2007, 0, 5]).week(), 1, 'Jan 5 2007 should be week 1');
- assert.equal(moment([2007, 0, 6]).week(), 2, 'Jan 6 2007 should be week 2');
- assert.equal(moment([2007, 0, 12]).week(), 2, 'Jan 12 2007 should be week 2');
- assert.equal(moment([2007, 0, 13]).week(), 3, 'Jan 13 2007 should be week 3');
- });
-
- test('weeks year starting tuesday', function (assert) {
- assert.equal(moment([2007, 11, 29]).week(), 1, 'Dec 29 2007 should be week 1');
- assert.equal(moment([2008, 0, 1]).week(), 1, 'Jan 1 2008 should be week 1');
- assert.equal(moment([2008, 0, 4]).week(), 1, 'Jan 4 2008 should be week 1');
- assert.equal(moment([2008, 0, 5]).week(), 2, 'Jan 5 2008 should be week 2');
- assert.equal(moment([2008, 0, 11]).week(), 2, 'Jan 11 2008 should be week 2');
- assert.equal(moment([2008, 0, 12]).week(), 3, 'Jan 12 2008 should be week 3');
- });
-
- test('weeks year starting wednesday', function (assert) {
- assert.equal(moment([2002, 11, 28]).week(), 1, 'Dec 28 2002 should be week 1');
- assert.equal(moment([2003, 0, 1]).week(), 1, 'Jan 1 2003 should be week 1');
- assert.equal(moment([2003, 0, 3]).week(), 1, 'Jan 3 2003 should be week 1');
- assert.equal(moment([2003, 0, 4]).week(), 2, 'Jan 4 2003 should be week 2');
- assert.equal(moment([2003, 0, 10]).week(), 2, 'Jan 10 2003 should be week 2');
- assert.equal(moment([2003, 0, 11]).week(), 3, 'Jan 11 2003 should be week 3');
- });
-
- test('weeks year starting thursday', function (assert) {
- assert.equal(moment([2008, 11, 27]).week(), 1, 'Dec 27 2008 should be week 1');
- assert.equal(moment([2009, 0, 1]).week(), 1, 'Jan 1 2009 should be week 1');
- assert.equal(moment([2009, 0, 2]).week(), 1, 'Jan 2 2009 should be week 1');
- assert.equal(moment([2009, 0, 3]).week(), 2, 'Jan 3 2009 should be week 2');
- assert.equal(moment([2009, 0, 9]).week(), 2, 'Jan 9 2009 should be week 2');
- assert.equal(moment([2009, 0, 10]).week(), 3, 'Jan 10 2009 should be week 3');
- });
-
- test('weeks year starting friday', function (assert) {
- assert.equal(moment([2009, 11, 26]).week(), 1, 'Dec 26 2009 should be week 1');
- assert.equal(moment([2010, 0, 1]).week(), 1, 'Jan 1 2010 should be week 1');
- assert.equal(moment([2010, 0, 2]).week(), 2, 'Jan 2 2010 should be week 2');
- assert.equal(moment([2010, 0, 8]).week(), 2, 'Jan 8 2010 should be week 2');
- assert.equal(moment([2010, 0, 9]).week(), 3, 'Jan 9 2010 should be week 3');
- });
-
- test('weeks year starting saturday', function (assert) {
- assert.equal(moment([2011, 0, 1]).week(), 1, 'Jan 1 2011 should be week 1');
- assert.equal(moment([2011, 0, 7]).week(), 1, 'Jan 7 2011 should be week 1');
- assert.equal(moment([2011, 0, 8]).week(), 2, 'Jan 8 2011 should be week 2');
- assert.equal(moment([2011, 0, 14]).week(), 2, 'Jan 14 2011 should be week 2');
- assert.equal(moment([2011, 0, 15]).week(), 3, 'Jan 15 2011 should be week 3');
- });
-
test('weeks year starting sunday formatted', function (assert) {
assert.equal(moment([2011, 11, 31]).format('w ww wo'), '1 01 1', 'Dec 31 2011 should be week 1');
assert.equal(moment([2012, 0, 6]).format('w ww wo'), '1 01 1', 'Jan 6 2012 should be week 1');
@@ -33455,42 +46974,6 @@
assert.equal(moment([2012, 0, 14]).format('w ww wo'), '3 03 3', 'Jan 14 2012 should be week 3');
});
- test('lenient ordinal parsing', function (assert) {
- var i, ordinalStr, testMoment;
- for (i = 1; i <= 31; ++i) {
- ordinalStr = moment([2014, 0, i]).format('YYYY MM Do');
- testMoment = moment(ordinalStr, 'YYYY MM Do');
- assert.equal(testMoment.year(), 2014,
- 'lenient ordinal parsing ' + i + ' year check');
- assert.equal(testMoment.month(), 0,
- 'lenient ordinal parsing ' + i + ' month check');
- assert.equal(testMoment.date(), i,
- 'lenient ordinal parsing ' + i + ' date check');
- }
- });
-
- test('lenient ordinal parsing of number', function (assert) {
- var i, testMoment;
- for (i = 1; i <= 31; ++i) {
- testMoment = moment('2014 01 ' + i, 'YYYY MM Do');
- assert.equal(testMoment.year(), 2014,
- 'lenient ordinal parsing of number ' + i + ' year check');
- assert.equal(testMoment.month(), 0,
- 'lenient ordinal parsing of number ' + i + ' month check');
- assert.equal(testMoment.date(), i,
- 'lenient ordinal parsing of number ' + i + ' date check');
- }
- });
-
- test('strict ordinal parsing', function (assert) {
- var i, ordinalStr, testMoment;
- for (i = 1; i <= 31; ++i) {
- ordinalStr = moment([2014, 0, i]).format('YYYY MM Do');
- testMoment = moment(ordinalStr, 'YYYY MM Do', true);
- assert.ok(testMoment.isValid(), 'strict ordinal parsing ' + i);
- }
- });
-
}));
;(function (global, factory) {
@@ -33499,6 +46982,224 @@
typeof define === 'function' && define.amd ? define(['../../moment'], factory) :
factory(global.moment)
}(this, function (moment) { 'use strict';
+
+ function each(array, callback) {
+ var i;
+ for (i = 0; i < array.length; i++) {
+ callback(array[i], i, array);
+ }
+ }
+
+ function objectKeys(obj) {
+ if (Object.keys) {
+ return Object.keys(obj);
+ } else {
+ // IE8
+ var res = [], i;
+ for (i in obj) {
+ if (obj.hasOwnProperty(i)) {
+ res.push(i);
+ }
+ }
+ return res;
+ }
+ }
+
+ // Pick the first defined of two or three arguments.
+ function defaults(a, b, c) {
+ if (a != null) {
+ return a;
+ }
+ if (b != null) {
+ return b;
+ }
+ return c;
+ }
+
+ function defineCommonLocaleTests(locale, options) {
+ test('lenient ordinal parsing', function (assert) {
+ var i, ordinalStr, testMoment;
+ for (i = 1; i <= 31; ++i) {
+ ordinalStr = moment([2014, 0, i]).format('YYYY MM Do');
+ testMoment = moment(ordinalStr, 'YYYY MM Do');
+ assert.equal(testMoment.year(), 2014,
+ 'lenient ordinal parsing ' + i + ' year check');
+ assert.equal(testMoment.month(), 0,
+ 'lenient ordinal parsing ' + i + ' month check');
+ assert.equal(testMoment.date(), i,
+ 'lenient ordinal parsing ' + i + ' date check');
+ }
+ });
+
+ test('lenient ordinal parsing of number', function (assert) {
+ var i, testMoment;
+ for (i = 1; i <= 31; ++i) {
+ testMoment = moment('2014 01 ' + i, 'YYYY MM Do');
+ assert.equal(testMoment.year(), 2014,
+ 'lenient ordinal parsing of number ' + i + ' year check');
+ assert.equal(testMoment.month(), 0,
+ 'lenient ordinal parsing of number ' + i + ' month check');
+ assert.equal(testMoment.date(), i,
+ 'lenient ordinal parsing of number ' + i + ' date check');
+ }
+ });
+
+ test('strict ordinal parsing', function (assert) {
+ var i, ordinalStr, testMoment;
+ for (i = 1; i <= 31; ++i) {
+ ordinalStr = moment([2014, 0, i]).format('YYYY MM Do');
+ testMoment = moment(ordinalStr, 'YYYY MM Do', true);
+ assert.ok(testMoment.isValid(), 'strict ordinal parsing ' + i);
+ }
+ });
+
+ test('meridiem invariant', function (assert) {
+ var h, m, t1, t2;
+ for (h = 0; h < 24; ++h) {
+ for (m = 0; m < 60; m += 15) {
+ t1 = moment.utc([2000, 0, 1, h, m]);
+ t2 = moment.utc(t1.format('A h:mm'), 'A h:mm');
+ assert.equal(t2.format('HH:mm'), t1.format('HH:mm'),
+ 'meridiem at ' + t1.format('HH:mm'));
+ }
+ }
+ });
+
+ test('date format correctness', function (assert) {
+ var data, tokens;
+ data = moment.localeData()._longDateFormat;
+ tokens = objectKeys(data);
+ each(tokens, function (srchToken) {
+ // Check each format string to make sure it does not contain any
+ // tokens that need to be expanded.
+ each(tokens, function (baseToken) {
+ // strip escaped sequences
+ var format = data[baseToken].replace(/(\[[^\]]*\])/g, '');
+ assert.equal(false, !!~format.indexOf(srchToken),
+ 'contains ' + srchToken + ' in ' + baseToken);
+ });
+ });
+ });
+
+ test('month parsing correctness', function (assert) {
+ var i, m;
+
+ if (locale === 'tr') {
+ // I can't fix it :(
+ expect(0);
+ return;
+ }
+ function tester(format) {
+ var r;
+ r = moment(m.format(format), format);
+ assert.equal(r.month(), m.month(), 'month ' + i + ' fmt ' + format);
+ r = moment(m.format(format).toLocaleUpperCase(), format);
+ assert.equal(r.month(), m.month(), 'month ' + i + ' fmt ' + format + ' upper');
+ r = moment(m.format(format).toLocaleLowerCase(), format);
+ assert.equal(r.month(), m.month(), 'month ' + i + ' fmt ' + format + ' lower');
+
+ r = moment(m.format(format), format, true);
+ assert.equal(r.month(), m.month(), 'month ' + i + ' fmt ' + format + ' strict');
+ r = moment(m.format(format).toLocaleUpperCase(), format, true);
+ assert.equal(r.month(), m.month(), 'month ' + i + ' fmt ' + format + ' upper strict');
+ r = moment(m.format(format).toLocaleLowerCase(), format, true);
+ assert.equal(r.month(), m.month(), 'month ' + i + ' fmt ' + format + ' lower strict');
+ }
+
+ for (i = 0; i < 12; ++i) {
+ m = moment([2015, i, 15, 18]);
+ tester('MMM');
+ tester('MMM.');
+ tester('MMMM');
+ tester('MMMM.');
+ }
+ });
+
+ test('weekday parsing correctness', function (assert) {
+ var i, m;
+
+ if (locale === 'tr' || locale === 'az') {
+ // There is a lower-case letter (ı), that converted to upper then
+ // lower changes to i
+ expect(0);
+ return;
+ }
+ function tester(format) {
+ var r, baseMsg = 'weekday ' + m.weekday() + ' fmt ' + format;
+ r = moment(m.format(format), format);
+ assert.equal(r.weekday(), m.weekday(), baseMsg);
+ r = moment(m.format(format).toLocaleUpperCase(), format);
+ assert.equal(r.weekday(), m.weekday(), baseMsg + ' upper');
+ r = moment(m.format(format).toLocaleLowerCase(), format);
+ assert.equal(r.weekday(), m.weekday(), baseMsg + ' lower');
+
+ r = moment(m.format(format), format, true);
+ assert.equal(r.weekday(), m.weekday(), baseMsg + ' strict');
+ r = moment(m.format(format).toLocaleUpperCase(), format, true);
+ assert.equal(r.weekday(), m.weekday(), baseMsg + ' upper strict');
+ r = moment(m.format(format).toLocaleLowerCase(), format, true);
+ assert.equal(r.weekday(), m.weekday(), baseMsg + ' lower strict');
+ }
+
+ for (i = 0; i < 7; ++i) {
+ m = moment.utc([2015, i, 15, 18]);
+ tester('dd');
+ tester('ddd');
+ tester('dddd');
+ }
+ });
+ }
+
+ function setupDeprecationHandler(test, moment, scope) {
+ test._expectedDeprecations = null;
+ test._observedDeprecations = null;
+ test._oldSupress = moment.suppressDeprecationWarnings;
+ moment.suppressDeprecationWarnings = true;
+ test.expectedDeprecations = function () {
+ test._expectedDeprecations = arguments;
+ test._observedDeprecations = [];
+ };
+ moment.deprecationHandler = function (name, msg) {
+ var deprecationId = matchedDeprecation(name, msg, test._expectedDeprecations);
+ if (deprecationId === -1) {
+ throw new Error('Unexpected deprecation thrown name=' +
+ name + ' msg=' + msg);
+ }
+ test._observedDeprecations[deprecationId] = 1;
+ };
+ }
+
+ function teardownDeprecationHandler(test, moment, scope) {
+ moment.suppressDeprecationWarnings = test._oldSupress;
+
+ if (test._expectedDeprecations != null) {
+ var missedDeprecations = [];
+ each(test._expectedDeprecations, function (deprecationPattern, id) {
+ if (test._observedDeprecations[id] !== 1) {
+ missedDeprecations.push(deprecationPattern);
+ }
+ });
+ if (missedDeprecations.length !== 0) {
+ throw new Error('Expected deprecation warnings did not happen: ' +
+ missedDeprecations.join(' '));
+ }
+ }
+ }
+
+ function matchedDeprecation(name, msg, deprecations) {
+ if (deprecations == null) {
+ return -1;
+ }
+ for (var i = 0; i < deprecations.length; ++i) {
+ if (name != null && name === deprecations[i]) {
+ return i;
+ }
+ if (msg != null && msg.substring(0, deprecations[i].length) === deprecations[i]) {
+ return i;
+ }
+ }
+ return -1;
+ }
/*global QUnit:false*/
@@ -33513,11 +47214,13 @@
moment.createFromInputFallback = function (config) {
throw new Error('input not handled by moment: ' + config._i);
};
+ setupDeprecationHandler(test, moment, 'core');
if (lifecycle && lifecycle.setup) {
lifecycle.setup();
}
},
teardown : function () {
+ teardownDeprecationHandler(test, moment, 'core');
if (lifecycle && lifecycle.teardown) {
lifecycle.teardown();
}
@@ -33532,17 +47235,20 @@
moment.createFromInputFallback = function (config) {
throw new Error('input not handled by moment: ' + config._i);
};
+ setupDeprecationHandler(test, moment, 'locale');
if (lifecycle && lifecycle.setup) {
lifecycle.setup();
}
},
teardown : function () {
moment.locale('en');
+ teardownDeprecationHandler(test, moment, 'locale');
if (lifecycle && lifecycle.teardown) {
lifecycle.teardown();
}
}
});
+ defineCommonLocaleTests(name, -1, -1);
}
localeModule('tzm');
@@ -33696,14 +47402,14 @@
});
test('calendar day', function (assert) {
- var a = moment().hours(2).minutes(0).seconds(0);
-
- assert.equal(moment(a).calendar(), 'ⴰⵙⴷⵅ ⴴ 02:00', 'today at the same time');
- assert.equal(moment(a).add({m: 25}).calendar(), 'ⴰⵙⴷⵅ ⴴ 02:25', 'Now plus 25 min');
- assert.equal(moment(a).add({h: 1}).calendar(), 'ⴰⵙⴷⵅ ⴴ 03:00', 'Now plus 1 hour');
- assert.equal(moment(a).add({d: 1}).calendar(), 'ⴰⵙⴽⴰ ⴴ 02:00', 'tomorrow at the same time');
- assert.equal(moment(a).subtract({h: 1}).calendar(), 'ⴰⵙⴷⵅ ⴴ 01:00', 'Now minus 1 hour');
- assert.equal(moment(a).subtract({d: 1}).calendar(), 'ⴰⵚⴰⵏⵜ ⴴ 02:00', 'yesterday at the same time');
+ var a = moment().hours(12).minutes(0).seconds(0);
+
+ assert.equal(moment(a).calendar(), 'ⴰⵙⴷⵅ ⴴ 12:00', 'today at the same time');
+ assert.equal(moment(a).add({m: 25}).calendar(), 'ⴰⵙⴷⵅ ⴴ 12:25', 'Now plus 25 min');
+ assert.equal(moment(a).add({h: 1}).calendar(), 'ⴰⵙⴷⵅ ⴴ 13:00', 'Now plus 1 hour');
+ assert.equal(moment(a).add({d: 1}).calendar(), 'ⴰⵙⴽⴰ ⴴ 12:00', 'tomorrow at the same time');
+ assert.equal(moment(a).subtract({h: 1}).calendar(), 'ⴰⵙⴷⵅ ⴴ 11:00', 'Now minus 1 hour');
+ assert.equal(moment(a).subtract({d: 1}).calendar(), 'ⴰⵚⴰⵏⵜ ⴴ 12:00', 'yesterday at the same time');
});
test('calendar next week', function (assert) {
@@ -33744,65 +47450,6 @@
assert.equal(weeksFromNow.calendar(), weeksFromNow.format('L'), 'in 2 weeks');
});
- test('weeks year starting sunday', function (assert) {
- assert.equal(moment([2011, 11, 31]).week(), 1, 'Dec 31 2011 should be week 1');
- assert.equal(moment([2012, 0, 6]).week(), 1, 'Jan 6 2012 should be week 1');
- assert.equal(moment([2012, 0, 7]).week(), 2, 'Jan 7 2012 should be week 2');
- assert.equal(moment([2012, 0, 13]).week(), 2, 'Jan 13 2012 should be week 2');
- assert.equal(moment([2012, 0, 14]).week(), 3, 'Jan 14 2012 should be week 3');
- });
-
- test('weeks year starting monday', function (assert) {
- assert.equal(moment([2006, 11, 30]).week(), 1, 'Dec 30 2006 should be week 1');
- assert.equal(moment([2007, 0, 5]).week(), 1, 'Jan 5 2007 should be week 1');
- assert.equal(moment([2007, 0, 6]).week(), 2, 'Jan 6 2007 should be week 2');
- assert.equal(moment([2007, 0, 12]).week(), 2, 'Jan 12 2007 should be week 2');
- assert.equal(moment([2007, 0, 13]).week(), 3, 'Jan 13 2007 should be week 3');
- });
-
- test('weeks year starting tuesday', function (assert) {
- assert.equal(moment([2007, 11, 29]).week(), 1, 'Dec 29 2007 should be week 1');
- assert.equal(moment([2008, 0, 1]).week(), 1, 'Jan 1 2008 should be week 1');
- assert.equal(moment([2008, 0, 4]).week(), 1, 'Jan 4 2008 should be week 1');
- assert.equal(moment([2008, 0, 5]).week(), 2, 'Jan 5 2008 should be week 2');
- assert.equal(moment([2008, 0, 11]).week(), 2, 'Jan 11 2008 should be week 2');
- assert.equal(moment([2008, 0, 12]).week(), 3, 'Jan 12 2008 should be week 3');
- });
-
- test('weeks year starting wednesday', function (assert) {
- assert.equal(moment([2002, 11, 28]).week(), 1, 'Dec 28 2002 should be week 1');
- assert.equal(moment([2003, 0, 1]).week(), 1, 'Jan 1 2003 should be week 1');
- assert.equal(moment([2003, 0, 3]).week(), 1, 'Jan 3 2003 should be week 1');
- assert.equal(moment([2003, 0, 4]).week(), 2, 'Jan 4 2003 should be week 2');
- assert.equal(moment([2003, 0, 10]).week(), 2, 'Jan 10 2003 should be week 2');
- assert.equal(moment([2003, 0, 11]).week(), 3, 'Jan 11 2003 should be week 3');
- });
-
- test('weeks year starting thursday', function (assert) {
- assert.equal(moment([2008, 11, 27]).week(), 1, 'Dec 27 2008 should be week 1');
- assert.equal(moment([2009, 0, 1]).week(), 1, 'Jan 1 2009 should be week 1');
- assert.equal(moment([2009, 0, 2]).week(), 1, 'Jan 2 2009 should be week 1');
- assert.equal(moment([2009, 0, 3]).week(), 2, 'Jan 3 2009 should be week 2');
- assert.equal(moment([2009, 0, 9]).week(), 2, 'Jan 9 2009 should be week 2');
- assert.equal(moment([2009, 0, 10]).week(), 3, 'Jan 10 2009 should be week 3');
- });
-
- test('weeks year starting friday', function (assert) {
- assert.equal(moment([2009, 11, 26]).week(), 1, 'Dec 26 2009 should be week 1');
- assert.equal(moment([2010, 0, 1]).week(), 1, 'Jan 1 2010 should be week 1');
- assert.equal(moment([2010, 0, 2]).week(), 2, 'Jan 2 2010 should be week 2');
- assert.equal(moment([2010, 0, 8]).week(), 2, 'Jan 8 2010 should be week 2');
- assert.equal(moment([2010, 0, 9]).week(), 3, 'Jan 9 2010 should be week 3');
- });
-
- test('weeks year starting saturday', function (assert) {
- assert.equal(moment([2011, 0, 1]).week(), 1, 'Jan 1 2011 should be week 1');
- assert.equal(moment([2011, 0, 7]).week(), 1, 'Jan 7 2011 should be week 1');
- assert.equal(moment([2011, 0, 8]).week(), 2, 'Jan 8 2011 should be week 2');
- assert.equal(moment([2011, 0, 14]).week(), 2, 'Jan 14 2011 should be week 2');
- assert.equal(moment([2011, 0, 15]).week(), 3, 'Jan 15 2011 should be week 3');
- });
-
test('weeks year starting sunday formatted', function (assert) {
assert.equal(moment([2011, 11, 31]).format('w ww wo'), '1 01 1', 'Dec 31 2011 should be week 1');
assert.equal(moment([2012, 0, 6]).format('w ww wo'), '1 01 1', 'Jan 6 2012 should be week 1');
@@ -33811,42 +47458,6 @@
assert.equal(moment([2012, 0, 14]).format('w ww wo'), '3 03 3', 'Jan 14 2012 should be week 3');
});
- test('lenient ordinal parsing', function (assert) {
- var i, ordinalStr, testMoment;
- for (i = 1; i <= 31; ++i) {
- ordinalStr = moment([2014, 0, i]).format('YYYY MM Do');
- testMoment = moment(ordinalStr, 'YYYY MM Do');
- assert.equal(testMoment.year(), 2014,
- 'lenient ordinal parsing ' + i + ' year check');
- assert.equal(testMoment.month(), 0,
- 'lenient ordinal parsing ' + i + ' month check');
- assert.equal(testMoment.date(), i,
- 'lenient ordinal parsing ' + i + ' date check');
- }
- });
-
- test('lenient ordinal parsing of number', function (assert) {
- var i, testMoment;
- for (i = 1; i <= 31; ++i) {
- testMoment = moment('2014 01 ' + i, 'YYYY MM Do');
- assert.equal(testMoment.year(), 2014,
- 'lenient ordinal parsing of number ' + i + ' year check');
- assert.equal(testMoment.month(), 0,
- 'lenient ordinal parsing of number ' + i + ' month check');
- assert.equal(testMoment.date(), i,
- 'lenient ordinal parsing of number ' + i + ' date check');
- }
- });
-
- test('strict ordinal parsing', function (assert) {
- var i, ordinalStr, testMoment;
- for (i = 1; i <= 31; ++i) {
- ordinalStr = moment([2014, 0, i]).format('YYYY MM Do');
- testMoment = moment(ordinalStr, 'YYYY MM Do', true);
- assert.ok(testMoment.isValid(), 'strict ordinal parsing ' + i);
- }
- });
-
}));
;(function (global, factory) {
@@ -33855,6 +47466,224 @@
typeof define === 'function' && define.amd ? define(['../../moment'], factory) :
factory(global.moment)
}(this, function (moment) { 'use strict';
+
+ function each(array, callback) {
+ var i;
+ for (i = 0; i < array.length; i++) {
+ callback(array[i], i, array);
+ }
+ }
+
+ function objectKeys(obj) {
+ if (Object.keys) {
+ return Object.keys(obj);
+ } else {
+ // IE8
+ var res = [], i;
+ for (i in obj) {
+ if (obj.hasOwnProperty(i)) {
+ res.push(i);
+ }
+ }
+ return res;
+ }
+ }
+
+ // Pick the first defined of two or three arguments.
+ function defaults(a, b, c) {
+ if (a != null) {
+ return a;
+ }
+ if (b != null) {
+ return b;
+ }
+ return c;
+ }
+
+ function defineCommonLocaleTests(locale, options) {
+ test('lenient ordinal parsing', function (assert) {
+ var i, ordinalStr, testMoment;
+ for (i = 1; i <= 31; ++i) {
+ ordinalStr = moment([2014, 0, i]).format('YYYY MM Do');
+ testMoment = moment(ordinalStr, 'YYYY MM Do');
+ assert.equal(testMoment.year(), 2014,
+ 'lenient ordinal parsing ' + i + ' year check');
+ assert.equal(testMoment.month(), 0,
+ 'lenient ordinal parsing ' + i + ' month check');
+ assert.equal(testMoment.date(), i,
+ 'lenient ordinal parsing ' + i + ' date check');
+ }
+ });
+
+ test('lenient ordinal parsing of number', function (assert) {
+ var i, testMoment;
+ for (i = 1; i <= 31; ++i) {
+ testMoment = moment('2014 01 ' + i, 'YYYY MM Do');
+ assert.equal(testMoment.year(), 2014,
+ 'lenient ordinal parsing of number ' + i + ' year check');
+ assert.equal(testMoment.month(), 0,
+ 'lenient ordinal parsing of number ' + i + ' month check');
+ assert.equal(testMoment.date(), i,
+ 'lenient ordinal parsing of number ' + i + ' date check');
+ }
+ });
+
+ test('strict ordinal parsing', function (assert) {
+ var i, ordinalStr, testMoment;
+ for (i = 1; i <= 31; ++i) {
+ ordinalStr = moment([2014, 0, i]).format('YYYY MM Do');
+ testMoment = moment(ordinalStr, 'YYYY MM Do', true);
+ assert.ok(testMoment.isValid(), 'strict ordinal parsing ' + i);
+ }
+ });
+
+ test('meridiem invariant', function (assert) {
+ var h, m, t1, t2;
+ for (h = 0; h < 24; ++h) {
+ for (m = 0; m < 60; m += 15) {
+ t1 = moment.utc([2000, 0, 1, h, m]);
+ t2 = moment.utc(t1.format('A h:mm'), 'A h:mm');
+ assert.equal(t2.format('HH:mm'), t1.format('HH:mm'),
+ 'meridiem at ' + t1.format('HH:mm'));
+ }
+ }
+ });
+
+ test('date format correctness', function (assert) {
+ var data, tokens;
+ data = moment.localeData()._longDateFormat;
+ tokens = objectKeys(data);
+ each(tokens, function (srchToken) {
+ // Check each format string to make sure it does not contain any
+ // tokens that need to be expanded.
+ each(tokens, function (baseToken) {
+ // strip escaped sequences
+ var format = data[baseToken].replace(/(\[[^\]]*\])/g, '');
+ assert.equal(false, !!~format.indexOf(srchToken),
+ 'contains ' + srchToken + ' in ' + baseToken);
+ });
+ });
+ });
+
+ test('month parsing correctness', function (assert) {
+ var i, m;
+
+ if (locale === 'tr') {
+ // I can't fix it :(
+ expect(0);
+ return;
+ }
+ function tester(format) {
+ var r;
+ r = moment(m.format(format), format);
+ assert.equal(r.month(), m.month(), 'month ' + i + ' fmt ' + format);
+ r = moment(m.format(format).toLocaleUpperCase(), format);
+ assert.equal(r.month(), m.month(), 'month ' + i + ' fmt ' + format + ' upper');
+ r = moment(m.format(format).toLocaleLowerCase(), format);
+ assert.equal(r.month(), m.month(), 'month ' + i + ' fmt ' + format + ' lower');
+
+ r = moment(m.format(format), format, true);
+ assert.equal(r.month(), m.month(), 'month ' + i + ' fmt ' + format + ' strict');
+ r = moment(m.format(format).toLocaleUpperCase(), format, true);
+ assert.equal(r.month(), m.month(), 'month ' + i + ' fmt ' + format + ' upper strict');
+ r = moment(m.format(format).toLocaleLowerCase(), format, true);
+ assert.equal(r.month(), m.month(), 'month ' + i + ' fmt ' + format + ' lower strict');
+ }
+
+ for (i = 0; i < 12; ++i) {
+ m = moment([2015, i, 15, 18]);
+ tester('MMM');
+ tester('MMM.');
+ tester('MMMM');
+ tester('MMMM.');
+ }
+ });
+
+ test('weekday parsing correctness', function (assert) {
+ var i, m;
+
+ if (locale === 'tr' || locale === 'az') {
+ // There is a lower-case letter (ı), that converted to upper then
+ // lower changes to i
+ expect(0);
+ return;
+ }
+ function tester(format) {
+ var r, baseMsg = 'weekday ' + m.weekday() + ' fmt ' + format;
+ r = moment(m.format(format), format);
+ assert.equal(r.weekday(), m.weekday(), baseMsg);
+ r = moment(m.format(format).toLocaleUpperCase(), format);
+ assert.equal(r.weekday(), m.weekday(), baseMsg + ' upper');
+ r = moment(m.format(format).toLocaleLowerCase(), format);
+ assert.equal(r.weekday(), m.weekday(), baseMsg + ' lower');
+
+ r = moment(m.format(format), format, true);
+ assert.equal(r.weekday(), m.weekday(), baseMsg + ' strict');
+ r = moment(m.format(format).toLocaleUpperCase(), format, true);
+ assert.equal(r.weekday(), m.weekday(), baseMsg + ' upper strict');
+ r = moment(m.format(format).toLocaleLowerCase(), format, true);
+ assert.equal(r.weekday(), m.weekday(), baseMsg + ' lower strict');
+ }
+
+ for (i = 0; i < 7; ++i) {
+ m = moment.utc([2015, i, 15, 18]);
+ tester('dd');
+ tester('ddd');
+ tester('dddd');
+ }
+ });
+ }
+
+ function setupDeprecationHandler(test, moment, scope) {
+ test._expectedDeprecations = null;
+ test._observedDeprecations = null;
+ test._oldSupress = moment.suppressDeprecationWarnings;
+ moment.suppressDeprecationWarnings = true;
+ test.expectedDeprecations = function () {
+ test._expectedDeprecations = arguments;
+ test._observedDeprecations = [];
+ };
+ moment.deprecationHandler = function (name, msg) {
+ var deprecationId = matchedDeprecation(name, msg, test._expectedDeprecations);
+ if (deprecationId === -1) {
+ throw new Error('Unexpected deprecation thrown name=' +
+ name + ' msg=' + msg);
+ }
+ test._observedDeprecations[deprecationId] = 1;
+ };
+ }
+
+ function teardownDeprecationHandler(test, moment, scope) {
+ moment.suppressDeprecationWarnings = test._oldSupress;
+
+ if (test._expectedDeprecations != null) {
+ var missedDeprecations = [];
+ each(test._expectedDeprecations, function (deprecationPattern, id) {
+ if (test._observedDeprecations[id] !== 1) {
+ missedDeprecations.push(deprecationPattern);
+ }
+ });
+ if (missedDeprecations.length !== 0) {
+ throw new Error('Expected deprecation warnings did not happen: ' +
+ missedDeprecations.join(' '));
+ }
+ }
+ }
+
+ function matchedDeprecation(name, msg, deprecations) {
+ if (deprecations == null) {
+ return -1;
+ }
+ for (var i = 0; i < deprecations.length; ++i) {
+ if (name != null && name === deprecations[i]) {
+ return i;
+ }
+ if (msg != null && msg.substring(0, deprecations[i].length) === deprecations[i]) {
+ return i;
+ }
+ }
+ return -1;
+ }
/*global QUnit:false*/
@@ -33869,11 +47698,13 @@
moment.createFromInputFallback = function (config) {
throw new Error('input not handled by moment: ' + config._i);
};
+ setupDeprecationHandler(test, moment, 'core');
if (lifecycle && lifecycle.setup) {
lifecycle.setup();
}
},
teardown : function () {
+ teardownDeprecationHandler(test, moment, 'core');
if (lifecycle && lifecycle.teardown) {
lifecycle.teardown();
}
@@ -33888,17 +47719,20 @@
moment.createFromInputFallback = function (config) {
throw new Error('input not handled by moment: ' + config._i);
};
+ setupDeprecationHandler(test, moment, 'locale');
if (lifecycle && lifecycle.setup) {
lifecycle.setup();
}
},
teardown : function () {
moment.locale('en');
+ teardownDeprecationHandler(test, moment, 'locale');
if (lifecycle && lifecycle.teardown) {
lifecycle.teardown();
}
}
});
+ defineCommonLocaleTests(name, -1, -1);
}
localeModule('uk');
@@ -34068,16 +47902,16 @@
});
test('calendar day', function (assert) {
- var a = moment().hours(2).minutes(0).seconds(0);
-
- assert.equal(moment(a).calendar(), 'Сьогодні о 02:00', 'today at the same time');
- assert.equal(moment(a).add({m: 25}).calendar(), 'Сьогодні о 02:25', 'Now plus 25 min');
- assert.equal(moment(a).add({h: 1}).calendar(), 'Сьогодні о 03:00', 'Now plus 1 hour');
- assert.equal(moment(a).add({d: 1}).calendar(), 'Завтра о 02:00', 'tomorrow at the same time');
- assert.equal(moment(a).subtract({h: 1}).calendar(), 'Сьогодні о 01:00', 'Now minus 1 hour');
- assert.equal(moment(a).subtract({d: 1}).calendar(), 'Вчора о 02:00', 'yesterday at the same time');
+ var a = moment().hours(12).minutes(0).seconds(0);
+
+ assert.equal(moment(a).calendar(), 'Сьогодні о 12:00', 'today at the same time');
+ assert.equal(moment(a).add({m: 25}).calendar(), 'Сьогодні о 12:25', 'Now plus 25 min');
+ assert.equal(moment(a).add({h: 1}).calendar(), 'Сьогодні о 13:00', 'Now plus 1 hour');
+ assert.equal(moment(a).add({d: 1}).calendar(), 'Завтра о 12:00', 'tomorrow at the same time');
+ assert.equal(moment(a).subtract({h: 2}).calendar(), 'Сьогодні о 10:00', 'Now minus 2 hours');
+ assert.equal(moment(a).subtract({d: 1}).calendar(), 'Вчора о 12:00', 'yesterday at the same time');
// A special case for Ukrainian since 11 hours have different preposition
- assert.equal(moment(a).add({h: 9}).calendar(), 'Сьогодні об 11:00', 'same day at 11 o\'clock');
+ assert.equal(moment(a).subtract({h: 1}).calendar(), 'Сьогодні об 11:00', 'same day at 11 o\'clock');
});
test('calendar next week', function (assert) {
@@ -34133,67 +47967,6 @@
assert.equal(weeksFromNow.calendar(), weeksFromNow.format('L'), 'in 2 weeks');
});
- test('weeks year starting sunday', function (assert) {
- assert.equal(moment([2011, 11, 26]).week(), 1, 'Dec 26 2011 should be week 1');
- assert.equal(moment([2012, 0, 1]).week(), 1, 'Jan 1 2012 should be week 1');
- assert.equal(moment([2012, 0, 2]).week(), 2, 'Jan 2 2012 should be week 2');
- assert.equal(moment([2012, 0, 8]).week(), 2, 'Jan 8 2012 should be week 2');
- assert.equal(moment([2012, 0, 9]).week(), 3, 'Jan 9 2012 should be week 3');
- });
-
- test('weeks year starting monday', function (assert) {
- assert.equal(moment([2007, 0, 1]).week(), 1, 'Jan 1 2007 should be week 1');
- assert.equal(moment([2007, 0, 7]).week(), 1, 'Jan 7 2007 should be week 1');
- assert.equal(moment([2007, 0, 8]).week(), 2, 'Jan 8 2007 should be week 2');
- assert.equal(moment([2007, 0, 14]).week(), 2, 'Jan 14 2007 should be week 2');
- assert.equal(moment([2007, 0, 15]).week(), 3, 'Jan 15 2007 should be week 3');
- });
-
- test('weeks year starting tuesday', function (assert) {
- assert.equal(moment([2007, 11, 31]).week(), 1, 'Dec 31 2007 should be week 1');
- assert.equal(moment([2008, 0, 1]).week(), 1, 'Jan 1 2008 should be week 1');
- assert.equal(moment([2008, 0, 6]).week(), 1, 'Jan 6 2008 should be week 1');
- assert.equal(moment([2008, 0, 7]).week(), 2, 'Jan 7 2008 should be week 2');
- assert.equal(moment([2008, 0, 13]).week(), 2, 'Jan 13 2008 should be week 2');
- assert.equal(moment([2008, 0, 14]).week(), 3, 'Jan 14 2008 should be week 3');
- });
-
- test('weeks year starting wednesday', function (assert) {
- assert.equal(moment([2002, 11, 30]).week(), 1, 'Dec 30 2002 should be week 1');
- assert.equal(moment([2003, 0, 1]).week(), 1, 'Jan 1 2003 should be week 1');
- assert.equal(moment([2003, 0, 5]).week(), 1, 'Jan 5 2003 should be week 1');
- assert.equal(moment([2003, 0, 6]).week(), 2, 'Jan 6 2003 should be week 2');
- assert.equal(moment([2003, 0, 12]).week(), 2, 'Jan 12 2003 should be week 2');
- assert.equal(moment([2003, 0, 13]).week(), 3, 'Jan 13 2003 should be week 3');
- });
-
- test('weeks year starting thursday', function (assert) {
- assert.equal(moment([2008, 11, 29]).week(), 1, 'Dec 29 2008 should be week 1');
- assert.equal(moment([2009, 0, 1]).week(), 1, 'Jan 1 2009 should be week 1');
- assert.equal(moment([2009, 0, 4]).week(), 1, 'Jan 4 2009 should be week 1');
- assert.equal(moment([2009, 0, 5]).week(), 2, 'Jan 5 2009 should be week 2');
- assert.equal(moment([2009, 0, 11]).week(), 2, 'Jan 11 2009 should be week 2');
- assert.equal(moment([2009, 0, 12]).week(), 3, 'Jan 12 2009 should be week 3');
- });
-
- test('weeks year starting friday', function (assert) {
- assert.equal(moment([2009, 11, 28]).week(), 1, 'Dec 28 2009 should be week 1');
- assert.equal(moment([2010, 0, 1]).week(), 1, 'Jan 1 2010 should be week 1');
- assert.equal(moment([2010, 0, 3]).week(), 1, 'Jan 3 2010 should be week 1');
- assert.equal(moment([2010, 0, 4]).week(), 2, 'Jan 4 2010 should be week 2');
- assert.equal(moment([2010, 0, 10]).week(), 2, 'Jan 10 2010 should be week 2');
- assert.equal(moment([2010, 0, 11]).week(), 3, 'Jan 11 2010 should be week 3');
- });
-
- test('weeks year starting saturday', function (assert) {
- assert.equal(moment([2010, 11, 27]).week(), 1, 'Dec 27 2010 should be week 1');
- assert.equal(moment([2011, 0, 1]).week(), 1, 'Jan 1 2011 should be week 1');
- assert.equal(moment([2011, 0, 2]).week(), 1, 'Jan 2 2011 should be week 1');
- assert.equal(moment([2011, 0, 3]).week(), 2, 'Jan 3 2011 should be week 2');
- assert.equal(moment([2011, 0, 9]).week(), 2, 'Jan 9 2011 should be week 2');
- assert.equal(moment([2011, 0, 10]).week(), 3, 'Jan 10 2011 should be week 3');
- });
-
test('weeks year starting sunday formatted', function (assert) {
assert.equal(moment([2011, 11, 26]).format('w ww wo'), '1 01 1-й', 'Dec 26 2011 should be week 1');
assert.equal(moment([2012, 0, 1]).format('w ww wo'), '1 01 1-й', 'Jan 1 2012 should be week 1');
@@ -34202,42 +47975,6 @@
assert.equal(moment([2012, 0, 9]).format('w ww wo'), '3 03 3-й', 'Jan 9 2012 should be week 3');
});
- test('lenient ordinal parsing', function (assert) {
- var i, ordinalStr, testMoment;
- for (i = 1; i <= 31; ++i) {
- ordinalStr = moment([2014, 0, i]).format('YYYY MM Do');
- testMoment = moment(ordinalStr, 'YYYY MM Do');
- assert.equal(testMoment.year(), 2014,
- 'lenient ordinal parsing ' + i + ' year check');
- assert.equal(testMoment.month(), 0,
- 'lenient ordinal parsing ' + i + ' month check');
- assert.equal(testMoment.date(), i,
- 'lenient ordinal parsing ' + i + ' date check');
- }
- });
-
- test('lenient ordinal parsing of number', function (assert) {
- var i, testMoment;
- for (i = 1; i <= 31; ++i) {
- testMoment = moment('2014 01 ' + i, 'YYYY MM Do');
- assert.equal(testMoment.year(), 2014,
- 'lenient ordinal parsing of number ' + i + ' year check');
- assert.equal(testMoment.month(), 0,
- 'lenient ordinal parsing of number ' + i + ' month check');
- assert.equal(testMoment.date(), i,
- 'lenient ordinal parsing of number ' + i + ' date check');
- }
- });
-
- test('strict ordinal parsing', function (assert) {
- var i, ordinalStr, testMoment;
- for (i = 1; i <= 31; ++i) {
- ordinalStr = moment([2014, 0, i]).format('YYYY MM Do');
- testMoment = moment(ordinalStr, 'YYYY MM Do', true);
- assert.ok(testMoment.isValid(), 'strict ordinal parsing ' + i);
- }
- });
-
}));
;(function (global, factory) {
@@ -34246,6 +47983,224 @@
typeof define === 'function' && define.amd ? define(['../../moment'], factory) :
factory(global.moment)
}(this, function (moment) { 'use strict';
+
+ function each(array, callback) {
+ var i;
+ for (i = 0; i < array.length; i++) {
+ callback(array[i], i, array);
+ }
+ }
+
+ function objectKeys(obj) {
+ if (Object.keys) {
+ return Object.keys(obj);
+ } else {
+ // IE8
+ var res = [], i;
+ for (i in obj) {
+ if (obj.hasOwnProperty(i)) {
+ res.push(i);
+ }
+ }
+ return res;
+ }
+ }
+
+ // Pick the first defined of two or three arguments.
+ function defaults(a, b, c) {
+ if (a != null) {
+ return a;
+ }
+ if (b != null) {
+ return b;
+ }
+ return c;
+ }
+
+ function defineCommonLocaleTests(locale, options) {
+ test('lenient ordinal parsing', function (assert) {
+ var i, ordinalStr, testMoment;
+ for (i = 1; i <= 31; ++i) {
+ ordinalStr = moment([2014, 0, i]).format('YYYY MM Do');
+ testMoment = moment(ordinalStr, 'YYYY MM Do');
+ assert.equal(testMoment.year(), 2014,
+ 'lenient ordinal parsing ' + i + ' year check');
+ assert.equal(testMoment.month(), 0,
+ 'lenient ordinal parsing ' + i + ' month check');
+ assert.equal(testMoment.date(), i,
+ 'lenient ordinal parsing ' + i + ' date check');
+ }
+ });
+
+ test('lenient ordinal parsing of number', function (assert) {
+ var i, testMoment;
+ for (i = 1; i <= 31; ++i) {
+ testMoment = moment('2014 01 ' + i, 'YYYY MM Do');
+ assert.equal(testMoment.year(), 2014,
+ 'lenient ordinal parsing of number ' + i + ' year check');
+ assert.equal(testMoment.month(), 0,
+ 'lenient ordinal parsing of number ' + i + ' month check');
+ assert.equal(testMoment.date(), i,
+ 'lenient ordinal parsing of number ' + i + ' date check');
+ }
+ });
+
+ test('strict ordinal parsing', function (assert) {
+ var i, ordinalStr, testMoment;
+ for (i = 1; i <= 31; ++i) {
+ ordinalStr = moment([2014, 0, i]).format('YYYY MM Do');
+ testMoment = moment(ordinalStr, 'YYYY MM Do', true);
+ assert.ok(testMoment.isValid(), 'strict ordinal parsing ' + i);
+ }
+ });
+
+ test('meridiem invariant', function (assert) {
+ var h, m, t1, t2;
+ for (h = 0; h < 24; ++h) {
+ for (m = 0; m < 60; m += 15) {
+ t1 = moment.utc([2000, 0, 1, h, m]);
+ t2 = moment.utc(t1.format('A h:mm'), 'A h:mm');
+ assert.equal(t2.format('HH:mm'), t1.format('HH:mm'),
+ 'meridiem at ' + t1.format('HH:mm'));
+ }
+ }
+ });
+
+ test('date format correctness', function (assert) {
+ var data, tokens;
+ data = moment.localeData()._longDateFormat;
+ tokens = objectKeys(data);
+ each(tokens, function (srchToken) {
+ // Check each format string to make sure it does not contain any
+ // tokens that need to be expanded.
+ each(tokens, function (baseToken) {
+ // strip escaped sequences
+ var format = data[baseToken].replace(/(\[[^\]]*\])/g, '');
+ assert.equal(false, !!~format.indexOf(srchToken),
+ 'contains ' + srchToken + ' in ' + baseToken);
+ });
+ });
+ });
+
+ test('month parsing correctness', function (assert) {
+ var i, m;
+
+ if (locale === 'tr') {
+ // I can't fix it :(
+ expect(0);
+ return;
+ }
+ function tester(format) {
+ var r;
+ r = moment(m.format(format), format);
+ assert.equal(r.month(), m.month(), 'month ' + i + ' fmt ' + format);
+ r = moment(m.format(format).toLocaleUpperCase(), format);
+ assert.equal(r.month(), m.month(), 'month ' + i + ' fmt ' + format + ' upper');
+ r = moment(m.format(format).toLocaleLowerCase(), format);
+ assert.equal(r.month(), m.month(), 'month ' + i + ' fmt ' + format + ' lower');
+
+ r = moment(m.format(format), format, true);
+ assert.equal(r.month(), m.month(), 'month ' + i + ' fmt ' + format + ' strict');
+ r = moment(m.format(format).toLocaleUpperCase(), format, true);
+ assert.equal(r.month(), m.month(), 'month ' + i + ' fmt ' + format + ' upper strict');
+ r = moment(m.format(format).toLocaleLowerCase(), format, true);
+ assert.equal(r.month(), m.month(), 'month ' + i + ' fmt ' + format + ' lower strict');
+ }
+
+ for (i = 0; i < 12; ++i) {
+ m = moment([2015, i, 15, 18]);
+ tester('MMM');
+ tester('MMM.');
+ tester('MMMM');
+ tester('MMMM.');
+ }
+ });
+
+ test('weekday parsing correctness', function (assert) {
+ var i, m;
+
+ if (locale === 'tr' || locale === 'az') {
+ // There is a lower-case letter (ı), that converted to upper then
+ // lower changes to i
+ expect(0);
+ return;
+ }
+ function tester(format) {
+ var r, baseMsg = 'weekday ' + m.weekday() + ' fmt ' + format;
+ r = moment(m.format(format), format);
+ assert.equal(r.weekday(), m.weekday(), baseMsg);
+ r = moment(m.format(format).toLocaleUpperCase(), format);
+ assert.equal(r.weekday(), m.weekday(), baseMsg + ' upper');
+ r = moment(m.format(format).toLocaleLowerCase(), format);
+ assert.equal(r.weekday(), m.weekday(), baseMsg + ' lower');
+
+ r = moment(m.format(format), format, true);
+ assert.equal(r.weekday(), m.weekday(), baseMsg + ' strict');
+ r = moment(m.format(format).toLocaleUpperCase(), format, true);
+ assert.equal(r.weekday(), m.weekday(), baseMsg + ' upper strict');
+ r = moment(m.format(format).toLocaleLowerCase(), format, true);
+ assert.equal(r.weekday(), m.weekday(), baseMsg + ' lower strict');
+ }
+
+ for (i = 0; i < 7; ++i) {
+ m = moment.utc([2015, i, 15, 18]);
+ tester('dd');
+ tester('ddd');
+ tester('dddd');
+ }
+ });
+ }
+
+ function setupDeprecationHandler(test, moment, scope) {
+ test._expectedDeprecations = null;
+ test._observedDeprecations = null;
+ test._oldSupress = moment.suppressDeprecationWarnings;
+ moment.suppressDeprecationWarnings = true;
+ test.expectedDeprecations = function () {
+ test._expectedDeprecations = arguments;
+ test._observedDeprecations = [];
+ };
+ moment.deprecationHandler = function (name, msg) {
+ var deprecationId = matchedDeprecation(name, msg, test._expectedDeprecations);
+ if (deprecationId === -1) {
+ throw new Error('Unexpected deprecation thrown name=' +
+ name + ' msg=' + msg);
+ }
+ test._observedDeprecations[deprecationId] = 1;
+ };
+ }
+
+ function teardownDeprecationHandler(test, moment, scope) {
+ moment.suppressDeprecationWarnings = test._oldSupress;
+
+ if (test._expectedDeprecations != null) {
+ var missedDeprecations = [];
+ each(test._expectedDeprecations, function (deprecationPattern, id) {
+ if (test._observedDeprecations[id] !== 1) {
+ missedDeprecations.push(deprecationPattern);
+ }
+ });
+ if (missedDeprecations.length !== 0) {
+ throw new Error('Expected deprecation warnings did not happen: ' +
+ missedDeprecations.join(' '));
+ }
+ }
+ }
+
+ function matchedDeprecation(name, msg, deprecations) {
+ if (deprecations == null) {
+ return -1;
+ }
+ for (var i = 0; i < deprecations.length; ++i) {
+ if (name != null && name === deprecations[i]) {
+ return i;
+ }
+ if (msg != null && msg.substring(0, deprecations[i].length) === deprecations[i]) {
+ return i;
+ }
+ }
+ return -1;
+ }
/*global QUnit:false*/
@@ -34260,11 +48215,13 @@
moment.createFromInputFallback = function (config) {
throw new Error('input not handled by moment: ' + config._i);
};
+ setupDeprecationHandler(test, moment, 'core');
if (lifecycle && lifecycle.setup) {
lifecycle.setup();
}
},
teardown : function () {
+ teardownDeprecationHandler(test, moment, 'core');
if (lifecycle && lifecycle.teardown) {
lifecycle.teardown();
}
@@ -34279,17 +48236,20 @@
moment.createFromInputFallback = function (config) {
throw new Error('input not handled by moment: ' + config._i);
};
+ setupDeprecationHandler(test, moment, 'locale');
if (lifecycle && lifecycle.setup) {
lifecycle.setup();
}
},
teardown : function () {
moment.locale('en');
+ teardownDeprecationHandler(test, moment, 'locale');
if (lifecycle && lifecycle.teardown) {
lifecycle.teardown();
}
}
});
+ defineCommonLocaleTests(name, -1, -1);
}
localeModule('uz');
@@ -34443,14 +48403,14 @@
});
test('calendar day', function (assert) {
- var a = moment().hours(2).minutes(0).seconds(0);
-
- assert.equal(moment(a).calendar(), 'Бугун соат 02:00 да', 'today at the same time');
- assert.equal(moment(a).add({m: 25}).calendar(), 'Бугун соат 02:25 да', 'Now plus 25 min');
- assert.equal(moment(a).add({h: 1}).calendar(), 'Бугун соат 03:00 да', 'Now plus 1 hour');
- assert.equal(moment(a).add({d: 1}).calendar(), 'Эртага 02:00 да', 'tomorrow at the same time');
- assert.equal(moment(a).subtract({h: 1}).calendar(), 'Бугун соат 01:00 да', 'Now minus 1 hour');
- assert.equal(moment(a).subtract({d: 1}).calendar(), 'Кеча соат 02:00 да', 'yesterday at the same time');
+ var a = moment().hours(12).minutes(0).seconds(0);
+
+ assert.equal(moment(a).calendar(), 'Бугун соат 12:00 да', 'today at the same time');
+ assert.equal(moment(a).add({m: 25}).calendar(), 'Бугун соат 12:25 да', 'Now plus 25 min');
+ assert.equal(moment(a).add({h: 1}).calendar(), 'Бугун соат 13:00 да', 'Now plus 1 hour');
+ assert.equal(moment(a).add({d: 1}).calendar(), 'Эртага 12:00 да', 'tomorrow at the same time');
+ assert.equal(moment(a).subtract({h: 1}).calendar(), 'Бугун соат 11:00 да', 'Now minus 1 hour');
+ assert.equal(moment(a).subtract({d: 1}).calendar(), 'Кеча соат 12:00 да', 'yesterday at the same time');
});
test('calendar next week', function (assert) {
@@ -34492,67 +48452,6 @@
assert.equal(weeksFromNow.calendar(), weeksFromNow.format('L'), 'in 2 weeks');
});
- test('weeks year starting sunday', function (assert) {
- assert.equal(moment([2012, 0, 1]).week(), 1, 'Jan 1 2012 should be week 52');
- assert.equal(moment([2012, 0, 2]).week(), 2, 'Jan 2 2012 should be week 1');
- assert.equal(moment([2012, 0, 8]).week(), 2, 'Jan 8 2012 should be week 1');
- assert.equal(moment([2012, 0, 9]).week(), 3, 'Jan 9 2012 should be week 2');
- assert.equal(moment([2012, 0, 15]).week(), 3, 'Jan 15 2012 should be week 2');
- });
-
- test('weeks year starting monday', function (assert) {
- assert.equal(moment([2007, 0, 1]).week(), 1, 'Jan 1 2007 should be week 1');
- assert.equal(moment([2007, 0, 7]).week(), 1, 'Jan 7 2007 should be week 1');
- assert.equal(moment([2007, 0, 8]).week(), 2, 'Jan 8 2007 should be week 2');
- assert.equal(moment([2007, 0, 14]).week(), 2, 'Jan 14 2007 should be week 2');
- assert.equal(moment([2007, 0, 15]).week(), 3, 'Jan 15 2007 should be week 3');
- });
-
- test('weeks year starting tuesday', function (assert) {
- assert.equal(moment([2007, 11, 31]).week(), 1, 'Dec 31 2007 should be week 1');
- assert.equal(moment([2008, 0, 1]).week(), 1, 'Jan 1 2008 should be week 1');
- assert.equal(moment([2008, 0, 6]).week(), 1, 'Jan 6 2008 should be week 1');
- assert.equal(moment([2008, 0, 7]).week(), 2, 'Jan 7 2008 should be week 2');
- assert.equal(moment([2008, 0, 13]).week(), 2, 'Jan 13 2008 should be week 2');
- assert.equal(moment([2008, 0, 14]).week(), 3, 'Jan 14 2008 should be week 3');
- });
-
- test('weeks year starting wednesday', function (assert) {
- assert.equal(moment([2002, 11, 30]).week(), 1, 'Dec 30 2002 should be week 1');
- assert.equal(moment([2003, 0, 1]).week(), 1, 'Jan 1 2003 should be week 1');
- assert.equal(moment([2003, 0, 5]).week(), 1, 'Jan 5 2003 should be week 1');
- assert.equal(moment([2003, 0, 6]).week(), 2, 'Jan 6 2003 should be week 2');
- assert.equal(moment([2003, 0, 12]).week(), 2, 'Jan 12 2003 should be week 2');
- assert.equal(moment([2003, 0, 13]).week(), 3, 'Jan 13 2003 should be week 3');
- });
-
- test('weeks year starting thursday', function (assert) {
- assert.equal(moment([2008, 11, 29]).week(), 1, 'Dec 29 2008 should be week 1');
- assert.equal(moment([2009, 0, 1]).week(), 1, 'Jan 1 2009 should be week 1');
- assert.equal(moment([2009, 0, 4]).week(), 1, 'Jan 4 2009 should be week 1');
- assert.equal(moment([2009, 0, 5]).week(), 2, 'Jan 5 2009 should be week 2');
- assert.equal(moment([2009, 0, 11]).week(), 2, 'Jan 11 2009 should be week 2');
- assert.equal(moment([2009, 0, 13]).week(), 3, 'Jan 12 2009 should be week 3');
- });
-
- test('weeks year starting friday', function (assert) {
- assert.equal(moment([2009, 11, 28]).week(), 1, 'Dec 28 2009 should be week 53');
- assert.equal(moment([2010, 0, 1]).week(), 1, 'Jan 1 2010 should be week 53');
- assert.equal(moment([2010, 0, 3]).week(), 1, 'Jan 3 2010 should be week 53');
- assert.equal(moment([2010, 0, 4]).week(), 2, 'Jan 4 2010 should be week 1');
- assert.equal(moment([2010, 0, 10]).week(), 2, 'Jan 10 2010 should be week 1');
- assert.equal(moment([2010, 0, 11]).week(), 3, 'Jan 11 2010 should be week 2');
- });
-
- test('weeks year starting saturday', function (assert) {
- assert.equal(moment([2010, 11, 27]).week(), 1, 'Dec 27 2010 should be week 52');
- assert.equal(moment([2011, 0, 1]).week(), 1, 'Jan 1 2011 should be week 52');
- assert.equal(moment([2011, 0, 2]).week(), 1, 'Jan 2 2011 should be week 52');
- assert.equal(moment([2011, 0, 3]).week(), 2, 'Jan 3 2011 should be week 1');
- assert.equal(moment([2011, 0, 9]).week(), 2, 'Jan 9 2011 should be week 1');
- assert.equal(moment([2011, 0, 10]).week(), 3, 'Jan 10 2011 should be week 2');
- });
-
test('weeks year starting sunday formatted', function (assert) {
assert.equal(moment([2012, 0, 1]).format('w ww wo'), '1 01 1', 'Jan 1 2012 should be week 52');
assert.equal(moment([2012, 0, 2]).format('w ww wo'), '2 02 2', 'Jan 2 2012 should be week 1');
@@ -34561,42 +48460,6 @@
assert.equal(moment([2012, 0, 15]).format('w ww wo'), '3 03 3', 'Jan 15 2012 should be week 2');
});
- test('lenient ordinal parsing', function (assert) {
- var i, ordinalStr, testMoment;
- for (i = 1; i <= 31; ++i) {
- ordinalStr = moment([2014, 0, i]).format('YYYY MM Do');
- testMoment = moment(ordinalStr, 'YYYY MM Do');
- assert.equal(testMoment.year(), 2014,
- 'lenient ordinal parsing ' + i + ' year check');
- assert.equal(testMoment.month(), 0,
- 'lenient ordinal parsing ' + i + ' month check');
- assert.equal(testMoment.date(), i,
- 'lenient ordinal parsing ' + i + ' date check');
- }
- });
-
- test('lenient ordinal parsing of number', function (assert) {
- var i, testMoment;
- for (i = 1; i <= 31; ++i) {
- testMoment = moment('2014 01 ' + i, 'YYYY MM Do');
- assert.equal(testMoment.year(), 2014,
- 'lenient ordinal parsing of number ' + i + ' year check');
- assert.equal(testMoment.month(), 0,
- 'lenient ordinal parsing of number ' + i + ' month check');
- assert.equal(testMoment.date(), i,
- 'lenient ordinal parsing of number ' + i + ' date check');
- }
- });
-
- test('strict ordinal parsing', function (assert) {
- var i, ordinalStr, testMoment;
- for (i = 1; i <= 31; ++i) {
- ordinalStr = moment([2014, 0, i]).format('YYYY MM Do');
- testMoment = moment(ordinalStr, 'YYYY MM Do', true);
- assert.ok(testMoment.isValid(), 'strict ordinal parsing ' + i);
- }
- });
-
}));
;(function (global, factory) {
@@ -34605,6 +48468,224 @@
typeof define === 'function' && define.amd ? define(['../../moment'], factory) :
factory(global.moment)
}(this, function (moment) { 'use strict';
+
+ function each(array, callback) {
+ var i;
+ for (i = 0; i < array.length; i++) {
+ callback(array[i], i, array);
+ }
+ }
+
+ function objectKeys(obj) {
+ if (Object.keys) {
+ return Object.keys(obj);
+ } else {
+ // IE8
+ var res = [], i;
+ for (i in obj) {
+ if (obj.hasOwnProperty(i)) {
+ res.push(i);
+ }
+ }
+ return res;
+ }
+ }
+
+ // Pick the first defined of two or three arguments.
+ function defaults(a, b, c) {
+ if (a != null) {
+ return a;
+ }
+ if (b != null) {
+ return b;
+ }
+ return c;
+ }
+
+ function defineCommonLocaleTests(locale, options) {
+ test('lenient ordinal parsing', function (assert) {
+ var i, ordinalStr, testMoment;
+ for (i = 1; i <= 31; ++i) {
+ ordinalStr = moment([2014, 0, i]).format('YYYY MM Do');
+ testMoment = moment(ordinalStr, 'YYYY MM Do');
+ assert.equal(testMoment.year(), 2014,
+ 'lenient ordinal parsing ' + i + ' year check');
+ assert.equal(testMoment.month(), 0,
+ 'lenient ordinal parsing ' + i + ' month check');
+ assert.equal(testMoment.date(), i,
+ 'lenient ordinal parsing ' + i + ' date check');
+ }
+ });
+
+ test('lenient ordinal parsing of number', function (assert) {
+ var i, testMoment;
+ for (i = 1; i <= 31; ++i) {
+ testMoment = moment('2014 01 ' + i, 'YYYY MM Do');
+ assert.equal(testMoment.year(), 2014,
+ 'lenient ordinal parsing of number ' + i + ' year check');
+ assert.equal(testMoment.month(), 0,
+ 'lenient ordinal parsing of number ' + i + ' month check');
+ assert.equal(testMoment.date(), i,
+ 'lenient ordinal parsing of number ' + i + ' date check');
+ }
+ });
+
+ test('strict ordinal parsing', function (assert) {
+ var i, ordinalStr, testMoment;
+ for (i = 1; i <= 31; ++i) {
+ ordinalStr = moment([2014, 0, i]).format('YYYY MM Do');
+ testMoment = moment(ordinalStr, 'YYYY MM Do', true);
+ assert.ok(testMoment.isValid(), 'strict ordinal parsing ' + i);
+ }
+ });
+
+ test('meridiem invariant', function (assert) {
+ var h, m, t1, t2;
+ for (h = 0; h < 24; ++h) {
+ for (m = 0; m < 60; m += 15) {
+ t1 = moment.utc([2000, 0, 1, h, m]);
+ t2 = moment.utc(t1.format('A h:mm'), 'A h:mm');
+ assert.equal(t2.format('HH:mm'), t1.format('HH:mm'),
+ 'meridiem at ' + t1.format('HH:mm'));
+ }
+ }
+ });
+
+ test('date format correctness', function (assert) {
+ var data, tokens;
+ data = moment.localeData()._longDateFormat;
+ tokens = objectKeys(data);
+ each(tokens, function (srchToken) {
+ // Check each format string to make sure it does not contain any
+ // tokens that need to be expanded.
+ each(tokens, function (baseToken) {
+ // strip escaped sequences
+ var format = data[baseToken].replace(/(\[[^\]]*\])/g, '');
+ assert.equal(false, !!~format.indexOf(srchToken),
+ 'contains ' + srchToken + ' in ' + baseToken);
+ });
+ });
+ });
+
+ test('month parsing correctness', function (assert) {
+ var i, m;
+
+ if (locale === 'tr') {
+ // I can't fix it :(
+ expect(0);
+ return;
+ }
+ function tester(format) {
+ var r;
+ r = moment(m.format(format), format);
+ assert.equal(r.month(), m.month(), 'month ' + i + ' fmt ' + format);
+ r = moment(m.format(format).toLocaleUpperCase(), format);
+ assert.equal(r.month(), m.month(), 'month ' + i + ' fmt ' + format + ' upper');
+ r = moment(m.format(format).toLocaleLowerCase(), format);
+ assert.equal(r.month(), m.month(), 'month ' + i + ' fmt ' + format + ' lower');
+
+ r = moment(m.format(format), format, true);
+ assert.equal(r.month(), m.month(), 'month ' + i + ' fmt ' + format + ' strict');
+ r = moment(m.format(format).toLocaleUpperCase(), format, true);
+ assert.equal(r.month(), m.month(), 'month ' + i + ' fmt ' + format + ' upper strict');
+ r = moment(m.format(format).toLocaleLowerCase(), format, true);
+ assert.equal(r.month(), m.month(), 'month ' + i + ' fmt ' + format + ' lower strict');
+ }
+
+ for (i = 0; i < 12; ++i) {
+ m = moment([2015, i, 15, 18]);
+ tester('MMM');
+ tester('MMM.');
+ tester('MMMM');
+ tester('MMMM.');
+ }
+ });
+
+ test('weekday parsing correctness', function (assert) {
+ var i, m;
+
+ if (locale === 'tr' || locale === 'az') {
+ // There is a lower-case letter (ı), that converted to upper then
+ // lower changes to i
+ expect(0);
+ return;
+ }
+ function tester(format) {
+ var r, baseMsg = 'weekday ' + m.weekday() + ' fmt ' + format;
+ r = moment(m.format(format), format);
+ assert.equal(r.weekday(), m.weekday(), baseMsg);
+ r = moment(m.format(format).toLocaleUpperCase(), format);
+ assert.equal(r.weekday(), m.weekday(), baseMsg + ' upper');
+ r = moment(m.format(format).toLocaleLowerCase(), format);
+ assert.equal(r.weekday(), m.weekday(), baseMsg + ' lower');
+
+ r = moment(m.format(format), format, true);
+ assert.equal(r.weekday(), m.weekday(), baseMsg + ' strict');
+ r = moment(m.format(format).toLocaleUpperCase(), format, true);
+ assert.equal(r.weekday(), m.weekday(), baseMsg + ' upper strict');
+ r = moment(m.format(format).toLocaleLowerCase(), format, true);
+ assert.equal(r.weekday(), m.weekday(), baseMsg + ' lower strict');
+ }
+
+ for (i = 0; i < 7; ++i) {
+ m = moment.utc([2015, i, 15, 18]);
+ tester('dd');
+ tester('ddd');
+ tester('dddd');
+ }
+ });
+ }
+
+ function setupDeprecationHandler(test, moment, scope) {
+ test._expectedDeprecations = null;
+ test._observedDeprecations = null;
+ test._oldSupress = moment.suppressDeprecationWarnings;
+ moment.suppressDeprecationWarnings = true;
+ test.expectedDeprecations = function () {
+ test._expectedDeprecations = arguments;
+ test._observedDeprecations = [];
+ };
+ moment.deprecationHandler = function (name, msg) {
+ var deprecationId = matchedDeprecation(name, msg, test._expectedDeprecations);
+ if (deprecationId === -1) {
+ throw new Error('Unexpected deprecation thrown name=' +
+ name + ' msg=' + msg);
+ }
+ test._observedDeprecations[deprecationId] = 1;
+ };
+ }
+
+ function teardownDeprecationHandler(test, moment, scope) {
+ moment.suppressDeprecationWarnings = test._oldSupress;
+
+ if (test._expectedDeprecations != null) {
+ var missedDeprecations = [];
+ each(test._expectedDeprecations, function (deprecationPattern, id) {
+ if (test._observedDeprecations[id] !== 1) {
+ missedDeprecations.push(deprecationPattern);
+ }
+ });
+ if (missedDeprecations.length !== 0) {
+ throw new Error('Expected deprecation warnings did not happen: ' +
+ missedDeprecations.join(' '));
+ }
+ }
+ }
+
+ function matchedDeprecation(name, msg, deprecations) {
+ if (deprecations == null) {
+ return -1;
+ }
+ for (var i = 0; i < deprecations.length; ++i) {
+ if (name != null && name === deprecations[i]) {
+ return i;
+ }
+ if (msg != null && msg.substring(0, deprecations[i].length) === deprecations[i]) {
+ return i;
+ }
+ }
+ return -1;
+ }
/*global QUnit:false*/
@@ -34619,11 +48700,13 @@
moment.createFromInputFallback = function (config) {
throw new Error('input not handled by moment: ' + config._i);
};
+ setupDeprecationHandler(test, moment, 'core');
if (lifecycle && lifecycle.setup) {
lifecycle.setup();
}
},
teardown : function () {
+ teardownDeprecationHandler(test, moment, 'core');
if (lifecycle && lifecycle.teardown) {
lifecycle.teardown();
}
@@ -34638,17 +48721,20 @@
moment.createFromInputFallback = function (config) {
throw new Error('input not handled by moment: ' + config._i);
};
+ setupDeprecationHandler(test, moment, 'locale');
if (lifecycle && lifecycle.setup) {
lifecycle.setup();
}
},
teardown : function () {
moment.locale('en');
+ teardownDeprecationHandler(test, moment, 'locale');
if (lifecycle && lifecycle.teardown) {
lifecycle.teardown();
}
}
});
+ defineCommonLocaleTests(name, -1, -1);
}
localeModule('vi');
@@ -34676,8 +48762,8 @@
test('format', function (assert) {
var a = [
- ['dddd, MMMM Do YYYY, h:mm:ss a', 'chủ nhật, tháng 2 14 2010, 3:25:50 pm'],
- ['ddd, hA', 'CN, 3PM'],
+ ['dddd, MMMM Do YYYY, h:mm:ss a', 'chủ nhật, tháng 2 14 2010, 3:25:50 ch'],
+ ['ddd, hA', 'CN, 3CH'],
['M Mo MM MMMM MMM', '2 2 02 tháng 2 Th02'],
['YYYY YY', '2010 10'],
['D Do DD', '14 14 14'],
@@ -34688,7 +48774,7 @@
['H HH', '15 15'],
['m mm', '25 25'],
['s ss', '50 50'],
- ['a A', 'pm PM'],
+ ['a A', 'ch CH'],
['[ngày thứ] DDDo [của năm]', 'ngày thứ 45 của năm'],
['LTS', '15:25:50'],
['L', '14/02/2010'],
@@ -34811,14 +48897,14 @@
});
test('calendar day', function (assert) {
- var a = moment().hours(2).minutes(0).seconds(0);
-
- assert.equal(moment(a).calendar(), 'Hôm nay lúc 02:00', 'today at the same time');
- assert.equal(moment(a).add({m: 25}).calendar(), 'Hôm nay lúc 02:25', 'Now plus 25 min');
- assert.equal(moment(a).add({h: 1}).calendar(), 'Hôm nay lúc 03:00', 'Now plus 1 hour');
- assert.equal(moment(a).add({d: 1}).calendar(), 'Ngày mai lúc 02:00', 'tomorrow at the same time');
- assert.equal(moment(a).subtract({h: 1}).calendar(), 'Hôm nay lúc 01:00', 'Now minus 1 hour');
- assert.equal(moment(a).subtract({d: 1}).calendar(), 'Hôm qua lúc 02:00', 'yesterday at the same time');
+ var a = moment().hours(12).minutes(0).seconds(0);
+
+ assert.equal(moment(a).calendar(), 'Hôm nay lúc 12:00', 'today at the same time');
+ assert.equal(moment(a).add({m: 25}).calendar(), 'Hôm nay lúc 12:25', 'Now plus 25 min');
+ assert.equal(moment(a).add({h: 1}).calendar(), 'Hôm nay lúc 13:00', 'Now plus 1 hour');
+ assert.equal(moment(a).add({d: 1}).calendar(), 'Ngày mai lúc 12:00', 'tomorrow at the same time');
+ assert.equal(moment(a).subtract({h: 1}).calendar(), 'Hôm nay lúc 11:00', 'Now minus 1 hour');
+ assert.equal(moment(a).subtract({d: 1}).calendar(), 'Hôm qua lúc 12:00', 'yesterday at the same time');
});
test('calendar next week', function (assert) {
@@ -34861,67 +48947,6 @@
assert.equal(weeksFromNow.calendar(), weeksFromNow.format('L'), 'in 2 weeks');
});
- test('weeks year starting sunday', function (assert) {
- assert.equal(moment([2012, 0, 1]).week(), 52, 'Jan 1 2012 should be week 52');
- assert.equal(moment([2012, 0, 2]).week(), 1, 'Jan 2 2012 should be week 1');
- assert.equal(moment([2012, 0, 8]).week(), 1, 'Jan 8 2012 should be week 1');
- assert.equal(moment([2012, 0, 9]).week(), 2, 'Jan 9 2012 should be week 2');
- assert.equal(moment([2012, 0, 15]).week(), 2, 'Jan 15 2012 should be week 2');
- });
-
- test('weeks year starting monday', function (assert) {
- assert.equal(moment([2007, 0, 1]).week(), 1, 'Jan 1 2007 should be week 1');
- assert.equal(moment([2007, 0, 7]).week(), 1, 'Jan 7 2007 should be week 1');
- assert.equal(moment([2007, 0, 8]).week(), 2, 'Jan 8 2007 should be week 2');
- assert.equal(moment([2007, 0, 14]).week(), 2, 'Jan 14 2007 should be week 2');
- assert.equal(moment([2007, 0, 15]).week(), 3, 'Jan 15 2007 should be week 3');
- });
-
- test('weeks year starting tuesday', function (assert) {
- assert.equal(moment([2007, 11, 31]).week(), 1, 'Dec 31 2007 should be week 1');
- assert.equal(moment([2008, 0, 1]).week(), 1, 'Jan 1 2008 should be week 1');
- assert.equal(moment([2008, 0, 6]).week(), 1, 'Jan 6 2008 should be week 1');
- assert.equal(moment([2008, 0, 7]).week(), 2, 'Jan 7 2008 should be week 2');
- assert.equal(moment([2008, 0, 13]).week(), 2, 'Jan 13 2008 should be week 2');
- assert.equal(moment([2008, 0, 14]).week(), 3, 'Jan 14 2008 should be week 3');
- });
-
- test('weeks year starting wednesday', function (assert) {
- assert.equal(moment([2002, 11, 30]).week(), 1, 'Dec 30 2002 should be week 1');
- assert.equal(moment([2003, 0, 1]).week(), 1, 'Jan 1 2003 should be week 1');
- assert.equal(moment([2003, 0, 5]).week(), 1, 'Jan 5 2003 should be week 1');
- assert.equal(moment([2003, 0, 6]).week(), 2, 'Jan 6 2003 should be week 2');
- assert.equal(moment([2003, 0, 12]).week(), 2, 'Jan 12 2003 should be week 2');
- assert.equal(moment([2003, 0, 13]).week(), 3, 'Jan 13 2003 should be week 3');
- });
-
- test('weeks year starting thursday', function (assert) {
- assert.equal(moment([2008, 11, 29]).week(), 1, 'Dec 29 2008 should be week 1');
- assert.equal(moment([2009, 0, 1]).week(), 1, 'Jan 1 2009 should be week 1');
- assert.equal(moment([2009, 0, 4]).week(), 1, 'Jan 4 2009 should be week 1');
- assert.equal(moment([2009, 0, 5]).week(), 2, 'Jan 5 2009 should be week 2');
- assert.equal(moment([2009, 0, 11]).week(), 2, 'Jan 11 2009 should be week 2');
- assert.equal(moment([2009, 0, 13]).week(), 3, 'Jan 12 2009 should be week 3');
- });
-
- test('weeks year starting friday', function (assert) {
- assert.equal(moment([2009, 11, 28]).week(), 53, 'Dec 28 2009 should be week 53');
- assert.equal(moment([2010, 0, 1]).week(), 53, 'Jan 1 2010 should be week 53');
- assert.equal(moment([2010, 0, 3]).week(), 53, 'Jan 3 2010 should be week 53');
- assert.equal(moment([2010, 0, 4]).week(), 1, 'Jan 4 2010 should be week 1');
- assert.equal(moment([2010, 0, 10]).week(), 1, 'Jan 10 2010 should be week 1');
- assert.equal(moment([2010, 0, 11]).week(), 2, 'Jan 11 2010 should be week 2');
- });
-
- test('weeks year starting saturday', function (assert) {
- assert.equal(moment([2010, 11, 27]).week(), 52, 'Dec 27 2010 should be week 52');
- assert.equal(moment([2011, 0, 1]).week(), 52, 'Jan 1 2011 should be week 52');
- assert.equal(moment([2011, 0, 2]).week(), 52, 'Jan 2 2011 should be week 52');
- assert.equal(moment([2011, 0, 3]).week(), 1, 'Jan 3 2011 should be week 1');
- assert.equal(moment([2011, 0, 9]).week(), 1, 'Jan 9 2011 should be week 1');
- assert.equal(moment([2011, 0, 10]).week(), 2, 'Jan 10 2011 should be week 2');
- });
-
test('weeks year starting sunday formatted', function (assert) {
assert.equal(moment([2012, 0, 1]).format('w ww wo'), '52 52 52', 'Jan 1 2012 should be week 52');
assert.equal(moment([2012, 0, 2]).format('w ww wo'), '1 01 1', 'Jan 2 2012 should be week 1');
@@ -34930,42 +48955,6 @@
assert.equal(moment([2012, 0, 15]).format('w ww wo'), '2 02 2', 'Jan 15 2012 should be week 2');
});
- test('lenient ordinal parsing', function (assert) {
- var i, ordinalStr, testMoment;
- for (i = 1; i <= 31; ++i) {
- ordinalStr = moment([2014, 0, i]).format('YYYY MM Do');
- testMoment = moment(ordinalStr, 'YYYY MM Do');
- assert.equal(testMoment.year(), 2014,
- 'lenient ordinal parsing ' + i + ' year check');
- assert.equal(testMoment.month(), 0,
- 'lenient ordinal parsing ' + i + ' month check');
- assert.equal(testMoment.date(), i,
- 'lenient ordinal parsing ' + i + ' date check');
- }
- });
-
- test('lenient ordinal parsing of number', function (assert) {
- var i, testMoment;
- for (i = 1; i <= 31; ++i) {
- testMoment = moment('2014 01 ' + i, 'YYYY MM Do');
- assert.equal(testMoment.year(), 2014,
- 'lenient ordinal parsing of number ' + i + ' year check');
- assert.equal(testMoment.month(), 0,
- 'lenient ordinal parsing of number ' + i + ' month check');
- assert.equal(testMoment.date(), i,
- 'lenient ordinal parsing of number ' + i + ' date check');
- }
- });
-
- test('strict ordinal parsing', function (assert) {
- var i, ordinalStr, testMoment;
- for (i = 1; i <= 31; ++i) {
- ordinalStr = moment([2014, 0, i]).format('YYYY MM Do');
- testMoment = moment(ordinalStr, 'YYYY MM Do', true);
- assert.ok(testMoment.isValid(), 'strict ordinal parsing ' + i);
- }
- });
-
}));
;(function (global, factory) {
@@ -34974,6 +48963,224 @@
typeof define === 'function' && define.amd ? define(['../../moment'], factory) :
factory(global.moment)
}(this, function (moment) { 'use strict';
+
+ function each(array, callback) {
+ var i;
+ for (i = 0; i < array.length; i++) {
+ callback(array[i], i, array);
+ }
+ }
+
+ function objectKeys(obj) {
+ if (Object.keys) {
+ return Object.keys(obj);
+ } else {
+ // IE8
+ var res = [], i;
+ for (i in obj) {
+ if (obj.hasOwnProperty(i)) {
+ res.push(i);
+ }
+ }
+ return res;
+ }
+ }
+
+ // Pick the first defined of two or three arguments.
+ function defaults(a, b, c) {
+ if (a != null) {
+ return a;
+ }
+ if (b != null) {
+ return b;
+ }
+ return c;
+ }
+
+ function defineCommonLocaleTests(locale, options) {
+ test('lenient ordinal parsing', function (assert) {
+ var i, ordinalStr, testMoment;
+ for (i = 1; i <= 31; ++i) {
+ ordinalStr = moment([2014, 0, i]).format('YYYY MM Do');
+ testMoment = moment(ordinalStr, 'YYYY MM Do');
+ assert.equal(testMoment.year(), 2014,
+ 'lenient ordinal parsing ' + i + ' year check');
+ assert.equal(testMoment.month(), 0,
+ 'lenient ordinal parsing ' + i + ' month check');
+ assert.equal(testMoment.date(), i,
+ 'lenient ordinal parsing ' + i + ' date check');
+ }
+ });
+
+ test('lenient ordinal parsing of number', function (assert) {
+ var i, testMoment;
+ for (i = 1; i <= 31; ++i) {
+ testMoment = moment('2014 01 ' + i, 'YYYY MM Do');
+ assert.equal(testMoment.year(), 2014,
+ 'lenient ordinal parsing of number ' + i + ' year check');
+ assert.equal(testMoment.month(), 0,
+ 'lenient ordinal parsing of number ' + i + ' month check');
+ assert.equal(testMoment.date(), i,
+ 'lenient ordinal parsing of number ' + i + ' date check');
+ }
+ });
+
+ test('strict ordinal parsing', function (assert) {
+ var i, ordinalStr, testMoment;
+ for (i = 1; i <= 31; ++i) {
+ ordinalStr = moment([2014, 0, i]).format('YYYY MM Do');
+ testMoment = moment(ordinalStr, 'YYYY MM Do', true);
+ assert.ok(testMoment.isValid(), 'strict ordinal parsing ' + i);
+ }
+ });
+
+ test('meridiem invariant', function (assert) {
+ var h, m, t1, t2;
+ for (h = 0; h < 24; ++h) {
+ for (m = 0; m < 60; m += 15) {
+ t1 = moment.utc([2000, 0, 1, h, m]);
+ t2 = moment.utc(t1.format('A h:mm'), 'A h:mm');
+ assert.equal(t2.format('HH:mm'), t1.format('HH:mm'),
+ 'meridiem at ' + t1.format('HH:mm'));
+ }
+ }
+ });
+
+ test('date format correctness', function (assert) {
+ var data, tokens;
+ data = moment.localeData()._longDateFormat;
+ tokens = objectKeys(data);
+ each(tokens, function (srchToken) {
+ // Check each format string to make sure it does not contain any
+ // tokens that need to be expanded.
+ each(tokens, function (baseToken) {
+ // strip escaped sequences
+ var format = data[baseToken].replace(/(\[[^\]]*\])/g, '');
+ assert.equal(false, !!~format.indexOf(srchToken),
+ 'contains ' + srchToken + ' in ' + baseToken);
+ });
+ });
+ });
+
+ test('month parsing correctness', function (assert) {
+ var i, m;
+
+ if (locale === 'tr') {
+ // I can't fix it :(
+ expect(0);
+ return;
+ }
+ function tester(format) {
+ var r;
+ r = moment(m.format(format), format);
+ assert.equal(r.month(), m.month(), 'month ' + i + ' fmt ' + format);
+ r = moment(m.format(format).toLocaleUpperCase(), format);
+ assert.equal(r.month(), m.month(), 'month ' + i + ' fmt ' + format + ' upper');
+ r = moment(m.format(format).toLocaleLowerCase(), format);
+ assert.equal(r.month(), m.month(), 'month ' + i + ' fmt ' + format + ' lower');
+
+ r = moment(m.format(format), format, true);
+ assert.equal(r.month(), m.month(), 'month ' + i + ' fmt ' + format + ' strict');
+ r = moment(m.format(format).toLocaleUpperCase(), format, true);
+ assert.equal(r.month(), m.month(), 'month ' + i + ' fmt ' + format + ' upper strict');
+ r = moment(m.format(format).toLocaleLowerCase(), format, true);
+ assert.equal(r.month(), m.month(), 'month ' + i + ' fmt ' + format + ' lower strict');
+ }
+
+ for (i = 0; i < 12; ++i) {
+ m = moment([2015, i, 15, 18]);
+ tester('MMM');
+ tester('MMM.');
+ tester('MMMM');
+ tester('MMMM.');
+ }
+ });
+
+ test('weekday parsing correctness', function (assert) {
+ var i, m;
+
+ if (locale === 'tr' || locale === 'az') {
+ // There is a lower-case letter (ı), that converted to upper then
+ // lower changes to i
+ expect(0);
+ return;
+ }
+ function tester(format) {
+ var r, baseMsg = 'weekday ' + m.weekday() + ' fmt ' + format;
+ r = moment(m.format(format), format);
+ assert.equal(r.weekday(), m.weekday(), baseMsg);
+ r = moment(m.format(format).toLocaleUpperCase(), format);
+ assert.equal(r.weekday(), m.weekday(), baseMsg + ' upper');
+ r = moment(m.format(format).toLocaleLowerCase(), format);
+ assert.equal(r.weekday(), m.weekday(), baseMsg + ' lower');
+
+ r = moment(m.format(format), format, true);
+ assert.equal(r.weekday(), m.weekday(), baseMsg + ' strict');
+ r = moment(m.format(format).toLocaleUpperCase(), format, true);
+ assert.equal(r.weekday(), m.weekday(), baseMsg + ' upper strict');
+ r = moment(m.format(format).toLocaleLowerCase(), format, true);
+ assert.equal(r.weekday(), m.weekday(), baseMsg + ' lower strict');
+ }
+
+ for (i = 0; i < 7; ++i) {
+ m = moment.utc([2015, i, 15, 18]);
+ tester('dd');
+ tester('ddd');
+ tester('dddd');
+ }
+ });
+ }
+
+ function setupDeprecationHandler(test, moment, scope) {
+ test._expectedDeprecations = null;
+ test._observedDeprecations = null;
+ test._oldSupress = moment.suppressDeprecationWarnings;
+ moment.suppressDeprecationWarnings = true;
+ test.expectedDeprecations = function () {
+ test._expectedDeprecations = arguments;
+ test._observedDeprecations = [];
+ };
+ moment.deprecationHandler = function (name, msg) {
+ var deprecationId = matchedDeprecation(name, msg, test._expectedDeprecations);
+ if (deprecationId === -1) {
+ throw new Error('Unexpected deprecation thrown name=' +
+ name + ' msg=' + msg);
+ }
+ test._observedDeprecations[deprecationId] = 1;
+ };
+ }
+
+ function teardownDeprecationHandler(test, moment, scope) {
+ moment.suppressDeprecationWarnings = test._oldSupress;
+
+ if (test._expectedDeprecations != null) {
+ var missedDeprecations = [];
+ each(test._expectedDeprecations, function (deprecationPattern, id) {
+ if (test._observedDeprecations[id] !== 1) {
+ missedDeprecations.push(deprecationPattern);
+ }
+ });
+ if (missedDeprecations.length !== 0) {
+ throw new Error('Expected deprecation warnings did not happen: ' +
+ missedDeprecations.join(' '));
+ }
+ }
+ }
+
+ function matchedDeprecation(name, msg, deprecations) {
+ if (deprecations == null) {
+ return -1;
+ }
+ for (var i = 0; i < deprecations.length; ++i) {
+ if (name != null && name === deprecations[i]) {
+ return i;
+ }
+ if (msg != null && msg.substring(0, deprecations[i].length) === deprecations[i]) {
+ return i;
+ }
+ }
+ return -1;
+ }
/*global QUnit:false*/
@@ -34988,11 +49195,13 @@
moment.createFromInputFallback = function (config) {
throw new Error('input not handled by moment: ' + config._i);
};
+ setupDeprecationHandler(test, moment, 'core');
if (lifecycle && lifecycle.setup) {
lifecycle.setup();
}
},
teardown : function () {
+ teardownDeprecationHandler(test, moment, 'core');
if (lifecycle && lifecycle.teardown) {
lifecycle.teardown();
}
@@ -35007,17 +49216,505 @@
moment.createFromInputFallback = function (config) {
throw new Error('input not handled by moment: ' + config._i);
};
+ setupDeprecationHandler(test, moment, 'locale');
if (lifecycle && lifecycle.setup) {
lifecycle.setup();
}
},
teardown : function () {
moment.locale('en');
+ teardownDeprecationHandler(test, moment, 'locale');
if (lifecycle && lifecycle.teardown) {
lifecycle.teardown();
}
}
});
+ defineCommonLocaleTests(name, -1, -1);
+ }
+
+ localeModule('x-pseudo');
+
+ test('parse', function (assert) {
+ var tests = 'J~áñúá~rý J~áñ_F~ébrú~árý ~Féb_~Márc~h ~Már_Áp~ríl ~Ápr_~Máý ~Máý_~Júñé~ ~Júñ_Júl~ý ~Júl_Áú~gúst~ ~Áúg_Sép~témb~ér ~Sép_Ó~ctób~ér ~Óct_Ñ~óvém~bér ~Ñóv_~Décé~mbér ~Déc'.split('_'), i;
+ function equalTest(input, mmm, i) {
+ assert.equal(moment(input, mmm).month(), i, input + ' should be month ' + (i + 1));
+ }
+ for (i = 0; i < 12; i++) {
+ tests[i] = tests[i].split(' ');
+ equalTest(tests[i][0], 'MMM', i);
+ equalTest(tests[i][1], 'MMM', i);
+ equalTest(tests[i][0], 'MMMM', i);
+ equalTest(tests[i][1], 'MMMM', i);
+ equalTest(tests[i][0].toLocaleLowerCase(), 'MMMM', i);
+ equalTest(tests[i][1].toLocaleLowerCase(), 'MMMM', i);
+ equalTest(tests[i][0].toLocaleUpperCase(), 'MMMM', i);
+ equalTest(tests[i][1].toLocaleUpperCase(), 'MMMM', i);
+ }
+ });
+
+ test('format', function (assert) {
+ var a = [
+ ['dddd, MMMM Do YYYY, h:mm:ss a', 'S~úñdá~ý, F~ébrú~árý 14th 2010, 3:25:50 pm'],
+ ['ddd, hA', 'S~úñ, 3PM'],
+ ['M Mo MM MMMM MMM', '2 2nd 02 F~ébrú~árý ~Féb'],
+ ['YYYY YY', '2010 10'],
+ ['D Do DD', '14 14th 14'],
+ ['d do dddd ddd dd', '0 0th S~úñdá~ý S~úñ S~ú'],
+ ['DDD DDDo DDDD', '45 45th 045'],
+ ['w wo ww', '6 6th 06'],
+ ['h hh', '3 03'],
+ ['H HH', '15 15'],
+ ['m mm', '25 25'],
+ ['s ss', '50 50'],
+ ['a A', 'pm PM'],
+ ['[the] DDDo [day of the year]', 'the 45th day of the year'],
+ ['LT', '15:25'],
+ ['L', '14/02/2010'],
+ ['LL', '14 F~ébrú~árý 2010'],
+ ['LLL', '14 F~ébrú~árý 2010 15:25'],
+ ['LLLL', 'S~úñdá~ý, 14 F~ébrú~árý 2010 15:25'],
+ ['l', '14/2/2010'],
+ ['ll', '14 ~Féb 2010'],
+ ['lll', '14 ~Féb 2010 15:25'],
+ ['llll', 'S~úñ, 14 ~Féb 2010 15:25']
+ ],
+ b = moment(new Date(2010, 1, 14, 15, 25, 50, 125)),
+ i;
+ for (i = 0; i < a.length; i++) {
+ assert.equal(b.format(a[i][0]), a[i][1], a[i][0] + ' ---> ' + a[i][1]);
+ }
+ });
+
+ test('format ordinal', function (assert) {
+ assert.equal(moment([2011, 0, 1]).format('DDDo'), '1st', '1st');
+ assert.equal(moment([2011, 0, 2]).format('DDDo'), '2nd', '2nd');
+ assert.equal(moment([2011, 0, 3]).format('DDDo'), '3rd', '3rd');
+ assert.equal(moment([2011, 0, 4]).format('DDDo'), '4th', '4th');
+ assert.equal(moment([2011, 0, 5]).format('DDDo'), '5th', '5th');
+ assert.equal(moment([2011, 0, 6]).format('DDDo'), '6th', '6th');
+ assert.equal(moment([2011, 0, 7]).format('DDDo'), '7th', '7th');
+ assert.equal(moment([2011, 0, 8]).format('DDDo'), '8th', '8th');
+ assert.equal(moment([2011, 0, 9]).format('DDDo'), '9th', '9th');
+ assert.equal(moment([2011, 0, 10]).format('DDDo'), '10th', '10th');
+
+ assert.equal(moment([2011, 0, 11]).format('DDDo'), '11th', '11th');
+ assert.equal(moment([2011, 0, 12]).format('DDDo'), '12th', '12th');
+ assert.equal(moment([2011, 0, 13]).format('DDDo'), '13th', '13th');
+ assert.equal(moment([2011, 0, 14]).format('DDDo'), '14th', '14th');
+ assert.equal(moment([2011, 0, 15]).format('DDDo'), '15th', '15th');
+ assert.equal(moment([2011, 0, 16]).format('DDDo'), '16th', '16th');
+ assert.equal(moment([2011, 0, 17]).format('DDDo'), '17th', '17th');
+ assert.equal(moment([2011, 0, 18]).format('DDDo'), '18th', '18th');
+ assert.equal(moment([2011, 0, 19]).format('DDDo'), '19th', '19th');
+ assert.equal(moment([2011, 0, 20]).format('DDDo'), '20th', '20th');
+
+ assert.equal(moment([2011, 0, 21]).format('DDDo'), '21st', '21st');
+ assert.equal(moment([2011, 0, 22]).format('DDDo'), '22nd', '22nd');
+ assert.equal(moment([2011, 0, 23]).format('DDDo'), '23rd', '23rd');
+ assert.equal(moment([2011, 0, 24]).format('DDDo'), '24th', '24th');
+ assert.equal(moment([2011, 0, 25]).format('DDDo'), '25th', '25th');
+ assert.equal(moment([2011, 0, 26]).format('DDDo'), '26th', '26th');
+ assert.equal(moment([2011, 0, 27]).format('DDDo'), '27th', '27th');
+ assert.equal(moment([2011, 0, 28]).format('DDDo'), '28th', '28th');
+ assert.equal(moment([2011, 0, 29]).format('DDDo'), '29th', '29th');
+ assert.equal(moment([2011, 0, 30]).format('DDDo'), '30th', '30th');
+
+ assert.equal(moment([2011, 0, 31]).format('DDDo'), '31st', '31st');
+ });
+
+ test('format month', function (assert) {
+ var expected = 'J~áñúá~rý J~áñ_F~ébrú~árý ~Féb_~Márc~h ~Már_Áp~ríl ~Ápr_~Máý ~Máý_~Júñé~ ~Júñ_Júl~ý ~Júl_Áú~gúst~ ~Áúg_Sép~témb~ér ~Sép_Ó~ctób~ér ~Óct_Ñ~óvém~bér ~Ñóv_~Décé~mbér ~Déc'.split('_'), i;
+ for (i = 0; i < expected.length; i++) {
+ assert.equal(moment([2011, i, 1]).format('MMMM MMM'), expected[i], expected[i]);
+ }
+ });
+
+ test('format week', function (assert) {
+ var expected = 'S~úñdá~ý S~úñ S~ú_Mó~ñdáý~ ~Móñ Mó~_Túé~sdáý~ ~Túé Tú_Wéd~ñésd~áý ~Wéd ~Wé_T~húrs~dáý ~Thú T~h_~Fríd~áý ~Frí Fr~_S~átúr~dáý ~Sát Sá'.split('_'), i;
+ for (i = 0; i < expected.length; i++) {
+ assert.equal(moment([2011, 0, 2 + i]).format('dddd ddd dd'), expected[i], expected[i]);
+ }
+ });
+
+ test('from', function (assert) {
+ var start = moment([2007, 1, 28]);
+ assert.equal(start.from(moment([2007, 1, 28]).add({s: 44}), true), 'á ~féw ~sécó~ñds', '44 seconds = a few seconds');
+ assert.equal(start.from(moment([2007, 1, 28]).add({s: 45}), true), 'á ~míñ~úté', '45 seconds = a minute');
+ assert.equal(start.from(moment([2007, 1, 28]).add({s: 89}), true), 'á ~míñ~úté', '89 seconds = a minute');
+ assert.equal(start.from(moment([2007, 1, 28]).add({s: 90}), true), '2 m~íñú~tés', '90 seconds = 2 minutes');
+ assert.equal(start.from(moment([2007, 1, 28]).add({m: 44}), true), '44 m~íñú~tés', '44 minutes = 44 minutes');
+ assert.equal(start.from(moment([2007, 1, 28]).add({m: 45}), true), 'á~ñ hó~úr', '45 minutes = an hour');
+ assert.equal(start.from(moment([2007, 1, 28]).add({m: 89}), true), 'á~ñ hó~úr', '89 minutes = an hour');
+ assert.equal(start.from(moment([2007, 1, 28]).add({m: 90}), true), '2 h~óúrs', '90 minutes = 2 hours');
+ assert.equal(start.from(moment([2007, 1, 28]).add({h: 5}), true), '5 h~óúrs', '5 hours = 5 hours');
+ assert.equal(start.from(moment([2007, 1, 28]).add({h: 21}), true), '21 h~óúrs', '21 hours = 21 hours');
+ assert.equal(start.from(moment([2007, 1, 28]).add({h: 22}), true), 'á ~dáý', '22 hours = a day');
+ assert.equal(start.from(moment([2007, 1, 28]).add({h: 35}), true), 'á ~dáý', '35 hours = a day');
+ assert.equal(start.from(moment([2007, 1, 28]).add({h: 36}), true), '2 d~áýs', '36 hours = 2 days');
+ assert.equal(start.from(moment([2007, 1, 28]).add({d: 1}), true), 'á ~dáý', '1 day = a day');
+ assert.equal(start.from(moment([2007, 1, 28]).add({d: 5}), true), '5 d~áýs', '5 days = 5 days');
+ assert.equal(start.from(moment([2007, 1, 28]).add({d: 25}), true), '25 d~áýs', '25 days = 25 days');
+ assert.equal(start.from(moment([2007, 1, 28]).add({d: 26}), true), 'á ~móñ~th', '26 days = a month');
+ assert.equal(start.from(moment([2007, 1, 28]).add({d: 30}), true), 'á ~móñ~th', '30 days = a month');
+ assert.equal(start.from(moment([2007, 1, 28]).add({d: 43}), true), 'á ~móñ~th', '43 days = a month');
+ assert.equal(start.from(moment([2007, 1, 28]).add({d: 46}), true), '2 m~óñt~hs', '46 days = 2 months');
+ assert.equal(start.from(moment([2007, 1, 28]).add({d: 74}), true), '2 m~óñt~hs', '75 days = 2 months');
+ assert.equal(start.from(moment([2007, 1, 28]).add({d: 76}), true), '3 m~óñt~hs', '76 days = 3 months');
+ assert.equal(start.from(moment([2007, 1, 28]).add({M: 1}), true), 'á ~móñ~th', '1 month = a month');
+ assert.equal(start.from(moment([2007, 1, 28]).add({M: 5}), true), '5 m~óñt~hs', '5 months = 5 months');
+ assert.equal(start.from(moment([2007, 1, 28]).add({d: 345}), true), 'á ~ýéár', '345 days = a year');
+ assert.equal(start.from(moment([2007, 1, 28]).add({d: 548}), true), '2 ý~éárs', '548 days = 2 years');
+ assert.equal(start.from(moment([2007, 1, 28]).add({y: 1}), true), 'á ~ýéár', '1 year = a year');
+ assert.equal(start.from(moment([2007, 1, 28]).add({y: 5}), true), '5 ý~éárs', '5 years = 5 years');
+ });
+
+ test('suffix', function (assert) {
+ assert.equal(moment(30000).from(0), 'í~ñ á ~féw ~sécó~ñds', 'prefix');
+ assert.equal(moment(0).from(30000), 'á ~féw ~sécó~ñds á~gó', 'suffix');
+ });
+
+ test('now from now', function (assert) {
+ assert.equal(moment().fromNow(), 'á ~féw ~sécó~ñds á~gó', 'now from now should display as in the past');
+ });
+
+ test('fromNow', function (assert) {
+ assert.equal(moment().add({s: 30}).fromNow(), 'í~ñ á ~féw ~sécó~ñds', 'in a few seconds');
+ assert.equal(moment().add({d: 5}).fromNow(), 'í~ñ 5 d~áýs', 'in 5 days');
+ });
+
+ test('calendar day', function (assert) {
+ var a = moment().hours(2).minutes(0).seconds(0);
+
+ assert.equal(moment(a).calendar(), 'T~ódá~ý át 02:00', 'today at the same time');
+ assert.equal(moment(a).add({m: 25}).calendar(), 'T~ódá~ý át 02:25', 'Now plus 25 min');
+ assert.equal(moment(a).add({h: 1}).calendar(), 'T~ódá~ý át 03:00', 'Now plus 1 hour');
+ assert.equal(moment(a).add({d: 1}).calendar(), 'T~ómó~rró~w át 02:00', 'tomorrow at the same time');
+ assert.equal(moment(a).subtract({h: 1}).calendar(), 'T~ódá~ý át 01:00', 'Now minus 1 hour');
+ assert.equal(moment(a).subtract({d: 1}).calendar(), 'Ý~ést~érdá~ý át 02:00', 'yesterday at the same time');
+ });
+
+ test('calendar next week', function (assert) {
+ var i, m;
+ for (i = 2; i < 7; i++) {
+ m = moment().add({d: i});
+ assert.equal(m.calendar(), m.format('dddd [át] LT'), 'Today + ' + i + ' days current time');
+ m.hours(0).minutes(0).seconds(0).milliseconds(0);
+ assert.equal(m.calendar(), m.format('dddd [át] LT'), 'Today + ' + i + ' days beginning of day');
+ m.hours(23).minutes(59).seconds(59).milliseconds(999);
+ assert.equal(m.calendar(), m.format('dddd [át] LT'), 'Today + ' + i + ' days end of day');
+ }
+ });
+
+ test('calendar last week', function (assert) {
+ var i, m;
+
+ for (i = 2; i < 7; i++) {
+ m = moment().subtract({d: i});
+ assert.equal(m.calendar(), m.format('[L~ást] dddd [át] LT'), 'Today - ' + i + ' days current time');
+ m.hours(0).minutes(0).seconds(0).milliseconds(0);
+ assert.equal(m.calendar(), m.format('[L~ást] dddd [át] LT'), 'Today - ' + i + ' days beginning of day');
+ m.hours(23).minutes(59).seconds(59).milliseconds(999);
+ assert.equal(m.calendar(), m.format('[L~ást] dddd [át] LT'), 'Today - ' + i + ' days end of day');
+ }
+ });
+
+ test('calendar all else', function (assert) {
+ var weeksAgo = moment().subtract({w: 1}),
+ weeksFromNow = moment().add({w: 1});
+
+ assert.equal(weeksAgo.calendar(), weeksAgo.format('L'), '1 week ago');
+ assert.equal(weeksFromNow.calendar(), weeksFromNow.format('L'), 'in 1 week');
+
+ weeksAgo = moment().subtract({w: 2});
+ weeksFromNow = moment().add({w: 2});
+
+ assert.equal(weeksAgo.calendar(), weeksAgo.format('L'), '2 weeks ago');
+ assert.equal(weeksFromNow.calendar(), weeksFromNow.format('L'), 'in 2 weeks');
+ });
+
+ test('weeks year starting sunday formatted', function (assert) {
+ assert.equal(moment([2012, 0, 1]).format('w ww wo'), '52 52 52nd', 'Jan 1 2012 should be week 52');
+ assert.equal(moment([2012, 0, 2]).format('w ww wo'), '1 01 1st', 'Jan 2 2012 should be week 1');
+ assert.equal(moment([2012, 0, 8]).format('w ww wo'), '1 01 1st', 'Jan 8 2012 should be week 1');
+ assert.equal(moment([2012, 0, 9]).format('w ww wo'), '2 02 2nd', 'Jan 9 2012 should be week 2');
+ assert.equal(moment([2012, 0, 15]).format('w ww wo'), '2 02 2nd', 'Jan 15 2012 should be week 2');
+ });
+
+}));
+
+;(function (global, factory) {
+ typeof exports === 'object' && typeof module !== 'undefined'
+ && typeof require === 'function' ? factory(require('../../moment')) :
+ typeof define === 'function' && define.amd ? define(['../../moment'], factory) :
+ factory(global.moment)
+}(this, function (moment) { 'use strict';
+
+ function each(array, callback) {
+ var i;
+ for (i = 0; i < array.length; i++) {
+ callback(array[i], i, array);
+ }
+ }
+
+ function objectKeys(obj) {
+ if (Object.keys) {
+ return Object.keys(obj);
+ } else {
+ // IE8
+ var res = [], i;
+ for (i in obj) {
+ if (obj.hasOwnProperty(i)) {
+ res.push(i);
+ }
+ }
+ return res;
+ }
+ }
+
+ // Pick the first defined of two or three arguments.
+ function defaults(a, b, c) {
+ if (a != null) {
+ return a;
+ }
+ if (b != null) {
+ return b;
+ }
+ return c;
+ }
+
+ function defineCommonLocaleTests(locale, options) {
+ test('lenient ordinal parsing', function (assert) {
+ var i, ordinalStr, testMoment;
+ for (i = 1; i <= 31; ++i) {
+ ordinalStr = moment([2014, 0, i]).format('YYYY MM Do');
+ testMoment = moment(ordinalStr, 'YYYY MM Do');
+ assert.equal(testMoment.year(), 2014,
+ 'lenient ordinal parsing ' + i + ' year check');
+ assert.equal(testMoment.month(), 0,
+ 'lenient ordinal parsing ' + i + ' month check');
+ assert.equal(testMoment.date(), i,
+ 'lenient ordinal parsing ' + i + ' date check');
+ }
+ });
+
+ test('lenient ordinal parsing of number', function (assert) {
+ var i, testMoment;
+ for (i = 1; i <= 31; ++i) {
+ testMoment = moment('2014 01 ' + i, 'YYYY MM Do');
+ assert.equal(testMoment.year(), 2014,
+ 'lenient ordinal parsing of number ' + i + ' year check');
+ assert.equal(testMoment.month(), 0,
+ 'lenient ordinal parsing of number ' + i + ' month check');
+ assert.equal(testMoment.date(), i,
+ 'lenient ordinal parsing of number ' + i + ' date check');
+ }
+ });
+
+ test('strict ordinal parsing', function (assert) {
+ var i, ordinalStr, testMoment;
+ for (i = 1; i <= 31; ++i) {
+ ordinalStr = moment([2014, 0, i]).format('YYYY MM Do');
+ testMoment = moment(ordinalStr, 'YYYY MM Do', true);
+ assert.ok(testMoment.isValid(), 'strict ordinal parsing ' + i);
+ }
+ });
+
+ test('meridiem invariant', function (assert) {
+ var h, m, t1, t2;
+ for (h = 0; h < 24; ++h) {
+ for (m = 0; m < 60; m += 15) {
+ t1 = moment.utc([2000, 0, 1, h, m]);
+ t2 = moment.utc(t1.format('A h:mm'), 'A h:mm');
+ assert.equal(t2.format('HH:mm'), t1.format('HH:mm'),
+ 'meridiem at ' + t1.format('HH:mm'));
+ }
+ }
+ });
+
+ test('date format correctness', function (assert) {
+ var data, tokens;
+ data = moment.localeData()._longDateFormat;
+ tokens = objectKeys(data);
+ each(tokens, function (srchToken) {
+ // Check each format string to make sure it does not contain any
+ // tokens that need to be expanded.
+ each(tokens, function (baseToken) {
+ // strip escaped sequences
+ var format = data[baseToken].replace(/(\[[^\]]*\])/g, '');
+ assert.equal(false, !!~format.indexOf(srchToken),
+ 'contains ' + srchToken + ' in ' + baseToken);
+ });
+ });
+ });
+
+ test('month parsing correctness', function (assert) {
+ var i, m;
+
+ if (locale === 'tr') {
+ // I can't fix it :(
+ expect(0);
+ return;
+ }
+ function tester(format) {
+ var r;
+ r = moment(m.format(format), format);
+ assert.equal(r.month(), m.month(), 'month ' + i + ' fmt ' + format);
+ r = moment(m.format(format).toLocaleUpperCase(), format);
+ assert.equal(r.month(), m.month(), 'month ' + i + ' fmt ' + format + ' upper');
+ r = moment(m.format(format).toLocaleLowerCase(), format);
+ assert.equal(r.month(), m.month(), 'month ' + i + ' fmt ' + format + ' lower');
+
+ r = moment(m.format(format), format, true);
+ assert.equal(r.month(), m.month(), 'month ' + i + ' fmt ' + format + ' strict');
+ r = moment(m.format(format).toLocaleUpperCase(), format, true);
+ assert.equal(r.month(), m.month(), 'month ' + i + ' fmt ' + format + ' upper strict');
+ r = moment(m.format(format).toLocaleLowerCase(), format, true);
+ assert.equal(r.month(), m.month(), 'month ' + i + ' fmt ' + format + ' lower strict');
+ }
+
+ for (i = 0; i < 12; ++i) {
+ m = moment([2015, i, 15, 18]);
+ tester('MMM');
+ tester('MMM.');
+ tester('MMMM');
+ tester('MMMM.');
+ }
+ });
+
+ test('weekday parsing correctness', function (assert) {
+ var i, m;
+
+ if (locale === 'tr' || locale === 'az') {
+ // There is a lower-case letter (ı), that converted to upper then
+ // lower changes to i
+ expect(0);
+ return;
+ }
+ function tester(format) {
+ var r, baseMsg = 'weekday ' + m.weekday() + ' fmt ' + format;
+ r = moment(m.format(format), format);
+ assert.equal(r.weekday(), m.weekday(), baseMsg);
+ r = moment(m.format(format).toLocaleUpperCase(), format);
+ assert.equal(r.weekday(), m.weekday(), baseMsg + ' upper');
+ r = moment(m.format(format).toLocaleLowerCase(), format);
+ assert.equal(r.weekday(), m.weekday(), baseMsg + ' lower');
+
+ r = moment(m.format(format), format, true);
+ assert.equal(r.weekday(), m.weekday(), baseMsg + ' strict');
+ r = moment(m.format(format).toLocaleUpperCase(), format, true);
+ assert.equal(r.weekday(), m.weekday(), baseMsg + ' upper strict');
+ r = moment(m.format(format).toLocaleLowerCase(), format, true);
+ assert.equal(r.weekday(), m.weekday(), baseMsg + ' lower strict');
+ }
+
+ for (i = 0; i < 7; ++i) {
+ m = moment.utc([2015, i, 15, 18]);
+ tester('dd');
+ tester('ddd');
+ tester('dddd');
+ }
+ });
+ }
+
+ function setupDeprecationHandler(test, moment, scope) {
+ test._expectedDeprecations = null;
+ test._observedDeprecations = null;
+ test._oldSupress = moment.suppressDeprecationWarnings;
+ moment.suppressDeprecationWarnings = true;
+ test.expectedDeprecations = function () {
+ test._expectedDeprecations = arguments;
+ test._observedDeprecations = [];
+ };
+ moment.deprecationHandler = function (name, msg) {
+ var deprecationId = matchedDeprecation(name, msg, test._expectedDeprecations);
+ if (deprecationId === -1) {
+ throw new Error('Unexpected deprecation thrown name=' +
+ name + ' msg=' + msg);
+ }
+ test._observedDeprecations[deprecationId] = 1;
+ };
+ }
+
+ function teardownDeprecationHandler(test, moment, scope) {
+ moment.suppressDeprecationWarnings = test._oldSupress;
+
+ if (test._expectedDeprecations != null) {
+ var missedDeprecations = [];
+ each(test._expectedDeprecations, function (deprecationPattern, id) {
+ if (test._observedDeprecations[id] !== 1) {
+ missedDeprecations.push(deprecationPattern);
+ }
+ });
+ if (missedDeprecations.length !== 0) {
+ throw new Error('Expected deprecation warnings did not happen: ' +
+ missedDeprecations.join(' '));
+ }
+ }
+ }
+
+ function matchedDeprecation(name, msg, deprecations) {
+ if (deprecations == null) {
+ return -1;
+ }
+ for (var i = 0; i < deprecations.length; ++i) {
+ if (name != null && name === deprecations[i]) {
+ return i;
+ }
+ if (msg != null && msg.substring(0, deprecations[i].length) === deprecations[i]) {
+ return i;
+ }
+ }
+ return -1;
+ }
+
+ /*global QUnit:false*/
+
+ var test = QUnit.test;
+
+ var expect = QUnit.expect;
+
+ function module (name, lifecycle) {
+ QUnit.module(name, {
+ setup : function () {
+ moment.locale('en');
+ moment.createFromInputFallback = function (config) {
+ throw new Error('input not handled by moment: ' + config._i);
+ };
+ setupDeprecationHandler(test, moment, 'core');
+ if (lifecycle && lifecycle.setup) {
+ lifecycle.setup();
+ }
+ },
+ teardown : function () {
+ teardownDeprecationHandler(test, moment, 'core');
+ if (lifecycle && lifecycle.teardown) {
+ lifecycle.teardown();
+ }
+ }
+ });
+ }
+
+ function localeModule (name, lifecycle) {
+ QUnit.module('locale:' + name, {
+ setup : function () {
+ moment.locale(name);
+ moment.createFromInputFallback = function (config) {
+ throw new Error('input not handled by moment: ' + config._i);
+ };
+ setupDeprecationHandler(test, moment, 'locale');
+ if (lifecycle && lifecycle.setup) {
+ lifecycle.setup();
+ }
+ },
+ teardown : function () {
+ moment.locale('en');
+ teardownDeprecationHandler(test, moment, 'locale');
+ if (lifecycle && lifecycle.teardown) {
+ lifecycle.teardown();
+ }
+ }
+ });
+ defineCommonLocaleTests(name, -1, -1);
}
localeModule('zh-cn');
@@ -35139,14 +49836,14 @@
});
test('calendar day', function (assert) {
- var a = moment().hours(2).minutes(0).seconds(0);
-
- assert.equal(moment(a).calendar(), '今天凌晨2点整', 'today at the same time');
- assert.equal(moment(a).add({m: 25}).calendar(), '今天凌晨2点25分', 'Now plus 25 min');
- assert.equal(moment(a).add({h: 1}).calendar(), '今天凌晨3点整', 'Now plus 1 hour');
- assert.equal(moment(a).add({d: 1}).calendar(), '明天凌晨2点整', 'tomorrow at the same time');
- assert.equal(moment(a).subtract({h: 1}).calendar(), '今天凌晨1点整', 'Now minus 1 hour');
- assert.equal(moment(a).subtract({d: 1}).calendar(), '昨天凌晨2点整', 'yesterday at the same time');
+ var a = moment().hours(12).minutes(0).seconds(0);
+
+ assert.equal(moment(a).calendar(), '今天中午12点整', 'today at the same time');
+ assert.equal(moment(a).add({m: 25}).calendar(), '今天中午12点25分', 'Now plus 25 min');
+ assert.equal(moment(a).add({h: 1}).calendar(), '今天下午1点整', 'Now plus 1 hour');
+ assert.equal(moment(a).add({d: 1}).calendar(), '明天中午12点整', 'tomorrow at the same time');
+ assert.equal(moment(a).subtract({h: 1}).calendar(), '今天上午11点整', 'Now minus 1 hour');
+ assert.equal(moment(a).subtract({d: 1}).calendar(), '昨天中午12点整', 'yesterday at the same time');
});
test('calendar current week', function (assert) {
@@ -35216,111 +49913,10 @@
assert.equal(moment([2011, 2, 23, 18, 0]).format('A'), '晚上', 'night');
});
- test('weeks year starting sunday', function (assert) {
- assert.equal(moment([2012, 0, 1]).week(), 52, 'Jan 1 2012 should be week 52');
- assert.equal(moment([2012, 0, 2]).week(), 1, 'Jan 2 2012 should be week 52');
- assert.equal(moment([2012, 0, 7]).week(), 1, 'Jan 7 2012 should be week 1');
- assert.equal(moment([2012, 0, 14]).week(), 2, 'Jan 14 2012 should be week 2');
- });
-
- test('weeks year starting monday', function (assert) {
- assert.equal(moment([2006, 11, 31]).week(), 52, 'Dec 31 2006 should be week 52');
- assert.equal(moment([2007, 0, 1]).week(), 1, 'Jan 1 2007 should be week 1');
- assert.equal(moment([2007, 0, 6]).week(), 1, 'Jan 6 2007 should be week 1');
- assert.equal(moment([2007, 0, 7]).week(), 1, 'Jan 7 2007 should be week 1');
- assert.equal(moment([2007, 0, 13]).week(), 2, 'Jan 13 2007 should be week 2');
- assert.equal(moment([2007, 0, 14]).week(), 2, 'Jan 14 2007 should be week 2');
- });
-
- test('weeks year starting tuesday', function (assert) {
- assert.equal(moment([2007, 11, 29]).week(), 52, 'Dec 29 2007 should be week 52');
- assert.equal(moment([2008, 0, 1]).week(), 1, 'Jan 1 2008 should be week 1');
- assert.equal(moment([2008, 0, 5]).week(), 1, 'Jan 5 2008 should be week 1');
- assert.equal(moment([2008, 0, 6]).week(), 1, 'Jan 6 2008 should be week 1');
- assert.equal(moment([2008, 0, 12]).week(), 2, 'Jan 12 2008 should be week 2');
- assert.equal(moment([2008, 0, 13]).week(), 2, 'Jan 13 2008 should be week 2');
- });
-
- test('weeks year starting wednesday', function (assert) {
- assert.equal(moment([2002, 11, 29]).week(), 52, 'Dec 29 2002 should be week 52');
- assert.equal(moment([2003, 0, 1]).week(), 1, 'Jan 1 2003 should be week 1');
- assert.equal(moment([2003, 0, 4]).week(), 1, 'Jan 4 2003 should be week 1');
- assert.equal(moment([2003, 0, 5]).week(), 1, 'Jan 5 2003 should be week 1');
- assert.equal(moment([2003, 0, 11]).week(), 2, 'Jan 11 2003 should be week 2');
- assert.equal(moment([2003, 0, 12]).week(), 2, 'Jan 12 2003 should be week 2');
- });
-
- test('weeks year starting thursday', function (assert) {
- assert.equal(moment([2009, 0, 1]).week(), 1, 'Jan 1 2009 should be week 1');
- assert.equal(moment([2009, 0, 3]).week(), 1, 'Jan 3 2009 should be week 1');
- assert.equal(moment([2009, 0, 4]).week(), 1, 'Jan 4 2009 should be week 1');
- assert.equal(moment([2009, 0, 10]).week(), 2, 'Jan 10 2009 should be week 2');
- assert.equal(moment([2009, 0, 11]).week(), 2, 'Jan 11 2009 should be week 2');
- });
-
- test('weeks year starting friday', function (assert) {
- assert.equal(moment([2010, 0, 2]).week(), 53, 'Jan 2 2010 should be week 53');
- assert.equal(moment([2010, 0, 10]).week(), 1, 'Jan 10 2010 should be week 1');
- });
-
- test('weeks year starting saturday', function (assert) {
- assert.equal(moment([2011, 0, 2]).week(), 52, 'Jan 2 2011 should be week 52');
- assert.equal(moment([2011, 0, 8]).week(), 1, 'Jan 8 2011 should be week 1');
- assert.equal(moment([2011, 0, 9]).week(), 1, 'Jan 9 2011 should be week 1');
- });
-
test('weeks year starting sunday format', function (assert) {
assert.equal(moment([2012, 0, 1]).format('w ww wo'), '52 52 52周', 'Jan 1 2012 应该是第52周');
assert.equal(moment([2012, 0, 7]).format('w ww wo'), '1 01 1周', 'Jan 7 2012 应该是第 1周');
assert.equal(moment([2012, 0, 14]).format('w ww wo'), '2 02 2周', 'Jan 14 2012 应该是第 2周');
- });
-
- test('lenient ordinal parsing', function (assert) {
- var i, ordinalStr, testMoment;
- for (i = 1; i <= 31; ++i) {
- ordinalStr = moment([2014, 0, i]).format('YYYY MM Do');
- testMoment = moment(ordinalStr, 'YYYY MM Do');
- assert.equal(testMoment.year(), 2014,
- 'lenient ordinal parsing ' + i + ' year check');
- assert.equal(testMoment.month(), 0,
- 'lenient ordinal parsing ' + i + ' month check');
- assert.equal(testMoment.date(), i,
- 'lenient ordinal parsing ' + i + ' date check');
- }
- });
-
- test('lenient ordinal parsing of number', function (assert) {
- var i, testMoment;
- for (i = 1; i <= 31; ++i) {
- testMoment = moment('2014 01 ' + i, 'YYYY MM Do');
- assert.equal(testMoment.year(), 2014,
- 'lenient ordinal parsing of number ' + i + ' year check');
- assert.equal(testMoment.month(), 0,
- 'lenient ordinal parsing of number ' + i + ' month check');
- assert.equal(testMoment.date(), i,
- 'lenient ordinal parsing of number ' + i + ' date check');
- }
- });
-
- test('meridiem invariant', function (assert) {
- var h, m, t1, t2;
- for (h = 0; h < 24; ++h) {
- for (m = 0; m < 60; m += 15) {
- t1 = moment.utc([2000, 0, 1, h, m]);
- t2 = moment(t1.format('A h:mm'), 'A h:mm');
- assert.equal(t2.format('HH:mm'), t1.format('HH:mm'),
- 'meridiem at ' + t1.format('HH:mm'));
- }
- }
- });
-
- test('strict ordinal parsing', function (assert) {
- var i, ordinalStr, testMoment;
- for (i = 1; i <= 31; ++i) {
- ordinalStr = moment([2014, 0, i]).format('YYYY MM Do');
- testMoment = moment(ordinalStr, 'YYYY MM Do', true);
- assert.ok(testMoment.isValid(), 'strict ordinal parsing ' + i);
- }
});
}));
@@ -35331,6 +49927,224 @@
typeof define === 'function' && define.amd ? define(['../../moment'], factory) :
factory(global.moment)
}(this, function (moment) { 'use strict';
+
+ function each(array, callback) {
+ var i;
+ for (i = 0; i < array.length; i++) {
+ callback(array[i], i, array);
+ }
+ }
+
+ function objectKeys(obj) {
+ if (Object.keys) {
+ return Object.keys(obj);
+ } else {
+ // IE8
+ var res = [], i;
+ for (i in obj) {
+ if (obj.hasOwnProperty(i)) {
+ res.push(i);
+ }
+ }
+ return res;
+ }
+ }
+
+ // Pick the first defined of two or three arguments.
+ function defaults(a, b, c) {
+ if (a != null) {
+ return a;
+ }
+ if (b != null) {
+ return b;
+ }
+ return c;
+ }
+
+ function defineCommonLocaleTests(locale, options) {
+ test('lenient ordinal parsing', function (assert) {
+ var i, ordinalStr, testMoment;
+ for (i = 1; i <= 31; ++i) {
+ ordinalStr = moment([2014, 0, i]).format('YYYY MM Do');
+ testMoment = moment(ordinalStr, 'YYYY MM Do');
+ assert.equal(testMoment.year(), 2014,
+ 'lenient ordinal parsing ' + i + ' year check');
+ assert.equal(testMoment.month(), 0,
+ 'lenient ordinal parsing ' + i + ' month check');
+ assert.equal(testMoment.date(), i,
+ 'lenient ordinal parsing ' + i + ' date check');
+ }
+ });
+
+ test('lenient ordinal parsing of number', function (assert) {
+ var i, testMoment;
+ for (i = 1; i <= 31; ++i) {
+ testMoment = moment('2014 01 ' + i, 'YYYY MM Do');
+ assert.equal(testMoment.year(), 2014,
+ 'lenient ordinal parsing of number ' + i + ' year check');
+ assert.equal(testMoment.month(), 0,
+ 'lenient ordinal parsing of number ' + i + ' month check');
+ assert.equal(testMoment.date(), i,
+ 'lenient ordinal parsing of number ' + i + ' date check');
+ }
+ });
+
+ test('strict ordinal parsing', function (assert) {
+ var i, ordinalStr, testMoment;
+ for (i = 1; i <= 31; ++i) {
+ ordinalStr = moment([2014, 0, i]).format('YYYY MM Do');
+ testMoment = moment(ordinalStr, 'YYYY MM Do', true);
+ assert.ok(testMoment.isValid(), 'strict ordinal parsing ' + i);
+ }
+ });
+
+ test('meridiem invariant', function (assert) {
+ var h, m, t1, t2;
+ for (h = 0; h < 24; ++h) {
+ for (m = 0; m < 60; m += 15) {
+ t1 = moment.utc([2000, 0, 1, h, m]);
+ t2 = moment.utc(t1.format('A h:mm'), 'A h:mm');
+ assert.equal(t2.format('HH:mm'), t1.format('HH:mm'),
+ 'meridiem at ' + t1.format('HH:mm'));
+ }
+ }
+ });
+
+ test('date format correctness', function (assert) {
+ var data, tokens;
+ data = moment.localeData()._longDateFormat;
+ tokens = objectKeys(data);
+ each(tokens, function (srchToken) {
+ // Check each format string to make sure it does not contain any
+ // tokens that need to be expanded.
+ each(tokens, function (baseToken) {
+ // strip escaped sequences
+ var format = data[baseToken].replace(/(\[[^\]]*\])/g, '');
+ assert.equal(false, !!~format.indexOf(srchToken),
+ 'contains ' + srchToken + ' in ' + baseToken);
+ });
+ });
+ });
+
+ test('month parsing correctness', function (assert) {
+ var i, m;
+
+ if (locale === 'tr') {
+ // I can't fix it :(
+ expect(0);
+ return;
+ }
+ function tester(format) {
+ var r;
+ r = moment(m.format(format), format);
+ assert.equal(r.month(), m.month(), 'month ' + i + ' fmt ' + format);
+ r = moment(m.format(format).toLocaleUpperCase(), format);
+ assert.equal(r.month(), m.month(), 'month ' + i + ' fmt ' + format + ' upper');
+ r = moment(m.format(format).toLocaleLowerCase(), format);
+ assert.equal(r.month(), m.month(), 'month ' + i + ' fmt ' + format + ' lower');
+
+ r = moment(m.format(format), format, true);
+ assert.equal(r.month(), m.month(), 'month ' + i + ' fmt ' + format + ' strict');
+ r = moment(m.format(format).toLocaleUpperCase(), format, true);
+ assert.equal(r.month(), m.month(), 'month ' + i + ' fmt ' + format + ' upper strict');
+ r = moment(m.format(format).toLocaleLowerCase(), format, true);
+ assert.equal(r.month(), m.month(), 'month ' + i + ' fmt ' + format + ' lower strict');
+ }
+
+ for (i = 0; i < 12; ++i) {
+ m = moment([2015, i, 15, 18]);
+ tester('MMM');
+ tester('MMM.');
+ tester('MMMM');
+ tester('MMMM.');
+ }
+ });
+
+ test('weekday parsing correctness', function (assert) {
+ var i, m;
+
+ if (locale === 'tr' || locale === 'az') {
+ // There is a lower-case letter (ı), that converted to upper then
+ // lower changes to i
+ expect(0);
+ return;
+ }
+ function tester(format) {
+ var r, baseMsg = 'weekday ' + m.weekday() + ' fmt ' + format;
+ r = moment(m.format(format), format);
+ assert.equal(r.weekday(), m.weekday(), baseMsg);
+ r = moment(m.format(format).toLocaleUpperCase(), format);
+ assert.equal(r.weekday(), m.weekday(), baseMsg + ' upper');
+ r = moment(m.format(format).toLocaleLowerCase(), format);
+ assert.equal(r.weekday(), m.weekday(), baseMsg + ' lower');
+
+ r = moment(m.format(format), format, true);
+ assert.equal(r.weekday(), m.weekday(), baseMsg + ' strict');
+ r = moment(m.format(format).toLocaleUpperCase(), format, true);
+ assert.equal(r.weekday(), m.weekday(), baseMsg + ' upper strict');
+ r = moment(m.format(format).toLocaleLowerCase(), format, true);
+ assert.equal(r.weekday(), m.weekday(), baseMsg + ' lower strict');
+ }
+
+ for (i = 0; i < 7; ++i) {
+ m = moment.utc([2015, i, 15, 18]);
+ tester('dd');
+ tester('ddd');
+ tester('dddd');
+ }
+ });
+ }
+
+ function setupDeprecationHandler(test, moment, scope) {
+ test._expectedDeprecations = null;
+ test._observedDeprecations = null;
+ test._oldSupress = moment.suppressDeprecationWarnings;
+ moment.suppressDeprecationWarnings = true;
+ test.expectedDeprecations = function () {
+ test._expectedDeprecations = arguments;
+ test._observedDeprecations = [];
+ };
+ moment.deprecationHandler = function (name, msg) {
+ var deprecationId = matchedDeprecation(name, msg, test._expectedDeprecations);
+ if (deprecationId === -1) {
+ throw new Error('Unexpected deprecation thrown name=' +
+ name + ' msg=' + msg);
+ }
+ test._observedDeprecations[deprecationId] = 1;
+ };
+ }
+
+ function teardownDeprecationHandler(test, moment, scope) {
+ moment.suppressDeprecationWarnings = test._oldSupress;
+
+ if (test._expectedDeprecations != null) {
+ var missedDeprecations = [];
+ each(test._expectedDeprecations, function (deprecationPattern, id) {
+ if (test._observedDeprecations[id] !== 1) {
+ missedDeprecations.push(deprecationPattern);
+ }
+ });
+ if (missedDeprecations.length !== 0) {
+ throw new Error('Expected deprecation warnings did not happen: ' +
+ missedDeprecations.join(' '));
+ }
+ }
+ }
+
+ function matchedDeprecation(name, msg, deprecations) {
+ if (deprecations == null) {
+ return -1;
+ }
+ for (var i = 0; i < deprecations.length; ++i) {
+ if (name != null && name === deprecations[i]) {
+ return i;
+ }
+ if (msg != null && msg.substring(0, deprecations[i].length) === deprecations[i]) {
+ return i;
+ }
+ }
+ return -1;
+ }
/*global QUnit:false*/
@@ -35345,11 +50159,13 @@
moment.createFromInputFallback = function (config) {
throw new Error('input not handled by moment: ' + config._i);
};
+ setupDeprecationHandler(test, moment, 'core');
if (lifecycle && lifecycle.setup) {
lifecycle.setup();
}
},
teardown : function () {
+ teardownDeprecationHandler(test, moment, 'core');
if (lifecycle && lifecycle.teardown) {
lifecycle.teardown();
}
@@ -35364,17 +50180,20 @@
moment.createFromInputFallback = function (config) {
throw new Error('input not handled by moment: ' + config._i);
};
+ setupDeprecationHandler(test, moment, 'locale');
if (lifecycle && lifecycle.setup) {
lifecycle.setup();
}
},
teardown : function () {
moment.locale('en');
+ teardownDeprecationHandler(test, moment, 'locale');
if (lifecycle && lifecycle.teardown) {
lifecycle.teardown();
}
}
});
+ defineCommonLocaleTests(name, -1, -1);
}
localeModule('zh-tw');
@@ -35450,32 +50269,32 @@
test('from', function (assert) {
var start = moment([2007, 1, 28]);
assert.equal(start.from(moment([2007, 1, 28]).add({s: 44}), true), '幾秒', '44 seconds = a few seconds');
- assert.equal(start.from(moment([2007, 1, 28]).add({s: 45}), true), '一分鐘', '45 seconds = a minute');
- assert.equal(start.from(moment([2007, 1, 28]).add({s: 89}), true), '一分鐘', '89 seconds = a minute');
+ assert.equal(start.from(moment([2007, 1, 28]).add({s: 45}), true), '1分鐘', '45 seconds = a minute');
+ assert.equal(start.from(moment([2007, 1, 28]).add({s: 89}), true), '1分鐘', '89 seconds = a minute');
assert.equal(start.from(moment([2007, 1, 28]).add({s: 90}), true), '2分鐘', '90 seconds = 2 minutes');
assert.equal(start.from(moment([2007, 1, 28]).add({m: 44}), true), '44分鐘', '44 minutes = 44 minutes');
- assert.equal(start.from(moment([2007, 1, 28]).add({m: 45}), true), '一小時', '45 minutes = an hour');
- assert.equal(start.from(moment([2007, 1, 28]).add({m: 89}), true), '一小時', '89 minutes = an hour');
+ assert.equal(start.from(moment([2007, 1, 28]).add({m: 45}), true), '1小時', '45 minutes = an hour');
+ assert.equal(start.from(moment([2007, 1, 28]).add({m: 89}), true), '1小時', '89 minutes = an hour');
assert.equal(start.from(moment([2007, 1, 28]).add({m: 90}), true), '2小時', '90 minutes = 2 hours');
assert.equal(start.from(moment([2007, 1, 28]).add({h: 5}), true), '5小時', '5 hours = 5 hours');
assert.equal(start.from(moment([2007, 1, 28]).add({h: 21}), true), '21小時', '21 hours = 21 hours');
- assert.equal(start.from(moment([2007, 1, 28]).add({h: 22}), true), '一天', '22 hours = a day');
- assert.equal(start.from(moment([2007, 1, 28]).add({h: 35}), true), '一天', '35 hours = a day');
+ assert.equal(start.from(moment([2007, 1, 28]).add({h: 22}), true), '1天', '22 hours = a day');
+ assert.equal(start.from(moment([2007, 1, 28]).add({h: 35}), true), '1天', '35 hours = a day');
assert.equal(start.from(moment([2007, 1, 28]).add({h: 36}), true), '2天', '36 hours = 2 days');
- assert.equal(start.from(moment([2007, 1, 28]).add({d: 1}), true), '一天', '1 day = a day');
+ assert.equal(start.from(moment([2007, 1, 28]).add({d: 1}), true), '1天', '1 day = a day');
assert.equal(start.from(moment([2007, 1, 28]).add({d: 5}), true), '5天', '5 days = 5 days');
assert.equal(start.from(moment([2007, 1, 28]).add({d: 25}), true), '25天', '25 days = 25 days');
- assert.equal(start.from(moment([2007, 1, 28]).add({d: 26}), true), '一個月', '26 days = a month');
- assert.equal(start.from(moment([2007, 1, 28]).add({d: 30}), true), '一個月', '30 days = a month');
- assert.equal(start.from(moment([2007, 1, 28]).add({d: 43}), true), '一個月', '43 days = a month');
+ assert.equal(start.from(moment([2007, 1, 28]).add({d: 26}), true), '1個月', '26 days = a month');
+ assert.equal(start.from(moment([2007, 1, 28]).add({d: 30}), true), '1個月', '30 days = a month');
+ assert.equal(start.from(moment([2007, 1, 28]).add({d: 43}), true), '1個月', '43 days = a month');
assert.equal(start.from(moment([2007, 1, 28]).add({d: 46}), true), '2個月', '46 days = 2 months');
assert.equal(start.from(moment([2007, 1, 28]).add({d: 74}), true), '2個月', '75 days = 2 months');
assert.equal(start.from(moment([2007, 1, 28]).add({d: 76}), true), '3個月', '76 days = 3 months');
- assert.equal(start.from(moment([2007, 1, 28]).add({M: 1}), true), '一個月', '1 month = a month');
+ assert.equal(start.from(moment([2007, 1, 28]).add({M: 1}), true), '1個月', '1 month = a month');
assert.equal(start.from(moment([2007, 1, 28]).add({M: 5}), true), '5個月', '5 months = 5 months');
- assert.equal(start.from(moment([2007, 1, 28]).add({d: 345}), true), '一年', '345 days = a year');
+ assert.equal(start.from(moment([2007, 1, 28]).add({d: 345}), true), '1年', '345 days = a year');
assert.equal(start.from(moment([2007, 1, 28]).add({d: 548}), true), '2年', '548 days = 2 years');
- assert.equal(start.from(moment([2007, 1, 28]).add({y: 1}), true), '一年', '1 year = a year');
+ assert.equal(start.from(moment([2007, 1, 28]).add({y: 1}), true), '1年', '1 year = a year');
assert.equal(start.from(moment([2007, 1, 28]).add({y: 5}), true), '5年', '5 years = 5 years');
});
@@ -35494,14 +50313,14 @@
});
test('calendar day', function (assert) {
- var a = moment().hours(2).minutes(0).seconds(0);
-
- assert.equal(moment(a).calendar(), '今天早上2點00分', 'today at the same time');
- assert.equal(moment(a).add({m: 25}).calendar(), '今天早上2點25分', 'Now plus 25 min');
- assert.equal(moment(a).add({h: 1}).calendar(), '今天早上3點00分', 'Now plus 1 hour');
- assert.equal(moment(a).add({d: 1}).calendar(), '明天早上2點00分', 'tomorrow at the same time');
- assert.equal(moment(a).subtract({h: 1}).calendar(), '今天早上1點00分', 'Now minus 1 hour');
- assert.equal(moment(a).subtract({d: 1}).calendar(), '昨天早上2點00分', 'yesterday at the same time');
+ var a = moment().hours(12).minutes(0).seconds(0);
+
+ assert.equal(moment(a).calendar(), '今天中午12點00分', 'today at the same time');
+ assert.equal(moment(a).add({m: 25}).calendar(), '今天中午12點25分', 'Now plus 25 min');
+ assert.equal(moment(a).add({h: 1}).calendar(), '今天下午1點00分', 'Now plus 1 hour');
+ assert.equal(moment(a).add({d: 1}).calendar(), '明天中午12點00分', 'tomorrow at the same time');
+ assert.equal(moment(a).subtract({h: 1}).calendar(), '今天上午11點00分', 'Now minus 1 hour');
+ assert.equal(moment(a).subtract({d: 1}).calendar(), '昨天中午12點00分', 'yesterday at the same time');
});
test('calendar next week', function (assert) {
@@ -35556,67 +50375,6 @@
assert.equal(moment([2011, 2, 23, 18, 0]).format('A'), '晚上', 'night');
});
- test('weeks year starting sunday', function (assert) {
- assert.equal(moment([2012, 0, 1]).week(), 1, 'Jan 1 2012 should be week 1');
- assert.equal(moment([2012, 0, 7]).week(), 1, 'Jan 7 2012 should be week 1');
- assert.equal(moment([2012, 0, 8]).week(), 2, 'Jan 8 2012 should be week 2');
- assert.equal(moment([2012, 0, 14]).week(), 2, 'Jan 14 2012 should be week 2');
- assert.equal(moment([2012, 0, 15]).week(), 3, 'Jan 15 2012 should be week 3');
- });
-
- test('weeks year starting monday', function (assert) {
- assert.equal(moment([2006, 11, 31]).week(), 1, 'Dec 31 2006 should be week 1');
- assert.equal(moment([2007, 0, 1]).week(), 1, 'Jan 1 2007 should be week 1');
- assert.equal(moment([2007, 0, 6]).week(), 1, 'Jan 6 2007 should be week 1');
- assert.equal(moment([2007, 0, 7]).week(), 2, 'Jan 7 2007 should be week 2');
- assert.equal(moment([2007, 0, 13]).week(), 2, 'Jan 13 2007 should be week 2');
- assert.equal(moment([2007, 0, 14]).week(), 3, 'Jan 14 2007 should be week 3');
- });
-
- test('weeks year starting tuesday', function (assert) {
- assert.equal(moment([2007, 11, 29]).week(), 52, 'Dec 29 2007 should be week 52');
- assert.equal(moment([2008, 0, 1]).week(), 1, 'Jan 1 2008 should be week 1');
- assert.equal(moment([2008, 0, 5]).week(), 1, 'Jan 5 2008 should be week 1');
- assert.equal(moment([2008, 0, 6]).week(), 2, 'Jan 6 2008 should be week 2');
- assert.equal(moment([2008, 0, 12]).week(), 2, 'Jan 12 2008 should be week 2');
- assert.equal(moment([2008, 0, 13]).week(), 3, 'Jan 13 2008 should be week 3');
- });
-
- test('weeks year starting wednesday', function (assert) {
- assert.equal(moment([2002, 11, 29]).week(), 1, 'Dec 29 2002 should be week 1');
- assert.equal(moment([2003, 0, 1]).week(), 1, 'Jan 1 2003 should be week 1');
- assert.equal(moment([2003, 0, 4]).week(), 1, 'Jan 4 2003 should be week 1');
- assert.equal(moment([2003, 0, 5]).week(), 2, 'Jan 5 2003 should be week 2');
- assert.equal(moment([2003, 0, 11]).week(), 2, 'Jan 11 2003 should be week 2');
- assert.equal(moment([2003, 0, 12]).week(), 3, 'Jan 12 2003 should be week 3');
- });
-
- test('weeks year starting thursday', function (assert) {
- assert.equal(moment([2008, 11, 28]).week(), 1, 'Dec 28 2008 should be week 1');
- assert.equal(moment([2009, 0, 1]).week(), 1, 'Jan 1 2009 should be week 1');
- assert.equal(moment([2009, 0, 3]).week(), 1, 'Jan 3 2009 should be week 1');
- assert.equal(moment([2009, 0, 4]).week(), 2, 'Jan 4 2009 should be week 2');
- assert.equal(moment([2009, 0, 10]).week(), 2, 'Jan 10 2009 should be week 2');
- assert.equal(moment([2009, 0, 11]).week(), 3, 'Jan 11 2009 should be week 3');
- });
-
- test('weeks year starting friday', function (assert) {
- assert.equal(moment([2009, 11, 27]).week(), 1, 'Dec 27 2009 should be week 1');
- assert.equal(moment([2010, 0, 1]).week(), 1, 'Jan 1 2010 should be week 1');
- assert.equal(moment([2010, 0, 2]).week(), 1, 'Jan 2 2010 should be week 1');
- assert.equal(moment([2010, 0, 3]).week(), 2, 'Jan 3 2010 should be week 2');
- assert.equal(moment([2010, 0, 9]).week(), 2, 'Jan 9 2010 should be week 2');
- assert.equal(moment([2010, 0, 10]).week(), 3, 'Jan 10 2010 should be week 3');
- });
-
- test('weeks year starting saturday', function (assert) {
- assert.equal(moment([2010, 11, 26]).week(), 1, 'Dec 26 2010 should be week 1');
- assert.equal(moment([2011, 0, 1]).week(), 1, 'Jan 1 2011 should be week 1');
- assert.equal(moment([2011, 0, 2]).week(), 2, 'Jan 2 2011 should be week 2');
- assert.equal(moment([2011, 0, 8]).week(), 2, 'Jan 8 2011 should be week 2');
- assert.equal(moment([2011, 0, 9]).week(), 3, 'Jan 9 2011 should be week 3');
- });
-
test('weeks year starting sunday format', function (assert) {
assert.equal(moment([2012, 0, 1]).format('w ww wo'), '1 01 1週', 'Jan 1 2012 應該是第 1週');
assert.equal(moment([2012, 0, 7]).format('w ww wo'), '1 01 1週', 'Jan 7 2012 應該是第 1週');
@@ -35625,54 +50383,6 @@
assert.equal(moment([2012, 0, 15]).format('w ww wo'), '3 03 3週', 'Jan 15 2012 應該是第 3週');
});
- test('lenient ordinal parsing', function (assert) {
- var i, ordinalStr, testMoment;
- for (i = 1; i <= 31; ++i) {
- ordinalStr = moment([2014, 0, i]).format('YYYY MM Do');
- testMoment = moment(ordinalStr, 'YYYY MM Do');
- assert.equal(testMoment.year(), 2014,
- 'lenient ordinal parsing ' + i + ' year check');
- assert.equal(testMoment.month(), 0,
- 'lenient ordinal parsing ' + i + ' month check');
- assert.equal(testMoment.date(), i,
- 'lenient ordinal parsing ' + i + ' date check');
- }
- });
-
- test('lenient ordinal parsing of number', function (assert) {
- var i, testMoment;
- for (i = 1; i <= 31; ++i) {
- testMoment = moment('2014 01 ' + i, 'YYYY MM Do');
- assert.equal(testMoment.year(), 2014,
- 'lenient ordinal parsing of number ' + i + ' year check');
- assert.equal(testMoment.month(), 0,
- 'lenient ordinal parsing of number ' + i + ' month check');
- assert.equal(testMoment.date(), i,
- 'lenient ordinal parsing of number ' + i + ' date check');
- }
- });
-
- test('meridiem invariant', function (assert) {
- var h, m, t1, t2;
- for (h = 0; h < 24; ++h) {
- for (m = 0; m < 60; m += 15) {
- t1 = moment.utc([2000, 0, 1, h, m]);
- t2 = moment(t1.format('A h:mm'), 'A h:mm');
- assert.equal(t2.format('HH:mm'), t1.format('HH:mm'),
- 'meridiem at ' + t1.format('HH:mm'));
- }
- }
- });
-
- test('strict ordinal parsing', function (assert) {
- var i, ordinalStr, testMoment;
- for (i = 1; i <= 31; ++i) {
- ordinalStr = moment([2014, 0, i]).format('YYYY MM Do');
- testMoment = moment(ordinalStr, 'YYYY MM Do', true);
- assert.ok(testMoment.isValid(), 'strict ordinal parsing ' + i);
- }
- });
-
}));
;(function (global, factory) {
@@ -35681,6 +50391,224 @@
typeof define === 'function' && define.amd ? define(['../../moment'], factory) :
factory(global.moment)
}(this, function (moment) { 'use strict';
+
+ function each(array, callback) {
+ var i;
+ for (i = 0; i < array.length; i++) {
+ callback(array[i], i, array);
+ }
+ }
+
+ function objectKeys(obj) {
+ if (Object.keys) {
+ return Object.keys(obj);
+ } else {
+ // IE8
+ var res = [], i;
+ for (i in obj) {
+ if (obj.hasOwnProperty(i)) {
+ res.push(i);
+ }
+ }
+ return res;
+ }
+ }
+
+ // Pick the first defined of two or three arguments.
+ function defaults(a, b, c) {
+ if (a != null) {
+ return a;
+ }
+ if (b != null) {
+ return b;
+ }
+ return c;
+ }
+
+ function defineCommonLocaleTests(locale, options) {
+ test('lenient ordinal parsing', function (assert) {
+ var i, ordinalStr, testMoment;
+ for (i = 1; i <= 31; ++i) {
+ ordinalStr = moment([2014, 0, i]).format('YYYY MM Do');
+ testMoment = moment(ordinalStr, 'YYYY MM Do');
+ assert.equal(testMoment.year(), 2014,
+ 'lenient ordinal parsing ' + i + ' year check');
+ assert.equal(testMoment.month(), 0,
+ 'lenient ordinal parsing ' + i + ' month check');
+ assert.equal(testMoment.date(), i,
+ 'lenient ordinal parsing ' + i + ' date check');
+ }
+ });
+
+ test('lenient ordinal parsing of number', function (assert) {
+ var i, testMoment;
+ for (i = 1; i <= 31; ++i) {
+ testMoment = moment('2014 01 ' + i, 'YYYY MM Do');
+ assert.equal(testMoment.year(), 2014,
+ 'lenient ordinal parsing of number ' + i + ' year check');
+ assert.equal(testMoment.month(), 0,
+ 'lenient ordinal parsing of number ' + i + ' month check');
+ assert.equal(testMoment.date(), i,
+ 'lenient ordinal parsing of number ' + i + ' date check');
+ }
+ });
+
+ test('strict ordinal parsing', function (assert) {
+ var i, ordinalStr, testMoment;
+ for (i = 1; i <= 31; ++i) {
+ ordinalStr = moment([2014, 0, i]).format('YYYY MM Do');
+ testMoment = moment(ordinalStr, 'YYYY MM Do', true);
+ assert.ok(testMoment.isValid(), 'strict ordinal parsing ' + i);
+ }
+ });
+
+ test('meridiem invariant', function (assert) {
+ var h, m, t1, t2;
+ for (h = 0; h < 24; ++h) {
+ for (m = 0; m < 60; m += 15) {
+ t1 = moment.utc([2000, 0, 1, h, m]);
+ t2 = moment.utc(t1.format('A h:mm'), 'A h:mm');
+ assert.equal(t2.format('HH:mm'), t1.format('HH:mm'),
+ 'meridiem at ' + t1.format('HH:mm'));
+ }
+ }
+ });
+
+ test('date format correctness', function (assert) {
+ var data, tokens;
+ data = moment.localeData()._longDateFormat;
+ tokens = objectKeys(data);
+ each(tokens, function (srchToken) {
+ // Check each format string to make sure it does not contain any
+ // tokens that need to be expanded.
+ each(tokens, function (baseToken) {
+ // strip escaped sequences
+ var format = data[baseToken].replace(/(\[[^\]]*\])/g, '');
+ assert.equal(false, !!~format.indexOf(srchToken),
+ 'contains ' + srchToken + ' in ' + baseToken);
+ });
+ });
+ });
+
+ test('month parsing correctness', function (assert) {
+ var i, m;
+
+ if (locale === 'tr') {
+ // I can't fix it :(
+ expect(0);
+ return;
+ }
+ function tester(format) {
+ var r;
+ r = moment(m.format(format), format);
+ assert.equal(r.month(), m.month(), 'month ' + i + ' fmt ' + format);
+ r = moment(m.format(format).toLocaleUpperCase(), format);
+ assert.equal(r.month(), m.month(), 'month ' + i + ' fmt ' + format + ' upper');
+ r = moment(m.format(format).toLocaleLowerCase(), format);
+ assert.equal(r.month(), m.month(), 'month ' + i + ' fmt ' + format + ' lower');
+
+ r = moment(m.format(format), format, true);
+ assert.equal(r.month(), m.month(), 'month ' + i + ' fmt ' + format + ' strict');
+ r = moment(m.format(format).toLocaleUpperCase(), format, true);
+ assert.equal(r.month(), m.month(), 'month ' + i + ' fmt ' + format + ' upper strict');
+ r = moment(m.format(format).toLocaleLowerCase(), format, true);
+ assert.equal(r.month(), m.month(), 'month ' + i + ' fmt ' + format + ' lower strict');
+ }
+
+ for (i = 0; i < 12; ++i) {
+ m = moment([2015, i, 15, 18]);
+ tester('MMM');
+ tester('MMM.');
+ tester('MMMM');
+ tester('MMMM.');
+ }
+ });
+
+ test('weekday parsing correctness', function (assert) {
+ var i, m;
+
+ if (locale === 'tr' || locale === 'az') {
+ // There is a lower-case letter (ı), that converted to upper then
+ // lower changes to i
+ expect(0);
+ return;
+ }
+ function tester(format) {
+ var r, baseMsg = 'weekday ' + m.weekday() + ' fmt ' + format;
+ r = moment(m.format(format), format);
+ assert.equal(r.weekday(), m.weekday(), baseMsg);
+ r = moment(m.format(format).toLocaleUpperCase(), format);
+ assert.equal(r.weekday(), m.weekday(), baseMsg + ' upper');
+ r = moment(m.format(format).toLocaleLowerCase(), format);
+ assert.equal(r.weekday(), m.weekday(), baseMsg + ' lower');
+
+ r = moment(m.format(format), format, true);
+ assert.equal(r.weekday(), m.weekday(), baseMsg + ' strict');
+ r = moment(m.format(format).toLocaleUpperCase(), format, true);
+ assert.equal(r.weekday(), m.weekday(), baseMsg + ' upper strict');
+ r = moment(m.format(format).toLocaleLowerCase(), format, true);
+ assert.equal(r.weekday(), m.weekday(), baseMsg + ' lower strict');
+ }
+
+ for (i = 0; i < 7; ++i) {
+ m = moment.utc([2015, i, 15, 18]);
+ tester('dd');
+ tester('ddd');
+ tester('dddd');
+ }
+ });
+ }
+
+ function setupDeprecationHandler(test, moment, scope) {
+ test._expectedDeprecations = null;
+ test._observedDeprecations = null;
+ test._oldSupress = moment.suppressDeprecationWarnings;
+ moment.suppressDeprecationWarnings = true;
+ test.expectedDeprecations = function () {
+ test._expectedDeprecations = arguments;
+ test._observedDeprecations = [];
+ };
+ moment.deprecationHandler = function (name, msg) {
+ var deprecationId = matchedDeprecation(name, msg, test._expectedDeprecations);
+ if (deprecationId === -1) {
+ throw new Error('Unexpected deprecation thrown name=' +
+ name + ' msg=' + msg);
+ }
+ test._observedDeprecations[deprecationId] = 1;
+ };
+ }
+
+ function teardownDeprecationHandler(test, moment, scope) {
+ moment.suppressDeprecationWarnings = test._oldSupress;
+
+ if (test._expectedDeprecations != null) {
+ var missedDeprecations = [];
+ each(test._expectedDeprecations, function (deprecationPattern, id) {
+ if (test._observedDeprecations[id] !== 1) {
+ missedDeprecations.push(deprecationPattern);
+ }
+ });
+ if (missedDeprecations.length !== 0) {
+ throw new Error('Expected deprecation warnings did not happen: ' +
+ missedDeprecations.join(' '));
+ }
+ }
+ }
+
+ function matchedDeprecation(name, msg, deprecations) {
+ if (deprecations == null) {
+ return -1;
+ }
+ for (var i = 0; i < deprecations.length; ++i) {
+ if (name != null && name === deprecations[i]) {
+ return i;
+ }
+ if (msg != null && msg.substring(0, deprecations[i].length) === deprecations[i]) {
+ return i;
+ }
+ }
+ return -1;
+ }
/*global QUnit:false*/
@@ -35695,11 +50623,13 @@
moment.createFromInputFallback = function (config) {
throw new Error('input not handled by moment: ' + config._i);
};
+ setupDeprecationHandler(test, moment, 'core');
if (lifecycle && lifecycle.setup) {
lifecycle.setup();
}
},
teardown : function () {
+ teardownDeprecationHandler(test, moment, 'core');
if (lifecycle && lifecycle.teardown) {
lifecycle.teardown();
}
@@ -35714,17 +50644,20 @@
moment.createFromInputFallback = function (config) {
throw new Error('input not handled by moment: ' + config._i);
};
+ setupDeprecationHandler(test, moment, 'locale');
if (lifecycle && lifecycle.setup) {
lifecycle.setup();
}
},
teardown : function () {
moment.locale('en');
+ teardownDeprecationHandler(test, moment, 'locale');
if (lifecycle && lifecycle.teardown) {
lifecycle.teardown();
}
}
});
+ defineCommonLocaleTests(name, -1, -1);
}
module('add and subtract');
@@ -35806,6 +50739,9 @@
test('add string long reverse args', function (assert) {
var a = moment(), b;
+
+ test.expectedDeprecations('moment().add(period, number)');
+
a.year(2011);
a.month(9);
a.date(12);
@@ -35830,6 +50766,9 @@
test('add string long singular reverse args', function (assert) {
var a = moment(), b;
+
+ test.expectedDeprecations('moment().add(period, number)');
+
a.year(2011);
a.month(9);
a.date(12);
@@ -35854,6 +50793,8 @@
test('add string short reverse args', function (assert) {
var a = moment();
+ test.expectedDeprecations('moment().add(period, number)');
+
a.year(2011);
a.month(9);
a.date(12);
@@ -35936,8 +50877,10 @@
assert.equal(a.add(1, 'Q').month(), 1, 'Add quarter');
});
- test('add strings string short args', function (assert) {
+ test('add strings string short reversed', function (assert) {
var a = moment();
+ test.expectedDeprecations('moment().add(period, number)');
+
a.year(2011);
a.month(9);
a.date(12);
@@ -35957,8 +50900,10 @@
assert.equal(a.add('Q', '1').month(), 1, 'Add quarter');
});
- test('subtract strings string short args', function (assert) {
+ test('subtract strings string short reversed', function (assert) {
var a = moment();
+ test.expectedDeprecations('moment().subtract(period, number)');
+
a.year(2011);
a.month(9);
a.date(12);
@@ -36050,6 +50995,26 @@
assert.equal(e.hours(), 5, 'adding quarters over DST difference should result in the same hour');
});
+ test('add decimal values of days and months', function (assert) {
+ assert.equal(moment([2016,3,3]).add(1.5, 'days').date(), 5, 'adding 1.5 days is rounded to adding 2 day');
+ assert.equal(moment([2016,3,3]).add(-1.5, 'days').date(), 1, 'adding -1.5 days is rounded to adding -2 day');
+ assert.equal(moment([2016,3,1]).add(-1.5, 'days').date(), 30, 'adding -1.5 days on first of month wraps around');
+ assert.equal(moment([2016,3,3]).add(1.5, 'months').month(), 5, 'adding 1.5 months adds 2 months');
+ assert.equal(moment([2016,3,3]).add(-1.5, 'months').month(), 1, 'adding -1.5 months adds -2 months');
+ assert.equal(moment([2016,0,3]).add(-1.5, 'months').month(), 10, 'adding -1.5 months at start of year wraps back');
+ assert.equal(moment([2016,3,3]).subtract(1.5, 'days').date(),1, 'subtract 1.5 days is rounded to subtract 2 day');
+ assert.equal(moment([2016,3,2]).subtract(1.5, 'days').date(), 31, 'subtract 1.5 days subtracts 2 days');
+ assert.equal(moment([2016,1,1]).subtract(1.1, 'days').date(), 31, 'subtract 1.1 days wraps to previous month');
+ assert.equal(moment([2016,3,3]).subtract(-1.5, 'days').date(), 5, 'subtract -1.5 days is rounded to subtract -2 day');
+ assert.equal(moment([2016,3,30]).subtract(-1.5, 'days').date(), 2, 'subtract -1.5 days on last of month wraps around');
+ assert.equal(moment([2016,3,3]).subtract(1.5, 'months').month(), 1, 'subtract 1.5 months subtract 2 months');
+ assert.equal(moment([2016,3,3]).subtract(-1.5, 'months').month(), 5, 'subtract -1.5 months subtract -2 month');
+ assert.equal(moment([2016,11,31]).subtract(-1.5, 'months').month(),1, 'subtract -1.5 months at end of year wraps back');
+ assert.equal(moment([2016, 0,1]).add(1.5, 'years').format('YYYY-MM-DD'), '2017-07-01', 'add 1.5 years adds 1 year six months');
+ assert.equal(moment([2016, 0,1]).add(1.6, 'years').format('YYYY-MM-DD'), '2017-08-01', 'add 1.6 years becomes 1.6*12 = 19.2, round, 19 months');
+ assert.equal(moment([2016,0,1]).add(1.1, 'quarters').format('YYYY-MM-DD'), '2016-04-01', 'add 1.1 quarters 1.1*3=3.3, round, 3 months');
+ });
+
}));
;(function (global, factory) {
@@ -36058,6 +51023,224 @@
typeof define === 'function' && define.amd ? define(['../../moment'], factory) :
factory(global.moment)
}(this, function (moment) { 'use strict';
+
+ function each(array, callback) {
+ var i;
+ for (i = 0; i < array.length; i++) {
+ callback(array[i], i, array);
+ }
+ }
+
+ function objectKeys(obj) {
+ if (Object.keys) {
+ return Object.keys(obj);
+ } else {
+ // IE8
+ var res = [], i;
+ for (i in obj) {
+ if (obj.hasOwnProperty(i)) {
+ res.push(i);
+ }
+ }
+ return res;
+ }
+ }
+
+ // Pick the first defined of two or three arguments.
+ function defaults(a, b, c) {
+ if (a != null) {
+ return a;
+ }
+ if (b != null) {
+ return b;
+ }
+ return c;
+ }
+
+ function defineCommonLocaleTests(locale, options) {
+ test('lenient ordinal parsing', function (assert) {
+ var i, ordinalStr, testMoment;
+ for (i = 1; i <= 31; ++i) {
+ ordinalStr = moment([2014, 0, i]).format('YYYY MM Do');
+ testMoment = moment(ordinalStr, 'YYYY MM Do');
+ assert.equal(testMoment.year(), 2014,
+ 'lenient ordinal parsing ' + i + ' year check');
+ assert.equal(testMoment.month(), 0,
+ 'lenient ordinal parsing ' + i + ' month check');
+ assert.equal(testMoment.date(), i,
+ 'lenient ordinal parsing ' + i + ' date check');
+ }
+ });
+
+ test('lenient ordinal parsing of number', function (assert) {
+ var i, testMoment;
+ for (i = 1; i <= 31; ++i) {
+ testMoment = moment('2014 01 ' + i, 'YYYY MM Do');
+ assert.equal(testMoment.year(), 2014,
+ 'lenient ordinal parsing of number ' + i + ' year check');
+ assert.equal(testMoment.month(), 0,
+ 'lenient ordinal parsing of number ' + i + ' month check');
+ assert.equal(testMoment.date(), i,
+ 'lenient ordinal parsing of number ' + i + ' date check');
+ }
+ });
+
+ test('strict ordinal parsing', function (assert) {
+ var i, ordinalStr, testMoment;
+ for (i = 1; i <= 31; ++i) {
+ ordinalStr = moment([2014, 0, i]).format('YYYY MM Do');
+ testMoment = moment(ordinalStr, 'YYYY MM Do', true);
+ assert.ok(testMoment.isValid(), 'strict ordinal parsing ' + i);
+ }
+ });
+
+ test('meridiem invariant', function (assert) {
+ var h, m, t1, t2;
+ for (h = 0; h < 24; ++h) {
+ for (m = 0; m < 60; m += 15) {
+ t1 = moment.utc([2000, 0, 1, h, m]);
+ t2 = moment.utc(t1.format('A h:mm'), 'A h:mm');
+ assert.equal(t2.format('HH:mm'), t1.format('HH:mm'),
+ 'meridiem at ' + t1.format('HH:mm'));
+ }
+ }
+ });
+
+ test('date format correctness', function (assert) {
+ var data, tokens;
+ data = moment.localeData()._longDateFormat;
+ tokens = objectKeys(data);
+ each(tokens, function (srchToken) {
+ // Check each format string to make sure it does not contain any
+ // tokens that need to be expanded.
+ each(tokens, function (baseToken) {
+ // strip escaped sequences
+ var format = data[baseToken].replace(/(\[[^\]]*\])/g, '');
+ assert.equal(false, !!~format.indexOf(srchToken),
+ 'contains ' + srchToken + ' in ' + baseToken);
+ });
+ });
+ });
+
+ test('month parsing correctness', function (assert) {
+ var i, m;
+
+ if (locale === 'tr') {
+ // I can't fix it :(
+ expect(0);
+ return;
+ }
+ function tester(format) {
+ var r;
+ r = moment(m.format(format), format);
+ assert.equal(r.month(), m.month(), 'month ' + i + ' fmt ' + format);
+ r = moment(m.format(format).toLocaleUpperCase(), format);
+ assert.equal(r.month(), m.month(), 'month ' + i + ' fmt ' + format + ' upper');
+ r = moment(m.format(format).toLocaleLowerCase(), format);
+ assert.equal(r.month(), m.month(), 'month ' + i + ' fmt ' + format + ' lower');
+
+ r = moment(m.format(format), format, true);
+ assert.equal(r.month(), m.month(), 'month ' + i + ' fmt ' + format + ' strict');
+ r = moment(m.format(format).toLocaleUpperCase(), format, true);
+ assert.equal(r.month(), m.month(), 'month ' + i + ' fmt ' + format + ' upper strict');
+ r = moment(m.format(format).toLocaleLowerCase(), format, true);
+ assert.equal(r.month(), m.month(), 'month ' + i + ' fmt ' + format + ' lower strict');
+ }
+
+ for (i = 0; i < 12; ++i) {
+ m = moment([2015, i, 15, 18]);
+ tester('MMM');
+ tester('MMM.');
+ tester('MMMM');
+ tester('MMMM.');
+ }
+ });
+
+ test('weekday parsing correctness', function (assert) {
+ var i, m;
+
+ if (locale === 'tr' || locale === 'az') {
+ // There is a lower-case letter (ı), that converted to upper then
+ // lower changes to i
+ expect(0);
+ return;
+ }
+ function tester(format) {
+ var r, baseMsg = 'weekday ' + m.weekday() + ' fmt ' + format;
+ r = moment(m.format(format), format);
+ assert.equal(r.weekday(), m.weekday(), baseMsg);
+ r = moment(m.format(format).toLocaleUpperCase(), format);
+ assert.equal(r.weekday(), m.weekday(), baseMsg + ' upper');
+ r = moment(m.format(format).toLocaleLowerCase(), format);
+ assert.equal(r.weekday(), m.weekday(), baseMsg + ' lower');
+
+ r = moment(m.format(format), format, true);
+ assert.equal(r.weekday(), m.weekday(), baseMsg + ' strict');
+ r = moment(m.format(format).toLocaleUpperCase(), format, true);
+ assert.equal(r.weekday(), m.weekday(), baseMsg + ' upper strict');
+ r = moment(m.format(format).toLocaleLowerCase(), format, true);
+ assert.equal(r.weekday(), m.weekday(), baseMsg + ' lower strict');
+ }
+
+ for (i = 0; i < 7; ++i) {
+ m = moment.utc([2015, i, 15, 18]);
+ tester('dd');
+ tester('ddd');
+ tester('dddd');
+ }
+ });
+ }
+
+ function setupDeprecationHandler(test, moment, scope) {
+ test._expectedDeprecations = null;
+ test._observedDeprecations = null;
+ test._oldSupress = moment.suppressDeprecationWarnings;
+ moment.suppressDeprecationWarnings = true;
+ test.expectedDeprecations = function () {
+ test._expectedDeprecations = arguments;
+ test._observedDeprecations = [];
+ };
+ moment.deprecationHandler = function (name, msg) {
+ var deprecationId = matchedDeprecation(name, msg, test._expectedDeprecations);
+ if (deprecationId === -1) {
+ throw new Error('Unexpected deprecation thrown name=' +
+ name + ' msg=' + msg);
+ }
+ test._observedDeprecations[deprecationId] = 1;
+ };
+ }
+
+ function teardownDeprecationHandler(test, moment, scope) {
+ moment.suppressDeprecationWarnings = test._oldSupress;
+
+ if (test._expectedDeprecations != null) {
+ var missedDeprecations = [];
+ each(test._expectedDeprecations, function (deprecationPattern, id) {
+ if (test._observedDeprecations[id] !== 1) {
+ missedDeprecations.push(deprecationPattern);
+ }
+ });
+ if (missedDeprecations.length !== 0) {
+ throw new Error('Expected deprecation warnings did not happen: ' +
+ missedDeprecations.join(' '));
+ }
+ }
+ }
+
+ function matchedDeprecation(name, msg, deprecations) {
+ if (deprecations == null) {
+ return -1;
+ }
+ for (var i = 0; i < deprecations.length; ++i) {
+ if (name != null && name === deprecations[i]) {
+ return i;
+ }
+ if (msg != null && msg.substring(0, deprecations[i].length) === deprecations[i]) {
+ return i;
+ }
+ }
+ return -1;
+ }
/*global QUnit:false*/
@@ -36072,11 +51255,13 @@
moment.createFromInputFallback = function (config) {
throw new Error('input not handled by moment: ' + config._i);
};
+ setupDeprecationHandler(test, moment, 'core');
if (lifecycle && lifecycle.setup) {
lifecycle.setup();
}
},
teardown : function () {
+ teardownDeprecationHandler(test, moment, 'core');
if (lifecycle && lifecycle.teardown) {
lifecycle.teardown();
}
@@ -36091,17 +51276,20 @@
moment.createFromInputFallback = function (config) {
throw new Error('input not handled by moment: ' + config._i);
};
+ setupDeprecationHandler(test, moment, 'locale');
if (lifecycle && lifecycle.setup) {
lifecycle.setup();
}
},
teardown : function () {
moment.locale('en');
+ teardownDeprecationHandler(test, moment, 'locale');
if (lifecycle && lifecycle.teardown) {
lifecycle.teardown();
}
}
});
+ defineCommonLocaleTests(name, -1, -1);
}
// These tests are for locale independent features
@@ -36109,12 +51297,12 @@
module('calendar');
test('passing a function', function (assert) {
- var a = moment().hours(2).minutes(0).seconds(0);
+ var a = moment().hours(13).minutes(0).seconds(0);
assert.equal(moment(a).calendar(null, {
'sameDay': function () {
return 'h:mmA';
}
- }), '2:00AM', 'should equate');
+ }), '1:00PM', 'should equate');
});
}));
@@ -36125,6 +51313,224 @@
typeof define === 'function' && define.amd ? define(['../../moment'], factory) :
factory(global.moment)
}(this, function (moment) { 'use strict';
+
+ function each(array, callback) {
+ var i;
+ for (i = 0; i < array.length; i++) {
+ callback(array[i], i, array);
+ }
+ }
+
+ function objectKeys(obj) {
+ if (Object.keys) {
+ return Object.keys(obj);
+ } else {
+ // IE8
+ var res = [], i;
+ for (i in obj) {
+ if (obj.hasOwnProperty(i)) {
+ res.push(i);
+ }
+ }
+ return res;
+ }
+ }
+
+ // Pick the first defined of two or three arguments.
+ function defaults(a, b, c) {
+ if (a != null) {
+ return a;
+ }
+ if (b != null) {
+ return b;
+ }
+ return c;
+ }
+
+ function defineCommonLocaleTests(locale, options) {
+ test('lenient ordinal parsing', function (assert) {
+ var i, ordinalStr, testMoment;
+ for (i = 1; i <= 31; ++i) {
+ ordinalStr = moment([2014, 0, i]).format('YYYY MM Do');
+ testMoment = moment(ordinalStr, 'YYYY MM Do');
+ assert.equal(testMoment.year(), 2014,
+ 'lenient ordinal parsing ' + i + ' year check');
+ assert.equal(testMoment.month(), 0,
+ 'lenient ordinal parsing ' + i + ' month check');
+ assert.equal(testMoment.date(), i,
+ 'lenient ordinal parsing ' + i + ' date check');
+ }
+ });
+
+ test('lenient ordinal parsing of number', function (assert) {
+ var i, testMoment;
+ for (i = 1; i <= 31; ++i) {
+ testMoment = moment('2014 01 ' + i, 'YYYY MM Do');
+ assert.equal(testMoment.year(), 2014,
+ 'lenient ordinal parsing of number ' + i + ' year check');
+ assert.equal(testMoment.month(), 0,
+ 'lenient ordinal parsing of number ' + i + ' month check');
+ assert.equal(testMoment.date(), i,
+ 'lenient ordinal parsing of number ' + i + ' date check');
+ }
+ });
+
+ test('strict ordinal parsing', function (assert) {
+ var i, ordinalStr, testMoment;
+ for (i = 1; i <= 31; ++i) {
+ ordinalStr = moment([2014, 0, i]).format('YYYY MM Do');
+ testMoment = moment(ordinalStr, 'YYYY MM Do', true);
+ assert.ok(testMoment.isValid(), 'strict ordinal parsing ' + i);
+ }
+ });
+
+ test('meridiem invariant', function (assert) {
+ var h, m, t1, t2;
+ for (h = 0; h < 24; ++h) {
+ for (m = 0; m < 60; m += 15) {
+ t1 = moment.utc([2000, 0, 1, h, m]);
+ t2 = moment.utc(t1.format('A h:mm'), 'A h:mm');
+ assert.equal(t2.format('HH:mm'), t1.format('HH:mm'),
+ 'meridiem at ' + t1.format('HH:mm'));
+ }
+ }
+ });
+
+ test('date format correctness', function (assert) {
+ var data, tokens;
+ data = moment.localeData()._longDateFormat;
+ tokens = objectKeys(data);
+ each(tokens, function (srchToken) {
+ // Check each format string to make sure it does not contain any
+ // tokens that need to be expanded.
+ each(tokens, function (baseToken) {
+ // strip escaped sequences
+ var format = data[baseToken].replace(/(\[[^\]]*\])/g, '');
+ assert.equal(false, !!~format.indexOf(srchToken),
+ 'contains ' + srchToken + ' in ' + baseToken);
+ });
+ });
+ });
+
+ test('month parsing correctness', function (assert) {
+ var i, m;
+
+ if (locale === 'tr') {
+ // I can't fix it :(
+ expect(0);
+ return;
+ }
+ function tester(format) {
+ var r;
+ r = moment(m.format(format), format);
+ assert.equal(r.month(), m.month(), 'month ' + i + ' fmt ' + format);
+ r = moment(m.format(format).toLocaleUpperCase(), format);
+ assert.equal(r.month(), m.month(), 'month ' + i + ' fmt ' + format + ' upper');
+ r = moment(m.format(format).toLocaleLowerCase(), format);
+ assert.equal(r.month(), m.month(), 'month ' + i + ' fmt ' + format + ' lower');
+
+ r = moment(m.format(format), format, true);
+ assert.equal(r.month(), m.month(), 'month ' + i + ' fmt ' + format + ' strict');
+ r = moment(m.format(format).toLocaleUpperCase(), format, true);
+ assert.equal(r.month(), m.month(), 'month ' + i + ' fmt ' + format + ' upper strict');
+ r = moment(m.format(format).toLocaleLowerCase(), format, true);
+ assert.equal(r.month(), m.month(), 'month ' + i + ' fmt ' + format + ' lower strict');
+ }
+
+ for (i = 0; i < 12; ++i) {
+ m = moment([2015, i, 15, 18]);
+ tester('MMM');
+ tester('MMM.');
+ tester('MMMM');
+ tester('MMMM.');
+ }
+ });
+
+ test('weekday parsing correctness', function (assert) {
+ var i, m;
+
+ if (locale === 'tr' || locale === 'az') {
+ // There is a lower-case letter (ı), that converted to upper then
+ // lower changes to i
+ expect(0);
+ return;
+ }
+ function tester(format) {
+ var r, baseMsg = 'weekday ' + m.weekday() + ' fmt ' + format;
+ r = moment(m.format(format), format);
+ assert.equal(r.weekday(), m.weekday(), baseMsg);
+ r = moment(m.format(format).toLocaleUpperCase(), format);
+ assert.equal(r.weekday(), m.weekday(), baseMsg + ' upper');
+ r = moment(m.format(format).toLocaleLowerCase(), format);
+ assert.equal(r.weekday(), m.weekday(), baseMsg + ' lower');
+
+ r = moment(m.format(format), format, true);
+ assert.equal(r.weekday(), m.weekday(), baseMsg + ' strict');
+ r = moment(m.format(format).toLocaleUpperCase(), format, true);
+ assert.equal(r.weekday(), m.weekday(), baseMsg + ' upper strict');
+ r = moment(m.format(format).toLocaleLowerCase(), format, true);
+ assert.equal(r.weekday(), m.weekday(), baseMsg + ' lower strict');
+ }
+
+ for (i = 0; i < 7; ++i) {
+ m = moment.utc([2015, i, 15, 18]);
+ tester('dd');
+ tester('ddd');
+ tester('dddd');
+ }
+ });
+ }
+
+ function setupDeprecationHandler(test, moment, scope) {
+ test._expectedDeprecations = null;
+ test._observedDeprecations = null;
+ test._oldSupress = moment.suppressDeprecationWarnings;
+ moment.suppressDeprecationWarnings = true;
+ test.expectedDeprecations = function () {
+ test._expectedDeprecations = arguments;
+ test._observedDeprecations = [];
+ };
+ moment.deprecationHandler = function (name, msg) {
+ var deprecationId = matchedDeprecation(name, msg, test._expectedDeprecations);
+ if (deprecationId === -1) {
+ throw new Error('Unexpected deprecation thrown name=' +
+ name + ' msg=' + msg);
+ }
+ test._observedDeprecations[deprecationId] = 1;
+ };
+ }
+
+ function teardownDeprecationHandler(test, moment, scope) {
+ moment.suppressDeprecationWarnings = test._oldSupress;
+
+ if (test._expectedDeprecations != null) {
+ var missedDeprecations = [];
+ each(test._expectedDeprecations, function (deprecationPattern, id) {
+ if (test._observedDeprecations[id] !== 1) {
+ missedDeprecations.push(deprecationPattern);
+ }
+ });
+ if (missedDeprecations.length !== 0) {
+ throw new Error('Expected deprecation warnings did not happen: ' +
+ missedDeprecations.join(' '));
+ }
+ }
+ }
+
+ function matchedDeprecation(name, msg, deprecations) {
+ if (deprecations == null) {
+ return -1;
+ }
+ for (var i = 0; i < deprecations.length; ++i) {
+ if (name != null && name === deprecations[i]) {
+ return i;
+ }
+ if (msg != null && msg.substring(0, deprecations[i].length) === deprecations[i]) {
+ return i;
+ }
+ }
+ return -1;
+ }
/*global QUnit:false*/
@@ -36139,11 +51545,13 @@
moment.createFromInputFallback = function (config) {
throw new Error('input not handled by moment: ' + config._i);
};
+ setupDeprecationHandler(test, moment, 'core');
if (lifecycle && lifecycle.setup) {
lifecycle.setup();
}
},
teardown : function () {
+ teardownDeprecationHandler(test, moment, 'core');
if (lifecycle && lifecycle.teardown) {
lifecycle.teardown();
}
@@ -36158,17 +51566,20 @@
moment.createFromInputFallback = function (config) {
throw new Error('input not handled by moment: ' + config._i);
};
+ setupDeprecationHandler(test, moment, 'locale');
if (lifecycle && lifecycle.setup) {
lifecycle.setup();
}
},
teardown : function () {
moment.locale('en');
+ teardownDeprecationHandler(test, moment, 'locale');
if (lifecycle && lifecycle.teardown) {
lifecycle.teardown();
}
}
});
+ defineCommonLocaleTests(name, -1, -1);
}
module('create');
@@ -36404,11 +51815,11 @@
['L', '09/02/1999'],
['l', '9/2/1999'],
['LL', 'September 2, 1999'],
- ['ll', 'Sept 2, 1999'],
+ ['ll', 'Sep 2, 1999'],
['LLL', 'September 2, 1999 12:30 AM'],
- ['lll', 'Sept 2, 1999 12:30 AM'],
+ ['lll', 'Sep 2, 1999 12:30 AM'],
['LLLL', 'Thursday, September 2, 1999 12:30 AM'],
- ['llll', 'Thu, Sept 2, 1999 12:30 AM']
+ ['llll', 'Thu, Sep 2, 1999 12:30 AM']
],
m,
i;
@@ -36460,7 +51871,7 @@
['MMDDYYYY', '12021999'],
['DDMMYYYY', '12021999'],
['YYYYMMDD', '19991202'],
- ['DDMMMYYYY', '10Sept2001']
+ ['DDMMMYYYY', '10Sep2001']
], i;
for (i = 0; i < a.length; i++) {
@@ -36775,25 +52186,25 @@
});
test('parsing iso week year/week/weekday', function (assert) {
- assert.equal(moment.utc('2007-W01').format(), '2007-01-01T00:00:00+00:00', '2008 week 1 (1st Jan Mon)');
- assert.equal(moment.utc('2008-W01').format(), '2007-12-31T00:00:00+00:00', '2008 week 1 (1st Jan Tue)');
- assert.equal(moment.utc('2003-W01').format(), '2002-12-30T00:00:00+00:00', '2008 week 1 (1st Jan Wed)');
- assert.equal(moment.utc('2009-W01').format(), '2008-12-29T00:00:00+00:00', '2009 week 1 (1st Jan Thu)');
- assert.equal(moment.utc('2010-W01').format(), '2010-01-04T00:00:00+00:00', '2010 week 1 (1st Jan Fri)');
- assert.equal(moment.utc('2011-W01').format(), '2011-01-03T00:00:00+00:00', '2011 week 1 (1st Jan Sat)');
- assert.equal(moment.utc('2012-W01').format(), '2012-01-02T00:00:00+00:00', '2012 week 1 (1st Jan Sun)');
+ assert.equal(moment.utc('2007-W01').format(), '2007-01-01T00:00:00Z', '2008 week 1 (1st Jan Mon)');
+ assert.equal(moment.utc('2008-W01').format(), '2007-12-31T00:00:00Z', '2008 week 1 (1st Jan Tue)');
+ assert.equal(moment.utc('2003-W01').format(), '2002-12-30T00:00:00Z', '2008 week 1 (1st Jan Wed)');
+ assert.equal(moment.utc('2009-W01').format(), '2008-12-29T00:00:00Z', '2009 week 1 (1st Jan Thu)');
+ assert.equal(moment.utc('2010-W01').format(), '2010-01-04T00:00:00Z', '2010 week 1 (1st Jan Fri)');
+ assert.equal(moment.utc('2011-W01').format(), '2011-01-03T00:00:00Z', '2011 week 1 (1st Jan Sat)');
+ assert.equal(moment.utc('2012-W01').format(), '2012-01-02T00:00:00Z', '2012 week 1 (1st Jan Sun)');
});
test('parsing week year/week/weekday (dow 1, doy 4)', function (assert) {
moment.locale('dow:1,doy:4', {week: {dow: 1, doy: 4}});
- assert.equal(moment.utc('2007-01', 'gggg-ww').format(), '2007-01-01T00:00:00+00:00', '2007 week 1 (1st Jan Mon)');
- assert.equal(moment.utc('2008-01', 'gggg-ww').format(), '2007-12-31T00:00:00+00:00', '2008 week 1 (1st Jan Tue)');
- assert.equal(moment.utc('2003-01', 'gggg-ww').format(), '2002-12-30T00:00:00+00:00', '2003 week 1 (1st Jan Wed)');
- assert.equal(moment.utc('2009-01', 'gggg-ww').format(), '2008-12-29T00:00:00+00:00', '2009 week 1 (1st Jan Thu)');
- assert.equal(moment.utc('2010-01', 'gggg-ww').format(), '2010-01-04T00:00:00+00:00', '2010 week 1 (1st Jan Fri)');
- assert.equal(moment.utc('2011-01', 'gggg-ww').format(), '2011-01-03T00:00:00+00:00', '2011 week 1 (1st Jan Sat)');
- assert.equal(moment.utc('2012-01', 'gggg-ww').format(), '2012-01-02T00:00:00+00:00', '2012 week 1 (1st Jan Sun)');
+ assert.equal(moment.utc('2007-01', 'gggg-ww').format(), '2007-01-01T00:00:00Z', '2007 week 1 (1st Jan Mon)');
+ assert.equal(moment.utc('2008-01', 'gggg-ww').format(), '2007-12-31T00:00:00Z', '2008 week 1 (1st Jan Tue)');
+ assert.equal(moment.utc('2003-01', 'gggg-ww').format(), '2002-12-30T00:00:00Z', '2003 week 1 (1st Jan Wed)');
+ assert.equal(moment.utc('2009-01', 'gggg-ww').format(), '2008-12-29T00:00:00Z', '2009 week 1 (1st Jan Thu)');
+ assert.equal(moment.utc('2010-01', 'gggg-ww').format(), '2010-01-04T00:00:00Z', '2010 week 1 (1st Jan Fri)');
+ assert.equal(moment.utc('2011-01', 'gggg-ww').format(), '2011-01-03T00:00:00Z', '2011 week 1 (1st Jan Sat)');
+ assert.equal(moment.utc('2012-01', 'gggg-ww').format(), '2012-01-02T00:00:00Z', '2012 week 1 (1st Jan Sun)');
moment.defineLocale('dow:1,doy:4', null);
});
@@ -36801,39 +52212,40 @@
test('parsing week year/week/weekday (dow 1, doy 7)', function (assert) {
moment.locale('dow:1,doy:7', {week: {dow: 1, doy: 7}});
- assert.equal(moment.utc('2007-01', 'gggg-ww').format(), '2007-01-01T00:00:00+00:00', '2007 week 1 (1st Jan Mon)');
- assert.equal(moment.utc('2008-01', 'gggg-ww').format(), '2007-12-31T00:00:00+00:00', '2008 week 1 (1st Jan Tue)');
- assert.equal(moment.utc('2003-01', 'gggg-ww').format(), '2002-12-30T00:00:00+00:00', '2003 week 1 (1st Jan Wed)');
- assert.equal(moment.utc('2009-01', 'gggg-ww').format(), '2008-12-29T00:00:00+00:00', '2009 week 1 (1st Jan Thu)');
- assert.equal(moment.utc('2010-01', 'gggg-ww').format(), '2009-12-28T00:00:00+00:00', '2010 week 1 (1st Jan Fri)');
- assert.equal(moment.utc('2011-01', 'gggg-ww').format(), '2010-12-27T00:00:00+00:00', '2011 week 1 (1st Jan Sat)');
- assert.equal(moment.utc('2012-01', 'gggg-ww').format(), '2011-12-26T00:00:00+00:00', '2012 week 1 (1st Jan Sun)');
+ assert.equal(moment.utc('2007-01', 'gggg-ww').format(), '2007-01-01T00:00:00Z', '2007 week 1 (1st Jan Mon)');
+ assert.equal(moment.utc('2008-01', 'gggg-ww').format(), '2007-12-31T00:00:00Z', '2008 week 1 (1st Jan Tue)');
+ assert.equal(moment.utc('2003-01', 'gggg-ww').format(), '2002-12-30T00:00:00Z', '2003 week 1 (1st Jan Wed)');
+ assert.equal(moment.utc('2009-01', 'gggg-ww').format(), '2008-12-29T00:00:00Z', '2009 week 1 (1st Jan Thu)');
+ assert.equal(moment.utc('2010-01', 'gggg-ww').format(), '2009-12-28T00:00:00Z', '2010 week 1 (1st Jan Fri)');
+ assert.equal(moment.utc('2011-01', 'gggg-ww').format(), '2010-12-27T00:00:00Z', '2011 week 1 (1st Jan Sat)');
+ assert.equal(moment.utc('2012-01', 'gggg-ww').format(), '2011-12-26T00:00:00Z', '2012 week 1 (1st Jan Sun)');
moment.defineLocale('dow:1,doy:7', null);
});
test('parsing week year/week/weekday (dow 0, doy 6)', function (assert) {
moment.locale('dow:0,doy:6', {week: {dow: 0, doy: 6}});
- assert.equal(moment.utc('2007-01', 'gggg-ww').format(), '2006-12-31T00:00:00+00:00', '2007 week 1 (1st Jan Mon)');
- assert.equal(moment.utc('2008-01', 'gggg-ww').format(), '2007-12-30T00:00:00+00:00', '2008 week 1 (1st Jan Tue)');
- assert.equal(moment.utc('2003-01', 'gggg-ww').format(), '2002-12-29T00:00:00+00:00', '2003 week 1 (1st Jan Wed)');
- assert.equal(moment.utc('2009-01', 'gggg-ww').format(), '2008-12-28T00:00:00+00:00', '2009 week 1 (1st Jan Thu)');
- assert.equal(moment.utc('2010-01', 'gggg-ww').format(), '2009-12-27T00:00:00+00:00', '2010 week 1 (1st Jan Fri)');
- assert.equal(moment.utc('2011-01', 'gggg-ww').format(), '2010-12-26T00:00:00+00:00', '2011 week 1 (1st Jan Sat)');
- assert.equal(moment.utc('2012-01', 'gggg-ww').format(), '2012-01-01T00:00:00+00:00', '2012 week 1 (1st Jan Sun)');
+ assert.equal(moment.utc('2007-01', 'gggg-ww').format(), '2006-12-31T00:00:00Z', '2007 week 1 (1st Jan Mon)');
+ assert.equal(moment.utc('2008-01', 'gggg-ww').format(), '2007-12-30T00:00:00Z', '2008 week 1 (1st Jan Tue)');
+ assert.equal(moment.utc('2003-01', 'gggg-ww').format(), '2002-12-29T00:00:00Z', '2003 week 1 (1st Jan Wed)');
+ assert.equal(moment.utc('2009-01', 'gggg-ww').format(), '2008-12-28T00:00:00Z', '2009 week 1 (1st Jan Thu)');
+ assert.equal(moment.utc('2010-01', 'gggg-ww').format(), '2009-12-27T00:00:00Z', '2010 week 1 (1st Jan Fri)');
+ assert.equal(moment.utc('2011-01', 'gggg-ww').format(), '2010-12-26T00:00:00Z', '2011 week 1 (1st Jan Sat)');
+ assert.equal(moment.utc('2012-01', 'gggg-ww').format(), '2012-01-01T00:00:00Z', '2012 week 1 (1st Jan Sun)');
moment.defineLocale('dow:0,doy:6', null);
});
test('parsing week year/week/weekday (dow 6, doy 12)', function (assert) {
moment.locale('dow:6,doy:12', {week: {dow: 6, doy: 12}});
- assert.equal(moment.utc('2007-01', 'gggg-ww').format(), '2006-12-30T00:00:00+00:00', '2007 week 1 (1st Jan Mon)');
- assert.equal(moment.utc('2008-01', 'gggg-ww').format(), '2007-12-29T00:00:00+00:00', '2008 week 1 (1st Jan Tue)');
- assert.equal(moment.utc('2003-01', 'gggg-ww').format(), '2002-12-28T00:00:00+00:00', '2003 week 1 (1st Jan Wed)');
- assert.equal(moment.utc('2009-01', 'gggg-ww').format(), '2008-12-27T00:00:00+00:00', '2009 week 1 (1st Jan Thu)');
- assert.equal(moment.utc('2010-01', 'gggg-ww').format(), '2009-12-26T00:00:00+00:00', '2010 week 1 (1st Jan Fri)');
- assert.equal(moment.utc('2011-01', 'gggg-ww').format(), '2011-01-01T00:00:00+00:00', '2011 week 1 (1st Jan Sat)');
- assert.equal(moment.utc('2012-01', 'gggg-ww').format(), '2011-12-31T00:00:00+00:00', '2012 week 1 (1st Jan Sun)');
+ assert.equal(moment.utc('2007-01', 'gggg-ww').format(), '2006-12-30T00:00:00Z', '2007 week 1 (1st Jan Mon)');
+ assert.equal(moment.utc('2008-01', 'gggg-ww').format(), '2007-12-29T00:00:00Z', '2008 week 1 (1st Jan Tue)');
+ assert.equal(moment.utc('2003-01', 'gggg-ww').format(), '2002-12-28T00:00:00Z', '2003 week 1 (1st Jan Wed)');
+ assert.equal(moment.utc('2009-01', 'gggg-ww').format(), '2008-12-27T00:00:00Z', '2009 week 1 (1st Jan Thu)');
+ assert.equal(moment.utc('2010-01', 'gggg-ww').format(), '2009-12-26T00:00:00Z', '2010 week 1 (1st Jan Fri)');
+ assert.equal(moment.utc('2011-01', 'gggg-ww').format(), '2011-01-01T00:00:00Z', '2011 week 1 (1st Jan Sat)');
+ assert.equal(moment.utc('2012-01', 'gggg-ww').format(), '2011-12-31T00:00:00Z', '2012 week 1 (1st Jan Sun)');
+ moment.defineLocale('dow:6,doy:12', null);
});
test('parsing ISO with Z', function (assert) {
@@ -36898,7 +52310,7 @@
});
test('parsing iso with more subsecond precision digits', function (assert) {
- assert.equal(moment.utc('2013-07-31T22:00:00.0000000Z').format(), '2013-07-31T22:00:00+00:00', 'more than 3 subsecond digits');
+ assert.equal(moment.utc('2013-07-31T22:00:00.0000000Z').format(), '2013-07-31T22:00:00Z', 'more than 3 subsecond digits');
});
test('null or empty', function (assert) {
@@ -37122,6 +52534,7 @@
ver('1999 37 Di', 'gggg ww dd', '1999 09 19', 'localized d uses 0-indexed days: 0 = sund');
}
finally {
+ moment.defineLocale('dow:1,doy:4', null);
moment.locale('en');
}
});
@@ -37153,7 +52566,7 @@
});
test('utc with array of formats', function (assert) {
- assert.equal(moment.utc('2014-01-01', ['YYYY-MM-DD', 'YYYY-MM']).format(), '2014-01-01T00:00:00+00:00', 'moment.utc works with array of formats');
+ assert.equal(moment.utc('2014-01-01', ['YYYY-MM-DD', 'YYYY-MM']).format(), '2014-01-01T00:00:00Z', 'moment.utc works with array of formats');
});
test('parsing invalid string weekdays', function (assert) {
@@ -37208,6 +52621,26 @@
assert.equal(moment('172345', 'Hmmss', true).format('HH:mm:ss'), '17:23:45', '112345 with Hmmss');
});
+ test('Y token', function (assert) {
+ assert.equal(moment('1-1-2010', 'M-D-Y', true).year(), 2010, 'parsing Y');
+ });
+
+ test('parsing flags retain parsed date parts', function (assert) {
+ var a = moment('10 p', 'hh:mm a');
+ assert.equal(a.parsingFlags().parsedDateParts[3], 10, 'parsed 10 as the hour');
+ assert.equal(a.parsingFlags().parsedDateParts[0], undefined, 'year was not parsed');
+ assert.equal(a.parsingFlags().meridiem, 'p', 'meridiem flag was added');
+ var b = moment('10:30', ['MMDDYY', 'HH:mm']);
+ assert.equal(b.parsingFlags().parsedDateParts[3], 10, 'multiple format parshing matched hour');
+ assert.equal(b.parsingFlags().parsedDateParts[0], undefined, 'array is properly copied, no residual data from first token parse');
+ });
+
+ test('parsing only meridiem results in invalid date', function (assert) {
+ assert.ok(!moment('alkj', 'hh:mm a').isValid(), 'because an a token is used, a meridiem will be parsed but nothing else was so invalid');
+ assert.ok(moment('02:30 p more extra stuff', 'hh:mm a').isValid(), 'because other tokens were parsed, date is valid');
+ assert.ok(moment('1/1/2016 extra data', ['a', 'M/D/YYYY']).isValid(), 'took second format, does not pick up on meridiem parsed from first format (good copy)');
+ });
+
}));
;(function (global, factory) {
@@ -37216,6 +52649,224 @@
typeof define === 'function' && define.amd ? define(['../../moment'], factory) :
factory(global.moment)
}(this, function (moment) { 'use strict';
+
+ function each(array, callback) {
+ var i;
+ for (i = 0; i < array.length; i++) {
+ callback(array[i], i, array);
+ }
+ }
+
+ function objectKeys(obj) {
+ if (Object.keys) {
+ return Object.keys(obj);
+ } else {
+ // IE8
+ var res = [], i;
+ for (i in obj) {
+ if (obj.hasOwnProperty(i)) {
+ res.push(i);
+ }
+ }
+ return res;
+ }
+ }
+
+ // Pick the first defined of two or three arguments.
+ function defaults(a, b, c) {
+ if (a != null) {
+ return a;
+ }
+ if (b != null) {
+ return b;
+ }
+ return c;
+ }
+
+ function defineCommonLocaleTests(locale, options) {
+ test('lenient ordinal parsing', function (assert) {
+ var i, ordinalStr, testMoment;
+ for (i = 1; i <= 31; ++i) {
+ ordinalStr = moment([2014, 0, i]).format('YYYY MM Do');
+ testMoment = moment(ordinalStr, 'YYYY MM Do');
+ assert.equal(testMoment.year(), 2014,
+ 'lenient ordinal parsing ' + i + ' year check');
+ assert.equal(testMoment.month(), 0,
+ 'lenient ordinal parsing ' + i + ' month check');
+ assert.equal(testMoment.date(), i,
+ 'lenient ordinal parsing ' + i + ' date check');
+ }
+ });
+
+ test('lenient ordinal parsing of number', function (assert) {
+ var i, testMoment;
+ for (i = 1; i <= 31; ++i) {
+ testMoment = moment('2014 01 ' + i, 'YYYY MM Do');
+ assert.equal(testMoment.year(), 2014,
+ 'lenient ordinal parsing of number ' + i + ' year check');
+ assert.equal(testMoment.month(), 0,
+ 'lenient ordinal parsing of number ' + i + ' month check');
+ assert.equal(testMoment.date(), i,
+ 'lenient ordinal parsing of number ' + i + ' date check');
+ }
+ });
+
+ test('strict ordinal parsing', function (assert) {
+ var i, ordinalStr, testMoment;
+ for (i = 1; i <= 31; ++i) {
+ ordinalStr = moment([2014, 0, i]).format('YYYY MM Do');
+ testMoment = moment(ordinalStr, 'YYYY MM Do', true);
+ assert.ok(testMoment.isValid(), 'strict ordinal parsing ' + i);
+ }
+ });
+
+ test('meridiem invariant', function (assert) {
+ var h, m, t1, t2;
+ for (h = 0; h < 24; ++h) {
+ for (m = 0; m < 60; m += 15) {
+ t1 = moment.utc([2000, 0, 1, h, m]);
+ t2 = moment.utc(t1.format('A h:mm'), 'A h:mm');
+ assert.equal(t2.format('HH:mm'), t1.format('HH:mm'),
+ 'meridiem at ' + t1.format('HH:mm'));
+ }
+ }
+ });
+
+ test('date format correctness', function (assert) {
+ var data, tokens;
+ data = moment.localeData()._longDateFormat;
+ tokens = objectKeys(data);
+ each(tokens, function (srchToken) {
+ // Check each format string to make sure it does not contain any
+ // tokens that need to be expanded.
+ each(tokens, function (baseToken) {
+ // strip escaped sequences
+ var format = data[baseToken].replace(/(\[[^\]]*\])/g, '');
+ assert.equal(false, !!~format.indexOf(srchToken),
+ 'contains ' + srchToken + ' in ' + baseToken);
+ });
+ });
+ });
+
+ test('month parsing correctness', function (assert) {
+ var i, m;
+
+ if (locale === 'tr') {
+ // I can't fix it :(
+ expect(0);
+ return;
+ }
+ function tester(format) {
+ var r;
+ r = moment(m.format(format), format);
+ assert.equal(r.month(), m.month(), 'month ' + i + ' fmt ' + format);
+ r = moment(m.format(format).toLocaleUpperCase(), format);
+ assert.equal(r.month(), m.month(), 'month ' + i + ' fmt ' + format + ' upper');
+ r = moment(m.format(format).toLocaleLowerCase(), format);
+ assert.equal(r.month(), m.month(), 'month ' + i + ' fmt ' + format + ' lower');
+
+ r = moment(m.format(format), format, true);
+ assert.equal(r.month(), m.month(), 'month ' + i + ' fmt ' + format + ' strict');
+ r = moment(m.format(format).toLocaleUpperCase(), format, true);
+ assert.equal(r.month(), m.month(), 'month ' + i + ' fmt ' + format + ' upper strict');
+ r = moment(m.format(format).toLocaleLowerCase(), format, true);
+ assert.equal(r.month(), m.month(), 'month ' + i + ' fmt ' + format + ' lower strict');
+ }
+
+ for (i = 0; i < 12; ++i) {
+ m = moment([2015, i, 15, 18]);
+ tester('MMM');
+ tester('MMM.');
+ tester('MMMM');
+ tester('MMMM.');
+ }
+ });
+
+ test('weekday parsing correctness', function (assert) {
+ var i, m;
+
+ if (locale === 'tr' || locale === 'az') {
+ // There is a lower-case letter (ı), that converted to upper then
+ // lower changes to i
+ expect(0);
+ return;
+ }
+ function tester(format) {
+ var r, baseMsg = 'weekday ' + m.weekday() + ' fmt ' + format;
+ r = moment(m.format(format), format);
+ assert.equal(r.weekday(), m.weekday(), baseMsg);
+ r = moment(m.format(format).toLocaleUpperCase(), format);
+ assert.equal(r.weekday(), m.weekday(), baseMsg + ' upper');
+ r = moment(m.format(format).toLocaleLowerCase(), format);
+ assert.equal(r.weekday(), m.weekday(), baseMsg + ' lower');
+
+ r = moment(m.format(format), format, true);
+ assert.equal(r.weekday(), m.weekday(), baseMsg + ' strict');
+ r = moment(m.format(format).toLocaleUpperCase(), format, true);
+ assert.equal(r.weekday(), m.weekday(), baseMsg + ' upper strict');
+ r = moment(m.format(format).toLocaleLowerCase(), format, true);
+ assert.equal(r.weekday(), m.weekday(), baseMsg + ' lower strict');
+ }
+
+ for (i = 0; i < 7; ++i) {
+ m = moment.utc([2015, i, 15, 18]);
+ tester('dd');
+ tester('ddd');
+ tester('dddd');
+ }
+ });
+ }
+
+ function setupDeprecationHandler(test, moment, scope) {
+ test._expectedDeprecations = null;
+ test._observedDeprecations = null;
+ test._oldSupress = moment.suppressDeprecationWarnings;
+ moment.suppressDeprecationWarnings = true;
+ test.expectedDeprecations = function () {
+ test._expectedDeprecations = arguments;
+ test._observedDeprecations = [];
+ };
+ moment.deprecationHandler = function (name, msg) {
+ var deprecationId = matchedDeprecation(name, msg, test._expectedDeprecations);
+ if (deprecationId === -1) {
+ throw new Error('Unexpected deprecation thrown name=' +
+ name + ' msg=' + msg);
+ }
+ test._observedDeprecations[deprecationId] = 1;
+ };
+ }
+
+ function teardownDeprecationHandler(test, moment, scope) {
+ moment.suppressDeprecationWarnings = test._oldSupress;
+
+ if (test._expectedDeprecations != null) {
+ var missedDeprecations = [];
+ each(test._expectedDeprecations, function (deprecationPattern, id) {
+ if (test._observedDeprecations[id] !== 1) {
+ missedDeprecations.push(deprecationPattern);
+ }
+ });
+ if (missedDeprecations.length !== 0) {
+ throw new Error('Expected deprecation warnings did not happen: ' +
+ missedDeprecations.join(' '));
+ }
+ }
+ }
+
+ function matchedDeprecation(name, msg, deprecations) {
+ if (deprecations == null) {
+ return -1;
+ }
+ for (var i = 0; i < deprecations.length; ++i) {
+ if (name != null && name === deprecations[i]) {
+ return i;
+ }
+ if (msg != null && msg.substring(0, deprecations[i].length) === deprecations[i]) {
+ return i;
+ }
+ }
+ return -1;
+ }
/*global QUnit:false*/
@@ -37230,11 +52881,13 @@
moment.createFromInputFallback = function (config) {
throw new Error('input not handled by moment: ' + config._i);
};
+ setupDeprecationHandler(test, moment, 'core');
if (lifecycle && lifecycle.setup) {
lifecycle.setup();
}
},
teardown : function () {
+ teardownDeprecationHandler(test, moment, 'core');
if (lifecycle && lifecycle.teardown) {
lifecycle.teardown();
}
@@ -37249,17 +52902,20 @@
moment.createFromInputFallback = function (config) {
throw new Error('input not handled by moment: ' + config._i);
};
+ setupDeprecationHandler(test, moment, 'locale');
if (lifecycle && lifecycle.setup) {
lifecycle.setup();
}
},
teardown : function () {
moment.locale('en');
+ teardownDeprecationHandler(test, moment, 'locale');
if (lifecycle && lifecycle.teardown) {
lifecycle.teardown();
}
}
});
+ defineCommonLocaleTests(name, -1, -1);
}
module('creation data');
@@ -37302,6 +52958,224 @@
typeof define === 'function' && define.amd ? define(['../../moment'], factory) :
factory(global.moment)
}(this, function (moment) { 'use strict';
+
+ function each(array, callback) {
+ var i;
+ for (i = 0; i < array.length; i++) {
+ callback(array[i], i, array);
+ }
+ }
+
+ function objectKeys(obj) {
+ if (Object.keys) {
+ return Object.keys(obj);
+ } else {
+ // IE8
+ var res = [], i;
+ for (i in obj) {
+ if (obj.hasOwnProperty(i)) {
+ res.push(i);
+ }
+ }
+ return res;
+ }
+ }
+
+ // Pick the first defined of two or three arguments.
+ function defaults(a, b, c) {
+ if (a != null) {
+ return a;
+ }
+ if (b != null) {
+ return b;
+ }
+ return c;
+ }
+
+ function defineCommonLocaleTests(locale, options) {
+ test('lenient ordinal parsing', function (assert) {
+ var i, ordinalStr, testMoment;
+ for (i = 1; i <= 31; ++i) {
+ ordinalStr = moment([2014, 0, i]).format('YYYY MM Do');
+ testMoment = moment(ordinalStr, 'YYYY MM Do');
+ assert.equal(testMoment.year(), 2014,
+ 'lenient ordinal parsing ' + i + ' year check');
+ assert.equal(testMoment.month(), 0,
+ 'lenient ordinal parsing ' + i + ' month check');
+ assert.equal(testMoment.date(), i,
+ 'lenient ordinal parsing ' + i + ' date check');
+ }
+ });
+
+ test('lenient ordinal parsing of number', function (assert) {
+ var i, testMoment;
+ for (i = 1; i <= 31; ++i) {
+ testMoment = moment('2014 01 ' + i, 'YYYY MM Do');
+ assert.equal(testMoment.year(), 2014,
+ 'lenient ordinal parsing of number ' + i + ' year check');
+ assert.equal(testMoment.month(), 0,
+ 'lenient ordinal parsing of number ' + i + ' month check');
+ assert.equal(testMoment.date(), i,
+ 'lenient ordinal parsing of number ' + i + ' date check');
+ }
+ });
+
+ test('strict ordinal parsing', function (assert) {
+ var i, ordinalStr, testMoment;
+ for (i = 1; i <= 31; ++i) {
+ ordinalStr = moment([2014, 0, i]).format('YYYY MM Do');
+ testMoment = moment(ordinalStr, 'YYYY MM Do', true);
+ assert.ok(testMoment.isValid(), 'strict ordinal parsing ' + i);
+ }
+ });
+
+ test('meridiem invariant', function (assert) {
+ var h, m, t1, t2;
+ for (h = 0; h < 24; ++h) {
+ for (m = 0; m < 60; m += 15) {
+ t1 = moment.utc([2000, 0, 1, h, m]);
+ t2 = moment.utc(t1.format('A h:mm'), 'A h:mm');
+ assert.equal(t2.format('HH:mm'), t1.format('HH:mm'),
+ 'meridiem at ' + t1.format('HH:mm'));
+ }
+ }
+ });
+
+ test('date format correctness', function (assert) {
+ var data, tokens;
+ data = moment.localeData()._longDateFormat;
+ tokens = objectKeys(data);
+ each(tokens, function (srchToken) {
+ // Check each format string to make sure it does not contain any
+ // tokens that need to be expanded.
+ each(tokens, function (baseToken) {
+ // strip escaped sequences
+ var format = data[baseToken].replace(/(\[[^\]]*\])/g, '');
+ assert.equal(false, !!~format.indexOf(srchToken),
+ 'contains ' + srchToken + ' in ' + baseToken);
+ });
+ });
+ });
+
+ test('month parsing correctness', function (assert) {
+ var i, m;
+
+ if (locale === 'tr') {
+ // I can't fix it :(
+ expect(0);
+ return;
+ }
+ function tester(format) {
+ var r;
+ r = moment(m.format(format), format);
+ assert.equal(r.month(), m.month(), 'month ' + i + ' fmt ' + format);
+ r = moment(m.format(format).toLocaleUpperCase(), format);
+ assert.equal(r.month(), m.month(), 'month ' + i + ' fmt ' + format + ' upper');
+ r = moment(m.format(format).toLocaleLowerCase(), format);
+ assert.equal(r.month(), m.month(), 'month ' + i + ' fmt ' + format + ' lower');
+
+ r = moment(m.format(format), format, true);
+ assert.equal(r.month(), m.month(), 'month ' + i + ' fmt ' + format + ' strict');
+ r = moment(m.format(format).toLocaleUpperCase(), format, true);
+ assert.equal(r.month(), m.month(), 'month ' + i + ' fmt ' + format + ' upper strict');
+ r = moment(m.format(format).toLocaleLowerCase(), format, true);
+ assert.equal(r.month(), m.month(), 'month ' + i + ' fmt ' + format + ' lower strict');
+ }
+
+ for (i = 0; i < 12; ++i) {
+ m = moment([2015, i, 15, 18]);
+ tester('MMM');
+ tester('MMM.');
+ tester('MMMM');
+ tester('MMMM.');
+ }
+ });
+
+ test('weekday parsing correctness', function (assert) {
+ var i, m;
+
+ if (locale === 'tr' || locale === 'az') {
+ // There is a lower-case letter (ı), that converted to upper then
+ // lower changes to i
+ expect(0);
+ return;
+ }
+ function tester(format) {
+ var r, baseMsg = 'weekday ' + m.weekday() + ' fmt ' + format;
+ r = moment(m.format(format), format);
+ assert.equal(r.weekday(), m.weekday(), baseMsg);
+ r = moment(m.format(format).toLocaleUpperCase(), format);
+ assert.equal(r.weekday(), m.weekday(), baseMsg + ' upper');
+ r = moment(m.format(format).toLocaleLowerCase(), format);
+ assert.equal(r.weekday(), m.weekday(), baseMsg + ' lower');
+
+ r = moment(m.format(format), format, true);
+ assert.equal(r.weekday(), m.weekday(), baseMsg + ' strict');
+ r = moment(m.format(format).toLocaleUpperCase(), format, true);
+ assert.equal(r.weekday(), m.weekday(), baseMsg + ' upper strict');
+ r = moment(m.format(format).toLocaleLowerCase(), format, true);
+ assert.equal(r.weekday(), m.weekday(), baseMsg + ' lower strict');
+ }
+
+ for (i = 0; i < 7; ++i) {
+ m = moment.utc([2015, i, 15, 18]);
+ tester('dd');
+ tester('ddd');
+ tester('dddd');
+ }
+ });
+ }
+
+ function setupDeprecationHandler(test, moment, scope) {
+ test._expectedDeprecations = null;
+ test._observedDeprecations = null;
+ test._oldSupress = moment.suppressDeprecationWarnings;
+ moment.suppressDeprecationWarnings = true;
+ test.expectedDeprecations = function () {
+ test._expectedDeprecations = arguments;
+ test._observedDeprecations = [];
+ };
+ moment.deprecationHandler = function (name, msg) {
+ var deprecationId = matchedDeprecation(name, msg, test._expectedDeprecations);
+ if (deprecationId === -1) {
+ throw new Error('Unexpected deprecation thrown name=' +
+ name + ' msg=' + msg);
+ }
+ test._observedDeprecations[deprecationId] = 1;
+ };
+ }
+
+ function teardownDeprecationHandler(test, moment, scope) {
+ moment.suppressDeprecationWarnings = test._oldSupress;
+
+ if (test._expectedDeprecations != null) {
+ var missedDeprecations = [];
+ each(test._expectedDeprecations, function (deprecationPattern, id) {
+ if (test._observedDeprecations[id] !== 1) {
+ missedDeprecations.push(deprecationPattern);
+ }
+ });
+ if (missedDeprecations.length !== 0) {
+ throw new Error('Expected deprecation warnings did not happen: ' +
+ missedDeprecations.join(' '));
+ }
+ }
+ }
+
+ function matchedDeprecation(name, msg, deprecations) {
+ if (deprecations == null) {
+ return -1;
+ }
+ for (var i = 0; i < deprecations.length; ++i) {
+ if (name != null && name === deprecations[i]) {
+ return i;
+ }
+ if (msg != null && msg.substring(0, deprecations[i].length) === deprecations[i]) {
+ return i;
+ }
+ }
+ return -1;
+ }
/*global QUnit:false*/
@@ -37316,11 +53190,13 @@
moment.createFromInputFallback = function (config) {
throw new Error('input not handled by moment: ' + config._i);
};
+ setupDeprecationHandler(test, moment, 'core');
if (lifecycle && lifecycle.setup) {
lifecycle.setup();
}
},
teardown : function () {
+ teardownDeprecationHandler(test, moment, 'core');
if (lifecycle && lifecycle.teardown) {
lifecycle.teardown();
}
@@ -37335,24 +53211,20 @@
moment.createFromInputFallback = function (config) {
throw new Error('input not handled by moment: ' + config._i);
};
+ setupDeprecationHandler(test, moment, 'locale');
if (lifecycle && lifecycle.setup) {
lifecycle.setup();
}
},
teardown : function () {
moment.locale('en');
+ teardownDeprecationHandler(test, moment, 'locale');
if (lifecycle && lifecycle.teardown) {
lifecycle.teardown();
}
}
});
- }
-
- function each(array, callback) {
- var i;
- for (i = 0; i < array.length; i++) {
- callback(array[i], i, array);
- }
+ defineCommonLocaleTests(name, -1, -1);
}
module('days in month');
@@ -37381,6 +53253,224 @@
typeof define === 'function' && define.amd ? define(['../../moment'], factory) :
factory(global.moment)
}(this, function (moment) { 'use strict';
+
+ function each(array, callback) {
+ var i;
+ for (i = 0; i < array.length; i++) {
+ callback(array[i], i, array);
+ }
+ }
+
+ function objectKeys(obj) {
+ if (Object.keys) {
+ return Object.keys(obj);
+ } else {
+ // IE8
+ var res = [], i;
+ for (i in obj) {
+ if (obj.hasOwnProperty(i)) {
+ res.push(i);
+ }
+ }
+ return res;
+ }
+ }
+
+ // Pick the first defined of two or three arguments.
+ function defaults(a, b, c) {
+ if (a != null) {
+ return a;
+ }
+ if (b != null) {
+ return b;
+ }
+ return c;
+ }
+
+ function defineCommonLocaleTests(locale, options) {
+ test('lenient ordinal parsing', function (assert) {
+ var i, ordinalStr, testMoment;
+ for (i = 1; i <= 31; ++i) {
+ ordinalStr = moment([2014, 0, i]).format('YYYY MM Do');
+ testMoment = moment(ordinalStr, 'YYYY MM Do');
+ assert.equal(testMoment.year(), 2014,
+ 'lenient ordinal parsing ' + i + ' year check');
+ assert.equal(testMoment.month(), 0,
+ 'lenient ordinal parsing ' + i + ' month check');
+ assert.equal(testMoment.date(), i,
+ 'lenient ordinal parsing ' + i + ' date check');
+ }
+ });
+
+ test('lenient ordinal parsing of number', function (assert) {
+ var i, testMoment;
+ for (i = 1; i <= 31; ++i) {
+ testMoment = moment('2014 01 ' + i, 'YYYY MM Do');
+ assert.equal(testMoment.year(), 2014,
+ 'lenient ordinal parsing of number ' + i + ' year check');
+ assert.equal(testMoment.month(), 0,
+ 'lenient ordinal parsing of number ' + i + ' month check');
+ assert.equal(testMoment.date(), i,
+ 'lenient ordinal parsing of number ' + i + ' date check');
+ }
+ });
+
+ test('strict ordinal parsing', function (assert) {
+ var i, ordinalStr, testMoment;
+ for (i = 1; i <= 31; ++i) {
+ ordinalStr = moment([2014, 0, i]).format('YYYY MM Do');
+ testMoment = moment(ordinalStr, 'YYYY MM Do', true);
+ assert.ok(testMoment.isValid(), 'strict ordinal parsing ' + i);
+ }
+ });
+
+ test('meridiem invariant', function (assert) {
+ var h, m, t1, t2;
+ for (h = 0; h < 24; ++h) {
+ for (m = 0; m < 60; m += 15) {
+ t1 = moment.utc([2000, 0, 1, h, m]);
+ t2 = moment.utc(t1.format('A h:mm'), 'A h:mm');
+ assert.equal(t2.format('HH:mm'), t1.format('HH:mm'),
+ 'meridiem at ' + t1.format('HH:mm'));
+ }
+ }
+ });
+
+ test('date format correctness', function (assert) {
+ var data, tokens;
+ data = moment.localeData()._longDateFormat;
+ tokens = objectKeys(data);
+ each(tokens, function (srchToken) {
+ // Check each format string to make sure it does not contain any
+ // tokens that need to be expanded.
+ each(tokens, function (baseToken) {
+ // strip escaped sequences
+ var format = data[baseToken].replace(/(\[[^\]]*\])/g, '');
+ assert.equal(false, !!~format.indexOf(srchToken),
+ 'contains ' + srchToken + ' in ' + baseToken);
+ });
+ });
+ });
+
+ test('month parsing correctness', function (assert) {
+ var i, m;
+
+ if (locale === 'tr') {
+ // I can't fix it :(
+ expect(0);
+ return;
+ }
+ function tester(format) {
+ var r;
+ r = moment(m.format(format), format);
+ assert.equal(r.month(), m.month(), 'month ' + i + ' fmt ' + format);
+ r = moment(m.format(format).toLocaleUpperCase(), format);
+ assert.equal(r.month(), m.month(), 'month ' + i + ' fmt ' + format + ' upper');
+ r = moment(m.format(format).toLocaleLowerCase(), format);
+ assert.equal(r.month(), m.month(), 'month ' + i + ' fmt ' + format + ' lower');
+
+ r = moment(m.format(format), format, true);
+ assert.equal(r.month(), m.month(), 'month ' + i + ' fmt ' + format + ' strict');
+ r = moment(m.format(format).toLocaleUpperCase(), format, true);
+ assert.equal(r.month(), m.month(), 'month ' + i + ' fmt ' + format + ' upper strict');
+ r = moment(m.format(format).toLocaleLowerCase(), format, true);
+ assert.equal(r.month(), m.month(), 'month ' + i + ' fmt ' + format + ' lower strict');
+ }
+
+ for (i = 0; i < 12; ++i) {
+ m = moment([2015, i, 15, 18]);
+ tester('MMM');
+ tester('MMM.');
+ tester('MMMM');
+ tester('MMMM.');
+ }
+ });
+
+ test('weekday parsing correctness', function (assert) {
+ var i, m;
+
+ if (locale === 'tr' || locale === 'az') {
+ // There is a lower-case letter (ı), that converted to upper then
+ // lower changes to i
+ expect(0);
+ return;
+ }
+ function tester(format) {
+ var r, baseMsg = 'weekday ' + m.weekday() + ' fmt ' + format;
+ r = moment(m.format(format), format);
+ assert.equal(r.weekday(), m.weekday(), baseMsg);
+ r = moment(m.format(format).toLocaleUpperCase(), format);
+ assert.equal(r.weekday(), m.weekday(), baseMsg + ' upper');
+ r = moment(m.format(format).toLocaleLowerCase(), format);
+ assert.equal(r.weekday(), m.weekday(), baseMsg + ' lower');
+
+ r = moment(m.format(format), format, true);
+ assert.equal(r.weekday(), m.weekday(), baseMsg + ' strict');
+ r = moment(m.format(format).toLocaleUpperCase(), format, true);
+ assert.equal(r.weekday(), m.weekday(), baseMsg + ' upper strict');
+ r = moment(m.format(format).toLocaleLowerCase(), format, true);
+ assert.equal(r.weekday(), m.weekday(), baseMsg + ' lower strict');
+ }
+
+ for (i = 0; i < 7; ++i) {
+ m = moment.utc([2015, i, 15, 18]);
+ tester('dd');
+ tester('ddd');
+ tester('dddd');
+ }
+ });
+ }
+
+ function setupDeprecationHandler(test, moment, scope) {
+ test._expectedDeprecations = null;
+ test._observedDeprecations = null;
+ test._oldSupress = moment.suppressDeprecationWarnings;
+ moment.suppressDeprecationWarnings = true;
+ test.expectedDeprecations = function () {
+ test._expectedDeprecations = arguments;
+ test._observedDeprecations = [];
+ };
+ moment.deprecationHandler = function (name, msg) {
+ var deprecationId = matchedDeprecation(name, msg, test._expectedDeprecations);
+ if (deprecationId === -1) {
+ throw new Error('Unexpected deprecation thrown name=' +
+ name + ' msg=' + msg);
+ }
+ test._observedDeprecations[deprecationId] = 1;
+ };
+ }
+
+ function teardownDeprecationHandler(test, moment, scope) {
+ moment.suppressDeprecationWarnings = test._oldSupress;
+
+ if (test._expectedDeprecations != null) {
+ var missedDeprecations = [];
+ each(test._expectedDeprecations, function (deprecationPattern, id) {
+ if (test._observedDeprecations[id] !== 1) {
+ missedDeprecations.push(deprecationPattern);
+ }
+ });
+ if (missedDeprecations.length !== 0) {
+ throw new Error('Expected deprecation warnings did not happen: ' +
+ missedDeprecations.join(' '));
+ }
+ }
+ }
+
+ function matchedDeprecation(name, msg, deprecations) {
+ if (deprecations == null) {
+ return -1;
+ }
+ for (var i = 0; i < deprecations.length; ++i) {
+ if (name != null && name === deprecations[i]) {
+ return i;
+ }
+ if (msg != null && msg.substring(0, deprecations[i].length) === deprecations[i]) {
+ return i;
+ }
+ }
+ return -1;
+ }
/*global QUnit:false*/
@@ -37395,11 +53485,13 @@
moment.createFromInputFallback = function (config) {
throw new Error('input not handled by moment: ' + config._i);
};
+ setupDeprecationHandler(test, moment, 'core');
if (lifecycle && lifecycle.setup) {
lifecycle.setup();
}
},
teardown : function () {
+ teardownDeprecationHandler(test, moment, 'core');
if (lifecycle && lifecycle.teardown) {
lifecycle.teardown();
}
@@ -37414,17 +53506,20 @@
moment.createFromInputFallback = function (config) {
throw new Error('input not handled by moment: ' + config._i);
};
+ setupDeprecationHandler(test, moment, 'locale');
if (lifecycle && lifecycle.setup) {
lifecycle.setup();
}
},
teardown : function () {
moment.locale('en');
+ teardownDeprecationHandler(test, moment, 'locale');
if (lifecycle && lifecycle.teardown) {
lifecycle.teardown();
}
}
});
+ defineCommonLocaleTests(name, -1, -1);
}
function hasOwnProp(a, b) {
@@ -37466,7 +53561,8 @@
}
function warn(msg) {
- if (hooks.suppressDeprecationWarnings === false && !isUndefined(console) && console.warn) {
+ if (hooks.suppressDeprecationWarnings === false &&
+ (typeof console !== 'undefined') && console.warn) {
console.warn('Deprecation warning: ' + msg);
}
}
@@ -37475,6 +53571,9 @@
var firstTime = true;
return extend(function () {
+ if (hooks.deprecationHandler != null) {
+ hooks.deprecationHandler(null, msg);
+ }
if (firstTime) {
warn(msg + '\nArguments: ' + Array.prototype.slice.call(arguments).join(', ') + '\n' + (new Error()).stack);
firstTime = false;
@@ -37486,6 +53585,9 @@
var deprecations = {};
function deprecateSimple(name, msg) {
+ if (hooks.deprecationHandler != null) {
+ hooks.deprecationHandler(name, msg);
+ }
if (!deprecations[name]) {
warn(msg);
deprecations[name] = true;
@@ -37493,10 +53595,13 @@
}
hooks.suppressDeprecationWarnings = false;
+ hooks.deprecationHandler = null;
module('deprecate');
test('deprecate', function (assert) {
+ // NOTE: hooks inside deprecate.js and moment are different, so this is can
+ // not be test.expectedDeprecations(...)
var fn = function () {};
var deprecatedFn = deprecate('testing deprecation', fn);
deprecatedFn();
@@ -37512,6 +53617,224 @@
typeof define === 'function' && define.amd ? define(['../../moment'], factory) :
factory(global.moment)
}(this, function (moment) { 'use strict';
+
+ function each(array, callback) {
+ var i;
+ for (i = 0; i < array.length; i++) {
+ callback(array[i], i, array);
+ }
+ }
+
+ function objectKeys(obj) {
+ if (Object.keys) {
+ return Object.keys(obj);
+ } else {
+ // IE8
+ var res = [], i;
+ for (i in obj) {
+ if (obj.hasOwnProperty(i)) {
+ res.push(i);
+ }
+ }
+ return res;
+ }
+ }
+
+ // Pick the first defined of two or three arguments.
+ function defaults(a, b, c) {
+ if (a != null) {
+ return a;
+ }
+ if (b != null) {
+ return b;
+ }
+ return c;
+ }
+
+ function defineCommonLocaleTests(locale, options) {
+ test('lenient ordinal parsing', function (assert) {
+ var i, ordinalStr, testMoment;
+ for (i = 1; i <= 31; ++i) {
+ ordinalStr = moment([2014, 0, i]).format('YYYY MM Do');
+ testMoment = moment(ordinalStr, 'YYYY MM Do');
+ assert.equal(testMoment.year(), 2014,
+ 'lenient ordinal parsing ' + i + ' year check');
+ assert.equal(testMoment.month(), 0,
+ 'lenient ordinal parsing ' + i + ' month check');
+ assert.equal(testMoment.date(), i,
+ 'lenient ordinal parsing ' + i + ' date check');
+ }
+ });
+
+ test('lenient ordinal parsing of number', function (assert) {
+ var i, testMoment;
+ for (i = 1; i <= 31; ++i) {
+ testMoment = moment('2014 01 ' + i, 'YYYY MM Do');
+ assert.equal(testMoment.year(), 2014,
+ 'lenient ordinal parsing of number ' + i + ' year check');
+ assert.equal(testMoment.month(), 0,
+ 'lenient ordinal parsing of number ' + i + ' month check');
+ assert.equal(testMoment.date(), i,
+ 'lenient ordinal parsing of number ' + i + ' date check');
+ }
+ });
+
+ test('strict ordinal parsing', function (assert) {
+ var i, ordinalStr, testMoment;
+ for (i = 1; i <= 31; ++i) {
+ ordinalStr = moment([2014, 0, i]).format('YYYY MM Do');
+ testMoment = moment(ordinalStr, 'YYYY MM Do', true);
+ assert.ok(testMoment.isValid(), 'strict ordinal parsing ' + i);
+ }
+ });
+
+ test('meridiem invariant', function (assert) {
+ var h, m, t1, t2;
+ for (h = 0; h < 24; ++h) {
+ for (m = 0; m < 60; m += 15) {
+ t1 = moment.utc([2000, 0, 1, h, m]);
+ t2 = moment.utc(t1.format('A h:mm'), 'A h:mm');
+ assert.equal(t2.format('HH:mm'), t1.format('HH:mm'),
+ 'meridiem at ' + t1.format('HH:mm'));
+ }
+ }
+ });
+
+ test('date format correctness', function (assert) {
+ var data, tokens;
+ data = moment.localeData()._longDateFormat;
+ tokens = objectKeys(data);
+ each(tokens, function (srchToken) {
+ // Check each format string to make sure it does not contain any
+ // tokens that need to be expanded.
+ each(tokens, function (baseToken) {
+ // strip escaped sequences
+ var format = data[baseToken].replace(/(\[[^\]]*\])/g, '');
+ assert.equal(false, !!~format.indexOf(srchToken),
+ 'contains ' + srchToken + ' in ' + baseToken);
+ });
+ });
+ });
+
+ test('month parsing correctness', function (assert) {
+ var i, m;
+
+ if (locale === 'tr') {
+ // I can't fix it :(
+ expect(0);
+ return;
+ }
+ function tester(format) {
+ var r;
+ r = moment(m.format(format), format);
+ assert.equal(r.month(), m.month(), 'month ' + i + ' fmt ' + format);
+ r = moment(m.format(format).toLocaleUpperCase(), format);
+ assert.equal(r.month(), m.month(), 'month ' + i + ' fmt ' + format + ' upper');
+ r = moment(m.format(format).toLocaleLowerCase(), format);
+ assert.equal(r.month(), m.month(), 'month ' + i + ' fmt ' + format + ' lower');
+
+ r = moment(m.format(format), format, true);
+ assert.equal(r.month(), m.month(), 'month ' + i + ' fmt ' + format + ' strict');
+ r = moment(m.format(format).toLocaleUpperCase(), format, true);
+ assert.equal(r.month(), m.month(), 'month ' + i + ' fmt ' + format + ' upper strict');
+ r = moment(m.format(format).toLocaleLowerCase(), format, true);
+ assert.equal(r.month(), m.month(), 'month ' + i + ' fmt ' + format + ' lower strict');
+ }
+
+ for (i = 0; i < 12; ++i) {
+ m = moment([2015, i, 15, 18]);
+ tester('MMM');
+ tester('MMM.');
+ tester('MMMM');
+ tester('MMMM.');
+ }
+ });
+
+ test('weekday parsing correctness', function (assert) {
+ var i, m;
+
+ if (locale === 'tr' || locale === 'az') {
+ // There is a lower-case letter (ı), that converted to upper then
+ // lower changes to i
+ expect(0);
+ return;
+ }
+ function tester(format) {
+ var r, baseMsg = 'weekday ' + m.weekday() + ' fmt ' + format;
+ r = moment(m.format(format), format);
+ assert.equal(r.weekday(), m.weekday(), baseMsg);
+ r = moment(m.format(format).toLocaleUpperCase(), format);
+ assert.equal(r.weekday(), m.weekday(), baseMsg + ' upper');
+ r = moment(m.format(format).toLocaleLowerCase(), format);
+ assert.equal(r.weekday(), m.weekday(), baseMsg + ' lower');
+
+ r = moment(m.format(format), format, true);
+ assert.equal(r.weekday(), m.weekday(), baseMsg + ' strict');
+ r = moment(m.format(format).toLocaleUpperCase(), format, true);
+ assert.equal(r.weekday(), m.weekday(), baseMsg + ' upper strict');
+ r = moment(m.format(format).toLocaleLowerCase(), format, true);
+ assert.equal(r.weekday(), m.weekday(), baseMsg + ' lower strict');
+ }
+
+ for (i = 0; i < 7; ++i) {
+ m = moment.utc([2015, i, 15, 18]);
+ tester('dd');
+ tester('ddd');
+ tester('dddd');
+ }
+ });
+ }
+
+ function setupDeprecationHandler(test, moment, scope) {
+ test._expectedDeprecations = null;
+ test._observedDeprecations = null;
+ test._oldSupress = moment.suppressDeprecationWarnings;
+ moment.suppressDeprecationWarnings = true;
+ test.expectedDeprecations = function () {
+ test._expectedDeprecations = arguments;
+ test._observedDeprecations = [];
+ };
+ moment.deprecationHandler = function (name, msg) {
+ var deprecationId = matchedDeprecation(name, msg, test._expectedDeprecations);
+ if (deprecationId === -1) {
+ throw new Error('Unexpected deprecation thrown name=' +
+ name + ' msg=' + msg);
+ }
+ test._observedDeprecations[deprecationId] = 1;
+ };
+ }
+
+ function teardownDeprecationHandler(test, moment, scope) {
+ moment.suppressDeprecationWarnings = test._oldSupress;
+
+ if (test._expectedDeprecations != null) {
+ var missedDeprecations = [];
+ each(test._expectedDeprecations, function (deprecationPattern, id) {
+ if (test._observedDeprecations[id] !== 1) {
+ missedDeprecations.push(deprecationPattern);
+ }
+ });
+ if (missedDeprecations.length !== 0) {
+ throw new Error('Expected deprecation warnings did not happen: ' +
+ missedDeprecations.join(' '));
+ }
+ }
+ }
+
+ function matchedDeprecation(name, msg, deprecations) {
+ if (deprecations == null) {
+ return -1;
+ }
+ for (var i = 0; i < deprecations.length; ++i) {
+ if (name != null && name === deprecations[i]) {
+ return i;
+ }
+ if (msg != null && msg.substring(0, deprecations[i].length) === deprecations[i]) {
+ return i;
+ }
+ }
+ return -1;
+ }
/*global QUnit:false*/
@@ -37526,11 +53849,13 @@
moment.createFromInputFallback = function (config) {
throw new Error('input not handled by moment: ' + config._i);
};
+ setupDeprecationHandler(test, moment, 'core');
if (lifecycle && lifecycle.setup) {
lifecycle.setup();
}
},
teardown : function () {
+ teardownDeprecationHandler(test, moment, 'core');
if (lifecycle && lifecycle.teardown) {
lifecycle.teardown();
}
@@ -37545,17 +53870,20 @@
moment.createFromInputFallback = function (config) {
throw new Error('input not handled by moment: ' + config._i);
};
+ setupDeprecationHandler(test, moment, 'locale');
if (lifecycle && lifecycle.setup) {
lifecycle.setup();
}
},
teardown : function () {
moment.locale('en');
+ teardownDeprecationHandler(test, moment, 'locale');
if (lifecycle && lifecycle.teardown) {
lifecycle.teardown();
}
}
});
+ defineCommonLocaleTests(name, -1, -1);
}
function equal(assert, a, b, message) {
@@ -37790,6 +54118,15 @@
equal(assert, moment([2012, 1, 29]).diff([2013, 1, 28], 'years', true), -1, 'Feb 29 2012 to Feb 28 2013 should be 1-(1 / 28.5) / 12 years');
});
+ test('negative zero', function (assert) {
+ function isNegative (n) {
+ return (1 / n) < 0;
+ }
+ assert.ok(!isNegative(moment([2012, 0, 1]).diff(moment([2012, 0, 1]), 'months')), 'month diff on same date is zero, not -0');
+ assert.ok(!isNegative(moment([2012, 0, 1]).diff(moment([2012, 0, 1]), 'years')), 'year diff on same date is zero, not -0');
+ assert.ok(!isNegative(moment([2012, 0, 1]).diff(moment([2012, 0, 1]), 'quarters')), 'quarter diff on same date is zero, not -0');
+ });
+
}));
;(function (global, factory) {
@@ -37798,6 +54135,224 @@
typeof define === 'function' && define.amd ? define(['../../moment'], factory) :
factory(global.moment)
}(this, function (moment) { 'use strict';
+
+ function each(array, callback) {
+ var i;
+ for (i = 0; i < array.length; i++) {
+ callback(array[i], i, array);
+ }
+ }
+
+ function objectKeys(obj) {
+ if (Object.keys) {
+ return Object.keys(obj);
+ } else {
+ // IE8
+ var res = [], i;
+ for (i in obj) {
+ if (obj.hasOwnProperty(i)) {
+ res.push(i);
+ }
+ }
+ return res;
+ }
+ }
+
+ // Pick the first defined of two or three arguments.
+ function defaults(a, b, c) {
+ if (a != null) {
+ return a;
+ }
+ if (b != null) {
+ return b;
+ }
+ return c;
+ }
+
+ function defineCommonLocaleTests(locale, options) {
+ test('lenient ordinal parsing', function (assert) {
+ var i, ordinalStr, testMoment;
+ for (i = 1; i <= 31; ++i) {
+ ordinalStr = moment([2014, 0, i]).format('YYYY MM Do');
+ testMoment = moment(ordinalStr, 'YYYY MM Do');
+ assert.equal(testMoment.year(), 2014,
+ 'lenient ordinal parsing ' + i + ' year check');
+ assert.equal(testMoment.month(), 0,
+ 'lenient ordinal parsing ' + i + ' month check');
+ assert.equal(testMoment.date(), i,
+ 'lenient ordinal parsing ' + i + ' date check');
+ }
+ });
+
+ test('lenient ordinal parsing of number', function (assert) {
+ var i, testMoment;
+ for (i = 1; i <= 31; ++i) {
+ testMoment = moment('2014 01 ' + i, 'YYYY MM Do');
+ assert.equal(testMoment.year(), 2014,
+ 'lenient ordinal parsing of number ' + i + ' year check');
+ assert.equal(testMoment.month(), 0,
+ 'lenient ordinal parsing of number ' + i + ' month check');
+ assert.equal(testMoment.date(), i,
+ 'lenient ordinal parsing of number ' + i + ' date check');
+ }
+ });
+
+ test('strict ordinal parsing', function (assert) {
+ var i, ordinalStr, testMoment;
+ for (i = 1; i <= 31; ++i) {
+ ordinalStr = moment([2014, 0, i]).format('YYYY MM Do');
+ testMoment = moment(ordinalStr, 'YYYY MM Do', true);
+ assert.ok(testMoment.isValid(), 'strict ordinal parsing ' + i);
+ }
+ });
+
+ test('meridiem invariant', function (assert) {
+ var h, m, t1, t2;
+ for (h = 0; h < 24; ++h) {
+ for (m = 0; m < 60; m += 15) {
+ t1 = moment.utc([2000, 0, 1, h, m]);
+ t2 = moment.utc(t1.format('A h:mm'), 'A h:mm');
+ assert.equal(t2.format('HH:mm'), t1.format('HH:mm'),
+ 'meridiem at ' + t1.format('HH:mm'));
+ }
+ }
+ });
+
+ test('date format correctness', function (assert) {
+ var data, tokens;
+ data = moment.localeData()._longDateFormat;
+ tokens = objectKeys(data);
+ each(tokens, function (srchToken) {
+ // Check each format string to make sure it does not contain any
+ // tokens that need to be expanded.
+ each(tokens, function (baseToken) {
+ // strip escaped sequences
+ var format = data[baseToken].replace(/(\[[^\]]*\])/g, '');
+ assert.equal(false, !!~format.indexOf(srchToken),
+ 'contains ' + srchToken + ' in ' + baseToken);
+ });
+ });
+ });
+
+ test('month parsing correctness', function (assert) {
+ var i, m;
+
+ if (locale === 'tr') {
+ // I can't fix it :(
+ expect(0);
+ return;
+ }
+ function tester(format) {
+ var r;
+ r = moment(m.format(format), format);
+ assert.equal(r.month(), m.month(), 'month ' + i + ' fmt ' + format);
+ r = moment(m.format(format).toLocaleUpperCase(), format);
+ assert.equal(r.month(), m.month(), 'month ' + i + ' fmt ' + format + ' upper');
+ r = moment(m.format(format).toLocaleLowerCase(), format);
+ assert.equal(r.month(), m.month(), 'month ' + i + ' fmt ' + format + ' lower');
+
+ r = moment(m.format(format), format, true);
+ assert.equal(r.month(), m.month(), 'month ' + i + ' fmt ' + format + ' strict');
+ r = moment(m.format(format).toLocaleUpperCase(), format, true);
+ assert.equal(r.month(), m.month(), 'month ' + i + ' fmt ' + format + ' upper strict');
+ r = moment(m.format(format).toLocaleLowerCase(), format, true);
+ assert.equal(r.month(), m.month(), 'month ' + i + ' fmt ' + format + ' lower strict');
+ }
+
+ for (i = 0; i < 12; ++i) {
+ m = moment([2015, i, 15, 18]);
+ tester('MMM');
+ tester('MMM.');
+ tester('MMMM');
+ tester('MMMM.');
+ }
+ });
+
+ test('weekday parsing correctness', function (assert) {
+ var i, m;
+
+ if (locale === 'tr' || locale === 'az') {
+ // There is a lower-case letter (ı), that converted to upper then
+ // lower changes to i
+ expect(0);
+ return;
+ }
+ function tester(format) {
+ var r, baseMsg = 'weekday ' + m.weekday() + ' fmt ' + format;
+ r = moment(m.format(format), format);
+ assert.equal(r.weekday(), m.weekday(), baseMsg);
+ r = moment(m.format(format).toLocaleUpperCase(), format);
+ assert.equal(r.weekday(), m.weekday(), baseMsg + ' upper');
+ r = moment(m.format(format).toLocaleLowerCase(), format);
+ assert.equal(r.weekday(), m.weekday(), baseMsg + ' lower');
+
+ r = moment(m.format(format), format, true);
+ assert.equal(r.weekday(), m.weekday(), baseMsg + ' strict');
+ r = moment(m.format(format).toLocaleUpperCase(), format, true);
+ assert.equal(r.weekday(), m.weekday(), baseMsg + ' upper strict');
+ r = moment(m.format(format).toLocaleLowerCase(), format, true);
+ assert.equal(r.weekday(), m.weekday(), baseMsg + ' lower strict');
+ }
+
+ for (i = 0; i < 7; ++i) {
+ m = moment.utc([2015, i, 15, 18]);
+ tester('dd');
+ tester('ddd');
+ tester('dddd');
+ }
+ });
+ }
+
+ function setupDeprecationHandler(test, moment, scope) {
+ test._expectedDeprecations = null;
+ test._observedDeprecations = null;
+ test._oldSupress = moment.suppressDeprecationWarnings;
+ moment.suppressDeprecationWarnings = true;
+ test.expectedDeprecations = function () {
+ test._expectedDeprecations = arguments;
+ test._observedDeprecations = [];
+ };
+ moment.deprecationHandler = function (name, msg) {
+ var deprecationId = matchedDeprecation(name, msg, test._expectedDeprecations);
+ if (deprecationId === -1) {
+ throw new Error('Unexpected deprecation thrown name=' +
+ name + ' msg=' + msg);
+ }
+ test._observedDeprecations[deprecationId] = 1;
+ };
+ }
+
+ function teardownDeprecationHandler(test, moment, scope) {
+ moment.suppressDeprecationWarnings = test._oldSupress;
+
+ if (test._expectedDeprecations != null) {
+ var missedDeprecations = [];
+ each(test._expectedDeprecations, function (deprecationPattern, id) {
+ if (test._observedDeprecations[id] !== 1) {
+ missedDeprecations.push(deprecationPattern);
+ }
+ });
+ if (missedDeprecations.length !== 0) {
+ throw new Error('Expected deprecation warnings did not happen: ' +
+ missedDeprecations.join(' '));
+ }
+ }
+ }
+
+ function matchedDeprecation(name, msg, deprecations) {
+ if (deprecations == null) {
+ return -1;
+ }
+ for (var i = 0; i < deprecations.length; ++i) {
+ if (name != null && name === deprecations[i]) {
+ return i;
+ }
+ if (msg != null && msg.substring(0, deprecations[i].length) === deprecations[i]) {
+ return i;
+ }
+ }
+ return -1;
+ }
/*global QUnit:false*/
@@ -37812,11 +54367,13 @@
moment.createFromInputFallback = function (config) {
throw new Error('input not handled by moment: ' + config._i);
};
+ setupDeprecationHandler(test, moment, 'core');
if (lifecycle && lifecycle.setup) {
lifecycle.setup();
}
},
teardown : function () {
+ teardownDeprecationHandler(test, moment, 'core');
if (lifecycle && lifecycle.teardown) {
lifecycle.teardown();
}
@@ -37831,17 +54388,20 @@
moment.createFromInputFallback = function (config) {
throw new Error('input not handled by moment: ' + config._i);
};
+ setupDeprecationHandler(test, moment, 'locale');
if (lifecycle && lifecycle.setup) {
lifecycle.setup();
}
},
teardown : function () {
moment.locale('en');
+ teardownDeprecationHandler(test, moment, 'locale');
if (lifecycle && lifecycle.teardown) {
lifecycle.teardown();
}
}
});
+ defineCommonLocaleTests(name, -1, -1);
}
module('duration');
@@ -38093,6 +54653,7 @@
test('instantiation from ISO 8601 duration', function (assert) {
assert.equal(moment.duration('P1Y2M3DT4H5M6S').asSeconds(), moment.duration({y: 1, M: 2, d: 3, h: 4, m: 5, s: 6}).asSeconds(), 'all fields');
+ assert.equal(moment.duration('P3W3D').asSeconds(), moment.duration({w: 3, d: 3}).asSeconds(), 'week and day fields');
assert.equal(moment.duration('P1M').asSeconds(), moment.duration({M: 1}).asSeconds(), 'single month field');
assert.equal(moment.duration('PT1M').asSeconds(), moment.duration({m: 1}).asSeconds(), 'single minute field');
assert.equal(moment.duration('P1MT2H').asSeconds(), moment.duration({M: 1, h: 2}).asSeconds(), 'random fields missing');
@@ -38122,6 +54683,8 @@
});
test('toIsoString deprecation', function (assert) {
+ test.expectedDeprecations('toIsoString()');
+
assert.equal(moment.duration({}).toIsoString(), moment.duration({}).toISOString(), 'toIsoString delegates to toISOString');
});
@@ -38150,6 +54713,12 @@
assert.equal(moment.duration('-P2Y').asSeconds(), moment.duration({y: -2}).asSeconds(), 'python isodate 22');
assert.equal(moment.duration('-P3Y6M4DT12H30M5S').asSeconds(), moment.duration({y: -3, M: -6, d: -4, h: -12, m: -30, s: -5}).asSeconds(), 'python isodate 23');
assert.equal(moment.duration('-P1DT2H3M4S').asSeconds(), moment.duration({d: -1, h: -2, m: -3, s: -4}).asSeconds(), 'python isodate 24');
+ assert.equal(moment.duration('PT-6H3M').asSeconds(), moment.duration({h: -6, m: 3}).asSeconds(), 'python isodate 25');
+ assert.equal(moment.duration('-PT-6H3M').asSeconds(), moment.duration({h: 6, m: -3}).asSeconds(), 'python isodate 26');
+ assert.equal(moment.duration('-P-3Y-6M-4DT-12H-30M-5S').asSeconds(), moment.duration({y: 3, M: 6, d: 4, h: 12, m: 30, s: 5}).asSeconds(), 'python isodate 27');
+ assert.equal(moment.duration('P-3Y-6M-4DT-12H-30M-5S').asSeconds(), moment.duration({y: -3, M: -6, d: -4, h: -12, m: -30, s: -5}).asSeconds(), 'python isodate 28');
+ assert.equal(moment.duration('-P-2W').asSeconds(), moment.duration({w: 2}).asSeconds(), 'python isodate 29');
+ assert.equal(moment.duration('P-2W').asSeconds(), moment.duration({w: -2}).asSeconds(), 'python isodate 30');
});
test('ISO 8601 misuse cases', function (assert) {
@@ -38160,7 +54729,6 @@
assert.equal(moment.duration('PT.5S').asSeconds(), 0.5, 'accept no leading zero for decimal');
assert.equal(moment.duration('PT1,S').asSeconds(), 1, 'accept trailing decimal separator');
assert.equal(moment.duration('PT1M0,,5S').asSeconds(), 60, 'extra decimal separators are ignored as 0');
- assert.equal(moment.duration('P-1DS').asSeconds(), 0, 'wrong position of negative');
});
test('humanize', function (assert) {
@@ -38383,6 +54951,13 @@
assert.equal(dm.asMinutes(), 13, 'asMinutes()');
});
+ test('minutes getter for floating point hours', function (assert) {
+ // Tests for issue #2978.
+ // For certain floating point hours, .minutes() getter produced incorrect values due to the rounding errors
+ assert.equal(moment.duration(2.3, 'h').minutes(), 18, 'minutes()');
+ assert.equal(moment.duration(4.1, 'h').minutes(), 6, 'minutes()');
+ });
+
test('isDuration', function (assert) {
assert.ok(moment.isDuration(moment.duration(12345678)), 'correctly says true');
assert.ok(!moment.isDuration(moment()), 'moment object is not a duration');
@@ -38481,6 +55056,224 @@
factory(global.moment)
}(this, function (moment) { 'use strict';
+ function each(array, callback) {
+ var i;
+ for (i = 0; i < array.length; i++) {
+ callback(array[i], i, array);
+ }
+ }
+
+ function objectKeys(obj) {
+ if (Object.keys) {
+ return Object.keys(obj);
+ } else {
+ // IE8
+ var res = [], i;
+ for (i in obj) {
+ if (obj.hasOwnProperty(i)) {
+ res.push(i);
+ }
+ }
+ return res;
+ }
+ }
+
+ // Pick the first defined of two or three arguments.
+ function defaults(a, b, c) {
+ if (a != null) {
+ return a;
+ }
+ if (b != null) {
+ return b;
+ }
+ return c;
+ }
+
+ function defineCommonLocaleTests(locale, options) {
+ test('lenient ordinal parsing', function (assert) {
+ var i, ordinalStr, testMoment;
+ for (i = 1; i <= 31; ++i) {
+ ordinalStr = moment([2014, 0, i]).format('YYYY MM Do');
+ testMoment = moment(ordinalStr, 'YYYY MM Do');
+ assert.equal(testMoment.year(), 2014,
+ 'lenient ordinal parsing ' + i + ' year check');
+ assert.equal(testMoment.month(), 0,
+ 'lenient ordinal parsing ' + i + ' month check');
+ assert.equal(testMoment.date(), i,
+ 'lenient ordinal parsing ' + i + ' date check');
+ }
+ });
+
+ test('lenient ordinal parsing of number', function (assert) {
+ var i, testMoment;
+ for (i = 1; i <= 31; ++i) {
+ testMoment = moment('2014 01 ' + i, 'YYYY MM Do');
+ assert.equal(testMoment.year(), 2014,
+ 'lenient ordinal parsing of number ' + i + ' year check');
+ assert.equal(testMoment.month(), 0,
+ 'lenient ordinal parsing of number ' + i + ' month check');
+ assert.equal(testMoment.date(), i,
+ 'lenient ordinal parsing of number ' + i + ' date check');
+ }
+ });
+
+ test('strict ordinal parsing', function (assert) {
+ var i, ordinalStr, testMoment;
+ for (i = 1; i <= 31; ++i) {
+ ordinalStr = moment([2014, 0, i]).format('YYYY MM Do');
+ testMoment = moment(ordinalStr, 'YYYY MM Do', true);
+ assert.ok(testMoment.isValid(), 'strict ordinal parsing ' + i);
+ }
+ });
+
+ test('meridiem invariant', function (assert) {
+ var h, m, t1, t2;
+ for (h = 0; h < 24; ++h) {
+ for (m = 0; m < 60; m += 15) {
+ t1 = moment.utc([2000, 0, 1, h, m]);
+ t2 = moment.utc(t1.format('A h:mm'), 'A h:mm');
+ assert.equal(t2.format('HH:mm'), t1.format('HH:mm'),
+ 'meridiem at ' + t1.format('HH:mm'));
+ }
+ }
+ });
+
+ test('date format correctness', function (assert) {
+ var data, tokens;
+ data = moment.localeData()._longDateFormat;
+ tokens = objectKeys(data);
+ each(tokens, function (srchToken) {
+ // Check each format string to make sure it does not contain any
+ // tokens that need to be expanded.
+ each(tokens, function (baseToken) {
+ // strip escaped sequences
+ var format = data[baseToken].replace(/(\[[^\]]*\])/g, '');
+ assert.equal(false, !!~format.indexOf(srchToken),
+ 'contains ' + srchToken + ' in ' + baseToken);
+ });
+ });
+ });
+
+ test('month parsing correctness', function (assert) {
+ var i, m;
+
+ if (locale === 'tr') {
+ // I can't fix it :(
+ expect(0);
+ return;
+ }
+ function tester(format) {
+ var r;
+ r = moment(m.format(format), format);
+ assert.equal(r.month(), m.month(), 'month ' + i + ' fmt ' + format);
+ r = moment(m.format(format).toLocaleUpperCase(), format);
+ assert.equal(r.month(), m.month(), 'month ' + i + ' fmt ' + format + ' upper');
+ r = moment(m.format(format).toLocaleLowerCase(), format);
+ assert.equal(r.month(), m.month(), 'month ' + i + ' fmt ' + format + ' lower');
+
+ r = moment(m.format(format), format, true);
+ assert.equal(r.month(), m.month(), 'month ' + i + ' fmt ' + format + ' strict');
+ r = moment(m.format(format).toLocaleUpperCase(), format, true);
+ assert.equal(r.month(), m.month(), 'month ' + i + ' fmt ' + format + ' upper strict');
+ r = moment(m.format(format).toLocaleLowerCase(), format, true);
+ assert.equal(r.month(), m.month(), 'month ' + i + ' fmt ' + format + ' lower strict');
+ }
+
+ for (i = 0; i < 12; ++i) {
+ m = moment([2015, i, 15, 18]);
+ tester('MMM');
+ tester('MMM.');
+ tester('MMMM');
+ tester('MMMM.');
+ }
+ });
+
+ test('weekday parsing correctness', function (assert) {
+ var i, m;
+
+ if (locale === 'tr' || locale === 'az') {
+ // There is a lower-case letter (ı), that converted to upper then
+ // lower changes to i
+ expect(0);
+ return;
+ }
+ function tester(format) {
+ var r, baseMsg = 'weekday ' + m.weekday() + ' fmt ' + format;
+ r = moment(m.format(format), format);
+ assert.equal(r.weekday(), m.weekday(), baseMsg);
+ r = moment(m.format(format).toLocaleUpperCase(), format);
+ assert.equal(r.weekday(), m.weekday(), baseMsg + ' upper');
+ r = moment(m.format(format).toLocaleLowerCase(), format);
+ assert.equal(r.weekday(), m.weekday(), baseMsg + ' lower');
+
+ r = moment(m.format(format), format, true);
+ assert.equal(r.weekday(), m.weekday(), baseMsg + ' strict');
+ r = moment(m.format(format).toLocaleUpperCase(), format, true);
+ assert.equal(r.weekday(), m.weekday(), baseMsg + ' upper strict');
+ r = moment(m.format(format).toLocaleLowerCase(), format, true);
+ assert.equal(r.weekday(), m.weekday(), baseMsg + ' lower strict');
+ }
+
+ for (i = 0; i < 7; ++i) {
+ m = moment.utc([2015, i, 15, 18]);
+ tester('dd');
+ tester('ddd');
+ tester('dddd');
+ }
+ });
+ }
+
+ function setupDeprecationHandler(test, moment, scope) {
+ test._expectedDeprecations = null;
+ test._observedDeprecations = null;
+ test._oldSupress = moment.suppressDeprecationWarnings;
+ moment.suppressDeprecationWarnings = true;
+ test.expectedDeprecations = function () {
+ test._expectedDeprecations = arguments;
+ test._observedDeprecations = [];
+ };
+ moment.deprecationHandler = function (name, msg) {
+ var deprecationId = matchedDeprecation(name, msg, test._expectedDeprecations);
+ if (deprecationId === -1) {
+ throw new Error('Unexpected deprecation thrown name=' +
+ name + ' msg=' + msg);
+ }
+ test._observedDeprecations[deprecationId] = 1;
+ };
+ }
+
+ function teardownDeprecationHandler(test, moment, scope) {
+ moment.suppressDeprecationWarnings = test._oldSupress;
+
+ if (test._expectedDeprecations != null) {
+ var missedDeprecations = [];
+ each(test._expectedDeprecations, function (deprecationPattern, id) {
+ if (test._observedDeprecations[id] !== 1) {
+ missedDeprecations.push(deprecationPattern);
+ }
+ });
+ if (missedDeprecations.length !== 0) {
+ throw new Error('Expected deprecation warnings did not happen: ' +
+ missedDeprecations.join(' '));
+ }
+ }
+ }
+
+ function matchedDeprecation(name, msg, deprecations) {
+ if (deprecations == null) {
+ return -1;
+ }
+ for (var i = 0; i < deprecations.length; ++i) {
+ if (name != null && name === deprecations[i]) {
+ return i;
+ }
+ if (msg != null && msg.substring(0, deprecations[i].length) === deprecations[i]) {
+ return i;
+ }
+ }
+ return -1;
+ }
+
/*global QUnit:false*/
var test = QUnit.test;
@@ -38494,11 +55287,13 @@
moment.createFromInputFallback = function (config) {
throw new Error('input not handled by moment: ' + config._i);
};
+ setupDeprecationHandler(test, moment, 'core');
if (lifecycle && lifecycle.setup) {
lifecycle.setup();
}
},
teardown : function () {
+ teardownDeprecationHandler(test, moment, 'core');
if (lifecycle && lifecycle.teardown) {
lifecycle.teardown();
}
@@ -38513,17 +55308,20 @@
moment.createFromInputFallback = function (config) {
throw new Error('input not handled by moment: ' + config._i);
};
+ setupDeprecationHandler(test, moment, 'locale');
if (lifecycle && lifecycle.setup) {
lifecycle.setup();
}
},
teardown : function () {
moment.locale('en');
+ teardownDeprecationHandler(test, moment, 'locale');
if (lifecycle && lifecycle.teardown) {
lifecycle.teardown();
}
}
});
+ defineCommonLocaleTests(name, -1, -1);
}
module('duration from moments');
@@ -38577,6 +55375,224 @@
typeof define === 'function' && define.amd ? define(['../../moment'], factory) :
factory(global.moment)
}(this, function (moment) { 'use strict';
+
+ function each(array, callback) {
+ var i;
+ for (i = 0; i < array.length; i++) {
+ callback(array[i], i, array);
+ }
+ }
+
+ function objectKeys(obj) {
+ if (Object.keys) {
+ return Object.keys(obj);
+ } else {
+ // IE8
+ var res = [], i;
+ for (i in obj) {
+ if (obj.hasOwnProperty(i)) {
+ res.push(i);
+ }
+ }
+ return res;
+ }
+ }
+
+ // Pick the first defined of two or three arguments.
+ function defaults(a, b, c) {
+ if (a != null) {
+ return a;
+ }
+ if (b != null) {
+ return b;
+ }
+ return c;
+ }
+
+ function defineCommonLocaleTests(locale, options) {
+ test('lenient ordinal parsing', function (assert) {
+ var i, ordinalStr, testMoment;
+ for (i = 1; i <= 31; ++i) {
+ ordinalStr = moment([2014, 0, i]).format('YYYY MM Do');
+ testMoment = moment(ordinalStr, 'YYYY MM Do');
+ assert.equal(testMoment.year(), 2014,
+ 'lenient ordinal parsing ' + i + ' year check');
+ assert.equal(testMoment.month(), 0,
+ 'lenient ordinal parsing ' + i + ' month check');
+ assert.equal(testMoment.date(), i,
+ 'lenient ordinal parsing ' + i + ' date check');
+ }
+ });
+
+ test('lenient ordinal parsing of number', function (assert) {
+ var i, testMoment;
+ for (i = 1; i <= 31; ++i) {
+ testMoment = moment('2014 01 ' + i, 'YYYY MM Do');
+ assert.equal(testMoment.year(), 2014,
+ 'lenient ordinal parsing of number ' + i + ' year check');
+ assert.equal(testMoment.month(), 0,
+ 'lenient ordinal parsing of number ' + i + ' month check');
+ assert.equal(testMoment.date(), i,
+ 'lenient ordinal parsing of number ' + i + ' date check');
+ }
+ });
+
+ test('strict ordinal parsing', function (assert) {
+ var i, ordinalStr, testMoment;
+ for (i = 1; i <= 31; ++i) {
+ ordinalStr = moment([2014, 0, i]).format('YYYY MM Do');
+ testMoment = moment(ordinalStr, 'YYYY MM Do', true);
+ assert.ok(testMoment.isValid(), 'strict ordinal parsing ' + i);
+ }
+ });
+
+ test('meridiem invariant', function (assert) {
+ var h, m, t1, t2;
+ for (h = 0; h < 24; ++h) {
+ for (m = 0; m < 60; m += 15) {
+ t1 = moment.utc([2000, 0, 1, h, m]);
+ t2 = moment.utc(t1.format('A h:mm'), 'A h:mm');
+ assert.equal(t2.format('HH:mm'), t1.format('HH:mm'),
+ 'meridiem at ' + t1.format('HH:mm'));
+ }
+ }
+ });
+
+ test('date format correctness', function (assert) {
+ var data, tokens;
+ data = moment.localeData()._longDateFormat;
+ tokens = objectKeys(data);
+ each(tokens, function (srchToken) {
+ // Check each format string to make sure it does not contain any
+ // tokens that need to be expanded.
+ each(tokens, function (baseToken) {
+ // strip escaped sequences
+ var format = data[baseToken].replace(/(\[[^\]]*\])/g, '');
+ assert.equal(false, !!~format.indexOf(srchToken),
+ 'contains ' + srchToken + ' in ' + baseToken);
+ });
+ });
+ });
+
+ test('month parsing correctness', function (assert) {
+ var i, m;
+
+ if (locale === 'tr') {
+ // I can't fix it :(
+ expect(0);
+ return;
+ }
+ function tester(format) {
+ var r;
+ r = moment(m.format(format), format);
+ assert.equal(r.month(), m.month(), 'month ' + i + ' fmt ' + format);
+ r = moment(m.format(format).toLocaleUpperCase(), format);
+ assert.equal(r.month(), m.month(), 'month ' + i + ' fmt ' + format + ' upper');
+ r = moment(m.format(format).toLocaleLowerCase(), format);
+ assert.equal(r.month(), m.month(), 'month ' + i + ' fmt ' + format + ' lower');
+
+ r = moment(m.format(format), format, true);
+ assert.equal(r.month(), m.month(), 'month ' + i + ' fmt ' + format + ' strict');
+ r = moment(m.format(format).toLocaleUpperCase(), format, true);
+ assert.equal(r.month(), m.month(), 'month ' + i + ' fmt ' + format + ' upper strict');
+ r = moment(m.format(format).toLocaleLowerCase(), format, true);
+ assert.equal(r.month(), m.month(), 'month ' + i + ' fmt ' + format + ' lower strict');
+ }
+
+ for (i = 0; i < 12; ++i) {
+ m = moment([2015, i, 15, 18]);
+ tester('MMM');
+ tester('MMM.');
+ tester('MMMM');
+ tester('MMMM.');
+ }
+ });
+
+ test('weekday parsing correctness', function (assert) {
+ var i, m;
+
+ if (locale === 'tr' || locale === 'az') {
+ // There is a lower-case letter (ı), that converted to upper then
+ // lower changes to i
+ expect(0);
+ return;
+ }
+ function tester(format) {
+ var r, baseMsg = 'weekday ' + m.weekday() + ' fmt ' + format;
+ r = moment(m.format(format), format);
+ assert.equal(r.weekday(), m.weekday(), baseMsg);
+ r = moment(m.format(format).toLocaleUpperCase(), format);
+ assert.equal(r.weekday(), m.weekday(), baseMsg + ' upper');
+ r = moment(m.format(format).toLocaleLowerCase(), format);
+ assert.equal(r.weekday(), m.weekday(), baseMsg + ' lower');
+
+ r = moment(m.format(format), format, true);
+ assert.equal(r.weekday(), m.weekday(), baseMsg + ' strict');
+ r = moment(m.format(format).toLocaleUpperCase(), format, true);
+ assert.equal(r.weekday(), m.weekday(), baseMsg + ' upper strict');
+ r = moment(m.format(format).toLocaleLowerCase(), format, true);
+ assert.equal(r.weekday(), m.weekday(), baseMsg + ' lower strict');
+ }
+
+ for (i = 0; i < 7; ++i) {
+ m = moment.utc([2015, i, 15, 18]);
+ tester('dd');
+ tester('ddd');
+ tester('dddd');
+ }
+ });
+ }
+
+ function setupDeprecationHandler(test, moment, scope) {
+ test._expectedDeprecations = null;
+ test._observedDeprecations = null;
+ test._oldSupress = moment.suppressDeprecationWarnings;
+ moment.suppressDeprecationWarnings = true;
+ test.expectedDeprecations = function () {
+ test._expectedDeprecations = arguments;
+ test._observedDeprecations = [];
+ };
+ moment.deprecationHandler = function (name, msg) {
+ var deprecationId = matchedDeprecation(name, msg, test._expectedDeprecations);
+ if (deprecationId === -1) {
+ throw new Error('Unexpected deprecation thrown name=' +
+ name + ' msg=' + msg);
+ }
+ test._observedDeprecations[deprecationId] = 1;
+ };
+ }
+
+ function teardownDeprecationHandler(test, moment, scope) {
+ moment.suppressDeprecationWarnings = test._oldSupress;
+
+ if (test._expectedDeprecations != null) {
+ var missedDeprecations = [];
+ each(test._expectedDeprecations, function (deprecationPattern, id) {
+ if (test._observedDeprecations[id] !== 1) {
+ missedDeprecations.push(deprecationPattern);
+ }
+ });
+ if (missedDeprecations.length !== 0) {
+ throw new Error('Expected deprecation warnings did not happen: ' +
+ missedDeprecations.join(' '));
+ }
+ }
+ }
+
+ function matchedDeprecation(name, msg, deprecations) {
+ if (deprecations == null) {
+ return -1;
+ }
+ for (var i = 0; i < deprecations.length; ++i) {
+ if (name != null && name === deprecations[i]) {
+ return i;
+ }
+ if (msg != null && msg.substring(0, deprecations[i].length) === deprecations[i]) {
+ return i;
+ }
+ }
+ return -1;
+ }
/*global QUnit:false*/
@@ -38591,11 +55607,13 @@
moment.createFromInputFallback = function (config) {
throw new Error('input not handled by moment: ' + config._i);
};
+ setupDeprecationHandler(test, moment, 'core');
if (lifecycle && lifecycle.setup) {
lifecycle.setup();
}
},
teardown : function () {
+ teardownDeprecationHandler(test, moment, 'core');
if (lifecycle && lifecycle.teardown) {
lifecycle.teardown();
}
@@ -38610,17 +55628,20 @@
moment.createFromInputFallback = function (config) {
throw new Error('input not handled by moment: ' + config._i);
};
+ setupDeprecationHandler(test, moment, 'locale');
if (lifecycle && lifecycle.setup) {
lifecycle.setup();
}
},
teardown : function () {
moment.locale('en');
+ teardownDeprecationHandler(test, moment, 'locale');
if (lifecycle && lifecycle.teardown) {
lifecycle.teardown();
}
}
});
+ defineCommonLocaleTests(name, -1, -1);
}
module('format');
@@ -38735,6 +55756,11 @@
test('default format', function (assert) {
var isoRegex = /\d{4}.\d\d.\d\dT\d\d.\d\d.\d\d[\+\-]\d\d:\d\d/;
assert.ok(isoRegex.exec(moment().format()), 'default format (' + moment().format() + ') should match ISO');
+ });
+
+ test('default UTC format', function (assert) {
+ var isoRegex = /\d{4}.\d\d.\d\dT\d\d.\d\d.\d\dZ/;
+ assert.ok(isoRegex.exec(moment.utc().format()), 'default UTC format (' + moment.utc().format() + ') should match ISO');
});
test('toJSON', function (assert) {
@@ -38863,7 +55889,7 @@
'405-12-31': '0405-52'
}, i, isoWeekYear, formatted5, formatted4, formatted2;
- moment.locale('dow:1,doy:4', {week: {dow: 1, doy: 4}});
+ moment.defineLocale('dow:1,doy:4', {week: {dow: 1, doy: 4}});
for (i in cases) {
isoWeekYear = cases[i].split('-')[0];
@@ -38874,6 +55900,7 @@
formatted2 = moment(i, 'YYYY-MM-DD').format('gg');
assert.equal(isoWeekYear.slice(2, 4), formatted2, i + ': gg should be ' + isoWeekYear + ', but ' + formatted2);
}
+ moment.defineLocale('dow:1,doy:4', null);
});
test('iso weekday formats', function (assert) {
@@ -38887,7 +55914,7 @@
});
test('weekday formats', function (assert) {
- moment.locale('dow: 3,doy: 5', {week: {dow: 3, doy: 5}});
+ moment.defineLocale('dow: 3,doy: 5', {week: {dow: 3, doy: 5}});
assert.equal(moment([1985, 1, 6]).format('e'), '0', 'Feb 6 1985 is Wednesday -- 0th day');
assert.equal(moment([2029, 8, 20]).format('e'), '1', 'Sep 20 2029 is Thursday -- 1st day');
assert.equal(moment([2013, 3, 26]).format('e'), '2', 'Apr 26 2013 is Friday -- 2nd day');
@@ -38895,6 +55922,7 @@
assert.equal(moment([1970, 0, 4]).format('e'), '4', 'Jan 4 1970 is Sunday -- 4th day');
assert.equal(moment([2001, 4, 14]).format('e'), '5', 'May 14 2001 is Monday -- 5th day');
assert.equal(moment([2000, 0, 4]).format('e'), '6', 'Jan 4 2000 is Tuesday -- 6th day');
+ moment.defineLocale('dow: 3,doy: 5', null);
});
test('toString is just human readable format', function (assert) {
@@ -38903,13 +55931,13 @@
});
test('toJSON skips postformat', function (assert) {
- moment.locale('postformat', {
+ moment.defineLocale('postformat', {
postformat: function (s) {
s.replace(/./g, 'X');
}
});
assert.equal(moment.utc([2000, 0, 1]).toJSON(), '2000-01-01T00:00:00.000Z', 'toJSON doesn\'t postformat');
- moment.locale('postformat', null);
+ moment.defineLocale('postformat', null);
});
test('calendar day timezone', function (assert) {
@@ -38963,54 +55991,44 @@
assert.equal(moment([2000, 0, 2]).format('Qo [quarter] YYYY'), '1st quarter 2000', 'Jan 2 2000 is 1st quarter');
});
- test('full expanded format is returned from abbreviated formats', function (assert) {
- function forEach(ar, fn) {
- if (ar.forEach) {
- return ar.forEach(fn);
- } else {
- // IE8
- for (var i = 0; i < ar.length; i += 1) {
- fn(ar[i]);
- }
- }
- }
- function objectKeys(obj) {
- if (Object.keys) {
- return Object.keys(obj);
- } else {
- // IE8
- var res = [], i;
- for (i in obj) {
- if (obj.hasOwnProperty(i)) {
- res.push(i);
- }
- }
- return res;
- }
- }
-
- var locales =
- 'ar-sa ar-tn ar az be bg bn bo br bs ca cs cv cy da de-at de dv el ' +
- 'en-au en-ca en-gb en-ie en-nz eo es et eu fa fi fo fr-ca fr-ch fr fy ' +
- 'gd gl he hi hr hu hy-am id is it ja jv ka kk km ko lb lo lt lv me mk ml ' +
- 'mr ms-my ms my nb ne nl nn pl pt-br pt ro ru se si sk sl sq sr-cyrl ' +
- 'sr sv sw ta te th tl-ph tlh tr tzl tzm-latn tzm uk uz vi zh-cn zh-tw';
-
- forEach(locales.split(' '), function (locale) {
- var data, tokens;
- data = moment().locale(locale).localeData()._longDateFormat;
- tokens = objectKeys(data);
- forEach(tokens, function (token) {
- // Check each format string to make sure it does not contain any
- // tokens that need to be expanded.
- forEach(tokens, function (i) {
- // strip escaped sequences
- var format = data[i].replace(/(\[[^\]]*\])/g, '');
- assert.equal(false, !!~format.indexOf(token), 'locale ' + locale + ' contains ' + token + ' in ' + i);
- });
- });
- });
- });
+ // test('full expanded format is returned from abbreviated formats', function (assert) {
+ // function objectKeys(obj) {
+ // if (Object.keys) {
+ // return Object.keys(obj);
+ // } else {
+ // // IE8
+ // var res = [], i;
+ // for (i in obj) {
+ // if (obj.hasOwnProperty(i)) {
+ // res.push(i);
+ // }
+ // }
+ // return res;
+ // }
+ // }
+
+ // var locales =
+ // 'ar-sa ar-tn ar az be bg bn bo br bs ca cs cv cy da de-at de dv el ' +
+ // 'en-au en-ca en-gb en-ie en-nz eo es et eu fa fi fo fr-ca fr-ch fr fy ' +
+ // 'gd gl he hi hr hu hy-am id is it ja jv ka kk km ko lb lo lt lv me mk ml ' +
+ // 'mr ms-my ms my nb ne nl nn pl pt-br pt ro ru se si sk sl sq sr-cyrl ' +
+ // 'sr sv sw ta te th tl-ph tlh tr tzl tzm-latn tzm uk uz vi zh-cn zh-tw';
+
+ // each(locales.split(' '), function (locale) {
+ // var data, tokens;
+ // data = moment().locale(locale).localeData()._longDateFormat;
+ // tokens = objectKeys(data);
+ // each(tokens, function (token) {
+ // // Check each format string to make sure it does not contain any
+ // // tokens that need to be expanded.
+ // each(tokens, function (i) {
+ // // strip escaped sequences
+ // var format = data[i].replace(/(\[[^\]]*\])/g, '');
+ // assert.equal(false, !!~format.indexOf(token), 'locale ' + locale + ' contains ' + token + ' in ' + i);
+ // });
+ // });
+ // });
+ // });
test('milliseconds', function (assert) {
var m = moment('123', 'SSS');
@@ -39047,6 +56065,25 @@
assert.equal(moment('18:34:56', 'HH:mm:ss').format('Hmmss'), '183456');
});
+ test('k and kk', function (assert) {
+ assert.equal(moment('01:23:45', 'HH:mm:ss').format('k'), '1');
+ assert.equal(moment('12:34:56', 'HH:mm:ss').format('k'), '12');
+ assert.equal(moment('01:23:45', 'HH:mm:ss').format('kk'), '01');
+ assert.equal(moment('12:34:56', 'HH:mm:ss').format('kk'), '12');
+ assert.equal(moment('00:34:56', 'HH:mm:ss').format('kk'), '24');
+ assert.equal(moment('00:00:00', 'HH:mm:ss').format('kk'), '24');
+ });
+
+ test('Y token', function (assert) {
+ assert.equal(moment('2010-01-01', 'YYYY-MM-DD', true).format('Y'), '2010', 'format 2010 with Y');
+ assert.equal(moment('-123-01-01', 'Y-MM-DD', true).format('Y'), '-123', 'format -123 with Y');
+ assert.equal(moment('12345-01-01', 'Y-MM-DD', true).format('Y'), '+12345', 'format 12345 with Y');
+ assert.equal(moment('0-01-01', 'Y-MM-DD', true).format('Y'), '0', 'format 0 with Y');
+ assert.equal(moment('1-01-01', 'Y-MM-DD', true).format('Y'), '1', 'format 1 with Y');
+ assert.equal(moment('9999-01-01', 'Y-MM-DD', true).format('Y'), '9999', 'format 9999 with Y');
+ assert.equal(moment('10000-01-01', 'Y-MM-DD', true).format('Y'), '+10000', 'format 10000 with Y');
+ });
+
}));
;(function (global, factory) {
@@ -39055,6 +56092,224 @@
typeof define === 'function' && define.amd ? define(['../../moment'], factory) :
factory(global.moment)
}(this, function (moment) { 'use strict';
+
+ function each(array, callback) {
+ var i;
+ for (i = 0; i < array.length; i++) {
+ callback(array[i], i, array);
+ }
+ }
+
+ function objectKeys(obj) {
+ if (Object.keys) {
+ return Object.keys(obj);
+ } else {
+ // IE8
+ var res = [], i;
+ for (i in obj) {
+ if (obj.hasOwnProperty(i)) {
+ res.push(i);
+ }
+ }
+ return res;
+ }
+ }
+
+ // Pick the first defined of two or three arguments.
+ function defaults(a, b, c) {
+ if (a != null) {
+ return a;
+ }
+ if (b != null) {
+ return b;
+ }
+ return c;
+ }
+
+ function defineCommonLocaleTests(locale, options) {
+ test('lenient ordinal parsing', function (assert) {
+ var i, ordinalStr, testMoment;
+ for (i = 1; i <= 31; ++i) {
+ ordinalStr = moment([2014, 0, i]).format('YYYY MM Do');
+ testMoment = moment(ordinalStr, 'YYYY MM Do');
+ assert.equal(testMoment.year(), 2014,
+ 'lenient ordinal parsing ' + i + ' year check');
+ assert.equal(testMoment.month(), 0,
+ 'lenient ordinal parsing ' + i + ' month check');
+ assert.equal(testMoment.date(), i,
+ 'lenient ordinal parsing ' + i + ' date check');
+ }
+ });
+
+ test('lenient ordinal parsing of number', function (assert) {
+ var i, testMoment;
+ for (i = 1; i <= 31; ++i) {
+ testMoment = moment('2014 01 ' + i, 'YYYY MM Do');
+ assert.equal(testMoment.year(), 2014,
+ 'lenient ordinal parsing of number ' + i + ' year check');
+ assert.equal(testMoment.month(), 0,
+ 'lenient ordinal parsing of number ' + i + ' month check');
+ assert.equal(testMoment.date(), i,
+ 'lenient ordinal parsing of number ' + i + ' date check');
+ }
+ });
+
+ test('strict ordinal parsing', function (assert) {
+ var i, ordinalStr, testMoment;
+ for (i = 1; i <= 31; ++i) {
+ ordinalStr = moment([2014, 0, i]).format('YYYY MM Do');
+ testMoment = moment(ordinalStr, 'YYYY MM Do', true);
+ assert.ok(testMoment.isValid(), 'strict ordinal parsing ' + i);
+ }
+ });
+
+ test('meridiem invariant', function (assert) {
+ var h, m, t1, t2;
+ for (h = 0; h < 24; ++h) {
+ for (m = 0; m < 60; m += 15) {
+ t1 = moment.utc([2000, 0, 1, h, m]);
+ t2 = moment.utc(t1.format('A h:mm'), 'A h:mm');
+ assert.equal(t2.format('HH:mm'), t1.format('HH:mm'),
+ 'meridiem at ' + t1.format('HH:mm'));
+ }
+ }
+ });
+
+ test('date format correctness', function (assert) {
+ var data, tokens;
+ data = moment.localeData()._longDateFormat;
+ tokens = objectKeys(data);
+ each(tokens, function (srchToken) {
+ // Check each format string to make sure it does not contain any
+ // tokens that need to be expanded.
+ each(tokens, function (baseToken) {
+ // strip escaped sequences
+ var format = data[baseToken].replace(/(\[[^\]]*\])/g, '');
+ assert.equal(false, !!~format.indexOf(srchToken),
+ 'contains ' + srchToken + ' in ' + baseToken);
+ });
+ });
+ });
+
+ test('month parsing correctness', function (assert) {
+ var i, m;
+
+ if (locale === 'tr') {
+ // I can't fix it :(
+ expect(0);
+ return;
+ }
+ function tester(format) {
+ var r;
+ r = moment(m.format(format), format);
+ assert.equal(r.month(), m.month(), 'month ' + i + ' fmt ' + format);
+ r = moment(m.format(format).toLocaleUpperCase(), format);
+ assert.equal(r.month(), m.month(), 'month ' + i + ' fmt ' + format + ' upper');
+ r = moment(m.format(format).toLocaleLowerCase(), format);
+ assert.equal(r.month(), m.month(), 'month ' + i + ' fmt ' + format + ' lower');
+
+ r = moment(m.format(format), format, true);
+ assert.equal(r.month(), m.month(), 'month ' + i + ' fmt ' + format + ' strict');
+ r = moment(m.format(format).toLocaleUpperCase(), format, true);
+ assert.equal(r.month(), m.month(), 'month ' + i + ' fmt ' + format + ' upper strict');
+ r = moment(m.format(format).toLocaleLowerCase(), format, true);
+ assert.equal(r.month(), m.month(), 'month ' + i + ' fmt ' + format + ' lower strict');
+ }
+
+ for (i = 0; i < 12; ++i) {
+ m = moment([2015, i, 15, 18]);
+ tester('MMM');
+ tester('MMM.');
+ tester('MMMM');
+ tester('MMMM.');
+ }
+ });
+
+ test('weekday parsing correctness', function (assert) {
+ var i, m;
+
+ if (locale === 'tr' || locale === 'az') {
+ // There is a lower-case letter (ı), that converted to upper then
+ // lower changes to i
+ expect(0);
+ return;
+ }
+ function tester(format) {
+ var r, baseMsg = 'weekday ' + m.weekday() + ' fmt ' + format;
+ r = moment(m.format(format), format);
+ assert.equal(r.weekday(), m.weekday(), baseMsg);
+ r = moment(m.format(format).toLocaleUpperCase(), format);
+ assert.equal(r.weekday(), m.weekday(), baseMsg + ' upper');
+ r = moment(m.format(format).toLocaleLowerCase(), format);
+ assert.equal(r.weekday(), m.weekday(), baseMsg + ' lower');
+
+ r = moment(m.format(format), format, true);
+ assert.equal(r.weekday(), m.weekday(), baseMsg + ' strict');
+ r = moment(m.format(format).toLocaleUpperCase(), format, true);
+ assert.equal(r.weekday(), m.weekday(), baseMsg + ' upper strict');
+ r = moment(m.format(format).toLocaleLowerCase(), format, true);
+ assert.equal(r.weekday(), m.weekday(), baseMsg + ' lower strict');
+ }
+
+ for (i = 0; i < 7; ++i) {
+ m = moment.utc([2015, i, 15, 18]);
+ tester('dd');
+ tester('ddd');
+ tester('dddd');
+ }
+ });
+ }
+
+ function setupDeprecationHandler(test, moment, scope) {
+ test._expectedDeprecations = null;
+ test._observedDeprecations = null;
+ test._oldSupress = moment.suppressDeprecationWarnings;
+ moment.suppressDeprecationWarnings = true;
+ test.expectedDeprecations = function () {
+ test._expectedDeprecations = arguments;
+ test._observedDeprecations = [];
+ };
+ moment.deprecationHandler = function (name, msg) {
+ var deprecationId = matchedDeprecation(name, msg, test._expectedDeprecations);
+ if (deprecationId === -1) {
+ throw new Error('Unexpected deprecation thrown name=' +
+ name + ' msg=' + msg);
+ }
+ test._observedDeprecations[deprecationId] = 1;
+ };
+ }
+
+ function teardownDeprecationHandler(test, moment, scope) {
+ moment.suppressDeprecationWarnings = test._oldSupress;
+
+ if (test._expectedDeprecations != null) {
+ var missedDeprecations = [];
+ each(test._expectedDeprecations, function (deprecationPattern, id) {
+ if (test._observedDeprecations[id] !== 1) {
+ missedDeprecations.push(deprecationPattern);
+ }
+ });
+ if (missedDeprecations.length !== 0) {
+ throw new Error('Expected deprecation warnings did not happen: ' +
+ missedDeprecations.join(' '));
+ }
+ }
+ }
+
+ function matchedDeprecation(name, msg, deprecations) {
+ if (deprecations == null) {
+ return -1;
+ }
+ for (var i = 0; i < deprecations.length; ++i) {
+ if (name != null && name === deprecations[i]) {
+ return i;
+ }
+ if (msg != null && msg.substring(0, deprecations[i].length) === deprecations[i]) {
+ return i;
+ }
+ }
+ return -1;
+ }
/*global QUnit:false*/
@@ -39069,11 +56324,13 @@
moment.createFromInputFallback = function (config) {
throw new Error('input not handled by moment: ' + config._i);
};
+ setupDeprecationHandler(test, moment, 'core');
if (lifecycle && lifecycle.setup) {
lifecycle.setup();
}
},
teardown : function () {
+ teardownDeprecationHandler(test, moment, 'core');
if (lifecycle && lifecycle.teardown) {
lifecycle.teardown();
}
@@ -39088,17 +56345,20 @@
moment.createFromInputFallback = function (config) {
throw new Error('input not handled by moment: ' + config._i);
};
+ setupDeprecationHandler(test, moment, 'locale');
if (lifecycle && lifecycle.setup) {
lifecycle.setup();
}
},
teardown : function () {
moment.locale('en');
+ teardownDeprecationHandler(test, moment, 'locale');
if (lifecycle && lifecycle.teardown) {
lifecycle.teardown();
}
}
});
+ defineCommonLocaleTests(name, -1, -1);
}
module('from_to');
@@ -39159,6 +56419,224 @@
typeof define === 'function' && define.amd ? define(['../../moment'], factory) :
factory(global.moment)
}(this, function (moment) { 'use strict';
+
+ function each(array, callback) {
+ var i;
+ for (i = 0; i < array.length; i++) {
+ callback(array[i], i, array);
+ }
+ }
+
+ function objectKeys(obj) {
+ if (Object.keys) {
+ return Object.keys(obj);
+ } else {
+ // IE8
+ var res = [], i;
+ for (i in obj) {
+ if (obj.hasOwnProperty(i)) {
+ res.push(i);
+ }
+ }
+ return res;
+ }
+ }
+
+ // Pick the first defined of two or three arguments.
+ function defaults(a, b, c) {
+ if (a != null) {
+ return a;
+ }
+ if (b != null) {
+ return b;
+ }
+ return c;
+ }
+
+ function defineCommonLocaleTests(locale, options) {
+ test('lenient ordinal parsing', function (assert) {
+ var i, ordinalStr, testMoment;
+ for (i = 1; i <= 31; ++i) {
+ ordinalStr = moment([2014, 0, i]).format('YYYY MM Do');
+ testMoment = moment(ordinalStr, 'YYYY MM Do');
+ assert.equal(testMoment.year(), 2014,
+ 'lenient ordinal parsing ' + i + ' year check');
+ assert.equal(testMoment.month(), 0,
+ 'lenient ordinal parsing ' + i + ' month check');
+ assert.equal(testMoment.date(), i,
+ 'lenient ordinal parsing ' + i + ' date check');
+ }
+ });
+
+ test('lenient ordinal parsing of number', function (assert) {
+ var i, testMoment;
+ for (i = 1; i <= 31; ++i) {
+ testMoment = moment('2014 01 ' + i, 'YYYY MM Do');
+ assert.equal(testMoment.year(), 2014,
+ 'lenient ordinal parsing of number ' + i + ' year check');
+ assert.equal(testMoment.month(), 0,
+ 'lenient ordinal parsing of number ' + i + ' month check');
+ assert.equal(testMoment.date(), i,
+ 'lenient ordinal parsing of number ' + i + ' date check');
+ }
+ });
+
+ test('strict ordinal parsing', function (assert) {
+ var i, ordinalStr, testMoment;
+ for (i = 1; i <= 31; ++i) {
+ ordinalStr = moment([2014, 0, i]).format('YYYY MM Do');
+ testMoment = moment(ordinalStr, 'YYYY MM Do', true);
+ assert.ok(testMoment.isValid(), 'strict ordinal parsing ' + i);
+ }
+ });
+
+ test('meridiem invariant', function (assert) {
+ var h, m, t1, t2;
+ for (h = 0; h < 24; ++h) {
+ for (m = 0; m < 60; m += 15) {
+ t1 = moment.utc([2000, 0, 1, h, m]);
+ t2 = moment.utc(t1.format('A h:mm'), 'A h:mm');
+ assert.equal(t2.format('HH:mm'), t1.format('HH:mm'),
+ 'meridiem at ' + t1.format('HH:mm'));
+ }
+ }
+ });
+
+ test('date format correctness', function (assert) {
+ var data, tokens;
+ data = moment.localeData()._longDateFormat;
+ tokens = objectKeys(data);
+ each(tokens, function (srchToken) {
+ // Check each format string to make sure it does not contain any
+ // tokens that need to be expanded.
+ each(tokens, function (baseToken) {
+ // strip escaped sequences
+ var format = data[baseToken].replace(/(\[[^\]]*\])/g, '');
+ assert.equal(false, !!~format.indexOf(srchToken),
+ 'contains ' + srchToken + ' in ' + baseToken);
+ });
+ });
+ });
+
+ test('month parsing correctness', function (assert) {
+ var i, m;
+
+ if (locale === 'tr') {
+ // I can't fix it :(
+ expect(0);
+ return;
+ }
+ function tester(format) {
+ var r;
+ r = moment(m.format(format), format);
+ assert.equal(r.month(), m.month(), 'month ' + i + ' fmt ' + format);
+ r = moment(m.format(format).toLocaleUpperCase(), format);
+ assert.equal(r.month(), m.month(), 'month ' + i + ' fmt ' + format + ' upper');
+ r = moment(m.format(format).toLocaleLowerCase(), format);
+ assert.equal(r.month(), m.month(), 'month ' + i + ' fmt ' + format + ' lower');
+
+ r = moment(m.format(format), format, true);
+ assert.equal(r.month(), m.month(), 'month ' + i + ' fmt ' + format + ' strict');
+ r = moment(m.format(format).toLocaleUpperCase(), format, true);
+ assert.equal(r.month(), m.month(), 'month ' + i + ' fmt ' + format + ' upper strict');
+ r = moment(m.format(format).toLocaleLowerCase(), format, true);
+ assert.equal(r.month(), m.month(), 'month ' + i + ' fmt ' + format + ' lower strict');
+ }
+
+ for (i = 0; i < 12; ++i) {
+ m = moment([2015, i, 15, 18]);
+ tester('MMM');
+ tester('MMM.');
+ tester('MMMM');
+ tester('MMMM.');
+ }
+ });
+
+ test('weekday parsing correctness', function (assert) {
+ var i, m;
+
+ if (locale === 'tr' || locale === 'az') {
+ // There is a lower-case letter (ı), that converted to upper then
+ // lower changes to i
+ expect(0);
+ return;
+ }
+ function tester(format) {
+ var r, baseMsg = 'weekday ' + m.weekday() + ' fmt ' + format;
+ r = moment(m.format(format), format);
+ assert.equal(r.weekday(), m.weekday(), baseMsg);
+ r = moment(m.format(format).toLocaleUpperCase(), format);
+ assert.equal(r.weekday(), m.weekday(), baseMsg + ' upper');
+ r = moment(m.format(format).toLocaleLowerCase(), format);
+ assert.equal(r.weekday(), m.weekday(), baseMsg + ' lower');
+
+ r = moment(m.format(format), format, true);
+ assert.equal(r.weekday(), m.weekday(), baseMsg + ' strict');
+ r = moment(m.format(format).toLocaleUpperCase(), format, true);
+ assert.equal(r.weekday(), m.weekday(), baseMsg + ' upper strict');
+ r = moment(m.format(format).toLocaleLowerCase(), format, true);
+ assert.equal(r.weekday(), m.weekday(), baseMsg + ' lower strict');
+ }
+
+ for (i = 0; i < 7; ++i) {
+ m = moment.utc([2015, i, 15, 18]);
+ tester('dd');
+ tester('ddd');
+ tester('dddd');
+ }
+ });
+ }
+
+ function setupDeprecationHandler(test, moment, scope) {
+ test._expectedDeprecations = null;
+ test._observedDeprecations = null;
+ test._oldSupress = moment.suppressDeprecationWarnings;
+ moment.suppressDeprecationWarnings = true;
+ test.expectedDeprecations = function () {
+ test._expectedDeprecations = arguments;
+ test._observedDeprecations = [];
+ };
+ moment.deprecationHandler = function (name, msg) {
+ var deprecationId = matchedDeprecation(name, msg, test._expectedDeprecations);
+ if (deprecationId === -1) {
+ throw new Error('Unexpected deprecation thrown name=' +
+ name + ' msg=' + msg);
+ }
+ test._observedDeprecations[deprecationId] = 1;
+ };
+ }
+
+ function teardownDeprecationHandler(test, moment, scope) {
+ moment.suppressDeprecationWarnings = test._oldSupress;
+
+ if (test._expectedDeprecations != null) {
+ var missedDeprecations = [];
+ each(test._expectedDeprecations, function (deprecationPattern, id) {
+ if (test._observedDeprecations[id] !== 1) {
+ missedDeprecations.push(deprecationPattern);
+ }
+ });
+ if (missedDeprecations.length !== 0) {
+ throw new Error('Expected deprecation warnings did not happen: ' +
+ missedDeprecations.join(' '));
+ }
+ }
+ }
+
+ function matchedDeprecation(name, msg, deprecations) {
+ if (deprecations == null) {
+ return -1;
+ }
+ for (var i = 0; i < deprecations.length; ++i) {
+ if (name != null && name === deprecations[i]) {
+ return i;
+ }
+ if (msg != null && msg.substring(0, deprecations[i].length) === deprecations[i]) {
+ return i;
+ }
+ }
+ return -1;
+ }
/*global QUnit:false*/
@@ -39173,11 +56651,13 @@
moment.createFromInputFallback = function (config) {
throw new Error('input not handled by moment: ' + config._i);
};
+ setupDeprecationHandler(test, moment, 'core');
if (lifecycle && lifecycle.setup) {
lifecycle.setup();
}
},
teardown : function () {
+ teardownDeprecationHandler(test, moment, 'core');
if (lifecycle && lifecycle.teardown) {
lifecycle.teardown();
}
@@ -39192,17 +56672,20 @@
moment.createFromInputFallback = function (config) {
throw new Error('input not handled by moment: ' + config._i);
};
+ setupDeprecationHandler(test, moment, 'locale');
if (lifecycle && lifecycle.setup) {
lifecycle.setup();
}
},
teardown : function () {
moment.locale('en');
+ teardownDeprecationHandler(test, moment, 'locale');
if (lifecycle && lifecycle.teardown) {
lifecycle.teardown();
}
}
});
+ defineCommonLocaleTests(name, -1, -1);
}
module('getters and setters');
@@ -39240,6 +56723,8 @@
test('setters plural', function (assert) {
var a = moment();
+ test.expectedDeprecations('years accessor', 'months accessor', 'dates accessor');
+
a.years(2011);
a.months(9);
a.dates(12);
@@ -39324,36 +56809,30 @@
assert.equal(a.month(), 3, 'month edge case');
});
- // Disable this, until we weekYear setter is fixed.
- // https://github.com/moment/moment/issues/1379
- // test('setters programatic with weeks', function (assert) {
- // var a = moment();
- // a.set('weekYear', 2001);
- // a.set('week', 49);
- // a.set('day', 4);
- // assert.equals(a.weekYear(), 2001);
- // assert.equals(a.week(), 49);
- // assert.equals(a.day(), 4);
-
- // a.set('weekday', 1);
- // assert.equals(a.weekday(), 1);
-
- // assert.done();
- //},
-
- // I think this suffers from the same issue as the non-iso version.
- // test('setters programatic with weeks ISO', function (assert) {
- // var a = moment();
- // a.set('isoWeekYear', 2001);
- // a.set('isoWeek', 49);
- // a.set('isoWeekday', 4);
-
- // assert.equals(a.weekYear(), 2001);
- // assert.equals(a.week(), 49);
- // assert.equals(a.day(), 4);
-
- // assert.done();
- //},
+ test('setters programatic with weeks', function (assert) {
+ var a = moment();
+ a.set('weekYear', 2001);
+ a.set('week', 49);
+ a.set('day', 4);
+
+ assert.equal(a.weekYear(), 2001, 'weekYear');
+ assert.equal(a.week(), 49, 'week');
+ assert.equal(a.day(), 4, 'day');
+
+ a.set('weekday', 1);
+ assert.equal(a.weekday(), 1, 'weekday');
+ });
+
+ test('setters programatic with weeks ISO', function (assert) {
+ var a = moment();
+ a.set('isoWeekYear', 2001);
+ a.set('isoWeek', 49);
+ a.set('isoWeekday', 4);
+
+ assert.equal(a.isoWeekYear(), 2001, 'isoWeekYear');
+ assert.equal(a.isoWeek(), 49, 'isoWeek');
+ assert.equal(a.isoWeekday(), 4, 'isoWeekday');
+ });
test('setters strings', function (assert) {
var a = moment([2012]).locale('en');
@@ -39441,6 +56920,91 @@
assert.equal(moment(a).day(17).date(), 26, 'set from wednesday to second next wednesday');
});
+ test('string setters', function (assert) {
+ var a = moment();
+ a.year('2011');
+ a.month('9');
+ a.date('12');
+ a.hours('6');
+ a.minutes('7');
+ a.seconds('8');
+ a.milliseconds('9');
+ assert.equal(a.year(), 2011, 'year');
+ assert.equal(a.month(), 9, 'month');
+ assert.equal(a.date(), 12, 'date');
+ assert.equal(a.day(), 3, 'day');
+ assert.equal(a.hours(), 6, 'hour');
+ assert.equal(a.minutes(), 7, 'minute');
+ assert.equal(a.seconds(), 8, 'second');
+ assert.equal(a.milliseconds(), 9, 'milliseconds');
+ });
+
+ test('setters across DST +1', function (assert) {
+ var oldUpdateOffset = moment.updateOffset,
+ // Based on a real story somewhere in America/Los_Angeles
+ dstAt = moment('2014-03-09T02:00:00-08:00').parseZone(),
+ m;
+
+ moment.updateOffset = function (mom, keepTime) {
+ if (mom.isBefore(dstAt)) {
+ mom.utcOffset(-8, keepTime);
+ } else {
+ mom.utcOffset(-7, keepTime);
+ }
+ };
+
+ m = moment('2014-03-15T00:00:00-07:00').parseZone();
+ m.year(2013);
+ assert.equal(m.format(), '2013-03-15T00:00:00-08:00', 'year across +1');
+
+ m = moment('2014-03-15T00:00:00-07:00').parseZone();
+ m.month(0);
+ assert.equal(m.format(), '2014-01-15T00:00:00-08:00', 'month across +1');
+
+ m = moment('2014-03-15T00:00:00-07:00').parseZone();
+ m.date(1);
+ assert.equal(m.format(), '2014-03-01T00:00:00-08:00', 'date across +1');
+
+ m = moment('2014-03-09T03:05:00-07:00').parseZone();
+ m.hour(0);
+ assert.equal(m.format(), '2014-03-09T00:05:00-08:00', 'hour across +1');
+
+ moment.updateOffset = oldUpdateOffset;
+ });
+
+ test('setters across DST -1', function (assert) {
+ var oldUpdateOffset = moment.updateOffset,
+ // Based on a real story somewhere in America/Los_Angeles
+ dstAt = moment('2014-11-02T02:00:00-07:00').parseZone(),
+ m;
+
+ moment.updateOffset = function (mom, keepTime) {
+ if (mom.isBefore(dstAt)) {
+ mom.utcOffset(-7, keepTime);
+ } else {
+ mom.utcOffset(-8, keepTime);
+ }
+ };
+
+ m = moment('2014-11-15T00:00:00-08:00').parseZone();
+ m.year(2013);
+ assert.equal(m.format(), '2013-11-15T00:00:00-07:00', 'year across -1');
+
+ m = moment('2014-11-15T00:00:00-08:00').parseZone();
+ m.month(0);
+ assert.equal(m.format(), '2014-01-15T00:00:00-07:00', 'month across -1');
+
+ m = moment('2014-11-15T00:00:00-08:00').parseZone();
+ m.date(1);
+ assert.equal(m.format(), '2014-11-01T00:00:00-07:00', 'date across -1');
+
+ m = moment('2014-11-02T03:30:00-08:00').parseZone();
+ m.hour(0);
+ assert.equal(m.format(), '2014-11-02T00:30:00-07:00', 'hour across -1');
+
+ moment.updateOffset = oldUpdateOffset;
+ });
+
}));
;(function (global, factory) {
@@ -39449,6 +57013,224 @@
typeof define === 'function' && define.amd ? define(['../../moment'], factory) :
factory(global.moment)
}(this, function (moment) { 'use strict';
+
+ function each(array, callback) {
+ var i;
+ for (i = 0; i < array.length; i++) {
+ callback(array[i], i, array);
+ }
+ }
+
+ function objectKeys(obj) {
+ if (Object.keys) {
+ return Object.keys(obj);
+ } else {
+ // IE8
+ var res = [], i;
+ for (i in obj) {
+ if (obj.hasOwnProperty(i)) {
+ res.push(i);
+ }
+ }
+ return res;
+ }
+ }
+
+ // Pick the first defined of two or three arguments.
+ function defaults(a, b, c) {
+ if (a != null) {
+ return a;
+ }
+ if (b != null) {
+ return b;
+ }
+ return c;
+ }
+
+ function defineCommonLocaleTests(locale, options) {
+ test('lenient ordinal parsing', function (assert) {
+ var i, ordinalStr, testMoment;
+ for (i = 1; i <= 31; ++i) {
+ ordinalStr = moment([2014, 0, i]).format('YYYY MM Do');
+ testMoment = moment(ordinalStr, 'YYYY MM Do');
+ assert.equal(testMoment.year(), 2014,
+ 'lenient ordinal parsing ' + i + ' year check');
+ assert.equal(testMoment.month(), 0,
+ 'lenient ordinal parsing ' + i + ' month check');
+ assert.equal(testMoment.date(), i,
+ 'lenient ordinal parsing ' + i + ' date check');
+ }
+ });
+
+ test('lenient ordinal parsing of number', function (assert) {
+ var i, testMoment;
+ for (i = 1; i <= 31; ++i) {
+ testMoment = moment('2014 01 ' + i, 'YYYY MM Do');
+ assert.equal(testMoment.year(), 2014,
+ 'lenient ordinal parsing of number ' + i + ' year check');
+ assert.equal(testMoment.month(), 0,
+ 'lenient ordinal parsing of number ' + i + ' month check');
+ assert.equal(testMoment.date(), i,
+ 'lenient ordinal parsing of number ' + i + ' date check');
+ }
+ });
+
+ test('strict ordinal parsing', function (assert) {
+ var i, ordinalStr, testMoment;
+ for (i = 1; i <= 31; ++i) {
+ ordinalStr = moment([2014, 0, i]).format('YYYY MM Do');
+ testMoment = moment(ordinalStr, 'YYYY MM Do', true);
+ assert.ok(testMoment.isValid(), 'strict ordinal parsing ' + i);
+ }
+ });
+
+ test('meridiem invariant', function (assert) {
+ var h, m, t1, t2;
+ for (h = 0; h < 24; ++h) {
+ for (m = 0; m < 60; m += 15) {
+ t1 = moment.utc([2000, 0, 1, h, m]);
+ t2 = moment.utc(t1.format('A h:mm'), 'A h:mm');
+ assert.equal(t2.format('HH:mm'), t1.format('HH:mm'),
+ 'meridiem at ' + t1.format('HH:mm'));
+ }
+ }
+ });
+
+ test('date format correctness', function (assert) {
+ var data, tokens;
+ data = moment.localeData()._longDateFormat;
+ tokens = objectKeys(data);
+ each(tokens, function (srchToken) {
+ // Check each format string to make sure it does not contain any
+ // tokens that need to be expanded.
+ each(tokens, function (baseToken) {
+ // strip escaped sequences
+ var format = data[baseToken].replace(/(\[[^\]]*\])/g, '');
+ assert.equal(false, !!~format.indexOf(srchToken),
+ 'contains ' + srchToken + ' in ' + baseToken);
+ });
+ });
+ });
+
+ test('month parsing correctness', function (assert) {
+ var i, m;
+
+ if (locale === 'tr') {
+ // I can't fix it :(
+ expect(0);
+ return;
+ }
+ function tester(format) {
+ var r;
+ r = moment(m.format(format), format);
+ assert.equal(r.month(), m.month(), 'month ' + i + ' fmt ' + format);
+ r = moment(m.format(format).toLocaleUpperCase(), format);
+ assert.equal(r.month(), m.month(), 'month ' + i + ' fmt ' + format + ' upper');
+ r = moment(m.format(format).toLocaleLowerCase(), format);
+ assert.equal(r.month(), m.month(), 'month ' + i + ' fmt ' + format + ' lower');
+
+ r = moment(m.format(format), format, true);
+ assert.equal(r.month(), m.month(), 'month ' + i + ' fmt ' + format + ' strict');
+ r = moment(m.format(format).toLocaleUpperCase(), format, true);
+ assert.equal(r.month(), m.month(), 'month ' + i + ' fmt ' + format + ' upper strict');
+ r = moment(m.format(format).toLocaleLowerCase(), format, true);
+ assert.equal(r.month(), m.month(), 'month ' + i + ' fmt ' + format + ' lower strict');
+ }
+
+ for (i = 0; i < 12; ++i) {
+ m = moment([2015, i, 15, 18]);
+ tester('MMM');
+ tester('MMM.');
+ tester('MMMM');
+ tester('MMMM.');
+ }
+ });
+
+ test('weekday parsing correctness', function (assert) {
+ var i, m;
+
+ if (locale === 'tr' || locale === 'az') {
+ // There is a lower-case letter (ı), that converted to upper then
+ // lower changes to i
+ expect(0);
+ return;
+ }
+ function tester(format) {
+ var r, baseMsg = 'weekday ' + m.weekday() + ' fmt ' + format;
+ r = moment(m.format(format), format);
+ assert.equal(r.weekday(), m.weekday(), baseMsg);
+ r = moment(m.format(format).toLocaleUpperCase(), format);
+ assert.equal(r.weekday(), m.weekday(), baseMsg + ' upper');
+ r = moment(m.format(format).toLocaleLowerCase(), format);
+ assert.equal(r.weekday(), m.weekday(), baseMsg + ' lower');
+
+ r = moment(m.format(format), format, true);
+ assert.equal(r.weekday(), m.weekday(), baseMsg + ' strict');
+ r = moment(m.format(format).toLocaleUpperCase(), format, true);
+ assert.equal(r.weekday(), m.weekday(), baseMsg + ' upper strict');
+ r = moment(m.format(format).toLocaleLowerCase(), format, true);
+ assert.equal(r.weekday(), m.weekday(), baseMsg + ' lower strict');
+ }
+
+ for (i = 0; i < 7; ++i) {
+ m = moment.utc([2015, i, 15, 18]);
+ tester('dd');
+ tester('ddd');
+ tester('dddd');
+ }
+ });
+ }
+
+ function setupDeprecationHandler(test, moment, scope) {
+ test._expectedDeprecations = null;
+ test._observedDeprecations = null;
+ test._oldSupress = moment.suppressDeprecationWarnings;
+ moment.suppressDeprecationWarnings = true;
+ test.expectedDeprecations = function () {
+ test._expectedDeprecations = arguments;
+ test._observedDeprecations = [];
+ };
+ moment.deprecationHandler = function (name, msg) {
+ var deprecationId = matchedDeprecation(name, msg, test._expectedDeprecations);
+ if (deprecationId === -1) {
+ throw new Error('Unexpected deprecation thrown name=' +
+ name + ' msg=' + msg);
+ }
+ test._observedDeprecations[deprecationId] = 1;
+ };
+ }
+
+ function teardownDeprecationHandler(test, moment, scope) {
+ moment.suppressDeprecationWarnings = test._oldSupress;
+
+ if (test._expectedDeprecations != null) {
+ var missedDeprecations = [];
+ each(test._expectedDeprecations, function (deprecationPattern, id) {
+ if (test._observedDeprecations[id] !== 1) {
+ missedDeprecations.push(deprecationPattern);
+ }
+ });
+ if (missedDeprecations.length !== 0) {
+ throw new Error('Expected deprecation warnings did not happen: ' +
+ missedDeprecations.join(' '));
+ }
+ }
+ }
+
+ function matchedDeprecation(name, msg, deprecations) {
+ if (deprecations == null) {
+ return -1;
+ }
+ for (var i = 0; i < deprecations.length; ++i) {
+ if (name != null && name === deprecations[i]) {
+ return i;
+ }
+ if (msg != null && msg.substring(0, deprecations[i].length) === deprecations[i]) {
+ return i;
+ }
+ }
+ return -1;
+ }
/*global QUnit:false*/
@@ -39463,11 +57245,13 @@
moment.createFromInputFallback = function (config) {
throw new Error('input not handled by moment: ' + config._i);
};
+ setupDeprecationHandler(test, moment, 'core');
if (lifecycle && lifecycle.setup) {
lifecycle.setup();
}
},
teardown : function () {
+ teardownDeprecationHandler(test, moment, 'core');
if (lifecycle && lifecycle.teardown) {
lifecycle.teardown();
}
@@ -39482,17 +57266,20 @@
moment.createFromInputFallback = function (config) {
throw new Error('input not handled by moment: ' + config._i);
};
+ setupDeprecationHandler(test, moment, 'locale');
if (lifecycle && lifecycle.setup) {
lifecycle.setup();
}
},
teardown : function () {
moment.locale('en');
+ teardownDeprecationHandler(test, moment, 'locale');
if (lifecycle && lifecycle.teardown) {
lifecycle.teardown();
}
}
});
+ defineCommonLocaleTests(name, -1, -1);
}
module('instanceof');
@@ -39530,6 +57317,224 @@
factory(global.moment)
}(this, function (moment) { 'use strict';
+ function each(array, callback) {
+ var i;
+ for (i = 0; i < array.length; i++) {
+ callback(array[i], i, array);
+ }
+ }
+
+ function objectKeys(obj) {
+ if (Object.keys) {
+ return Object.keys(obj);
+ } else {
+ // IE8
+ var res = [], i;
+ for (i in obj) {
+ if (obj.hasOwnProperty(i)) {
+ res.push(i);
+ }
+ }
+ return res;
+ }
+ }
+
+ // Pick the first defined of two or three arguments.
+ function defaults(a, b, c) {
+ if (a != null) {
+ return a;
+ }
+ if (b != null) {
+ return b;
+ }
+ return c;
+ }
+
+ function defineCommonLocaleTests(locale, options) {
+ test('lenient ordinal parsing', function (assert) {
+ var i, ordinalStr, testMoment;
+ for (i = 1; i <= 31; ++i) {
+ ordinalStr = moment([2014, 0, i]).format('YYYY MM Do');
+ testMoment = moment(ordinalStr, 'YYYY MM Do');
+ assert.equal(testMoment.year(), 2014,
+ 'lenient ordinal parsing ' + i + ' year check');
+ assert.equal(testMoment.month(), 0,
+ 'lenient ordinal parsing ' + i + ' month check');
+ assert.equal(testMoment.date(), i,
+ 'lenient ordinal parsing ' + i + ' date check');
+ }
+ });
+
+ test('lenient ordinal parsing of number', function (assert) {
+ var i, testMoment;
+ for (i = 1; i <= 31; ++i) {
+ testMoment = moment('2014 01 ' + i, 'YYYY MM Do');
+ assert.equal(testMoment.year(), 2014,
+ 'lenient ordinal parsing of number ' + i + ' year check');
+ assert.equal(testMoment.month(), 0,
+ 'lenient ordinal parsing of number ' + i + ' month check');
+ assert.equal(testMoment.date(), i,
+ 'lenient ordinal parsing of number ' + i + ' date check');
+ }
+ });
+
+ test('strict ordinal parsing', function (assert) {
+ var i, ordinalStr, testMoment;
+ for (i = 1; i <= 31; ++i) {
+ ordinalStr = moment([2014, 0, i]).format('YYYY MM Do');
+ testMoment = moment(ordinalStr, 'YYYY MM Do', true);
+ assert.ok(testMoment.isValid(), 'strict ordinal parsing ' + i);
+ }
+ });
+
+ test('meridiem invariant', function (assert) {
+ var h, m, t1, t2;
+ for (h = 0; h < 24; ++h) {
+ for (m = 0; m < 60; m += 15) {
+ t1 = moment.utc([2000, 0, 1, h, m]);
+ t2 = moment.utc(t1.format('A h:mm'), 'A h:mm');
+ assert.equal(t2.format('HH:mm'), t1.format('HH:mm'),
+ 'meridiem at ' + t1.format('HH:mm'));
+ }
+ }
+ });
+
+ test('date format correctness', function (assert) {
+ var data, tokens;
+ data = moment.localeData()._longDateFormat;
+ tokens = objectKeys(data);
+ each(tokens, function (srchToken) {
+ // Check each format string to make sure it does not contain any
+ // tokens that need to be expanded.
+ each(tokens, function (baseToken) {
+ // strip escaped sequences
+ var format = data[baseToken].replace(/(\[[^\]]*\])/g, '');
+ assert.equal(false, !!~format.indexOf(srchToken),
+ 'contains ' + srchToken + ' in ' + baseToken);
+ });
+ });
+ });
+
+ test('month parsing correctness', function (assert) {
+ var i, m;
+
+ if (locale === 'tr') {
+ // I can't fix it :(
+ expect(0);
+ return;
+ }
+ function tester(format) {
+ var r;
+ r = moment(m.format(format), format);
+ assert.equal(r.month(), m.month(), 'month ' + i + ' fmt ' + format);
+ r = moment(m.format(format).toLocaleUpperCase(), format);
+ assert.equal(r.month(), m.month(), 'month ' + i + ' fmt ' + format + ' upper');
+ r = moment(m.format(format).toLocaleLowerCase(), format);
+ assert.equal(r.month(), m.month(), 'month ' + i + ' fmt ' + format + ' lower');
+
+ r = moment(m.format(format), format, true);
+ assert.equal(r.month(), m.month(), 'month ' + i + ' fmt ' + format + ' strict');
+ r = moment(m.format(format).toLocaleUpperCase(), format, true);
+ assert.equal(r.month(), m.month(), 'month ' + i + ' fmt ' + format + ' upper strict');
+ r = moment(m.format(format).toLocaleLowerCase(), format, true);
+ assert.equal(r.month(), m.month(), 'month ' + i + ' fmt ' + format + ' lower strict');
+ }
+
+ for (i = 0; i < 12; ++i) {
+ m = moment([2015, i, 15, 18]);
+ tester('MMM');
+ tester('MMM.');
+ tester('MMMM');
+ tester('MMMM.');
+ }
+ });
+
+ test('weekday parsing correctness', function (assert) {
+ var i, m;
+
+ if (locale === 'tr' || locale === 'az') {
+ // There is a lower-case letter (ı), that converted to upper then
+ // lower changes to i
+ expect(0);
+ return;
+ }
+ function tester(format) {
+ var r, baseMsg = 'weekday ' + m.weekday() + ' fmt ' + format;
+ r = moment(m.format(format), format);
+ assert.equal(r.weekday(), m.weekday(), baseMsg);
+ r = moment(m.format(format).toLocaleUpperCase(), format);
+ assert.equal(r.weekday(), m.weekday(), baseMsg + ' upper');
+ r = moment(m.format(format).toLocaleLowerCase(), format);
+ assert.equal(r.weekday(), m.weekday(), baseMsg + ' lower');
+
+ r = moment(m.format(format), format, true);
+ assert.equal(r.weekday(), m.weekday(), baseMsg + ' strict');
+ r = moment(m.format(format).toLocaleUpperCase(), format, true);
+ assert.equal(r.weekday(), m.weekday(), baseMsg + ' upper strict');
+ r = moment(m.format(format).toLocaleLowerCase(), format, true);
+ assert.equal(r.weekday(), m.weekday(), baseMsg + ' lower strict');
+ }
+
+ for (i = 0; i < 7; ++i) {
+ m = moment.utc([2015, i, 15, 18]);
+ tester('dd');
+ tester('ddd');
+ tester('dddd');
+ }
+ });
+ }
+
+ function setupDeprecationHandler(test, moment, scope) {
+ test._expectedDeprecations = null;
+ test._observedDeprecations = null;
+ test._oldSupress = moment.suppressDeprecationWarnings;
+ moment.suppressDeprecationWarnings = true;
+ test.expectedDeprecations = function () {
+ test._expectedDeprecations = arguments;
+ test._observedDeprecations = [];
+ };
+ moment.deprecationHandler = function (name, msg) {
+ var deprecationId = matchedDeprecation(name, msg, test._expectedDeprecations);
+ if (deprecationId === -1) {
+ throw new Error('Unexpected deprecation thrown name=' +
+ name + ' msg=' + msg);
+ }
+ test._observedDeprecations[deprecationId] = 1;
+ };
+ }
+
+ function teardownDeprecationHandler(test, moment, scope) {
+ moment.suppressDeprecationWarnings = test._oldSupress;
+
+ if (test._expectedDeprecations != null) {
+ var missedDeprecations = [];
+ each(test._expectedDeprecations, function (deprecationPattern, id) {
+ if (test._observedDeprecations[id] !== 1) {
+ missedDeprecations.push(deprecationPattern);
+ }
+ });
+ if (missedDeprecations.length !== 0) {
+ throw new Error('Expected deprecation warnings did not happen: ' +
+ missedDeprecations.join(' '));
+ }
+ }
+ }
+
+ function matchedDeprecation(name, msg, deprecations) {
+ if (deprecations == null) {
+ return -1;
+ }
+ for (var i = 0; i < deprecations.length; ++i) {
+ if (name != null && name === deprecations[i]) {
+ return i;
+ }
+ if (msg != null && msg.substring(0, deprecations[i].length) === deprecations[i]) {
+ return i;
+ }
+ }
+ return -1;
+ }
+
/*global QUnit:false*/
var test = QUnit.test;
@@ -39543,11 +57548,13 @@
moment.createFromInputFallback = function (config) {
throw new Error('input not handled by moment: ' + config._i);
};
+ setupDeprecationHandler(test, moment, 'core');
if (lifecycle && lifecycle.setup) {
lifecycle.setup();
}
},
teardown : function () {
+ teardownDeprecationHandler(test, moment, 'core');
if (lifecycle && lifecycle.teardown) {
lifecycle.teardown();
}
@@ -39562,17 +57569,20 @@
moment.createFromInputFallback = function (config) {
throw new Error('input not handled by moment: ' + config._i);
};
+ setupDeprecationHandler(test, moment, 'locale');
if (lifecycle && lifecycle.setup) {
lifecycle.setup();
}
},
teardown : function () {
moment.locale('en');
+ teardownDeprecationHandler(test, moment, 'locale');
if (lifecycle && lifecycle.teardown) {
lifecycle.teardown();
}
}
});
+ defineCommonLocaleTests(name, -1, -1);
}
module('invalid');
@@ -39610,6 +57620,8 @@
i,
invalid,
valid = moment();
+
+ test.expectedDeprecations('moment().min', 'moment().max');
for (i = 0; i < invalids.length; ++i) {
invalid = invalids[i];
@@ -39673,7 +57685,7 @@
});
assert.ok(moment.isDate(invalid.toDate()));
assert.ok(isNaN(invalid.toDate().valueOf()));
- assert.equal(invalid.toJSON(), 'null');
+ assert.equal(invalid.toJSON(), null);
assert.equal(invalid.toString(), 'Invalid date');
assert.ok(isNaN(invalid.unix()));
assert.ok(isNaN(invalid.valueOf()));
@@ -39761,6 +57773,224 @@
factory(global.moment)
}(this, function (moment) { 'use strict';
+ function each(array, callback) {
+ var i;
+ for (i = 0; i < array.length; i++) {
+ callback(array[i], i, array);
+ }
+ }
+
+ function objectKeys(obj) {
+ if (Object.keys) {
+ return Object.keys(obj);
+ } else {
+ // IE8
+ var res = [], i;
+ for (i in obj) {
+ if (obj.hasOwnProperty(i)) {
+ res.push(i);
+ }
+ }
+ return res;
+ }
+ }
+
+ // Pick the first defined of two or three arguments.
+ function defaults(a, b, c) {
+ if (a != null) {
+ return a;
+ }
+ if (b != null) {
+ return b;
+ }
+ return c;
+ }
+
+ function defineCommonLocaleTests(locale, options) {
+ test('lenient ordinal parsing', function (assert) {
+ var i, ordinalStr, testMoment;
+ for (i = 1; i <= 31; ++i) {
+ ordinalStr = moment([2014, 0, i]).format('YYYY MM Do');
+ testMoment = moment(ordinalStr, 'YYYY MM Do');
+ assert.equal(testMoment.year(), 2014,
+ 'lenient ordinal parsing ' + i + ' year check');
+ assert.equal(testMoment.month(), 0,
+ 'lenient ordinal parsing ' + i + ' month check');
+ assert.equal(testMoment.date(), i,
+ 'lenient ordinal parsing ' + i + ' date check');
+ }
+ });
+
+ test('lenient ordinal parsing of number', function (assert) {
+ var i, testMoment;
+ for (i = 1; i <= 31; ++i) {
+ testMoment = moment('2014 01 ' + i, 'YYYY MM Do');
+ assert.equal(testMoment.year(), 2014,
+ 'lenient ordinal parsing of number ' + i + ' year check');
+ assert.equal(testMoment.month(), 0,
+ 'lenient ordinal parsing of number ' + i + ' month check');
+ assert.equal(testMoment.date(), i,
+ 'lenient ordinal parsing of number ' + i + ' date check');
+ }
+ });
+
+ test('strict ordinal parsing', function (assert) {
+ var i, ordinalStr, testMoment;
+ for (i = 1; i <= 31; ++i) {
+ ordinalStr = moment([2014, 0, i]).format('YYYY MM Do');
+ testMoment = moment(ordinalStr, 'YYYY MM Do', true);
+ assert.ok(testMoment.isValid(), 'strict ordinal parsing ' + i);
+ }
+ });
+
+ test('meridiem invariant', function (assert) {
+ var h, m, t1, t2;
+ for (h = 0; h < 24; ++h) {
+ for (m = 0; m < 60; m += 15) {
+ t1 = moment.utc([2000, 0, 1, h, m]);
+ t2 = moment.utc(t1.format('A h:mm'), 'A h:mm');
+ assert.equal(t2.format('HH:mm'), t1.format('HH:mm'),
+ 'meridiem at ' + t1.format('HH:mm'));
+ }
+ }
+ });
+
+ test('date format correctness', function (assert) {
+ var data, tokens;
+ data = moment.localeData()._longDateFormat;
+ tokens = objectKeys(data);
+ each(tokens, function (srchToken) {
+ // Check each format string to make sure it does not contain any
+ // tokens that need to be expanded.
+ each(tokens, function (baseToken) {
+ // strip escaped sequences
+ var format = data[baseToken].replace(/(\[[^\]]*\])/g, '');
+ assert.equal(false, !!~format.indexOf(srchToken),
+ 'contains ' + srchToken + ' in ' + baseToken);
+ });
+ });
+ });
+
+ test('month parsing correctness', function (assert) {
+ var i, m;
+
+ if (locale === 'tr') {
+ // I can't fix it :(
+ expect(0);
+ return;
+ }
+ function tester(format) {
+ var r;
+ r = moment(m.format(format), format);
+ assert.equal(r.month(), m.month(), 'month ' + i + ' fmt ' + format);
+ r = moment(m.format(format).toLocaleUpperCase(), format);
+ assert.equal(r.month(), m.month(), 'month ' + i + ' fmt ' + format + ' upper');
+ r = moment(m.format(format).toLocaleLowerCase(), format);
+ assert.equal(r.month(), m.month(), 'month ' + i + ' fmt ' + format + ' lower');
+
+ r = moment(m.format(format), format, true);
+ assert.equal(r.month(), m.month(), 'month ' + i + ' fmt ' + format + ' strict');
+ r = moment(m.format(format).toLocaleUpperCase(), format, true);
+ assert.equal(r.month(), m.month(), 'month ' + i + ' fmt ' + format + ' upper strict');
+ r = moment(m.format(format).toLocaleLowerCase(), format, true);
+ assert.equal(r.month(), m.month(), 'month ' + i + ' fmt ' + format + ' lower strict');
+ }
+
+ for (i = 0; i < 12; ++i) {
+ m = moment([2015, i, 15, 18]);
+ tester('MMM');
+ tester('MMM.');
+ tester('MMMM');
+ tester('MMMM.');
+ }
+ });
+
+ test('weekday parsing correctness', function (assert) {
+ var i, m;
+
+ if (locale === 'tr' || locale === 'az') {
+ // There is a lower-case letter (ı), that converted to upper then
+ // lower changes to i
+ expect(0);
+ return;
+ }
+ function tester(format) {
+ var r, baseMsg = 'weekday ' + m.weekday() + ' fmt ' + format;
+ r = moment(m.format(format), format);
+ assert.equal(r.weekday(), m.weekday(), baseMsg);
+ r = moment(m.format(format).toLocaleUpperCase(), format);
+ assert.equal(r.weekday(), m.weekday(), baseMsg + ' upper');
+ r = moment(m.format(format).toLocaleLowerCase(), format);
+ assert.equal(r.weekday(), m.weekday(), baseMsg + ' lower');
+
+ r = moment(m.format(format), format, true);
+ assert.equal(r.weekday(), m.weekday(), baseMsg + ' strict');
+ r = moment(m.format(format).toLocaleUpperCase(), format, true);
+ assert.equal(r.weekday(), m.weekday(), baseMsg + ' upper strict');
+ r = moment(m.format(format).toLocaleLowerCase(), format, true);
+ assert.equal(r.weekday(), m.weekday(), baseMsg + ' lower strict');
+ }
+
+ for (i = 0; i < 7; ++i) {
+ m = moment.utc([2015, i, 15, 18]);
+ tester('dd');
+ tester('ddd');
+ tester('dddd');
+ }
+ });
+ }
+
+ function setupDeprecationHandler(test, moment, scope) {
+ test._expectedDeprecations = null;
+ test._observedDeprecations = null;
+ test._oldSupress = moment.suppressDeprecationWarnings;
+ moment.suppressDeprecationWarnings = true;
+ test.expectedDeprecations = function () {
+ test._expectedDeprecations = arguments;
+ test._observedDeprecations = [];
+ };
+ moment.deprecationHandler = function (name, msg) {
+ var deprecationId = matchedDeprecation(name, msg, test._expectedDeprecations);
+ if (deprecationId === -1) {
+ throw new Error('Unexpected deprecation thrown name=' +
+ name + ' msg=' + msg);
+ }
+ test._observedDeprecations[deprecationId] = 1;
+ };
+ }
+
+ function teardownDeprecationHandler(test, moment, scope) {
+ moment.suppressDeprecationWarnings = test._oldSupress;
+
+ if (test._expectedDeprecations != null) {
+ var missedDeprecations = [];
+ each(test._expectedDeprecations, function (deprecationPattern, id) {
+ if (test._observedDeprecations[id] !== 1) {
+ missedDeprecations.push(deprecationPattern);
+ }
+ });
+ if (missedDeprecations.length !== 0) {
+ throw new Error('Expected deprecation warnings did not happen: ' +
+ missedDeprecations.join(' '));
+ }
+ }
+ }
+
+ function matchedDeprecation(name, msg, deprecations) {
+ if (deprecations == null) {
+ return -1;
+ }
+ for (var i = 0; i < deprecations.length; ++i) {
+ if (name != null && name === deprecations[i]) {
+ return i;
+ }
+ if (msg != null && msg.substring(0, deprecations[i].length) === deprecations[i]) {
+ return i;
+ }
+ }
+ return -1;
+ }
+
/*global QUnit:false*/
var test = QUnit.test;
@@ -39774,11 +58004,13 @@
moment.createFromInputFallback = function (config) {
throw new Error('input not handled by moment: ' + config._i);
};
+ setupDeprecationHandler(test, moment, 'core');
if (lifecycle && lifecycle.setup) {
lifecycle.setup();
}
},
teardown : function () {
+ teardownDeprecationHandler(test, moment, 'core');
if (lifecycle && lifecycle.teardown) {
lifecycle.teardown();
}
@@ -39793,17 +58025,20 @@
moment.createFromInputFallback = function (config) {
throw new Error('input not handled by moment: ' + config._i);
};
+ setupDeprecationHandler(test, moment, 'locale');
if (lifecycle && lifecycle.setup) {
lifecycle.setup();
}
},
teardown : function () {
moment.locale('en');
+ teardownDeprecationHandler(test, moment, 'locale');
if (lifecycle && lifecycle.teardown) {
lifecycle.teardown();
}
}
});
+ defineCommonLocaleTests(name, -1, -1);
}
module('is after');
@@ -39990,6 +58225,224 @@
factory(global.moment)
}(this, function (moment) { 'use strict';
+ function each(array, callback) {
+ var i;
+ for (i = 0; i < array.length; i++) {
+ callback(array[i], i, array);
+ }
+ }
+
+ function objectKeys(obj) {
+ if (Object.keys) {
+ return Object.keys(obj);
+ } else {
+ // IE8
+ var res = [], i;
+ for (i in obj) {
+ if (obj.hasOwnProperty(i)) {
+ res.push(i);
+ }
+ }
+ return res;
+ }
+ }
+
+ // Pick the first defined of two or three arguments.
+ function defaults(a, b, c) {
+ if (a != null) {
+ return a;
+ }
+ if (b != null) {
+ return b;
+ }
+ return c;
+ }
+
+ function defineCommonLocaleTests(locale, options) {
+ test('lenient ordinal parsing', function (assert) {
+ var i, ordinalStr, testMoment;
+ for (i = 1; i <= 31; ++i) {
+ ordinalStr = moment([2014, 0, i]).format('YYYY MM Do');
+ testMoment = moment(ordinalStr, 'YYYY MM Do');
+ assert.equal(testMoment.year(), 2014,
+ 'lenient ordinal parsing ' + i + ' year check');
+ assert.equal(testMoment.month(), 0,
+ 'lenient ordinal parsing ' + i + ' month check');
+ assert.equal(testMoment.date(), i,
+ 'lenient ordinal parsing ' + i + ' date check');
+ }
+ });
+
+ test('lenient ordinal parsing of number', function (assert) {
+ var i, testMoment;
+ for (i = 1; i <= 31; ++i) {
+ testMoment = moment('2014 01 ' + i, 'YYYY MM Do');
+ assert.equal(testMoment.year(), 2014,
+ 'lenient ordinal parsing of number ' + i + ' year check');
+ assert.equal(testMoment.month(), 0,
+ 'lenient ordinal parsing of number ' + i + ' month check');
+ assert.equal(testMoment.date(), i,
+ 'lenient ordinal parsing of number ' + i + ' date check');
+ }
+ });
+
+ test('strict ordinal parsing', function (assert) {
+ var i, ordinalStr, testMoment;
+ for (i = 1; i <= 31; ++i) {
+ ordinalStr = moment([2014, 0, i]).format('YYYY MM Do');
+ testMoment = moment(ordinalStr, 'YYYY MM Do', true);
+ assert.ok(testMoment.isValid(), 'strict ordinal parsing ' + i);
+ }
+ });
+
+ test('meridiem invariant', function (assert) {
+ var h, m, t1, t2;
+ for (h = 0; h < 24; ++h) {
+ for (m = 0; m < 60; m += 15) {
+ t1 = moment.utc([2000, 0, 1, h, m]);
+ t2 = moment.utc(t1.format('A h:mm'), 'A h:mm');
+ assert.equal(t2.format('HH:mm'), t1.format('HH:mm'),
+ 'meridiem at ' + t1.format('HH:mm'));
+ }
+ }
+ });
+
+ test('date format correctness', function (assert) {
+ var data, tokens;
+ data = moment.localeData()._longDateFormat;
+ tokens = objectKeys(data);
+ each(tokens, function (srchToken) {
+ // Check each format string to make sure it does not contain any
+ // tokens that need to be expanded.
+ each(tokens, function (baseToken) {
+ // strip escaped sequences
+ var format = data[baseToken].replace(/(\[[^\]]*\])/g, '');
+ assert.equal(false, !!~format.indexOf(srchToken),
+ 'contains ' + srchToken + ' in ' + baseToken);
+ });
+ });
+ });
+
+ test('month parsing correctness', function (assert) {
+ var i, m;
+
+ if (locale === 'tr') {
+ // I can't fix it :(
+ expect(0);
+ return;
+ }
+ function tester(format) {
+ var r;
+ r = moment(m.format(format), format);
+ assert.equal(r.month(), m.month(), 'month ' + i + ' fmt ' + format);
+ r = moment(m.format(format).toLocaleUpperCase(), format);
+ assert.equal(r.month(), m.month(), 'month ' + i + ' fmt ' + format + ' upper');
+ r = moment(m.format(format).toLocaleLowerCase(), format);
+ assert.equal(r.month(), m.month(), 'month ' + i + ' fmt ' + format + ' lower');
+
+ r = moment(m.format(format), format, true);
+ assert.equal(r.month(), m.month(), 'month ' + i + ' fmt ' + format + ' strict');
+ r = moment(m.format(format).toLocaleUpperCase(), format, true);
+ assert.equal(r.month(), m.month(), 'month ' + i + ' fmt ' + format + ' upper strict');
+ r = moment(m.format(format).toLocaleLowerCase(), format, true);
+ assert.equal(r.month(), m.month(), 'month ' + i + ' fmt ' + format + ' lower strict');
+ }
+
+ for (i = 0; i < 12; ++i) {
+ m = moment([2015, i, 15, 18]);
+ tester('MMM');
+ tester('MMM.');
+ tester('MMMM');
+ tester('MMMM.');
+ }
+ });
+
+ test('weekday parsing correctness', function (assert) {
+ var i, m;
+
+ if (locale === 'tr' || locale === 'az') {
+ // There is a lower-case letter (ı), that converted to upper then
+ // lower changes to i
+ expect(0);
+ return;
+ }
+ function tester(format) {
+ var r, baseMsg = 'weekday ' + m.weekday() + ' fmt ' + format;
+ r = moment(m.format(format), format);
+ assert.equal(r.weekday(), m.weekday(), baseMsg);
+ r = moment(m.format(format).toLocaleUpperCase(), format);
+ assert.equal(r.weekday(), m.weekday(), baseMsg + ' upper');
+ r = moment(m.format(format).toLocaleLowerCase(), format);
+ assert.equal(r.weekday(), m.weekday(), baseMsg + ' lower');
+
+ r = moment(m.format(format), format, true);
+ assert.equal(r.weekday(), m.weekday(), baseMsg + ' strict');
+ r = moment(m.format(format).toLocaleUpperCase(), format, true);
+ assert.equal(r.weekday(), m.weekday(), baseMsg + ' upper strict');
+ r = moment(m.format(format).toLocaleLowerCase(), format, true);
+ assert.equal(r.weekday(), m.weekday(), baseMsg + ' lower strict');
+ }
+
+ for (i = 0; i < 7; ++i) {
+ m = moment.utc([2015, i, 15, 18]);
+ tester('dd');
+ tester('ddd');
+ tester('dddd');
+ }
+ });
+ }
+
+ function setupDeprecationHandler(test, moment, scope) {
+ test._expectedDeprecations = null;
+ test._observedDeprecations = null;
+ test._oldSupress = moment.suppressDeprecationWarnings;
+ moment.suppressDeprecationWarnings = true;
+ test.expectedDeprecations = function () {
+ test._expectedDeprecations = arguments;
+ test._observedDeprecations = [];
+ };
+ moment.deprecationHandler = function (name, msg) {
+ var deprecationId = matchedDeprecation(name, msg, test._expectedDeprecations);
+ if (deprecationId === -1) {
+ throw new Error('Unexpected deprecation thrown name=' +
+ name + ' msg=' + msg);
+ }
+ test._observedDeprecations[deprecationId] = 1;
+ };
+ }
+
+ function teardownDeprecationHandler(test, moment, scope) {
+ moment.suppressDeprecationWarnings = test._oldSupress;
+
+ if (test._expectedDeprecations != null) {
+ var missedDeprecations = [];
+ each(test._expectedDeprecations, function (deprecationPattern, id) {
+ if (test._observedDeprecations[id] !== 1) {
+ missedDeprecations.push(deprecationPattern);
+ }
+ });
+ if (missedDeprecations.length !== 0) {
+ throw new Error('Expected deprecation warnings did not happen: ' +
+ missedDeprecations.join(' '));
+ }
+ }
+ }
+
+ function matchedDeprecation(name, msg, deprecations) {
+ if (deprecations == null) {
+ return -1;
+ }
+ for (var i = 0; i < deprecations.length; ++i) {
+ if (name != null && name === deprecations[i]) {
+ return i;
+ }
+ if (msg != null && msg.substring(0, deprecations[i].length) === deprecations[i]) {
+ return i;
+ }
+ }
+ return -1;
+ }
+
/*global QUnit:false*/
var test = QUnit.test;
@@ -40003,11 +58456,13 @@
moment.createFromInputFallback = function (config) {
throw new Error('input not handled by moment: ' + config._i);
};
+ setupDeprecationHandler(test, moment, 'core');
if (lifecycle && lifecycle.setup) {
lifecycle.setup();
}
},
teardown : function () {
+ teardownDeprecationHandler(test, moment, 'core');
if (lifecycle && lifecycle.teardown) {
lifecycle.teardown();
}
@@ -40022,17 +58477,317 @@
moment.createFromInputFallback = function (config) {
throw new Error('input not handled by moment: ' + config._i);
};
+ setupDeprecationHandler(test, moment, 'locale');
if (lifecycle && lifecycle.setup) {
lifecycle.setup();
}
},
teardown : function () {
moment.locale('en');
+ teardownDeprecationHandler(test, moment, 'locale');
if (lifecycle && lifecycle.teardown) {
lifecycle.teardown();
}
}
});
+ defineCommonLocaleTests(name, -1, -1);
+ }
+
+ function isArray(input) {
+ return input instanceof Array || Object.prototype.toString.call(input) === '[object Array]';
+ }
+
+ test('isArray recognizes Array objects', function (assert) {
+ assert.ok(isArray([1,2,3]), 'array args');
+ assert.ok(isArray([]), 'empty array');
+ assert.ok(isArray(new Array(1,2,3)), 'array constructor');
+ });
+
+ test('isArray rejects non-Array objects', function (assert) {
+ assert.ok(!isArray(), 'nothing');
+ assert.ok(!isArray(undefined), 'undefined');
+ assert.ok(!isArray(null), 'null');
+ assert.ok(!isArray(123), 'number');
+ assert.ok(!isArray('[1,2,3]'), 'string');
+ assert.ok(!isArray(new Date()), 'date');
+ assert.ok(!isArray({a:1,b:2}), 'object');
+ });
+
+}));
+
+;(function (global, factory) {
+ typeof exports === 'object' && typeof module !== 'undefined'
+ && typeof require === 'function' ? factory(require('../../moment')) :
+ typeof define === 'function' && define.amd ? define(['../../moment'], factory) :
+ factory(global.moment)
+}(this, function (moment) { 'use strict';
+
+ function each(array, callback) {
+ var i;
+ for (i = 0; i < array.length; i++) {
+ callback(array[i], i, array);
+ }
+ }
+
+ function objectKeys(obj) {
+ if (Object.keys) {
+ return Object.keys(obj);
+ } else {
+ // IE8
+ var res = [], i;
+ for (i in obj) {
+ if (obj.hasOwnProperty(i)) {
+ res.push(i);
+ }
+ }
+ return res;
+ }
+ }
+
+ // Pick the first defined of two or three arguments.
+ function defaults(a, b, c) {
+ if (a != null) {
+ return a;
+ }
+ if (b != null) {
+ return b;
+ }
+ return c;
+ }
+
+ function defineCommonLocaleTests(locale, options) {
+ test('lenient ordinal parsing', function (assert) {
+ var i, ordinalStr, testMoment;
+ for (i = 1; i <= 31; ++i) {
+ ordinalStr = moment([2014, 0, i]).format('YYYY MM Do');
+ testMoment = moment(ordinalStr, 'YYYY MM Do');
+ assert.equal(testMoment.year(), 2014,
+ 'lenient ordinal parsing ' + i + ' year check');
+ assert.equal(testMoment.month(), 0,
+ 'lenient ordinal parsing ' + i + ' month check');
+ assert.equal(testMoment.date(), i,
+ 'lenient ordinal parsing ' + i + ' date check');
+ }
+ });
+
+ test('lenient ordinal parsing of number', function (assert) {
+ var i, testMoment;
+ for (i = 1; i <= 31; ++i) {
+ testMoment = moment('2014 01 ' + i, 'YYYY MM Do');
+ assert.equal(testMoment.year(), 2014,
+ 'lenient ordinal parsing of number ' + i + ' year check');
+ assert.equal(testMoment.month(), 0,
+ 'lenient ordinal parsing of number ' + i + ' month check');
+ assert.equal(testMoment.date(), i,
+ 'lenient ordinal parsing of number ' + i + ' date check');
+ }
+ });
+
+ test('strict ordinal parsing', function (assert) {
+ var i, ordinalStr, testMoment;
+ for (i = 1; i <= 31; ++i) {
+ ordinalStr = moment([2014, 0, i]).format('YYYY MM Do');
+ testMoment = moment(ordinalStr, 'YYYY MM Do', true);
+ assert.ok(testMoment.isValid(), 'strict ordinal parsing ' + i);
+ }
+ });
+
+ test('meridiem invariant', function (assert) {
+ var h, m, t1, t2;
+ for (h = 0; h < 24; ++h) {
+ for (m = 0; m < 60; m += 15) {
+ t1 = moment.utc([2000, 0, 1, h, m]);
+ t2 = moment.utc(t1.format('A h:mm'), 'A h:mm');
+ assert.equal(t2.format('HH:mm'), t1.format('HH:mm'),
+ 'meridiem at ' + t1.format('HH:mm'));
+ }
+ }
+ });
+
+ test('date format correctness', function (assert) {
+ var data, tokens;
+ data = moment.localeData()._longDateFormat;
+ tokens = objectKeys(data);
+ each(tokens, function (srchToken) {
+ // Check each format string to make sure it does not contain any
+ // tokens that need to be expanded.
+ each(tokens, function (baseToken) {
+ // strip escaped sequences
+ var format = data[baseToken].replace(/(\[[^\]]*\])/g, '');
+ assert.equal(false, !!~format.indexOf(srchToken),
+ 'contains ' + srchToken + ' in ' + baseToken);
+ });
+ });
+ });
+
+ test('month parsing correctness', function (assert) {
+ var i, m;
+
+ if (locale === 'tr') {
+ // I can't fix it :(
+ expect(0);
+ return;
+ }
+ function tester(format) {
+ var r;
+ r = moment(m.format(format), format);
+ assert.equal(r.month(), m.month(), 'month ' + i + ' fmt ' + format);
+ r = moment(m.format(format).toLocaleUpperCase(), format);
+ assert.equal(r.month(), m.month(), 'month ' + i + ' fmt ' + format + ' upper');
+ r = moment(m.format(format).toLocaleLowerCase(), format);
+ assert.equal(r.month(), m.month(), 'month ' + i + ' fmt ' + format + ' lower');
+
+ r = moment(m.format(format), format, true);
+ assert.equal(r.month(), m.month(), 'month ' + i + ' fmt ' + format + ' strict');
+ r = moment(m.format(format).toLocaleUpperCase(), format, true);
+ assert.equal(r.month(), m.month(), 'month ' + i + ' fmt ' + format + ' upper strict');
+ r = moment(m.format(format).toLocaleLowerCase(), format, true);
+ assert.equal(r.month(), m.month(), 'month ' + i + ' fmt ' + format + ' lower strict');
+ }
+
+ for (i = 0; i < 12; ++i) {
+ m = moment([2015, i, 15, 18]);
+ tester('MMM');
+ tester('MMM.');
+ tester('MMMM');
+ tester('MMMM.');
+ }
+ });
+
+ test('weekday parsing correctness', function (assert) {
+ var i, m;
+
+ if (locale === 'tr' || locale === 'az') {
+ // There is a lower-case letter (ı), that converted to upper then
+ // lower changes to i
+ expect(0);
+ return;
+ }
+ function tester(format) {
+ var r, baseMsg = 'weekday ' + m.weekday() + ' fmt ' + format;
+ r = moment(m.format(format), format);
+ assert.equal(r.weekday(), m.weekday(), baseMsg);
+ r = moment(m.format(format).toLocaleUpperCase(), format);
+ assert.equal(r.weekday(), m.weekday(), baseMsg + ' upper');
+ r = moment(m.format(format).toLocaleLowerCase(), format);
+ assert.equal(r.weekday(), m.weekday(), baseMsg + ' lower');
+
+ r = moment(m.format(format), format, true);
+ assert.equal(r.weekday(), m.weekday(), baseMsg + ' strict');
+ r = moment(m.format(format).toLocaleUpperCase(), format, true);
+ assert.equal(r.weekday(), m.weekday(), baseMsg + ' upper strict');
+ r = moment(m.format(format).toLocaleLowerCase(), format, true);
+ assert.equal(r.weekday(), m.weekday(), baseMsg + ' lower strict');
+ }
+
+ for (i = 0; i < 7; ++i) {
+ m = moment.utc([2015, i, 15, 18]);
+ tester('dd');
+ tester('ddd');
+ tester('dddd');
+ }
+ });
+ }
+
+ function setupDeprecationHandler(test, moment, scope) {
+ test._expectedDeprecations = null;
+ test._observedDeprecations = null;
+ test._oldSupress = moment.suppressDeprecationWarnings;
+ moment.suppressDeprecationWarnings = true;
+ test.expectedDeprecations = function () {
+ test._expectedDeprecations = arguments;
+ test._observedDeprecations = [];
+ };
+ moment.deprecationHandler = function (name, msg) {
+ var deprecationId = matchedDeprecation(name, msg, test._expectedDeprecations);
+ if (deprecationId === -1) {
+ throw new Error('Unexpected deprecation thrown name=' +
+ name + ' msg=' + msg);
+ }
+ test._observedDeprecations[deprecationId] = 1;
+ };
+ }
+
+ function teardownDeprecationHandler(test, moment, scope) {
+ moment.suppressDeprecationWarnings = test._oldSupress;
+
+ if (test._expectedDeprecations != null) {
+ var missedDeprecations = [];
+ each(test._expectedDeprecations, function (deprecationPattern, id) {
+ if (test._observedDeprecations[id] !== 1) {
+ missedDeprecations.push(deprecationPattern);
+ }
+ });
+ if (missedDeprecations.length !== 0) {
+ throw new Error('Expected deprecation warnings did not happen: ' +
+ missedDeprecations.join(' '));
+ }
+ }
+ }
+
+ function matchedDeprecation(name, msg, deprecations) {
+ if (deprecations == null) {
+ return -1;
+ }
+ for (var i = 0; i < deprecations.length; ++i) {
+ if (name != null && name === deprecations[i]) {
+ return i;
+ }
+ if (msg != null && msg.substring(0, deprecations[i].length) === deprecations[i]) {
+ return i;
+ }
+ }
+ return -1;
+ }
+
+ /*global QUnit:false*/
+
+ var test = QUnit.test;
+
+ var expect = QUnit.expect;
+
+ function module (name, lifecycle) {
+ QUnit.module(name, {
+ setup : function () {
+ moment.locale('en');
+ moment.createFromInputFallback = function (config) {
+ throw new Error('input not handled by moment: ' + config._i);
+ };
+ setupDeprecationHandler(test, moment, 'core');
+ if (lifecycle && lifecycle.setup) {
+ lifecycle.setup();
+ }
+ },
+ teardown : function () {
+ teardownDeprecationHandler(test, moment, 'core');
+ if (lifecycle && lifecycle.teardown) {
+ lifecycle.teardown();
+ }
+ }
+ });
+ }
+
+ function localeModule (name, lifecycle) {
+ QUnit.module('locale:' + name, {
+ setup : function () {
+ moment.locale(name);
+ moment.createFromInputFallback = function (config) {
+ throw new Error('input not handled by moment: ' + config._i);
+ };
+ setupDeprecationHandler(test, moment, 'locale');
+ if (lifecycle && lifecycle.setup) {
+ lifecycle.setup();
+ }
+ },
+ teardown : function () {
+ moment.locale('en');
+ teardownDeprecationHandler(test, moment, 'locale');
+ if (lifecycle && lifecycle.teardown) {
+ lifecycle.teardown();
+ }
+ }
+ });
+ defineCommonLocaleTests(name, -1, -1);
}
module('is before');
@@ -40219,6 +58974,224 @@
factory(global.moment)
}(this, function (moment) { 'use strict';
+ function each(array, callback) {
+ var i;
+ for (i = 0; i < array.length; i++) {
+ callback(array[i], i, array);
+ }
+ }
+
+ function objectKeys(obj) {
+ if (Object.keys) {
+ return Object.keys(obj);
+ } else {
+ // IE8
+ var res = [], i;
+ for (i in obj) {
+ if (obj.hasOwnProperty(i)) {
+ res.push(i);
+ }
+ }
+ return res;
+ }
+ }
+
+ // Pick the first defined of two or three arguments.
+ function defaults(a, b, c) {
+ if (a != null) {
+ return a;
+ }
+ if (b != null) {
+ return b;
+ }
+ return c;
+ }
+
+ function defineCommonLocaleTests(locale, options) {
+ test('lenient ordinal parsing', function (assert) {
+ var i, ordinalStr, testMoment;
+ for (i = 1; i <= 31; ++i) {
+ ordinalStr = moment([2014, 0, i]).format('YYYY MM Do');
+ testMoment = moment(ordinalStr, 'YYYY MM Do');
+ assert.equal(testMoment.year(), 2014,
+ 'lenient ordinal parsing ' + i + ' year check');
+ assert.equal(testMoment.month(), 0,
+ 'lenient ordinal parsing ' + i + ' month check');
+ assert.equal(testMoment.date(), i,
+ 'lenient ordinal parsing ' + i + ' date check');
+ }
+ });
+
+ test('lenient ordinal parsing of number', function (assert) {
+ var i, testMoment;
+ for (i = 1; i <= 31; ++i) {
+ testMoment = moment('2014 01 ' + i, 'YYYY MM Do');
+ assert.equal(testMoment.year(), 2014,
+ 'lenient ordinal parsing of number ' + i + ' year check');
+ assert.equal(testMoment.month(), 0,
+ 'lenient ordinal parsing of number ' + i + ' month check');
+ assert.equal(testMoment.date(), i,
+ 'lenient ordinal parsing of number ' + i + ' date check');
+ }
+ });
+
+ test('strict ordinal parsing', function (assert) {
+ var i, ordinalStr, testMoment;
+ for (i = 1; i <= 31; ++i) {
+ ordinalStr = moment([2014, 0, i]).format('YYYY MM Do');
+ testMoment = moment(ordinalStr, 'YYYY MM Do', true);
+ assert.ok(testMoment.isValid(), 'strict ordinal parsing ' + i);
+ }
+ });
+
+ test('meridiem invariant', function (assert) {
+ var h, m, t1, t2;
+ for (h = 0; h < 24; ++h) {
+ for (m = 0; m < 60; m += 15) {
+ t1 = moment.utc([2000, 0, 1, h, m]);
+ t2 = moment.utc(t1.format('A h:mm'), 'A h:mm');
+ assert.equal(t2.format('HH:mm'), t1.format('HH:mm'),
+ 'meridiem at ' + t1.format('HH:mm'));
+ }
+ }
+ });
+
+ test('date format correctness', function (assert) {
+ var data, tokens;
+ data = moment.localeData()._longDateFormat;
+ tokens = objectKeys(data);
+ each(tokens, function (srchToken) {
+ // Check each format string to make sure it does not contain any
+ // tokens that need to be expanded.
+ each(tokens, function (baseToken) {
+ // strip escaped sequences
+ var format = data[baseToken].replace(/(\[[^\]]*\])/g, '');
+ assert.equal(false, !!~format.indexOf(srchToken),
+ 'contains ' + srchToken + ' in ' + baseToken);
+ });
+ });
+ });
+
+ test('month parsing correctness', function (assert) {
+ var i, m;
+
+ if (locale === 'tr') {
+ // I can't fix it :(
+ expect(0);
+ return;
+ }
+ function tester(format) {
+ var r;
+ r = moment(m.format(format), format);
+ assert.equal(r.month(), m.month(), 'month ' + i + ' fmt ' + format);
+ r = moment(m.format(format).toLocaleUpperCase(), format);
+ assert.equal(r.month(), m.month(), 'month ' + i + ' fmt ' + format + ' upper');
+ r = moment(m.format(format).toLocaleLowerCase(), format);
+ assert.equal(r.month(), m.month(), 'month ' + i + ' fmt ' + format + ' lower');
+
+ r = moment(m.format(format), format, true);
+ assert.equal(r.month(), m.month(), 'month ' + i + ' fmt ' + format + ' strict');
+ r = moment(m.format(format).toLocaleUpperCase(), format, true);
+ assert.equal(r.month(), m.month(), 'month ' + i + ' fmt ' + format + ' upper strict');
+ r = moment(m.format(format).toLocaleLowerCase(), format, true);
+ assert.equal(r.month(), m.month(), 'month ' + i + ' fmt ' + format + ' lower strict');
+ }
+
+ for (i = 0; i < 12; ++i) {
+ m = moment([2015, i, 15, 18]);
+ tester('MMM');
+ tester('MMM.');
+ tester('MMMM');
+ tester('MMMM.');
+ }
+ });
+
+ test('weekday parsing correctness', function (assert) {
+ var i, m;
+
+ if (locale === 'tr' || locale === 'az') {
+ // There is a lower-case letter (ı), that converted to upper then
+ // lower changes to i
+ expect(0);
+ return;
+ }
+ function tester(format) {
+ var r, baseMsg = 'weekday ' + m.weekday() + ' fmt ' + format;
+ r = moment(m.format(format), format);
+ assert.equal(r.weekday(), m.weekday(), baseMsg);
+ r = moment(m.format(format).toLocaleUpperCase(), format);
+ assert.equal(r.weekday(), m.weekday(), baseMsg + ' upper');
+ r = moment(m.format(format).toLocaleLowerCase(), format);
+ assert.equal(r.weekday(), m.weekday(), baseMsg + ' lower');
+
+ r = moment(m.format(format), format, true);
+ assert.equal(r.weekday(), m.weekday(), baseMsg + ' strict');
+ r = moment(m.format(format).toLocaleUpperCase(), format, true);
+ assert.equal(r.weekday(), m.weekday(), baseMsg + ' upper strict');
+ r = moment(m.format(format).toLocaleLowerCase(), format, true);
+ assert.equal(r.weekday(), m.weekday(), baseMsg + ' lower strict');
+ }
+
+ for (i = 0; i < 7; ++i) {
+ m = moment.utc([2015, i, 15, 18]);
+ tester('dd');
+ tester('ddd');
+ tester('dddd');
+ }
+ });
+ }
+
+ function setupDeprecationHandler(test, moment, scope) {
+ test._expectedDeprecations = null;
+ test._observedDeprecations = null;
+ test._oldSupress = moment.suppressDeprecationWarnings;
+ moment.suppressDeprecationWarnings = true;
+ test.expectedDeprecations = function () {
+ test._expectedDeprecations = arguments;
+ test._observedDeprecations = [];
+ };
+ moment.deprecationHandler = function (name, msg) {
+ var deprecationId = matchedDeprecation(name, msg, test._expectedDeprecations);
+ if (deprecationId === -1) {
+ throw new Error('Unexpected deprecation thrown name=' +
+ name + ' msg=' + msg);
+ }
+ test._observedDeprecations[deprecationId] = 1;
+ };
+ }
+
+ function teardownDeprecationHandler(test, moment, scope) {
+ moment.suppressDeprecationWarnings = test._oldSupress;
+
+ if (test._expectedDeprecations != null) {
+ var missedDeprecations = [];
+ each(test._expectedDeprecations, function (deprecationPattern, id) {
+ if (test._observedDeprecations[id] !== 1) {
+ missedDeprecations.push(deprecationPattern);
+ }
+ });
+ if (missedDeprecations.length !== 0) {
+ throw new Error('Expected deprecation warnings did not happen: ' +
+ missedDeprecations.join(' '));
+ }
+ }
+ }
+
+ function matchedDeprecation(name, msg, deprecations) {
+ if (deprecations == null) {
+ return -1;
+ }
+ for (var i = 0; i < deprecations.length; ++i) {
+ if (name != null && name === deprecations[i]) {
+ return i;
+ }
+ if (msg != null && msg.substring(0, deprecations[i].length) === deprecations[i]) {
+ return i;
+ }
+ }
+ return -1;
+ }
+
/*global QUnit:false*/
var test = QUnit.test;
@@ -40232,11 +59205,13 @@
moment.createFromInputFallback = function (config) {
throw new Error('input not handled by moment: ' + config._i);
};
+ setupDeprecationHandler(test, moment, 'core');
if (lifecycle && lifecycle.setup) {
lifecycle.setup();
}
},
teardown : function () {
+ teardownDeprecationHandler(test, moment, 'core');
if (lifecycle && lifecycle.teardown) {
lifecycle.teardown();
}
@@ -40251,17 +59226,20 @@
moment.createFromInputFallback = function (config) {
throw new Error('input not handled by moment: ' + config._i);
};
+ setupDeprecationHandler(test, moment, 'locale');
if (lifecycle && lifecycle.setup) {
lifecycle.setup();
}
},
teardown : function () {
moment.locale('en');
+ teardownDeprecationHandler(test, moment, 'locale');
if (lifecycle && lifecycle.teardown) {
lifecycle.teardown();
}
}
});
+ defineCommonLocaleTests(name, -1, -1);
}
module('is between');
@@ -40335,6 +59313,143 @@
assert.equal(+m, +mCopy, 'isBetween second should not change moment');
});
+ test('is between without units inclusivity', function (assert) {
+ var m = moment(new Date(2011, 3, 2, 3, 4, 5, 10)), mCopy = moment(m);
+ assert.equal(m.isBetween(
+ moment(new Date(2011, 3, 2, 3, 4, 5, 10)),
+ moment(new Date(2012, 3, 2, 3, 4, 5, 10)), null, '()'), false, 'start and end are excluded, start is equal to moment');
+ assert.equal(m.isBetween(
+ moment(new Date(2010, 3, 2, 3, 4, 5, 10)),
+ moment(new Date(2011, 3, 2, 3, 4, 5, 10)), null, '()'), false, 'start and end are excluded, end is equal to moment');
+ assert.equal(m.isBetween(
+ moment(new Date(2010, 3, 2, 3, 4, 5, 10)),
+ moment(new Date(2012, 3, 2, 3, 4, 5, 10)), null, '()'), true, 'start and end are excluded, is between');
+ assert.equal(m.isBetween(
+ moment(new Date(2009, 3, 2, 3, 4, 5, 10)),
+ moment(new Date(2010, 3, 2, 3, 4, 5, 10)), null, '()'), false, 'start and end are excluded, is not between');
+ assert.equal(m.isBetween(
+ moment(new Date(2011, 3, 2, 3, 4, 5, 10)),
+ moment(new Date(2011, 3, 2, 3, 4, 5, 10)), null, '()'), false, 'start and end are excluded, should fail on same start/end date.');
+
+ assert.equal(m.isBetween(
+ moment(new Date(2011, 3, 2, 3, 4, 5, 10)),
+ moment(new Date(2012, 3, 2, 3, 4, 5, 10)), null, '(]'), false, 'start is excluded and end is included should fail on same start date');
+ assert.equal(m.isBetween(
+ moment(new Date(2010, 3, 2, 3, 4, 5, 10)),
+ moment(new Date(2011, 3, 2, 3, 4, 5, 10)), null, '(]'), true, 'start is excluded and end is included should succeed on end date');
+ assert.equal(m.isBetween(
+ moment(new Date(2010, 3, 2, 3, 4, 5, 10)),
+ moment(new Date(2012, 3, 2, 3, 4, 5, 10)), null, '(]'), true, 'start is excluded and end is included, is between');
+ assert.equal(m.isBetween(
+ moment(new Date(2009, 3, 2, 3, 4, 5, 10)),
+ moment(new Date(2010, 3, 2, 3, 4, 5, 10)), null, '(]'), false, 'start is excluded and end is included, is not between');
+ assert.equal(m.isBetween(
+ moment(new Date(2011, 3, 2, 3, 4, 5, 10)),
+ moment(new Date(2011, 3, 2, 3, 4, 5, 10)), null, '(]'), false, 'start is excluded and end is included, should fail on same start/end date.');
+
+ assert.equal(m.isBetween(
+ moment(new Date(2011, 3, 2, 3, 4, 5, 10)),
+ moment(new Date(2012, 3, 2, 3, 4, 5, 10)), null, '[)'), true, 'start is included and end is excluded should succeed on same start date');
+ assert.equal(m.isBetween(
+ moment(new Date(2010, 3, 2, 3, 4, 5, 10)),
+ moment(new Date(2011, 3, 2, 3, 4, 5, 10)), null, '[)'), false, 'start is included and end is excluded should fail on same end date');
+ assert.equal(m.isBetween(
+ moment(new Date(2010, 3, 2, 3, 4, 5, 10)),
+ moment(new Date(2012, 3, 2, 3, 4, 5, 10)), null, '[)'), true, 'start is included and end is excluded, is between');
+ assert.equal(m.isBetween(
+ moment(new Date(2009, 3, 2, 3, 4, 5, 10)),
+ moment(new Date(2010, 3, 2, 3, 4, 5, 10)), null, '[)'), false, 'start is included and end is excluded, is not between');
+ assert.equal(m.isBetween(
+ moment(new Date(2011, 3, 2, 3, 4, 5, 10)),
+ moment(new Date(2011, 3, 2, 3, 4, 5, 10)), null, '[)'), false, 'start is included and end is excluded, should fail on same end and start date');
+
+ assert.equal(m.isBetween(
+ moment(new Date(2011, 3, 2, 3, 4, 5, 10)),
+ moment(new Date(2012, 3, 2, 3, 4, 5, 10)), null, '[]'), true, 'start and end inclusive should succeed on same start date');
+ assert.equal(m.isBetween(
+ moment(new Date(2010, 3, 2, 3, 4, 5, 10)),
+ moment(new Date(2011, 3, 2, 3, 4, 5, 10)), null, '[]'), true, 'start and end inclusive should succeed on same end date');
+ assert.equal(m.isBetween(
+ moment(new Date(2010, 3, 2, 3, 4, 5, 10)),
+ moment(new Date(2012, 3, 2, 3, 4, 5, 10)), null, '[]'), true, 'start and end inclusive, is between');
+ assert.equal(m.isBetween(
+ moment(new Date(2009, 3, 2, 3, 4, 5, 10)),
+ moment(new Date(2010, 3, 2, 3, 4, 5, 10)), null, '[]'), false, 'start and end inclusive, is not between');
+ assert.equal(m.isBetween(
+ moment(new Date(2011, 3, 2, 3, 4, 5, 10)),
+ moment(new Date(2011, 3, 2, 3, 4, 5, 10)), null, '[]'), true, 'start and end inclusive, should handle same end and start date');
+ });
+
+ test('is between milliseconds inclusivity', function (assert) {
+ var m = moment(new Date(2011, 3, 2, 3, 4, 5, 10)), mCopy = moment(m);
+ assert.equal(m.isBetween(
+ moment(new Date(2010, 3, 2, 3, 4, 5, 10)),
+ moment(new Date(2012, 3, 2, 3, 4, 5, 10)), 'milliseconds'), true, 'options, no inclusive');
+ assert.equal(m.isBetween(
+ moment(new Date(2011, 3, 2, 3, 4, 5, 10)),
+ moment(new Date(2012, 3, 2, 3, 4, 5, 10)), 'milliseconds', '()'), false, 'start and end are excluded, start is equal to moment');
+ assert.equal(m.isBetween(
+ moment(new Date(2010, 3, 2, 3, 4, 5, 10)),
+ moment(new Date(2011, 3, 2, 3, 4, 5, 10)), 'milliseconds', '()'), false, 'start and end are excluded, end is equal to moment');
+ assert.equal(m.isBetween(
+ moment(new Date(2010, 3, 2, 3, 4, 5, 10)),
+ moment(new Date(2012, 3, 2, 3, 4, 5, 10)), 'milliseconds', '()'), true, 'start and end are excluded, is between');
+ assert.equal(m.isBetween(
+ moment(new Date(2009, 3, 2, 3, 4, 5, 10)),
+ moment(new Date(2010, 3, 2, 3, 4, 5, 10)), 'milliseconds', '()'), false, 'start and end are excluded, is not between');
+ assert.equal(m.isBetween(
+ moment(new Date(2011, 3, 2, 3, 4, 5, 10)),
+ moment(new Date(2011, 3, 2, 3, 4, 5, 10)), 'milliseconds', '()'), false, 'start and end are excluded, should fail on same start/end date.');
+
+ assert.equal(m.isBetween(
+ moment(new Date(2011, 3, 2, 3, 4, 5, 10)),
+ moment(new Date(2012, 3, 2, 3, 4, 5, 10)), 'milliseconds', '(]'), false, 'start is excluded and end is included should fail on same start date');
+ assert.equal(m.isBetween(
+ moment(new Date(2010, 3, 2, 3, 4, 5, 10)),
+ moment(new Date(2011, 3, 2, 3, 4, 5, 10)), 'milliseconds', '(]'), true, 'start is excluded and end is included should succeed on end date');
+ assert.equal(m.isBetween(
+ moment(new Date(2010, 3, 2, 3, 4, 5, 10)),
+ moment(new Date(2012, 3, 2, 3, 4, 5, 10)), 'milliseconds', '(]'), true, 'start is excluded and end is included, is between');
+ assert.equal(m.isBetween(
+ moment(new Date(2009, 3, 2, 3, 4, 5, 10)),
+ moment(new Date(2010, 3, 2, 3, 4, 5, 10)), 'milliseconds', '(]'), false, 'start is excluded and end is included, is not between');
+ assert.equal(m.isBetween(
+ moment(new Date(2011, 3, 2, 3, 4, 5, 10)),
+ moment(new Date(2011, 3, 2, 3, 4, 5, 10)), 'milliseconds', '(]'), false, 'start is excluded and end is included, should fail on same start/end date.');
+
+ assert.equal(m.isBetween(
+ moment(new Date(2011, 3, 2, 3, 4, 5, 10)),
+ moment(new Date(2012, 3, 2, 3, 4, 5, 10)), 'milliseconds', '[)'), true, 'start is included and end is excluded should succeed on same start date');
+ assert.equal(m.isBetween(
+ moment(new Date(2010, 3, 2, 3, 4, 5, 10)),
+ moment(new Date(2011, 3, 2, 3, 4, 5, 10)), 'milliseconds', '[)'), false, 'start is included and end is excluded should fail on same end date');
+ assert.equal(m.isBetween(
+ moment(new Date(2010, 3, 2, 3, 4, 5, 10)),
+ moment(new Date(2012, 3, 2, 3, 4, 5, 10)), 'milliseconds', '[)'), true, 'start is included and end is excluded, is between');
+ assert.equal(m.isBetween(
+ moment(new Date(2009, 3, 2, 3, 4, 5, 10)),
+ moment(new Date(2010, 3, 2, 3, 4, 5, 10)), 'milliseconds', '[)'), false, 'start is included and end is excluded, is not between');
+ assert.equal(m.isBetween(
+ moment(new Date(2011, 3, 2, 3, 4, 5, 10)),
+ moment(new Date(2011, 3, 2, 3, 4, 5, 10)), 'milliseconds', '[)'), false, 'start is included and end is excluded, should fail on same end and start date');
+
+ assert.equal(m.isBetween(
+ moment(new Date(2011, 3, 2, 3, 4, 5, 10)),
+ moment(new Date(2012, 3, 2, 3, 4, 5, 10)), 'milliseconds', '[]'), true, 'start and end inclusive should succeed on same start date');
+ assert.equal(m.isBetween(
+ moment(new Date(2010, 3, 2, 3, 4, 5, 10)),
+ moment(new Date(2011, 3, 2, 3, 4, 5, 10)), 'milliseconds', '[]'), true, 'start and end inclusive should succeed on same end date');
+ assert.equal(m.isBetween(
+ moment(new Date(2010, 3, 2, 3, 4, 5, 10)),
+ moment(new Date(2012, 3, 2, 3, 4, 5, 10)), 'milliseconds', '[]'), true, 'start and end inclusive, is between');
+ assert.equal(m.isBetween(
+ moment(new Date(2009, 3, 2, 3, 4, 5, 10)),
+ moment(new Date(2010, 3, 2, 3, 4, 5, 10)), 'milliseconds', '[]'), false, 'start and end inclusive, is not between');
+ assert.equal(m.isBetween(
+ moment(new Date(2011, 3, 2, 3, 4, 5, 10)),
+ moment(new Date(2011, 3, 2, 3, 4, 5, 10)), 'milliseconds', '[]'), true, 'start and end inclusive, should handle same end and start date');
+ });
+
test('is between year', function (assert) {
var m = moment(new Date(2011, 1, 2, 3, 4, 5, 6)), mCopy = moment(m);
assert.equal(m.isBetween(
@@ -40491,6 +59606,224 @@
factory(global.moment)
}(this, function (moment) { 'use strict';
+ function each(array, callback) {
+ var i;
+ for (i = 0; i < array.length; i++) {
+ callback(array[i], i, array);
+ }
+ }
+
+ function objectKeys(obj) {
+ if (Object.keys) {
+ return Object.keys(obj);
+ } else {
+ // IE8
+ var res = [], i;
+ for (i in obj) {
+ if (obj.hasOwnProperty(i)) {
+ res.push(i);
+ }
+ }
+ return res;
+ }
+ }
+
+ // Pick the first defined of two or three arguments.
+ function defaults(a, b, c) {
+ if (a != null) {
+ return a;
+ }
+ if (b != null) {
+ return b;
+ }
+ return c;
+ }
+
+ function defineCommonLocaleTests(locale, options) {
+ test('lenient ordinal parsing', function (assert) {
+ var i, ordinalStr, testMoment;
+ for (i = 1; i <= 31; ++i) {
+ ordinalStr = moment([2014, 0, i]).format('YYYY MM Do');
+ testMoment = moment(ordinalStr, 'YYYY MM Do');
+ assert.equal(testMoment.year(), 2014,
+ 'lenient ordinal parsing ' + i + ' year check');
+ assert.equal(testMoment.month(), 0,
+ 'lenient ordinal parsing ' + i + ' month check');
+ assert.equal(testMoment.date(), i,
+ 'lenient ordinal parsing ' + i + ' date check');
+ }
+ });
+
+ test('lenient ordinal parsing of number', function (assert) {
+ var i, testMoment;
+ for (i = 1; i <= 31; ++i) {
+ testMoment = moment('2014 01 ' + i, 'YYYY MM Do');
+ assert.equal(testMoment.year(), 2014,
+ 'lenient ordinal parsing of number ' + i + ' year check');
+ assert.equal(testMoment.month(), 0,
+ 'lenient ordinal parsing of number ' + i + ' month check');
+ assert.equal(testMoment.date(), i,
+ 'lenient ordinal parsing of number ' + i + ' date check');
+ }
+ });
+
+ test('strict ordinal parsing', function (assert) {
+ var i, ordinalStr, testMoment;
+ for (i = 1; i <= 31; ++i) {
+ ordinalStr = moment([2014, 0, i]).format('YYYY MM Do');
+ testMoment = moment(ordinalStr, 'YYYY MM Do', true);
+ assert.ok(testMoment.isValid(), 'strict ordinal parsing ' + i);
+ }
+ });
+
+ test('meridiem invariant', function (assert) {
+ var h, m, t1, t2;
+ for (h = 0; h < 24; ++h) {
+ for (m = 0; m < 60; m += 15) {
+ t1 = moment.utc([2000, 0, 1, h, m]);
+ t2 = moment.utc(t1.format('A h:mm'), 'A h:mm');
+ assert.equal(t2.format('HH:mm'), t1.format('HH:mm'),
+ 'meridiem at ' + t1.format('HH:mm'));
+ }
+ }
+ });
+
+ test('date format correctness', function (assert) {
+ var data, tokens;
+ data = moment.localeData()._longDateFormat;
+ tokens = objectKeys(data);
+ each(tokens, function (srchToken) {
+ // Check each format string to make sure it does not contain any
+ // tokens that need to be expanded.
+ each(tokens, function (baseToken) {
+ // strip escaped sequences
+ var format = data[baseToken].replace(/(\[[^\]]*\])/g, '');
+ assert.equal(false, !!~format.indexOf(srchToken),
+ 'contains ' + srchToken + ' in ' + baseToken);
+ });
+ });
+ });
+
+ test('month parsing correctness', function (assert) {
+ var i, m;
+
+ if (locale === 'tr') {
+ // I can't fix it :(
+ expect(0);
+ return;
+ }
+ function tester(format) {
+ var r;
+ r = moment(m.format(format), format);
+ assert.equal(r.month(), m.month(), 'month ' + i + ' fmt ' + format);
+ r = moment(m.format(format).toLocaleUpperCase(), format);
+ assert.equal(r.month(), m.month(), 'month ' + i + ' fmt ' + format + ' upper');
+ r = moment(m.format(format).toLocaleLowerCase(), format);
+ assert.equal(r.month(), m.month(), 'month ' + i + ' fmt ' + format + ' lower');
+
+ r = moment(m.format(format), format, true);
+ assert.equal(r.month(), m.month(), 'month ' + i + ' fmt ' + format + ' strict');
+ r = moment(m.format(format).toLocaleUpperCase(), format, true);
+ assert.equal(r.month(), m.month(), 'month ' + i + ' fmt ' + format + ' upper strict');
+ r = moment(m.format(format).toLocaleLowerCase(), format, true);
+ assert.equal(r.month(), m.month(), 'month ' + i + ' fmt ' + format + ' lower strict');
+ }
+
+ for (i = 0; i < 12; ++i) {
+ m = moment([2015, i, 15, 18]);
+ tester('MMM');
+ tester('MMM.');
+ tester('MMMM');
+ tester('MMMM.');
+ }
+ });
+
+ test('weekday parsing correctness', function (assert) {
+ var i, m;
+
+ if (locale === 'tr' || locale === 'az') {
+ // There is a lower-case letter (ı), that converted to upper then
+ // lower changes to i
+ expect(0);
+ return;
+ }
+ function tester(format) {
+ var r, baseMsg = 'weekday ' + m.weekday() + ' fmt ' + format;
+ r = moment(m.format(format), format);
+ assert.equal(r.weekday(), m.weekday(), baseMsg);
+ r = moment(m.format(format).toLocaleUpperCase(), format);
+ assert.equal(r.weekday(), m.weekday(), baseMsg + ' upper');
+ r = moment(m.format(format).toLocaleLowerCase(), format);
+ assert.equal(r.weekday(), m.weekday(), baseMsg + ' lower');
+
+ r = moment(m.format(format), format, true);
+ assert.equal(r.weekday(), m.weekday(), baseMsg + ' strict');
+ r = moment(m.format(format).toLocaleUpperCase(), format, true);
+ assert.equal(r.weekday(), m.weekday(), baseMsg + ' upper strict');
+ r = moment(m.format(format).toLocaleLowerCase(), format, true);
+ assert.equal(r.weekday(), m.weekday(), baseMsg + ' lower strict');
+ }
+
+ for (i = 0; i < 7; ++i) {
+ m = moment.utc([2015, i, 15, 18]);
+ tester('dd');
+ tester('ddd');
+ tester('dddd');
+ }
+ });
+ }
+
+ function setupDeprecationHandler(test, moment, scope) {
+ test._expectedDeprecations = null;
+ test._observedDeprecations = null;
+ test._oldSupress = moment.suppressDeprecationWarnings;
+ moment.suppressDeprecationWarnings = true;
+ test.expectedDeprecations = function () {
+ test._expectedDeprecations = arguments;
+ test._observedDeprecations = [];
+ };
+ moment.deprecationHandler = function (name, msg) {
+ var deprecationId = matchedDeprecation(name, msg, test._expectedDeprecations);
+ if (deprecationId === -1) {
+ throw new Error('Unexpected deprecation thrown name=' +
+ name + ' msg=' + msg);
+ }
+ test._observedDeprecations[deprecationId] = 1;
+ };
+ }
+
+ function teardownDeprecationHandler(test, moment, scope) {
+ moment.suppressDeprecationWarnings = test._oldSupress;
+
+ if (test._expectedDeprecations != null) {
+ var missedDeprecations = [];
+ each(test._expectedDeprecations, function (deprecationPattern, id) {
+ if (test._observedDeprecations[id] !== 1) {
+ missedDeprecations.push(deprecationPattern);
+ }
+ });
+ if (missedDeprecations.length !== 0) {
+ throw new Error('Expected deprecation warnings did not happen: ' +
+ missedDeprecations.join(' '));
+ }
+ }
+ }
+
+ function matchedDeprecation(name, msg, deprecations) {
+ if (deprecations == null) {
+ return -1;
+ }
+ for (var i = 0; i < deprecations.length; ++i) {
+ if (name != null && name === deprecations[i]) {
+ return i;
+ }
+ if (msg != null && msg.substring(0, deprecations[i].length) === deprecations[i]) {
+ return i;
+ }
+ }
+ return -1;
+ }
+
/*global QUnit:false*/
var test = QUnit.test;
@@ -40504,11 +59837,13 @@
moment.createFromInputFallback = function (config) {
throw new Error('input not handled by moment: ' + config._i);
};
+ setupDeprecationHandler(test, moment, 'core');
if (lifecycle && lifecycle.setup) {
lifecycle.setup();
}
},
teardown : function () {
+ teardownDeprecationHandler(test, moment, 'core');
if (lifecycle && lifecycle.teardown) {
lifecycle.teardown();
}
@@ -40523,17 +59858,20 @@
moment.createFromInputFallback = function (config) {
throw new Error('input not handled by moment: ' + config._i);
};
+ setupDeprecationHandler(test, moment, 'locale');
if (lifecycle && lifecycle.setup) {
lifecycle.setup();
}
},
teardown : function () {
moment.locale('en');
+ teardownDeprecationHandler(test, moment, 'locale');
if (lifecycle && lifecycle.teardown) {
lifecycle.teardown();
}
}
});
+ defineCommonLocaleTests(name, -1, -1);
}
module('is date');
@@ -40567,6 +59905,224 @@
factory(global.moment)
}(this, function (moment) { 'use strict';
+ function each(array, callback) {
+ var i;
+ for (i = 0; i < array.length; i++) {
+ callback(array[i], i, array);
+ }
+ }
+
+ function objectKeys(obj) {
+ if (Object.keys) {
+ return Object.keys(obj);
+ } else {
+ // IE8
+ var res = [], i;
+ for (i in obj) {
+ if (obj.hasOwnProperty(i)) {
+ res.push(i);
+ }
+ }
+ return res;
+ }
+ }
+
+ // Pick the first defined of two or three arguments.
+ function defaults(a, b, c) {
+ if (a != null) {
+ return a;
+ }
+ if (b != null) {
+ return b;
+ }
+ return c;
+ }
+
+ function defineCommonLocaleTests(locale, options) {
+ test('lenient ordinal parsing', function (assert) {
+ var i, ordinalStr, testMoment;
+ for (i = 1; i <= 31; ++i) {
+ ordinalStr = moment([2014, 0, i]).format('YYYY MM Do');
+ testMoment = moment(ordinalStr, 'YYYY MM Do');
+ assert.equal(testMoment.year(), 2014,
+ 'lenient ordinal parsing ' + i + ' year check');
+ assert.equal(testMoment.month(), 0,
+ 'lenient ordinal parsing ' + i + ' month check');
+ assert.equal(testMoment.date(), i,
+ 'lenient ordinal parsing ' + i + ' date check');
+ }
+ });
+
+ test('lenient ordinal parsing of number', function (assert) {
+ var i, testMoment;
+ for (i = 1; i <= 31; ++i) {
+ testMoment = moment('2014 01 ' + i, 'YYYY MM Do');
+ assert.equal(testMoment.year(), 2014,
+ 'lenient ordinal parsing of number ' + i + ' year check');
+ assert.equal(testMoment.month(), 0,
+ 'lenient ordinal parsing of number ' + i + ' month check');
+ assert.equal(testMoment.date(), i,
+ 'lenient ordinal parsing of number ' + i + ' date check');
+ }
+ });
+
+ test('strict ordinal parsing', function (assert) {
+ var i, ordinalStr, testMoment;
+ for (i = 1; i <= 31; ++i) {
+ ordinalStr = moment([2014, 0, i]).format('YYYY MM Do');
+ testMoment = moment(ordinalStr, 'YYYY MM Do', true);
+ assert.ok(testMoment.isValid(), 'strict ordinal parsing ' + i);
+ }
+ });
+
+ test('meridiem invariant', function (assert) {
+ var h, m, t1, t2;
+ for (h = 0; h < 24; ++h) {
+ for (m = 0; m < 60; m += 15) {
+ t1 = moment.utc([2000, 0, 1, h, m]);
+ t2 = moment.utc(t1.format('A h:mm'), 'A h:mm');
+ assert.equal(t2.format('HH:mm'), t1.format('HH:mm'),
+ 'meridiem at ' + t1.format('HH:mm'));
+ }
+ }
+ });
+
+ test('date format correctness', function (assert) {
+ var data, tokens;
+ data = moment.localeData()._longDateFormat;
+ tokens = objectKeys(data);
+ each(tokens, function (srchToken) {
+ // Check each format string to make sure it does not contain any
+ // tokens that need to be expanded.
+ each(tokens, function (baseToken) {
+ // strip escaped sequences
+ var format = data[baseToken].replace(/(\[[^\]]*\])/g, '');
+ assert.equal(false, !!~format.indexOf(srchToken),
+ 'contains ' + srchToken + ' in ' + baseToken);
+ });
+ });
+ });
+
+ test('month parsing correctness', function (assert) {
+ var i, m;
+
+ if (locale === 'tr') {
+ // I can't fix it :(
+ expect(0);
+ return;
+ }
+ function tester(format) {
+ var r;
+ r = moment(m.format(format), format);
+ assert.equal(r.month(), m.month(), 'month ' + i + ' fmt ' + format);
+ r = moment(m.format(format).toLocaleUpperCase(), format);
+ assert.equal(r.month(), m.month(), 'month ' + i + ' fmt ' + format + ' upper');
+ r = moment(m.format(format).toLocaleLowerCase(), format);
+ assert.equal(r.month(), m.month(), 'month ' + i + ' fmt ' + format + ' lower');
+
+ r = moment(m.format(format), format, true);
+ assert.equal(r.month(), m.month(), 'month ' + i + ' fmt ' + format + ' strict');
+ r = moment(m.format(format).toLocaleUpperCase(), format, true);
+ assert.equal(r.month(), m.month(), 'month ' + i + ' fmt ' + format + ' upper strict');
+ r = moment(m.format(format).toLocaleLowerCase(), format, true);
+ assert.equal(r.month(), m.month(), 'month ' + i + ' fmt ' + format + ' lower strict');
+ }
+
+ for (i = 0; i < 12; ++i) {
+ m = moment([2015, i, 15, 18]);
+ tester('MMM');
+ tester('MMM.');
+ tester('MMMM');
+ tester('MMMM.');
+ }
+ });
+
+ test('weekday parsing correctness', function (assert) {
+ var i, m;
+
+ if (locale === 'tr' || locale === 'az') {
+ // There is a lower-case letter (ı), that converted to upper then
+ // lower changes to i
+ expect(0);
+ return;
+ }
+ function tester(format) {
+ var r, baseMsg = 'weekday ' + m.weekday() + ' fmt ' + format;
+ r = moment(m.format(format), format);
+ assert.equal(r.weekday(), m.weekday(), baseMsg);
+ r = moment(m.format(format).toLocaleUpperCase(), format);
+ assert.equal(r.weekday(), m.weekday(), baseMsg + ' upper');
+ r = moment(m.format(format).toLocaleLowerCase(), format);
+ assert.equal(r.weekday(), m.weekday(), baseMsg + ' lower');
+
+ r = moment(m.format(format), format, true);
+ assert.equal(r.weekday(), m.weekday(), baseMsg + ' strict');
+ r = moment(m.format(format).toLocaleUpperCase(), format, true);
+ assert.equal(r.weekday(), m.weekday(), baseMsg + ' upper strict');
+ r = moment(m.format(format).toLocaleLowerCase(), format, true);
+ assert.equal(r.weekday(), m.weekday(), baseMsg + ' lower strict');
+ }
+
+ for (i = 0; i < 7; ++i) {
+ m = moment.utc([2015, i, 15, 18]);
+ tester('dd');
+ tester('ddd');
+ tester('dddd');
+ }
+ });
+ }
+
+ function setupDeprecationHandler(test, moment, scope) {
+ test._expectedDeprecations = null;
+ test._observedDeprecations = null;
+ test._oldSupress = moment.suppressDeprecationWarnings;
+ moment.suppressDeprecationWarnings = true;
+ test.expectedDeprecations = function () {
+ test._expectedDeprecations = arguments;
+ test._observedDeprecations = [];
+ };
+ moment.deprecationHandler = function (name, msg) {
+ var deprecationId = matchedDeprecation(name, msg, test._expectedDeprecations);
+ if (deprecationId === -1) {
+ throw new Error('Unexpected deprecation thrown name=' +
+ name + ' msg=' + msg);
+ }
+ test._observedDeprecations[deprecationId] = 1;
+ };
+ }
+
+ function teardownDeprecationHandler(test, moment, scope) {
+ moment.suppressDeprecationWarnings = test._oldSupress;
+
+ if (test._expectedDeprecations != null) {
+ var missedDeprecations = [];
+ each(test._expectedDeprecations, function (deprecationPattern, id) {
+ if (test._observedDeprecations[id] !== 1) {
+ missedDeprecations.push(deprecationPattern);
+ }
+ });
+ if (missedDeprecations.length !== 0) {
+ throw new Error('Expected deprecation warnings did not happen: ' +
+ missedDeprecations.join(' '));
+ }
+ }
+ }
+
+ function matchedDeprecation(name, msg, deprecations) {
+ if (deprecations == null) {
+ return -1;
+ }
+ for (var i = 0; i < deprecations.length; ++i) {
+ if (name != null && name === deprecations[i]) {
+ return i;
+ }
+ if (msg != null && msg.substring(0, deprecations[i].length) === deprecations[i]) {
+ return i;
+ }
+ }
+ return -1;
+ }
+
/*global QUnit:false*/
var test = QUnit.test;
@@ -40580,11 +60136,13 @@
moment.createFromInputFallback = function (config) {
throw new Error('input not handled by moment: ' + config._i);
};
+ setupDeprecationHandler(test, moment, 'core');
if (lifecycle && lifecycle.setup) {
lifecycle.setup();
}
},
teardown : function () {
+ teardownDeprecationHandler(test, moment, 'core');
if (lifecycle && lifecycle.teardown) {
lifecycle.teardown();
}
@@ -40599,17 +60157,20 @@
moment.createFromInputFallback = function (config) {
throw new Error('input not handled by moment: ' + config._i);
};
+ setupDeprecationHandler(test, moment, 'locale');
if (lifecycle && lifecycle.setup) {
lifecycle.setup();
}
},
teardown : function () {
moment.locale('en');
+ teardownDeprecationHandler(test, moment, 'locale');
if (lifecycle && lifecycle.teardown) {
lifecycle.teardown();
}
}
});
+ defineCommonLocaleTests(name, -1, -1);
}
module('is moment');
@@ -40662,6 +60223,224 @@
factory(global.moment)
}(this, function (moment) { 'use strict';
+ function each(array, callback) {
+ var i;
+ for (i = 0; i < array.length; i++) {
+ callback(array[i], i, array);
+ }
+ }
+
+ function objectKeys(obj) {
+ if (Object.keys) {
+ return Object.keys(obj);
+ } else {
+ // IE8
+ var res = [], i;
+ for (i in obj) {
+ if (obj.hasOwnProperty(i)) {
+ res.push(i);
+ }
+ }
+ return res;
+ }
+ }
+
+ // Pick the first defined of two or three arguments.
+ function defaults(a, b, c) {
+ if (a != null) {
+ return a;
+ }
+ if (b != null) {
+ return b;
+ }
+ return c;
+ }
+
+ function defineCommonLocaleTests(locale, options) {
+ test('lenient ordinal parsing', function (assert) {
+ var i, ordinalStr, testMoment;
+ for (i = 1; i <= 31; ++i) {
+ ordinalStr = moment([2014, 0, i]).format('YYYY MM Do');
+ testMoment = moment(ordinalStr, 'YYYY MM Do');
+ assert.equal(testMoment.year(), 2014,
+ 'lenient ordinal parsing ' + i + ' year check');
+ assert.equal(testMoment.month(), 0,
+ 'lenient ordinal parsing ' + i + ' month check');
+ assert.equal(testMoment.date(), i,
+ 'lenient ordinal parsing ' + i + ' date check');
+ }
+ });
+
+ test('lenient ordinal parsing of number', function (assert) {
+ var i, testMoment;
+ for (i = 1; i <= 31; ++i) {
+ testMoment = moment('2014 01 ' + i, 'YYYY MM Do');
+ assert.equal(testMoment.year(), 2014,
+ 'lenient ordinal parsing of number ' + i + ' year check');
+ assert.equal(testMoment.month(), 0,
+ 'lenient ordinal parsing of number ' + i + ' month check');
+ assert.equal(testMoment.date(), i,
+ 'lenient ordinal parsing of number ' + i + ' date check');
+ }
+ });
+
+ test('strict ordinal parsing', function (assert) {
+ var i, ordinalStr, testMoment;
+ for (i = 1; i <= 31; ++i) {
+ ordinalStr = moment([2014, 0, i]).format('YYYY MM Do');
+ testMoment = moment(ordinalStr, 'YYYY MM Do', true);
+ assert.ok(testMoment.isValid(), 'strict ordinal parsing ' + i);
+ }
+ });
+
+ test('meridiem invariant', function (assert) {
+ var h, m, t1, t2;
+ for (h = 0; h < 24; ++h) {
+ for (m = 0; m < 60; m += 15) {
+ t1 = moment.utc([2000, 0, 1, h, m]);
+ t2 = moment.utc(t1.format('A h:mm'), 'A h:mm');
+ assert.equal(t2.format('HH:mm'), t1.format('HH:mm'),
+ 'meridiem at ' + t1.format('HH:mm'));
+ }
+ }
+ });
+
+ test('date format correctness', function (assert) {
+ var data, tokens;
+ data = moment.localeData()._longDateFormat;
+ tokens = objectKeys(data);
+ each(tokens, function (srchToken) {
+ // Check each format string to make sure it does not contain any
+ // tokens that need to be expanded.
+ each(tokens, function (baseToken) {
+ // strip escaped sequences
+ var format = data[baseToken].replace(/(\[[^\]]*\])/g, '');
+ assert.equal(false, !!~format.indexOf(srchToken),
+ 'contains ' + srchToken + ' in ' + baseToken);
+ });
+ });
+ });
+
+ test('month parsing correctness', function (assert) {
+ var i, m;
+
+ if (locale === 'tr') {
+ // I can't fix it :(
+ expect(0);
+ return;
+ }
+ function tester(format) {
+ var r;
+ r = moment(m.format(format), format);
+ assert.equal(r.month(), m.month(), 'month ' + i + ' fmt ' + format);
+ r = moment(m.format(format).toLocaleUpperCase(), format);
+ assert.equal(r.month(), m.month(), 'month ' + i + ' fmt ' + format + ' upper');
+ r = moment(m.format(format).toLocaleLowerCase(), format);
+ assert.equal(r.month(), m.month(), 'month ' + i + ' fmt ' + format + ' lower');
+
+ r = moment(m.format(format), format, true);
+ assert.equal(r.month(), m.month(), 'month ' + i + ' fmt ' + format + ' strict');
+ r = moment(m.format(format).toLocaleUpperCase(), format, true);
+ assert.equal(r.month(), m.month(), 'month ' + i + ' fmt ' + format + ' upper strict');
+ r = moment(m.format(format).toLocaleLowerCase(), format, true);
+ assert.equal(r.month(), m.month(), 'month ' + i + ' fmt ' + format + ' lower strict');
+ }
+
+ for (i = 0; i < 12; ++i) {
+ m = moment([2015, i, 15, 18]);
+ tester('MMM');
+ tester('MMM.');
+ tester('MMMM');
+ tester('MMMM.');
+ }
+ });
+
+ test('weekday parsing correctness', function (assert) {
+ var i, m;
+
+ if (locale === 'tr' || locale === 'az') {
+ // There is a lower-case letter (ı), that converted to upper then
+ // lower changes to i
+ expect(0);
+ return;
+ }
+ function tester(format) {
+ var r, baseMsg = 'weekday ' + m.weekday() + ' fmt ' + format;
+ r = moment(m.format(format), format);
+ assert.equal(r.weekday(), m.weekday(), baseMsg);
+ r = moment(m.format(format).toLocaleUpperCase(), format);
+ assert.equal(r.weekday(), m.weekday(), baseMsg + ' upper');
+ r = moment(m.format(format).toLocaleLowerCase(), format);
+ assert.equal(r.weekday(), m.weekday(), baseMsg + ' lower');
+
+ r = moment(m.format(format), format, true);
+ assert.equal(r.weekday(), m.weekday(), baseMsg + ' strict');
+ r = moment(m.format(format).toLocaleUpperCase(), format, true);
+ assert.equal(r.weekday(), m.weekday(), baseMsg + ' upper strict');
+ r = moment(m.format(format).toLocaleLowerCase(), format, true);
+ assert.equal(r.weekday(), m.weekday(), baseMsg + ' lower strict');
+ }
+
+ for (i = 0; i < 7; ++i) {
+ m = moment.utc([2015, i, 15, 18]);
+ tester('dd');
+ tester('ddd');
+ tester('dddd');
+ }
+ });
+ }
+
+ function setupDeprecationHandler(test, moment, scope) {
+ test._expectedDeprecations = null;
+ test._observedDeprecations = null;
+ test._oldSupress = moment.suppressDeprecationWarnings;
+ moment.suppressDeprecationWarnings = true;
+ test.expectedDeprecations = function () {
+ test._expectedDeprecations = arguments;
+ test._observedDeprecations = [];
+ };
+ moment.deprecationHandler = function (name, msg) {
+ var deprecationId = matchedDeprecation(name, msg, test._expectedDeprecations);
+ if (deprecationId === -1) {
+ throw new Error('Unexpected deprecation thrown name=' +
+ name + ' msg=' + msg);
+ }
+ test._observedDeprecations[deprecationId] = 1;
+ };
+ }
+
+ function teardownDeprecationHandler(test, moment, scope) {
+ moment.suppressDeprecationWarnings = test._oldSupress;
+
+ if (test._expectedDeprecations != null) {
+ var missedDeprecations = [];
+ each(test._expectedDeprecations, function (deprecationPattern, id) {
+ if (test._observedDeprecations[id] !== 1) {
+ missedDeprecations.push(deprecationPattern);
+ }
+ });
+ if (missedDeprecations.length !== 0) {
+ throw new Error('Expected deprecation warnings did not happen: ' +
+ missedDeprecations.join(' '));
+ }
+ }
+ }
+
+ function matchedDeprecation(name, msg, deprecations) {
+ if (deprecations == null) {
+ return -1;
+ }
+ for (var i = 0; i < deprecations.length; ++i) {
+ if (name != null && name === deprecations[i]) {
+ return i;
+ }
+ if (msg != null && msg.substring(0, deprecations[i].length) === deprecations[i]) {
+ return i;
+ }
+ }
+ return -1;
+ }
+
/*global QUnit:false*/
var test = QUnit.test;
@@ -40675,11 +60454,13 @@
moment.createFromInputFallback = function (config) {
throw new Error('input not handled by moment: ' + config._i);
};
+ setupDeprecationHandler(test, moment, 'core');
if (lifecycle && lifecycle.setup) {
lifecycle.setup();
}
},
teardown : function () {
+ teardownDeprecationHandler(test, moment, 'core');
if (lifecycle && lifecycle.teardown) {
lifecycle.teardown();
}
@@ -40694,17 +60475,20 @@
moment.createFromInputFallback = function (config) {
throw new Error('input not handled by moment: ' + config._i);
};
+ setupDeprecationHandler(test, moment, 'locale');
if (lifecycle && lifecycle.setup) {
lifecycle.setup();
}
},
teardown : function () {
moment.locale('en');
+ teardownDeprecationHandler(test, moment, 'locale');
if (lifecycle && lifecycle.teardown) {
lifecycle.teardown();
}
}
});
+ defineCommonLocaleTests(name, -1, -1);
}
module('is same');
@@ -40865,6 +60649,224 @@
factory(global.moment)
}(this, function (moment) { 'use strict';
+ function each(array, callback) {
+ var i;
+ for (i = 0; i < array.length; i++) {
+ callback(array[i], i, array);
+ }
+ }
+
+ function objectKeys(obj) {
+ if (Object.keys) {
+ return Object.keys(obj);
+ } else {
+ // IE8
+ var res = [], i;
+ for (i in obj) {
+ if (obj.hasOwnProperty(i)) {
+ res.push(i);
+ }
+ }
+ return res;
+ }
+ }
+
+ // Pick the first defined of two or three arguments.
+ function defaults(a, b, c) {
+ if (a != null) {
+ return a;
+ }
+ if (b != null) {
+ return b;
+ }
+ return c;
+ }
+
+ function defineCommonLocaleTests(locale, options) {
+ test('lenient ordinal parsing', function (assert) {
+ var i, ordinalStr, testMoment;
+ for (i = 1; i <= 31; ++i) {
+ ordinalStr = moment([2014, 0, i]).format('YYYY MM Do');
+ testMoment = moment(ordinalStr, 'YYYY MM Do');
+ assert.equal(testMoment.year(), 2014,
+ 'lenient ordinal parsing ' + i + ' year check');
+ assert.equal(testMoment.month(), 0,
+ 'lenient ordinal parsing ' + i + ' month check');
+ assert.equal(testMoment.date(), i,
+ 'lenient ordinal parsing ' + i + ' date check');
+ }
+ });
+
+ test('lenient ordinal parsing of number', function (assert) {
+ var i, testMoment;
+ for (i = 1; i <= 31; ++i) {
+ testMoment = moment('2014 01 ' + i, 'YYYY MM Do');
+ assert.equal(testMoment.year(), 2014,
+ 'lenient ordinal parsing of number ' + i + ' year check');
+ assert.equal(testMoment.month(), 0,
+ 'lenient ordinal parsing of number ' + i + ' month check');
+ assert.equal(testMoment.date(), i,
+ 'lenient ordinal parsing of number ' + i + ' date check');
+ }
+ });
+
+ test('strict ordinal parsing', function (assert) {
+ var i, ordinalStr, testMoment;
+ for (i = 1; i <= 31; ++i) {
+ ordinalStr = moment([2014, 0, i]).format('YYYY MM Do');
+ testMoment = moment(ordinalStr, 'YYYY MM Do', true);
+ assert.ok(testMoment.isValid(), 'strict ordinal parsing ' + i);
+ }
+ });
+
+ test('meridiem invariant', function (assert) {
+ var h, m, t1, t2;
+ for (h = 0; h < 24; ++h) {
+ for (m = 0; m < 60; m += 15) {
+ t1 = moment.utc([2000, 0, 1, h, m]);
+ t2 = moment.utc(t1.format('A h:mm'), 'A h:mm');
+ assert.equal(t2.format('HH:mm'), t1.format('HH:mm'),
+ 'meridiem at ' + t1.format('HH:mm'));
+ }
+ }
+ });
+
+ test('date format correctness', function (assert) {
+ var data, tokens;
+ data = moment.localeData()._longDateFormat;
+ tokens = objectKeys(data);
+ each(tokens, function (srchToken) {
+ // Check each format string to make sure it does not contain any
+ // tokens that need to be expanded.
+ each(tokens, function (baseToken) {
+ // strip escaped sequences
+ var format = data[baseToken].replace(/(\[[^\]]*\])/g, '');
+ assert.equal(false, !!~format.indexOf(srchToken),
+ 'contains ' + srchToken + ' in ' + baseToken);
+ });
+ });
+ });
+
+ test('month parsing correctness', function (assert) {
+ var i, m;
+
+ if (locale === 'tr') {
+ // I can't fix it :(
+ expect(0);
+ return;
+ }
+ function tester(format) {
+ var r;
+ r = moment(m.format(format), format);
+ assert.equal(r.month(), m.month(), 'month ' + i + ' fmt ' + format);
+ r = moment(m.format(format).toLocaleUpperCase(), format);
+ assert.equal(r.month(), m.month(), 'month ' + i + ' fmt ' + format + ' upper');
+ r = moment(m.format(format).toLocaleLowerCase(), format);
+ assert.equal(r.month(), m.month(), 'month ' + i + ' fmt ' + format + ' lower');
+
+ r = moment(m.format(format), format, true);
+ assert.equal(r.month(), m.month(), 'month ' + i + ' fmt ' + format + ' strict');
+ r = moment(m.format(format).toLocaleUpperCase(), format, true);
+ assert.equal(r.month(), m.month(), 'month ' + i + ' fmt ' + format + ' upper strict');
+ r = moment(m.format(format).toLocaleLowerCase(), format, true);
+ assert.equal(r.month(), m.month(), 'month ' + i + ' fmt ' + format + ' lower strict');
+ }
+
+ for (i = 0; i < 12; ++i) {
+ m = moment([2015, i, 15, 18]);
+ tester('MMM');
+ tester('MMM.');
+ tester('MMMM');
+ tester('MMMM.');
+ }
+ });
+
+ test('weekday parsing correctness', function (assert) {
+ var i, m;
+
+ if (locale === 'tr' || locale === 'az') {
+ // There is a lower-case letter (ı), that converted to upper then
+ // lower changes to i
+ expect(0);
+ return;
+ }
+ function tester(format) {
+ var r, baseMsg = 'weekday ' + m.weekday() + ' fmt ' + format;
+ r = moment(m.format(format), format);
+ assert.equal(r.weekday(), m.weekday(), baseMsg);
+ r = moment(m.format(format).toLocaleUpperCase(), format);
+ assert.equal(r.weekday(), m.weekday(), baseMsg + ' upper');
+ r = moment(m.format(format).toLocaleLowerCase(), format);
+ assert.equal(r.weekday(), m.weekday(), baseMsg + ' lower');
+
+ r = moment(m.format(format), format, true);
+ assert.equal(r.weekday(), m.weekday(), baseMsg + ' strict');
+ r = moment(m.format(format).toLocaleUpperCase(), format, true);
+ assert.equal(r.weekday(), m.weekday(), baseMsg + ' upper strict');
+ r = moment(m.format(format).toLocaleLowerCase(), format, true);
+ assert.equal(r.weekday(), m.weekday(), baseMsg + ' lower strict');
+ }
+
+ for (i = 0; i < 7; ++i) {
+ m = moment.utc([2015, i, 15, 18]);
+ tester('dd');
+ tester('ddd');
+ tester('dddd');
+ }
+ });
+ }
+
+ function setupDeprecationHandler(test, moment, scope) {
+ test._expectedDeprecations = null;
+ test._observedDeprecations = null;
+ test._oldSupress = moment.suppressDeprecationWarnings;
+ moment.suppressDeprecationWarnings = true;
+ test.expectedDeprecations = function () {
+ test._expectedDeprecations = arguments;
+ test._observedDeprecations = [];
+ };
+ moment.deprecationHandler = function (name, msg) {
+ var deprecationId = matchedDeprecation(name, msg, test._expectedDeprecations);
+ if (deprecationId === -1) {
+ throw new Error('Unexpected deprecation thrown name=' +
+ name + ' msg=' + msg);
+ }
+ test._observedDeprecations[deprecationId] = 1;
+ };
+ }
+
+ function teardownDeprecationHandler(test, moment, scope) {
+ moment.suppressDeprecationWarnings = test._oldSupress;
+
+ if (test._expectedDeprecations != null) {
+ var missedDeprecations = [];
+ each(test._expectedDeprecations, function (deprecationPattern, id) {
+ if (test._observedDeprecations[id] !== 1) {
+ missedDeprecations.push(deprecationPattern);
+ }
+ });
+ if (missedDeprecations.length !== 0) {
+ throw new Error('Expected deprecation warnings did not happen: ' +
+ missedDeprecations.join(' '));
+ }
+ }
+ }
+
+ function matchedDeprecation(name, msg, deprecations) {
+ if (deprecations == null) {
+ return -1;
+ }
+ for (var i = 0; i < deprecations.length; ++i) {
+ if (name != null && name === deprecations[i]) {
+ return i;
+ }
+ if (msg != null && msg.substring(0, deprecations[i].length) === deprecations[i]) {
+ return i;
+ }
+ }
+ return -1;
+ }
+
/*global QUnit:false*/
var test = QUnit.test;
@@ -40878,11 +60880,13 @@
moment.createFromInputFallback = function (config) {
throw new Error('input not handled by moment: ' + config._i);
};
+ setupDeprecationHandler(test, moment, 'core');
if (lifecycle && lifecycle.setup) {
lifecycle.setup();
}
},
teardown : function () {
+ teardownDeprecationHandler(test, moment, 'core');
if (lifecycle && lifecycle.teardown) {
lifecycle.teardown();
}
@@ -40897,17 +60901,20 @@
moment.createFromInputFallback = function (config) {
throw new Error('input not handled by moment: ' + config._i);
};
+ setupDeprecationHandler(test, moment, 'locale');
if (lifecycle && lifecycle.setup) {
lifecycle.setup();
}
},
teardown : function () {
moment.locale('en');
+ teardownDeprecationHandler(test, moment, 'locale');
if (lifecycle && lifecycle.teardown) {
lifecycle.teardown();
}
}
});
+ defineCommonLocaleTests(name, -1, -1);
}
module('is same or after');
@@ -41099,6 +61106,224 @@
factory(global.moment)
}(this, function (moment) { 'use strict';
+ function each(array, callback) {
+ var i;
+ for (i = 0; i < array.length; i++) {
+ callback(array[i], i, array);
+ }
+ }
+
+ function objectKeys(obj) {
+ if (Object.keys) {
+ return Object.keys(obj);
+ } else {
+ // IE8
+ var res = [], i;
+ for (i in obj) {
+ if (obj.hasOwnProperty(i)) {
+ res.push(i);
+ }
+ }
+ return res;
+ }
+ }
+
+ // Pick the first defined of two or three arguments.
+ function defaults(a, b, c) {
+ if (a != null) {
+ return a;
+ }
+ if (b != null) {
+ return b;
+ }
+ return c;
+ }
+
+ function defineCommonLocaleTests(locale, options) {
+ test('lenient ordinal parsing', function (assert) {
+ var i, ordinalStr, testMoment;
+ for (i = 1; i <= 31; ++i) {
+ ordinalStr = moment([2014, 0, i]).format('YYYY MM Do');
+ testMoment = moment(ordinalStr, 'YYYY MM Do');
+ assert.equal(testMoment.year(), 2014,
+ 'lenient ordinal parsing ' + i + ' year check');
+ assert.equal(testMoment.month(), 0,
+ 'lenient ordinal parsing ' + i + ' month check');
+ assert.equal(testMoment.date(), i,
+ 'lenient ordinal parsing ' + i + ' date check');
+ }
+ });
+
+ test('lenient ordinal parsing of number', function (assert) {
+ var i, testMoment;
+ for (i = 1; i <= 31; ++i) {
+ testMoment = moment('2014 01 ' + i, 'YYYY MM Do');
+ assert.equal(testMoment.year(), 2014,
+ 'lenient ordinal parsing of number ' + i + ' year check');
+ assert.equal(testMoment.month(), 0,
+ 'lenient ordinal parsing of number ' + i + ' month check');
+ assert.equal(testMoment.date(), i,
+ 'lenient ordinal parsing of number ' + i + ' date check');
+ }
+ });
+
+ test('strict ordinal parsing', function (assert) {
+ var i, ordinalStr, testMoment;
+ for (i = 1; i <= 31; ++i) {
+ ordinalStr = moment([2014, 0, i]).format('YYYY MM Do');
+ testMoment = moment(ordinalStr, 'YYYY MM Do', true);
+ assert.ok(testMoment.isValid(), 'strict ordinal parsing ' + i);
+ }
+ });
+
+ test('meridiem invariant', function (assert) {
+ var h, m, t1, t2;
+ for (h = 0; h < 24; ++h) {
+ for (m = 0; m < 60; m += 15) {
+ t1 = moment.utc([2000, 0, 1, h, m]);
+ t2 = moment.utc(t1.format('A h:mm'), 'A h:mm');
+ assert.equal(t2.format('HH:mm'), t1.format('HH:mm'),
+ 'meridiem at ' + t1.format('HH:mm'));
+ }
+ }
+ });
+
+ test('date format correctness', function (assert) {
+ var data, tokens;
+ data = moment.localeData()._longDateFormat;
+ tokens = objectKeys(data);
+ each(tokens, function (srchToken) {
+ // Check each format string to make sure it does not contain any
+ // tokens that need to be expanded.
+ each(tokens, function (baseToken) {
+ // strip escaped sequences
+ var format = data[baseToken].replace(/(\[[^\]]*\])/g, '');
+ assert.equal(false, !!~format.indexOf(srchToken),
+ 'contains ' + srchToken + ' in ' + baseToken);
+ });
+ });
+ });
+
+ test('month parsing correctness', function (assert) {
+ var i, m;
+
+ if (locale === 'tr') {
+ // I can't fix it :(
+ expect(0);
+ return;
+ }
+ function tester(format) {
+ var r;
+ r = moment(m.format(format), format);
+ assert.equal(r.month(), m.month(), 'month ' + i + ' fmt ' + format);
+ r = moment(m.format(format).toLocaleUpperCase(), format);
+ assert.equal(r.month(), m.month(), 'month ' + i + ' fmt ' + format + ' upper');
+ r = moment(m.format(format).toLocaleLowerCase(), format);
+ assert.equal(r.month(), m.month(), 'month ' + i + ' fmt ' + format + ' lower');
+
+ r = moment(m.format(format), format, true);
+ assert.equal(r.month(), m.month(), 'month ' + i + ' fmt ' + format + ' strict');
+ r = moment(m.format(format).toLocaleUpperCase(), format, true);
+ assert.equal(r.month(), m.month(), 'month ' + i + ' fmt ' + format + ' upper strict');
+ r = moment(m.format(format).toLocaleLowerCase(), format, true);
+ assert.equal(r.month(), m.month(), 'month ' + i + ' fmt ' + format + ' lower strict');
+ }
+
+ for (i = 0; i < 12; ++i) {
+ m = moment([2015, i, 15, 18]);
+ tester('MMM');
+ tester('MMM.');
+ tester('MMMM');
+ tester('MMMM.');
+ }
+ });
+
+ test('weekday parsing correctness', function (assert) {
+ var i, m;
+
+ if (locale === 'tr' || locale === 'az') {
+ // There is a lower-case letter (ı), that converted to upper then
+ // lower changes to i
+ expect(0);
+ return;
+ }
+ function tester(format) {
+ var r, baseMsg = 'weekday ' + m.weekday() + ' fmt ' + format;
+ r = moment(m.format(format), format);
+ assert.equal(r.weekday(), m.weekday(), baseMsg);
+ r = moment(m.format(format).toLocaleUpperCase(), format);
+ assert.equal(r.weekday(), m.weekday(), baseMsg + ' upper');
+ r = moment(m.format(format).toLocaleLowerCase(), format);
+ assert.equal(r.weekday(), m.weekday(), baseMsg + ' lower');
+
+ r = moment(m.format(format), format, true);
+ assert.equal(r.weekday(), m.weekday(), baseMsg + ' strict');
+ r = moment(m.format(format).toLocaleUpperCase(), format, true);
+ assert.equal(r.weekday(), m.weekday(), baseMsg + ' upper strict');
+ r = moment(m.format(format).toLocaleLowerCase(), format, true);
+ assert.equal(r.weekday(), m.weekday(), baseMsg + ' lower strict');
+ }
+
+ for (i = 0; i < 7; ++i) {
+ m = moment.utc([2015, i, 15, 18]);
+ tester('dd');
+ tester('ddd');
+ tester('dddd');
+ }
+ });
+ }
+
+ function setupDeprecationHandler(test, moment, scope) {
+ test._expectedDeprecations = null;
+ test._observedDeprecations = null;
+ test._oldSupress = moment.suppressDeprecationWarnings;
+ moment.suppressDeprecationWarnings = true;
+ test.expectedDeprecations = function () {
+ test._expectedDeprecations = arguments;
+ test._observedDeprecations = [];
+ };
+ moment.deprecationHandler = function (name, msg) {
+ var deprecationId = matchedDeprecation(name, msg, test._expectedDeprecations);
+ if (deprecationId === -1) {
+ throw new Error('Unexpected deprecation thrown name=' +
+ name + ' msg=' + msg);
+ }
+ test._observedDeprecations[deprecationId] = 1;
+ };
+ }
+
+ function teardownDeprecationHandler(test, moment, scope) {
+ moment.suppressDeprecationWarnings = test._oldSupress;
+
+ if (test._expectedDeprecations != null) {
+ var missedDeprecations = [];
+ each(test._expectedDeprecations, function (deprecationPattern, id) {
+ if (test._observedDeprecations[id] !== 1) {
+ missedDeprecations.push(deprecationPattern);
+ }
+ });
+ if (missedDeprecations.length !== 0) {
+ throw new Error('Expected deprecation warnings did not happen: ' +
+ missedDeprecations.join(' '));
+ }
+ }
+ }
+
+ function matchedDeprecation(name, msg, deprecations) {
+ if (deprecations == null) {
+ return -1;
+ }
+ for (var i = 0; i < deprecations.length; ++i) {
+ if (name != null && name === deprecations[i]) {
+ return i;
+ }
+ if (msg != null && msg.substring(0, deprecations[i].length) === deprecations[i]) {
+ return i;
+ }
+ }
+ return -1;
+ }
+
/*global QUnit:false*/
var test = QUnit.test;
@@ -41112,11 +61337,13 @@
moment.createFromInputFallback = function (config) {
throw new Error('input not handled by moment: ' + config._i);
};
+ setupDeprecationHandler(test, moment, 'core');
if (lifecycle && lifecycle.setup) {
lifecycle.setup();
}
},
teardown : function () {
+ teardownDeprecationHandler(test, moment, 'core');
if (lifecycle && lifecycle.teardown) {
lifecycle.teardown();
}
@@ -41131,17 +61358,20 @@
moment.createFromInputFallback = function (config) {
throw new Error('input not handled by moment: ' + config._i);
};
+ setupDeprecationHandler(test, moment, 'locale');
if (lifecycle && lifecycle.setup) {
lifecycle.setup();
}
},
teardown : function () {
moment.locale('en');
+ teardownDeprecationHandler(test, moment, 'locale');
if (lifecycle && lifecycle.teardown) {
lifecycle.teardown();
}
}
});
+ defineCommonLocaleTests(name, -1, -1);
}
module('is same or before');
@@ -41333,6 +61563,224 @@
factory(global.moment)
}(this, function (moment) { 'use strict';
+ function each(array, callback) {
+ var i;
+ for (i = 0; i < array.length; i++) {
+ callback(array[i], i, array);
+ }
+ }
+
+ function objectKeys(obj) {
+ if (Object.keys) {
+ return Object.keys(obj);
+ } else {
+ // IE8
+ var res = [], i;
+ for (i in obj) {
+ if (obj.hasOwnProperty(i)) {
+ res.push(i);
+ }
+ }
+ return res;
+ }
+ }
+
+ // Pick the first defined of two or three arguments.
+ function defaults(a, b, c) {
+ if (a != null) {
+ return a;
+ }
+ if (b != null) {
+ return b;
+ }
+ return c;
+ }
+
+ function defineCommonLocaleTests(locale, options) {
+ test('lenient ordinal parsing', function (assert) {
+ var i, ordinalStr, testMoment;
+ for (i = 1; i <= 31; ++i) {
+ ordinalStr = moment([2014, 0, i]).format('YYYY MM Do');
+ testMoment = moment(ordinalStr, 'YYYY MM Do');
+ assert.equal(testMoment.year(), 2014,
+ 'lenient ordinal parsing ' + i + ' year check');
+ assert.equal(testMoment.month(), 0,
+ 'lenient ordinal parsing ' + i + ' month check');
+ assert.equal(testMoment.date(), i,
+ 'lenient ordinal parsing ' + i + ' date check');
+ }
+ });
+
+ test('lenient ordinal parsing of number', function (assert) {
+ var i, testMoment;
+ for (i = 1; i <= 31; ++i) {
+ testMoment = moment('2014 01 ' + i, 'YYYY MM Do');
+ assert.equal(testMoment.year(), 2014,
+ 'lenient ordinal parsing of number ' + i + ' year check');
+ assert.equal(testMoment.month(), 0,
+ 'lenient ordinal parsing of number ' + i + ' month check');
+ assert.equal(testMoment.date(), i,
+ 'lenient ordinal parsing of number ' + i + ' date check');
+ }
+ });
+
+ test('strict ordinal parsing', function (assert) {
+ var i, ordinalStr, testMoment;
+ for (i = 1; i <= 31; ++i) {
+ ordinalStr = moment([2014, 0, i]).format('YYYY MM Do');
+ testMoment = moment(ordinalStr, 'YYYY MM Do', true);
+ assert.ok(testMoment.isValid(), 'strict ordinal parsing ' + i);
+ }
+ });
+
+ test('meridiem invariant', function (assert) {
+ var h, m, t1, t2;
+ for (h = 0; h < 24; ++h) {
+ for (m = 0; m < 60; m += 15) {
+ t1 = moment.utc([2000, 0, 1, h, m]);
+ t2 = moment.utc(t1.format('A h:mm'), 'A h:mm');
+ assert.equal(t2.format('HH:mm'), t1.format('HH:mm'),
+ 'meridiem at ' + t1.format('HH:mm'));
+ }
+ }
+ });
+
+ test('date format correctness', function (assert) {
+ var data, tokens;
+ data = moment.localeData()._longDateFormat;
+ tokens = objectKeys(data);
+ each(tokens, function (srchToken) {
+ // Check each format string to make sure it does not contain any
+ // tokens that need to be expanded.
+ each(tokens, function (baseToken) {
+ // strip escaped sequences
+ var format = data[baseToken].replace(/(\[[^\]]*\])/g, '');
+ assert.equal(false, !!~format.indexOf(srchToken),
+ 'contains ' + srchToken + ' in ' + baseToken);
+ });
+ });
+ });
+
+ test('month parsing correctness', function (assert) {
+ var i, m;
+
+ if (locale === 'tr') {
+ // I can't fix it :(
+ expect(0);
+ return;
+ }
+ function tester(format) {
+ var r;
+ r = moment(m.format(format), format);
+ assert.equal(r.month(), m.month(), 'month ' + i + ' fmt ' + format);
+ r = moment(m.format(format).toLocaleUpperCase(), format);
+ assert.equal(r.month(), m.month(), 'month ' + i + ' fmt ' + format + ' upper');
+ r = moment(m.format(format).toLocaleLowerCase(), format);
+ assert.equal(r.month(), m.month(), 'month ' + i + ' fmt ' + format + ' lower');
+
+ r = moment(m.format(format), format, true);
+ assert.equal(r.month(), m.month(), 'month ' + i + ' fmt ' + format + ' strict');
+ r = moment(m.format(format).toLocaleUpperCase(), format, true);
+ assert.equal(r.month(), m.month(), 'month ' + i + ' fmt ' + format + ' upper strict');
+ r = moment(m.format(format).toLocaleLowerCase(), format, true);
+ assert.equal(r.month(), m.month(), 'month ' + i + ' fmt ' + format + ' lower strict');
+ }
+
+ for (i = 0; i < 12; ++i) {
+ m = moment([2015, i, 15, 18]);
+ tester('MMM');
+ tester('MMM.');
+ tester('MMMM');
+ tester('MMMM.');
+ }
+ });
+
+ test('weekday parsing correctness', function (assert) {
+ var i, m;
+
+ if (locale === 'tr' || locale === 'az') {
+ // There is a lower-case letter (ı), that converted to upper then
+ // lower changes to i
+ expect(0);
+ return;
+ }
+ function tester(format) {
+ var r, baseMsg = 'weekday ' + m.weekday() + ' fmt ' + format;
+ r = moment(m.format(format), format);
+ assert.equal(r.weekday(), m.weekday(), baseMsg);
+ r = moment(m.format(format).toLocaleUpperCase(), format);
+ assert.equal(r.weekday(), m.weekday(), baseMsg + ' upper');
+ r = moment(m.format(format).toLocaleLowerCase(), format);
+ assert.equal(r.weekday(), m.weekday(), baseMsg + ' lower');
+
+ r = moment(m.format(format), format, true);
+ assert.equal(r.weekday(), m.weekday(), baseMsg + ' strict');
+ r = moment(m.format(format).toLocaleUpperCase(), format, true);
+ assert.equal(r.weekday(), m.weekday(), baseMsg + ' upper strict');
+ r = moment(m.format(format).toLocaleLowerCase(), format, true);
+ assert.equal(r.weekday(), m.weekday(), baseMsg + ' lower strict');
+ }
+
+ for (i = 0; i < 7; ++i) {
+ m = moment.utc([2015, i, 15, 18]);
+ tester('dd');
+ tester('ddd');
+ tester('dddd');
+ }
+ });
+ }
+
+ function setupDeprecationHandler(test, moment, scope) {
+ test._expectedDeprecations = null;
+ test._observedDeprecations = null;
+ test._oldSupress = moment.suppressDeprecationWarnings;
+ moment.suppressDeprecationWarnings = true;
+ test.expectedDeprecations = function () {
+ test._expectedDeprecations = arguments;
+ test._observedDeprecations = [];
+ };
+ moment.deprecationHandler = function (name, msg) {
+ var deprecationId = matchedDeprecation(name, msg, test._expectedDeprecations);
+ if (deprecationId === -1) {
+ throw new Error('Unexpected deprecation thrown name=' +
+ name + ' msg=' + msg);
+ }
+ test._observedDeprecations[deprecationId] = 1;
+ };
+ }
+
+ function teardownDeprecationHandler(test, moment, scope) {
+ moment.suppressDeprecationWarnings = test._oldSupress;
+
+ if (test._expectedDeprecations != null) {
+ var missedDeprecations = [];
+ each(test._expectedDeprecations, function (deprecationPattern, id) {
+ if (test._observedDeprecations[id] !== 1) {
+ missedDeprecations.push(deprecationPattern);
+ }
+ });
+ if (missedDeprecations.length !== 0) {
+ throw new Error('Expected deprecation warnings did not happen: ' +
+ missedDeprecations.join(' '));
+ }
+ }
+ }
+
+ function matchedDeprecation(name, msg, deprecations) {
+ if (deprecations == null) {
+ return -1;
+ }
+ for (var i = 0; i < deprecations.length; ++i) {
+ if (name != null && name === deprecations[i]) {
+ return i;
+ }
+ if (msg != null && msg.substring(0, deprecations[i].length) === deprecations[i]) {
+ return i;
+ }
+ }
+ return -1;
+ }
+
/*global QUnit:false*/
var test = QUnit.test;
@@ -41346,11 +61794,13 @@
moment.createFromInputFallback = function (config) {
throw new Error('input not handled by moment: ' + config._i);
};
+ setupDeprecationHandler(test, moment, 'core');
if (lifecycle && lifecycle.setup) {
lifecycle.setup();
}
},
teardown : function () {
+ teardownDeprecationHandler(test, moment, 'core');
if (lifecycle && lifecycle.teardown) {
lifecycle.teardown();
}
@@ -41365,17 +61815,20 @@
moment.createFromInputFallback = function (config) {
throw new Error('input not handled by moment: ' + config._i);
};
+ setupDeprecationHandler(test, moment, 'locale');
if (lifecycle && lifecycle.setup) {
lifecycle.setup();
}
},
teardown : function () {
moment.locale('en');
+ teardownDeprecationHandler(test, moment, 'locale');
if (lifecycle && lifecycle.teardown) {
lifecycle.teardown();
}
}
});
+ defineCommonLocaleTests(name, -1, -1);
}
module('is valid');
@@ -41454,7 +61907,6 @@
test('string with spaceless format', function (assert) {
assert.equal(moment('10Sep2001', 'DDMMMYYYY').isValid(), true, 'Parsing 10Sep2001 should result in a valid date');
- assert.equal(moment('10Sept2001', 'DDMMMYYYY').isValid(), true, 'Parsing 10Sept2001 should result in a valid date');
});
test('invalid string iso 8601', function (assert) {
@@ -41663,6 +62115,224 @@
factory(global.moment)
}(this, function (moment) { 'use strict';
+ function each(array, callback) {
+ var i;
+ for (i = 0; i < array.length; i++) {
+ callback(array[i], i, array);
+ }
+ }
+
+ function objectKeys(obj) {
+ if (Object.keys) {
+ return Object.keys(obj);
+ } else {
+ // IE8
+ var res = [], i;
+ for (i in obj) {
+ if (obj.hasOwnProperty(i)) {
+ res.push(i);
+ }
+ }
+ return res;
+ }
+ }
+
+ // Pick the first defined of two or three arguments.
+ function defaults(a, b, c) {
+ if (a != null) {
+ return a;
+ }
+ if (b != null) {
+ return b;
+ }
+ return c;
+ }
+
+ function defineCommonLocaleTests(locale, options) {
+ test('lenient ordinal parsing', function (assert) {
+ var i, ordinalStr, testMoment;
+ for (i = 1; i <= 31; ++i) {
+ ordinalStr = moment([2014, 0, i]).format('YYYY MM Do');
+ testMoment = moment(ordinalStr, 'YYYY MM Do');
+ assert.equal(testMoment.year(), 2014,
+ 'lenient ordinal parsing ' + i + ' year check');
+ assert.equal(testMoment.month(), 0,
+ 'lenient ordinal parsing ' + i + ' month check');
+ assert.equal(testMoment.date(), i,
+ 'lenient ordinal parsing ' + i + ' date check');
+ }
+ });
+
+ test('lenient ordinal parsing of number', function (assert) {
+ var i, testMoment;
+ for (i = 1; i <= 31; ++i) {
+ testMoment = moment('2014 01 ' + i, 'YYYY MM Do');
+ assert.equal(testMoment.year(), 2014,
+ 'lenient ordinal parsing of number ' + i + ' year check');
+ assert.equal(testMoment.month(), 0,
+ 'lenient ordinal parsing of number ' + i + ' month check');
+ assert.equal(testMoment.date(), i,
+ 'lenient ordinal parsing of number ' + i + ' date check');
+ }
+ });
+
+ test('strict ordinal parsing', function (assert) {
+ var i, ordinalStr, testMoment;
+ for (i = 1; i <= 31; ++i) {
+ ordinalStr = moment([2014, 0, i]).format('YYYY MM Do');
+ testMoment = moment(ordinalStr, 'YYYY MM Do', true);
+ assert.ok(testMoment.isValid(), 'strict ordinal parsing ' + i);
+ }
+ });
+
+ test('meridiem invariant', function (assert) {
+ var h, m, t1, t2;
+ for (h = 0; h < 24; ++h) {
+ for (m = 0; m < 60; m += 15) {
+ t1 = moment.utc([2000, 0, 1, h, m]);
+ t2 = moment.utc(t1.format('A h:mm'), 'A h:mm');
+ assert.equal(t2.format('HH:mm'), t1.format('HH:mm'),
+ 'meridiem at ' + t1.format('HH:mm'));
+ }
+ }
+ });
+
+ test('date format correctness', function (assert) {
+ var data, tokens;
+ data = moment.localeData()._longDateFormat;
+ tokens = objectKeys(data);
+ each(tokens, function (srchToken) {
+ // Check each format string to make sure it does not contain any
+ // tokens that need to be expanded.
+ each(tokens, function (baseToken) {
+ // strip escaped sequences
+ var format = data[baseToken].replace(/(\[[^\]]*\])/g, '');
+ assert.equal(false, !!~format.indexOf(srchToken),
+ 'contains ' + srchToken + ' in ' + baseToken);
+ });
+ });
+ });
+
+ test('month parsing correctness', function (assert) {
+ var i, m;
+
+ if (locale === 'tr') {
+ // I can't fix it :(
+ expect(0);
+ return;
+ }
+ function tester(format) {
+ var r;
+ r = moment(m.format(format), format);
+ assert.equal(r.month(), m.month(), 'month ' + i + ' fmt ' + format);
+ r = moment(m.format(format).toLocaleUpperCase(), format);
+ assert.equal(r.month(), m.month(), 'month ' + i + ' fmt ' + format + ' upper');
+ r = moment(m.format(format).toLocaleLowerCase(), format);
+ assert.equal(r.month(), m.month(), 'month ' + i + ' fmt ' + format + ' lower');
+
+ r = moment(m.format(format), format, true);
+ assert.equal(r.month(), m.month(), 'month ' + i + ' fmt ' + format + ' strict');
+ r = moment(m.format(format).toLocaleUpperCase(), format, true);
+ assert.equal(r.month(), m.month(), 'month ' + i + ' fmt ' + format + ' upper strict');
+ r = moment(m.format(format).toLocaleLowerCase(), format, true);
+ assert.equal(r.month(), m.month(), 'month ' + i + ' fmt ' + format + ' lower strict');
+ }
+
+ for (i = 0; i < 12; ++i) {
+ m = moment([2015, i, 15, 18]);
+ tester('MMM');
+ tester('MMM.');
+ tester('MMMM');
+ tester('MMMM.');
+ }
+ });
+
+ test('weekday parsing correctness', function (assert) {
+ var i, m;
+
+ if (locale === 'tr' || locale === 'az') {
+ // There is a lower-case letter (ı), that converted to upper then
+ // lower changes to i
+ expect(0);
+ return;
+ }
+ function tester(format) {
+ var r, baseMsg = 'weekday ' + m.weekday() + ' fmt ' + format;
+ r = moment(m.format(format), format);
+ assert.equal(r.weekday(), m.weekday(), baseMsg);
+ r = moment(m.format(format).toLocaleUpperCase(), format);
+ assert.equal(r.weekday(), m.weekday(), baseMsg + ' upper');
+ r = moment(m.format(format).toLocaleLowerCase(), format);
+ assert.equal(r.weekday(), m.weekday(), baseMsg + ' lower');
+
+ r = moment(m.format(format), format, true);
+ assert.equal(r.weekday(), m.weekday(), baseMsg + ' strict');
+ r = moment(m.format(format).toLocaleUpperCase(), format, true);
+ assert.equal(r.weekday(), m.weekday(), baseMsg + ' upper strict');
+ r = moment(m.format(format).toLocaleLowerCase(), format, true);
+ assert.equal(r.weekday(), m.weekday(), baseMsg + ' lower strict');
+ }
+
+ for (i = 0; i < 7; ++i) {
+ m = moment.utc([2015, i, 15, 18]);
+ tester('dd');
+ tester('ddd');
+ tester('dddd');
+ }
+ });
+ }
+
+ function setupDeprecationHandler(test, moment, scope) {
+ test._expectedDeprecations = null;
+ test._observedDeprecations = null;
+ test._oldSupress = moment.suppressDeprecationWarnings;
+ moment.suppressDeprecationWarnings = true;
+ test.expectedDeprecations = function () {
+ test._expectedDeprecations = arguments;
+ test._observedDeprecations = [];
+ };
+ moment.deprecationHandler = function (name, msg) {
+ var deprecationId = matchedDeprecation(name, msg, test._expectedDeprecations);
+ if (deprecationId === -1) {
+ throw new Error('Unexpected deprecation thrown name=' +
+ name + ' msg=' + msg);
+ }
+ test._observedDeprecations[deprecationId] = 1;
+ };
+ }
+
+ function teardownDeprecationHandler(test, moment, scope) {
+ moment.suppressDeprecationWarnings = test._oldSupress;
+
+ if (test._expectedDeprecations != null) {
+ var missedDeprecations = [];
+ each(test._expectedDeprecations, function (deprecationPattern, id) {
+ if (test._observedDeprecations[id] !== 1) {
+ missedDeprecations.push(deprecationPattern);
+ }
+ });
+ if (missedDeprecations.length !== 0) {
+ throw new Error('Expected deprecation warnings did not happen: ' +
+ missedDeprecations.join(' '));
+ }
+ }
+ }
+
+ function matchedDeprecation(name, msg, deprecations) {
+ if (deprecations == null) {
+ return -1;
+ }
+ for (var i = 0; i < deprecations.length; ++i) {
+ if (name != null && name === deprecations[i]) {
+ return i;
+ }
+ if (msg != null && msg.substring(0, deprecations[i].length) === deprecations[i]) {
+ return i;
+ }
+ }
+ return -1;
+ }
+
/*global QUnit:false*/
var test = QUnit.test;
@@ -41676,11 +62346,13 @@
moment.createFromInputFallback = function (config) {
throw new Error('input not handled by moment: ' + config._i);
};
+ setupDeprecationHandler(test, moment, 'core');
if (lifecycle && lifecycle.setup) {
lifecycle.setup();
}
},
teardown : function () {
+ teardownDeprecationHandler(test, moment, 'core');
if (lifecycle && lifecycle.teardown) {
lifecycle.teardown();
}
@@ -41695,17 +62367,20 @@
moment.createFromInputFallback = function (config) {
throw new Error('input not handled by moment: ' + config._i);
};
+ setupDeprecationHandler(test, moment, 'locale');
if (lifecycle && lifecycle.setup) {
lifecycle.setup();
}
},
teardown : function () {
moment.locale('en');
+ teardownDeprecationHandler(test, moment, 'locale');
if (lifecycle && lifecycle.teardown) {
lifecycle.teardown();
}
}
});
+ defineCommonLocaleTests(name, -1, -1);
}
module('leap year');
@@ -41725,6 +62400,224 @@
typeof define === 'function' && define.amd ? define(['../../moment'], factory) :
factory(global.moment)
}(this, function (moment) { 'use strict';
+
+ function each(array, callback) {
+ var i;
+ for (i = 0; i < array.length; i++) {
+ callback(array[i], i, array);
+ }
+ }
+
+ function objectKeys(obj) {
+ if (Object.keys) {
+ return Object.keys(obj);
+ } else {
+ // IE8
+ var res = [], i;
+ for (i in obj) {
+ if (obj.hasOwnProperty(i)) {
+ res.push(i);
+ }
+ }
+ return res;
+ }
+ }
+
+ // Pick the first defined of two or three arguments.
+ function defaults(a, b, c) {
+ if (a != null) {
+ return a;
+ }
+ if (b != null) {
+ return b;
+ }
+ return c;
+ }
+
+ function defineCommonLocaleTests(locale, options) {
+ test('lenient ordinal parsing', function (assert) {
+ var i, ordinalStr, testMoment;
+ for (i = 1; i <= 31; ++i) {
+ ordinalStr = moment([2014, 0, i]).format('YYYY MM Do');
+ testMoment = moment(ordinalStr, 'YYYY MM Do');
+ assert.equal(testMoment.year(), 2014,
+ 'lenient ordinal parsing ' + i + ' year check');
+ assert.equal(testMoment.month(), 0,
+ 'lenient ordinal parsing ' + i + ' month check');
+ assert.equal(testMoment.date(), i,
+ 'lenient ordinal parsing ' + i + ' date check');
+ }
+ });
+
+ test('lenient ordinal parsing of number', function (assert) {
+ var i, testMoment;
+ for (i = 1; i <= 31; ++i) {
+ testMoment = moment('2014 01 ' + i, 'YYYY MM Do');
+ assert.equal(testMoment.year(), 2014,
+ 'lenient ordinal parsing of number ' + i + ' year check');
+ assert.equal(testMoment.month(), 0,
+ 'lenient ordinal parsing of number ' + i + ' month check');
+ assert.equal(testMoment.date(), i,
+ 'lenient ordinal parsing of number ' + i + ' date check');
+ }
+ });
+
+ test('strict ordinal parsing', function (assert) {
+ var i, ordinalStr, testMoment;
+ for (i = 1; i <= 31; ++i) {
+ ordinalStr = moment([2014, 0, i]).format('YYYY MM Do');
+ testMoment = moment(ordinalStr, 'YYYY MM Do', true);
+ assert.ok(testMoment.isValid(), 'strict ordinal parsing ' + i);
+ }
+ });
+
+ test('meridiem invariant', function (assert) {
+ var h, m, t1, t2;
+ for (h = 0; h < 24; ++h) {
+ for (m = 0; m < 60; m += 15) {
+ t1 = moment.utc([2000, 0, 1, h, m]);
+ t2 = moment.utc(t1.format('A h:mm'), 'A h:mm');
+ assert.equal(t2.format('HH:mm'), t1.format('HH:mm'),
+ 'meridiem at ' + t1.format('HH:mm'));
+ }
+ }
+ });
+
+ test('date format correctness', function (assert) {
+ var data, tokens;
+ data = moment.localeData()._longDateFormat;
+ tokens = objectKeys(data);
+ each(tokens, function (srchToken) {
+ // Check each format string to make sure it does not contain any
+ // tokens that need to be expanded.
+ each(tokens, function (baseToken) {
+ // strip escaped sequences
+ var format = data[baseToken].replace(/(\[[^\]]*\])/g, '');
+ assert.equal(false, !!~format.indexOf(srchToken),
+ 'contains ' + srchToken + ' in ' + baseToken);
+ });
+ });
+ });
+
+ test('month parsing correctness', function (assert) {
+ var i, m;
+
+ if (locale === 'tr') {
+ // I can't fix it :(
+ expect(0);
+ return;
+ }
+ function tester(format) {
+ var r;
+ r = moment(m.format(format), format);
+ assert.equal(r.month(), m.month(), 'month ' + i + ' fmt ' + format);
+ r = moment(m.format(format).toLocaleUpperCase(), format);
+ assert.equal(r.month(), m.month(), 'month ' + i + ' fmt ' + format + ' upper');
+ r = moment(m.format(format).toLocaleLowerCase(), format);
+ assert.equal(r.month(), m.month(), 'month ' + i + ' fmt ' + format + ' lower');
+
+ r = moment(m.format(format), format, true);
+ assert.equal(r.month(), m.month(), 'month ' + i + ' fmt ' + format + ' strict');
+ r = moment(m.format(format).toLocaleUpperCase(), format, true);
+ assert.equal(r.month(), m.month(), 'month ' + i + ' fmt ' + format + ' upper strict');
+ r = moment(m.format(format).toLocaleLowerCase(), format, true);
+ assert.equal(r.month(), m.month(), 'month ' + i + ' fmt ' + format + ' lower strict');
+ }
+
+ for (i = 0; i < 12; ++i) {
+ m = moment([2015, i, 15, 18]);
+ tester('MMM');
+ tester('MMM.');
+ tester('MMMM');
+ tester('MMMM.');
+ }
+ });
+
+ test('weekday parsing correctness', function (assert) {
+ var i, m;
+
+ if (locale === 'tr' || locale === 'az') {
+ // There is a lower-case letter (ı), that converted to upper then
+ // lower changes to i
+ expect(0);
+ return;
+ }
+ function tester(format) {
+ var r, baseMsg = 'weekday ' + m.weekday() + ' fmt ' + format;
+ r = moment(m.format(format), format);
+ assert.equal(r.weekday(), m.weekday(), baseMsg);
+ r = moment(m.format(format).toLocaleUpperCase(), format);
+ assert.equal(r.weekday(), m.weekday(), baseMsg + ' upper');
+ r = moment(m.format(format).toLocaleLowerCase(), format);
+ assert.equal(r.weekday(), m.weekday(), baseMsg + ' lower');
+
+ r = moment(m.format(format), format, true);
+ assert.equal(r.weekday(), m.weekday(), baseMsg + ' strict');
+ r = moment(m.format(format).toLocaleUpperCase(), format, true);
+ assert.equal(r.weekday(), m.weekday(), baseMsg + ' upper strict');
+ r = moment(m.format(format).toLocaleLowerCase(), format, true);
+ assert.equal(r.weekday(), m.weekday(), baseMsg + ' lower strict');
+ }
+
+ for (i = 0; i < 7; ++i) {
+ m = moment.utc([2015, i, 15, 18]);
+ tester('dd');
+ tester('ddd');
+ tester('dddd');
+ }
+ });
+ }
+
+ function setupDeprecationHandler(test, moment, scope) {
+ test._expectedDeprecations = null;
+ test._observedDeprecations = null;
+ test._oldSupress = moment.suppressDeprecationWarnings;
+ moment.suppressDeprecationWarnings = true;
+ test.expectedDeprecations = function () {
+ test._expectedDeprecations = arguments;
+ test._observedDeprecations = [];
+ };
+ moment.deprecationHandler = function (name, msg) {
+ var deprecationId = matchedDeprecation(name, msg, test._expectedDeprecations);
+ if (deprecationId === -1) {
+ throw new Error('Unexpected deprecation thrown name=' +
+ name + ' msg=' + msg);
+ }
+ test._observedDeprecations[deprecationId] = 1;
+ };
+ }
+
+ function teardownDeprecationHandler(test, moment, scope) {
+ moment.suppressDeprecationWarnings = test._oldSupress;
+
+ if (test._expectedDeprecations != null) {
+ var missedDeprecations = [];
+ each(test._expectedDeprecations, function (deprecationPattern, id) {
+ if (test._observedDeprecations[id] !== 1) {
+ missedDeprecations.push(deprecationPattern);
+ }
+ });
+ if (missedDeprecations.length !== 0) {
+ throw new Error('Expected deprecation warnings did not happen: ' +
+ missedDeprecations.join(' '));
+ }
+ }
+ }
+
+ function matchedDeprecation(name, msg, deprecations) {
+ if (deprecations == null) {
+ return -1;
+ }
+ for (var i = 0; i < deprecations.length; ++i) {
+ if (name != null && name === deprecations[i]) {
+ return i;
+ }
+ if (msg != null && msg.substring(0, deprecations[i].length) === deprecations[i]) {
+ return i;
+ }
+ }
+ return -1;
+ }
/*global QUnit:false*/
@@ -41739,11 +62632,13 @@
moment.createFromInputFallback = function (config) {
throw new Error('input not handled by moment: ' + config._i);
};
+ setupDeprecationHandler(test, moment, 'core');
if (lifecycle && lifecycle.setup) {
lifecycle.setup();
}
},
teardown : function () {
+ teardownDeprecationHandler(test, moment, 'core');
if (lifecycle && lifecycle.teardown) {
lifecycle.teardown();
}
@@ -41758,24 +62653,27 @@
moment.createFromInputFallback = function (config) {
throw new Error('input not handled by moment: ' + config._i);
};
+ setupDeprecationHandler(test, moment, 'locale');
if (lifecycle && lifecycle.setup) {
lifecycle.setup();
}
},
teardown : function () {
moment.locale('en');
+ teardownDeprecationHandler(test, moment, 'locale');
if (lifecycle && lifecycle.teardown) {
lifecycle.teardown();
}
}
});
+ defineCommonLocaleTests(name, -1, -1);
}
module('listers');
test('default', function (assert) {
assert.deepEqual(moment.months(), ['January', 'February', 'March', 'April', 'May', 'June', 'July', 'August', 'September', 'October', 'November', 'December']);
- assert.deepEqual(moment.monthsShort(), ['Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun', 'Jul', 'Aug', 'Sept', 'Oct', 'Nov', 'Dec']);
+ assert.deepEqual(moment.monthsShort(), ['Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun', 'Jul', 'Aug', 'Sep', 'Oct', 'Nov', 'Dec']);
assert.deepEqual(moment.weekdays(), ['Sunday', 'Monday', 'Tuesday', 'Wednesday', 'Thursday', 'Friday', 'Saturday']);
assert.deepEqual(moment.weekdaysShort(), ['Sun', 'Mon', 'Tue', 'Wed', 'Thu', 'Fri', 'Sat']);
assert.deepEqual(moment.weekdaysMin(), ['Su', 'Mo', 'Tu', 'We', 'Th', 'Fr', 'Sa']);
@@ -41799,14 +62697,22 @@
monthsShort = 'on_tw_th_fo_fi_si_se_ei_ni_te_el_tw'.split('_'),
weekdays = 'one_two_three_four_five_six_seven'.split('_'),
weekdaysShort = 'on_tw_th_fo_fi_si_se'.split('_'),
- weekdaysMin = '1_2_3_4_5_6_7'.split('_');
+ weekdaysMin = '1_2_3_4_5_6_7'.split('_'),
+ weekdaysLocale = 'four_five_six_seven_one_two_three'.split('_'),
+ weekdaysShortLocale = 'fo_fi_si_se_on_tw_th'.split('_'),
+ weekdaysMinLocale = '4_5_6_7_1_2_3'.split('_'),
+ week = {
+ dow : 3,
+ doy : 6
+ };
moment.locale('numerologists', {
months : months,
monthsShort : monthsShort,
weekdays : weekdays,
weekdaysShort: weekdaysShort,
- weekdaysMin: weekdaysMin
+ weekdaysMin: weekdaysMin,
+ week : week
});
assert.deepEqual(moment.months(), months);
@@ -41826,6 +62732,18 @@
assert.equal(moment.weekdays(2), 'three');
assert.equal(moment.weekdaysShort(2), 'th');
assert.equal(moment.weekdaysMin(2), '3');
+
+ assert.deepEqual(moment.weekdays(true), weekdaysLocale);
+ assert.deepEqual(moment.weekdaysShort(true), weekdaysShortLocale);
+ assert.deepEqual(moment.weekdaysMin(true), weekdaysMinLocale);
+
+ assert.equal(moment.weekdays(true, 0), 'four');
+ assert.equal(moment.weekdaysShort(true, 0), 'fo');
+ assert.equal(moment.weekdaysMin(true, 0), '4');
+
+ assert.equal(moment.weekdays(false, 2), 'three');
+ assert.equal(moment.weekdaysShort(false, 2), 'th');
+ assert.equal(moment.weekdaysMin(false, 2), '3');
});
test('with functions', function (assert) {
@@ -41857,6 +62775,224 @@
typeof define === 'function' && define.amd ? define(['../../moment'], factory) :
factory(global.moment)
}(this, function (moment) { 'use strict';
+
+ function each(array, callback) {
+ var i;
+ for (i = 0; i < array.length; i++) {
+ callback(array[i], i, array);
+ }
+ }
+
+ function objectKeys(obj) {
+ if (Object.keys) {
+ return Object.keys(obj);
+ } else {
+ // IE8
+ var res = [], i;
+ for (i in obj) {
+ if (obj.hasOwnProperty(i)) {
+ res.push(i);
+ }
+ }
+ return res;
+ }
+ }
+
+ // Pick the first defined of two or three arguments.
+ function defaults(a, b, c) {
+ if (a != null) {
+ return a;
+ }
+ if (b != null) {
+ return b;
+ }
+ return c;
+ }
+
+ function defineCommonLocaleTests(locale, options) {
+ test('lenient ordinal parsing', function (assert) {
+ var i, ordinalStr, testMoment;
+ for (i = 1; i <= 31; ++i) {
+ ordinalStr = moment([2014, 0, i]).format('YYYY MM Do');
+ testMoment = moment(ordinalStr, 'YYYY MM Do');
+ assert.equal(testMoment.year(), 2014,
+ 'lenient ordinal parsing ' + i + ' year check');
+ assert.equal(testMoment.month(), 0,
+ 'lenient ordinal parsing ' + i + ' month check');
+ assert.equal(testMoment.date(), i,
+ 'lenient ordinal parsing ' + i + ' date check');
+ }
+ });
+
+ test('lenient ordinal parsing of number', function (assert) {
+ var i, testMoment;
+ for (i = 1; i <= 31; ++i) {
+ testMoment = moment('2014 01 ' + i, 'YYYY MM Do');
+ assert.equal(testMoment.year(), 2014,
+ 'lenient ordinal parsing of number ' + i + ' year check');
+ assert.equal(testMoment.month(), 0,
+ 'lenient ordinal parsing of number ' + i + ' month check');
+ assert.equal(testMoment.date(), i,
+ 'lenient ordinal parsing of number ' + i + ' date check');
+ }
+ });
+
+ test('strict ordinal parsing', function (assert) {
+ var i, ordinalStr, testMoment;
+ for (i = 1; i <= 31; ++i) {
+ ordinalStr = moment([2014, 0, i]).format('YYYY MM Do');
+ testMoment = moment(ordinalStr, 'YYYY MM Do', true);
+ assert.ok(testMoment.isValid(), 'strict ordinal parsing ' + i);
+ }
+ });
+
+ test('meridiem invariant', function (assert) {
+ var h, m, t1, t2;
+ for (h = 0; h < 24; ++h) {
+ for (m = 0; m < 60; m += 15) {
+ t1 = moment.utc([2000, 0, 1, h, m]);
+ t2 = moment.utc(t1.format('A h:mm'), 'A h:mm');
+ assert.equal(t2.format('HH:mm'), t1.format('HH:mm'),
+ 'meridiem at ' + t1.format('HH:mm'));
+ }
+ }
+ });
+
+ test('date format correctness', function (assert) {
+ var data, tokens;
+ data = moment.localeData()._longDateFormat;
+ tokens = objectKeys(data);
+ each(tokens, function (srchToken) {
+ // Check each format string to make sure it does not contain any
+ // tokens that need to be expanded.
+ each(tokens, function (baseToken) {
+ // strip escaped sequences
+ var format = data[baseToken].replace(/(\[[^\]]*\])/g, '');
+ assert.equal(false, !!~format.indexOf(srchToken),
+ 'contains ' + srchToken + ' in ' + baseToken);
+ });
+ });
+ });
+
+ test('month parsing correctness', function (assert) {
+ var i, m;
+
+ if (locale === 'tr') {
+ // I can't fix it :(
+ expect(0);
+ return;
+ }
+ function tester(format) {
+ var r;
+ r = moment(m.format(format), format);
+ assert.equal(r.month(), m.month(), 'month ' + i + ' fmt ' + format);
+ r = moment(m.format(format).toLocaleUpperCase(), format);
+ assert.equal(r.month(), m.month(), 'month ' + i + ' fmt ' + format + ' upper');
+ r = moment(m.format(format).toLocaleLowerCase(), format);
+ assert.equal(r.month(), m.month(), 'month ' + i + ' fmt ' + format + ' lower');
+
+ r = moment(m.format(format), format, true);
+ assert.equal(r.month(), m.month(), 'month ' + i + ' fmt ' + format + ' strict');
+ r = moment(m.format(format).toLocaleUpperCase(), format, true);
+ assert.equal(r.month(), m.month(), 'month ' + i + ' fmt ' + format + ' upper strict');
+ r = moment(m.format(format).toLocaleLowerCase(), format, true);
+ assert.equal(r.month(), m.month(), 'month ' + i + ' fmt ' + format + ' lower strict');
+ }
+
+ for (i = 0; i < 12; ++i) {
+ m = moment([2015, i, 15, 18]);
+ tester('MMM');
+ tester('MMM.');
+ tester('MMMM');
+ tester('MMMM.');
+ }
+ });
+
+ test('weekday parsing correctness', function (assert) {
+ var i, m;
+
+ if (locale === 'tr' || locale === 'az') {
+ // There is a lower-case letter (ı), that converted to upper then
+ // lower changes to i
+ expect(0);
+ return;
+ }
+ function tester(format) {
+ var r, baseMsg = 'weekday ' + m.weekday() + ' fmt ' + format;
+ r = moment(m.format(format), format);
+ assert.equal(r.weekday(), m.weekday(), baseMsg);
+ r = moment(m.format(format).toLocaleUpperCase(), format);
+ assert.equal(r.weekday(), m.weekday(), baseMsg + ' upper');
+ r = moment(m.format(format).toLocaleLowerCase(), format);
+ assert.equal(r.weekday(), m.weekday(), baseMsg + ' lower');
+
+ r = moment(m.format(format), format, true);
+ assert.equal(r.weekday(), m.weekday(), baseMsg + ' strict');
+ r = moment(m.format(format).toLocaleUpperCase(), format, true);
+ assert.equal(r.weekday(), m.weekday(), baseMsg + ' upper strict');
+ r = moment(m.format(format).toLocaleLowerCase(), format, true);
+ assert.equal(r.weekday(), m.weekday(), baseMsg + ' lower strict');
+ }
+
+ for (i = 0; i < 7; ++i) {
+ m = moment.utc([2015, i, 15, 18]);
+ tester('dd');
+ tester('ddd');
+ tester('dddd');
+ }
+ });
+ }
+
+ function setupDeprecationHandler(test, moment, scope) {
+ test._expectedDeprecations = null;
+ test._observedDeprecations = null;
+ test._oldSupress = moment.suppressDeprecationWarnings;
+ moment.suppressDeprecationWarnings = true;
+ test.expectedDeprecations = function () {
+ test._expectedDeprecations = arguments;
+ test._observedDeprecations = [];
+ };
+ moment.deprecationHandler = function (name, msg) {
+ var deprecationId = matchedDeprecation(name, msg, test._expectedDeprecations);
+ if (deprecationId === -1) {
+ throw new Error('Unexpected deprecation thrown name=' +
+ name + ' msg=' + msg);
+ }
+ test._observedDeprecations[deprecationId] = 1;
+ };
+ }
+
+ function teardownDeprecationHandler(test, moment, scope) {
+ moment.suppressDeprecationWarnings = test._oldSupress;
+
+ if (test._expectedDeprecations != null) {
+ var missedDeprecations = [];
+ each(test._expectedDeprecations, function (deprecationPattern, id) {
+ if (test._observedDeprecations[id] !== 1) {
+ missedDeprecations.push(deprecationPattern);
+ }
+ });
+ if (missedDeprecations.length !== 0) {
+ throw new Error('Expected deprecation warnings did not happen: ' +
+ missedDeprecations.join(' '));
+ }
+ }
+ }
+
+ function matchedDeprecation(name, msg, deprecations) {
+ if (deprecations == null) {
+ return -1;
+ }
+ for (var i = 0; i < deprecations.length; ++i) {
+ if (name != null && name === deprecations[i]) {
+ return i;
+ }
+ if (msg != null && msg.substring(0, deprecations[i].length) === deprecations[i]) {
+ return i;
+ }
+ }
+ return -1;
+ }
/*global QUnit:false*/
@@ -41871,11 +63007,13 @@
moment.createFromInputFallback = function (config) {
throw new Error('input not handled by moment: ' + config._i);
};
+ setupDeprecationHandler(test, moment, 'core');
if (lifecycle && lifecycle.setup) {
lifecycle.setup();
}
},
teardown : function () {
+ teardownDeprecationHandler(test, moment, 'core');
if (lifecycle && lifecycle.teardown) {
lifecycle.teardown();
}
@@ -41890,24 +63028,37 @@
moment.createFromInputFallback = function (config) {
throw new Error('input not handled by moment: ' + config._i);
};
+ setupDeprecationHandler(test, moment, 'locale');
if (lifecycle && lifecycle.setup) {
lifecycle.setup();
}
},
teardown : function () {
moment.locale('en');
+ teardownDeprecationHandler(test, moment, 'locale');
if (lifecycle && lifecycle.teardown) {
lifecycle.teardown();
}
}
});
- }
-
- function each(array, callback) {
- var i;
- for (i = 0; i < array.length; i++) {
- callback(array[i], i, array);
- }
+ defineCommonLocaleTests(name, -1, -1);
+ }
+
+ var indexOf;
+
+ if (Array.prototype.indexOf) {
+ indexOf = Array.prototype.indexOf;
+ } else {
+ indexOf = function (o) {
+ // I know
+ var i;
+ for (i = 0; i < this.length; ++i) {
+ if (this[i] === o) {
+ return i;
+ }
+ }
+ return -1;
+ };
}
module('locale', {
@@ -42047,10 +63198,12 @@
});
test('library deprecations', function (assert) {
+ test.expectedDeprecations('moment.lang');
moment.lang('dude', {months: ['Movember']});
assert.equal(moment.locale(), 'dude', 'setting the lang sets the locale');
assert.equal(moment.lang(), moment.locale());
assert.equal(moment.langData(), moment.localeData(), 'langData is localeData');
+ moment.defineLocale('dude', null);
});
test('defineLocale', function (assert) {
@@ -42058,12 +63211,21 @@
moment.defineLocale('dude', {months: ['Movember']});
assert.equal(moment().locale(), 'dude', 'defineLocale also sets it');
assert.equal(moment().locale('dude').locale(), 'dude', 'defineLocale defines a locale');
+ moment.defineLocale('dude', null);
+ });
+
+ test('locales', function (assert) {
+ moment.defineLocale('dude', {months: ['Movember']});
+ assert.equal(true, !!~indexOf.call(moment.locales(), 'dude'), 'locales returns an array of defined locales');
+ assert.equal(true, !!~indexOf.call(moment.locales(), 'en'), 'locales should always include english');
+ moment.defineLocale('dude', null);
});
test('library convenience', function (assert) {
moment.locale('something', {week: {dow: 3}});
moment.locale('something');
assert.equal(moment.locale(), 'something', 'locale can be used to create the locale too');
+ moment.defineLocale('something', null);
});
test('firstDayOfWeek firstDayOfYear locale getters', function (assert) {
@@ -42071,6 +63233,7 @@
moment.locale('something');
assert.equal(moment.localeData().firstDayOfWeek(), 3, 'firstDayOfWeek');
assert.equal(moment.localeData().firstDayOfYear(), 4, 'firstDayOfYear');
+ moment.defineLocale('something', null);
});
test('instance locale method', function (assert) {
@@ -42141,6 +63304,7 @@
});
test('duration deprecations', function (assert) {
+ test.expectedDeprecations('moment().lang()');
assert.equal(moment.duration().lang(), moment.duration().localeData(), 'duration.lang is the same as duration.localeData');
});
@@ -42232,6 +63396,7 @@
test('instance localeData', function (assert) {
moment.defineLocale('dude', {week: {dow: 3}});
assert.equal(moment().locale('dude').localeData()._week.dow, 3);
+ moment.defineLocale('dude', null);
});
test('month name callback function', function (assert) {
@@ -42259,6 +63424,8 @@
});
test('changing parts of a locale config', function (assert) {
+ test.expectedDeprecations('defineLocaleOverride');
+
moment.locale('partial-lang', {
months : 'a b c d e f g h i j k l'.split(' ')
});
@@ -42270,6 +63437,8 @@
});
assert.equal(moment([2011, 0, 1]).format('MMMM MMM'), 'a A', 'should be able to set locale values after creating the localeuage');
+
+ moment.defineLocale('partial-lang', null);
});
test('start/endOf week feature for first-day-is-monday locales', function (assert) {
@@ -42282,6 +63451,7 @@
moment.locale('monday-lang');
assert.equal(moment([2013, 0, 1]).startOf('week').day(), 1, 'for locale monday-lang first day of the week should be monday');
assert.equal(moment([2013, 0, 1]).endOf('week').day(), 0, 'for locale monday-lang last day of the week should be sunday');
+ moment.defineLocale('monday-lang', null);
});
test('meridiem parsing', function (assert) {
@@ -42295,6 +63465,7 @@
moment.locale('meridiem-parsing');
assert.equal(moment('2012-01-01 3b', 'YYYY-MM-DD ha').hour(), 15, 'Custom parsing of meridiem should work');
assert.equal(moment('2012-01-01 3d', 'YYYY-MM-DD ha').hour(), 3, 'Custom parsing of meridiem should work');
+ moment.defineLocale('meridiem-parsing', null);
});
test('invalid date formatting', function (assert) {
@@ -42304,12 +63475,14 @@
assert.equal(moment.invalid().format(), 'KHAAAAAAAAAAAN!');
assert.equal(moment.invalid().format('YYYY-MM-DD'), 'KHAAAAAAAAAAAN!');
+ moment.defineLocale('has-invalid', null);
});
test('return locale name', function (assert) {
var registered = moment.locale('return-this', {});
assert.equal(registered, 'return-this', 'returns the locale configured');
+ moment.locale('return-this', null);
});
test('changing the global locale doesn\'t affect existing instances', function (assert) {
@@ -42319,6 +63492,7 @@
});
test('setting a language on instance returns the original moment for chaining', function (assert) {
+ test.expectedDeprecations('moment().lang()');
var mom = moment();
assert.equal(mom.lang('fr'), mom, 'setting the language (lang) returns the original moment for chaining');
@@ -42326,6 +63500,7 @@
});
test('lang(key) changes the language of the instance', function (assert) {
+ test.expectedDeprecations('moment().lang()');
var m = moment().month(0);
m.lang('fr');
assert.equal(m.locale(), 'fr', 'm.lang(key) changes instance locale');
@@ -42349,9 +63524,43 @@
});
test('moment().lang with missing key doesn\'t change locale', function (assert) {
+ test.expectedDeprecations('moment().lang()');
assert.equal(moment().lang('boo').localeData(), moment.localeData(),
'preserve global locale in case of bad locale id');
});
+
+
+ // TODO: Enable this after fixing pl months parse hack hack
+ // test('monthsParseExact', function (assert) {
+ // var locale = 'test-months-parse-exact';
+
+ // moment.defineLocale(locale, {
+ // monthsParseExact: true,
+ // months: 'A_AA_AAA_B_B B_BB B_C_C-C_C,C2C_D_D+D_D`D*D'.split('_'),
+ // monthsShort: 'E_EE_EEE_F_FF_FFF_G_GG_GGG_H_HH_HHH'.split('_')
+ // });
+
+ // assert.equal(moment('A', 'MMMM', true).month(), 0, 'parse long month 0 with MMMM');
+ // assert.equal(moment('AA', 'MMMM', true).month(), 1, 'parse long month 1 with MMMM');
+ // assert.equal(moment('AAA', 'MMMM', true).month(), 2, 'parse long month 2 with MMMM');
+ // assert.equal(moment('B B', 'MMMM', true).month(), 4, 'parse long month 4 with MMMM');
+ // assert.equal(moment('BB B', 'MMMM', true).month(), 5, 'parse long month 5 with MMMM');
+ // assert.equal(moment('C-C', 'MMMM', true).month(), 7, 'parse long month 7 with MMMM');
+ // assert.equal(moment('C,C2C', 'MMMM', true).month(), 8, 'parse long month 8 with MMMM');
+ // assert.equal(moment('D+D', 'MMMM', true).month(), 10, 'parse long month 10 with MMMM');
+ // assert.equal(moment('D`D*D', 'MMMM', true).month(), 11, 'parse long month 11 with MMMM');
+
+ // assert.equal(moment('E', 'MMM', true).month(), 0, 'parse long month 0 with MMM');
+ // assert.equal(moment('EE', 'MMM', true).month(), 1, 'parse long month 1 with MMM');
+ // assert.equal(moment('EEE', 'MMM', true).month(), 2, 'parse long month 2 with MMM');
+
+ // assert.equal(moment('A', 'MMM').month(), 0, 'non-strict parse long month 0 with MMM');
+ // assert.equal(moment('AA', 'MMM').month(), 1, 'non-strict parse long month 1 with MMM');
+ // assert.equal(moment('AAA', 'MMM').month(), 2, 'non-strict parse long month 2 with MMM');
+ // assert.equal(moment('E', 'MMMM').month(), 0, 'non-strict parse short month 0 with MMMM');
+ // assert.equal(moment('EE', 'MMMM').month(), 1, 'non-strict parse short month 1 with MMMM');
+ // assert.equal(moment('EEE', 'MMMM').month(), 2, 'non-strict parse short month 2 with MMMM');
+ // });
}));
@@ -42361,6 +63570,224 @@
typeof define === 'function' && define.amd ? define(['../../moment'], factory) :
factory(global.moment)
}(this, function (moment) { 'use strict';
+
+ function each(array, callback) {
+ var i;
+ for (i = 0; i < array.length; i++) {
+ callback(array[i], i, array);
+ }
+ }
+
+ function objectKeys(obj) {
+ if (Object.keys) {
+ return Object.keys(obj);
+ } else {
+ // IE8
+ var res = [], i;
+ for (i in obj) {
+ if (obj.hasOwnProperty(i)) {
+ res.push(i);
+ }
+ }
+ return res;
+ }
+ }
+
+ // Pick the first defined of two or three arguments.
+ function defaults(a, b, c) {
+ if (a != null) {
+ return a;
+ }
+ if (b != null) {
+ return b;
+ }
+ return c;
+ }
+
+ function defineCommonLocaleTests(locale, options) {
+ test('lenient ordinal parsing', function (assert) {
+ var i, ordinalStr, testMoment;
+ for (i = 1; i <= 31; ++i) {
+ ordinalStr = moment([2014, 0, i]).format('YYYY MM Do');
+ testMoment = moment(ordinalStr, 'YYYY MM Do');
+ assert.equal(testMoment.year(), 2014,
+ 'lenient ordinal parsing ' + i + ' year check');
+ assert.equal(testMoment.month(), 0,
+ 'lenient ordinal parsing ' + i + ' month check');
+ assert.equal(testMoment.date(), i,
+ 'lenient ordinal parsing ' + i + ' date check');
+ }
+ });
+
+ test('lenient ordinal parsing of number', function (assert) {
+ var i, testMoment;
+ for (i = 1; i <= 31; ++i) {
+ testMoment = moment('2014 01 ' + i, 'YYYY MM Do');
+ assert.equal(testMoment.year(), 2014,
+ 'lenient ordinal parsing of number ' + i + ' year check');
+ assert.equal(testMoment.month(), 0,
+ 'lenient ordinal parsing of number ' + i + ' month check');
+ assert.equal(testMoment.date(), i,
+ 'lenient ordinal parsing of number ' + i + ' date check');
+ }
+ });
+
+ test('strict ordinal parsing', function (assert) {
+ var i, ordinalStr, testMoment;
+ for (i = 1; i <= 31; ++i) {
+ ordinalStr = moment([2014, 0, i]).format('YYYY MM Do');
+ testMoment = moment(ordinalStr, 'YYYY MM Do', true);
+ assert.ok(testMoment.isValid(), 'strict ordinal parsing ' + i);
+ }
+ });
+
+ test('meridiem invariant', function (assert) {
+ var h, m, t1, t2;
+ for (h = 0; h < 24; ++h) {
+ for (m = 0; m < 60; m += 15) {
+ t1 = moment.utc([2000, 0, 1, h, m]);
+ t2 = moment.utc(t1.format('A h:mm'), 'A h:mm');
+ assert.equal(t2.format('HH:mm'), t1.format('HH:mm'),
+ 'meridiem at ' + t1.format('HH:mm'));
+ }
+ }
+ });
+
+ test('date format correctness', function (assert) {
+ var data, tokens;
+ data = moment.localeData()._longDateFormat;
+ tokens = objectKeys(data);
+ each(tokens, function (srchToken) {
+ // Check each format string to make sure it does not contain any
+ // tokens that need to be expanded.
+ each(tokens, function (baseToken) {
+ // strip escaped sequences
+ var format = data[baseToken].replace(/(\[[^\]]*\])/g, '');
+ assert.equal(false, !!~format.indexOf(srchToken),
+ 'contains ' + srchToken + ' in ' + baseToken);
+ });
+ });
+ });
+
+ test('month parsing correctness', function (assert) {
+ var i, m;
+
+ if (locale === 'tr') {
+ // I can't fix it :(
+ expect(0);
+ return;
+ }
+ function tester(format) {
+ var r;
+ r = moment(m.format(format), format);
+ assert.equal(r.month(), m.month(), 'month ' + i + ' fmt ' + format);
+ r = moment(m.format(format).toLocaleUpperCase(), format);
+ assert.equal(r.month(), m.month(), 'month ' + i + ' fmt ' + format + ' upper');
+ r = moment(m.format(format).toLocaleLowerCase(), format);
+ assert.equal(r.month(), m.month(), 'month ' + i + ' fmt ' + format + ' lower');
+
+ r = moment(m.format(format), format, true);
+ assert.equal(r.month(), m.month(), 'month ' + i + ' fmt ' + format + ' strict');
+ r = moment(m.format(format).toLocaleUpperCase(), format, true);
+ assert.equal(r.month(), m.month(), 'month ' + i + ' fmt ' + format + ' upper strict');
+ r = moment(m.format(format).toLocaleLowerCase(), format, true);
+ assert.equal(r.month(), m.month(), 'month ' + i + ' fmt ' + format + ' lower strict');
+ }
+
+ for (i = 0; i < 12; ++i) {
+ m = moment([2015, i, 15, 18]);
+ tester('MMM');
+ tester('MMM.');
+ tester('MMMM');
+ tester('MMMM.');
+ }
+ });
+
+ test('weekday parsing correctness', function (assert) {
+ var i, m;
+
+ if (locale === 'tr' || locale === 'az') {
+ // There is a lower-case letter (ı), that converted to upper then
+ // lower changes to i
+ expect(0);
+ return;
+ }
+ function tester(format) {
+ var r, baseMsg = 'weekday ' + m.weekday() + ' fmt ' + format;
+ r = moment(m.format(format), format);
+ assert.equal(r.weekday(), m.weekday(), baseMsg);
+ r = moment(m.format(format).toLocaleUpperCase(), format);
+ assert.equal(r.weekday(), m.weekday(), baseMsg + ' upper');
+ r = moment(m.format(format).toLocaleLowerCase(), format);
+ assert.equal(r.weekday(), m.weekday(), baseMsg + ' lower');
+
+ r = moment(m.format(format), format, true);
+ assert.equal(r.weekday(), m.weekday(), baseMsg + ' strict');
+ r = moment(m.format(format).toLocaleUpperCase(), format, true);
+ assert.equal(r.weekday(), m.weekday(), baseMsg + ' upper strict');
+ r = moment(m.format(format).toLocaleLowerCase(), format, true);
+ assert.equal(r.weekday(), m.weekday(), baseMsg + ' lower strict');
+ }
+
+ for (i = 0; i < 7; ++i) {
+ m = moment.utc([2015, i, 15, 18]);
+ tester('dd');
+ tester('ddd');
+ tester('dddd');
+ }
+ });
+ }
+
+ function setupDeprecationHandler(test, moment, scope) {
+ test._expectedDeprecations = null;
+ test._observedDeprecations = null;
+ test._oldSupress = moment.suppressDeprecationWarnings;
+ moment.suppressDeprecationWarnings = true;
+ test.expectedDeprecations = function () {
+ test._expectedDeprecations = arguments;
+ test._observedDeprecations = [];
+ };
+ moment.deprecationHandler = function (name, msg) {
+ var deprecationId = matchedDeprecation(name, msg, test._expectedDeprecations);
+ if (deprecationId === -1) {
+ throw new Error('Unexpected deprecation thrown name=' +
+ name + ' msg=' + msg);
+ }
+ test._observedDeprecations[deprecationId] = 1;
+ };
+ }
+
+ function teardownDeprecationHandler(test, moment, scope) {
+ moment.suppressDeprecationWarnings = test._oldSupress;
+
+ if (test._expectedDeprecations != null) {
+ var missedDeprecations = [];
+ each(test._expectedDeprecations, function (deprecationPattern, id) {
+ if (test._observedDeprecations[id] !== 1) {
+ missedDeprecations.push(deprecationPattern);
+ }
+ });
+ if (missedDeprecations.length !== 0) {
+ throw new Error('Expected deprecation warnings did not happen: ' +
+ missedDeprecations.join(' '));
+ }
+ }
+ }
+
+ function matchedDeprecation(name, msg, deprecations) {
+ if (deprecations == null) {
+ return -1;
+ }
+ for (var i = 0; i < deprecations.length; ++i) {
+ if (name != null && name === deprecations[i]) {
+ return i;
+ }
+ if (msg != null && msg.substring(0, deprecations[i].length) === deprecations[i]) {
+ return i;
+ }
+ }
+ return -1;
+ }
/*global QUnit:false*/
@@ -42375,11 +63802,13 @@
moment.createFromInputFallback = function (config) {
throw new Error('input not handled by moment: ' + config._i);
};
+ setupDeprecationHandler(test, moment, 'core');
if (lifecycle && lifecycle.setup) {
lifecycle.setup();
}
},
teardown : function () {
+ teardownDeprecationHandler(test, moment, 'core');
if (lifecycle && lifecycle.teardown) {
lifecycle.teardown();
}
@@ -42394,17 +63823,901 @@
moment.createFromInputFallback = function (config) {
throw new Error('input not handled by moment: ' + config._i);
};
+ setupDeprecationHandler(test, moment, 'locale');
if (lifecycle && lifecycle.setup) {
lifecycle.setup();
}
},
teardown : function () {
moment.locale('en');
+ teardownDeprecationHandler(test, moment, 'locale');
if (lifecycle && lifecycle.teardown) {
lifecycle.teardown();
}
}
});
+ defineCommonLocaleTests(name, -1, -1);
+ }
+
+ module('locale inheritance');
+
+ test('calendar', function (assert) {
+ moment.defineLocale('base-cal', {
+ calendar : {
+ sameDay: '[Today at] HH:mm',
+ nextDay: '[Tomorrow at] HH:mm',
+ nextWeek: '[Next week at] HH:mm',
+ lastDay: '[Yesterday at] HH:mm',
+ lastWeek: '[Last week at] HH:mm',
+ sameElse: '[whatever]'
+ }
+ });
+ moment.defineLocale('child-cal', {
+ parentLocale: 'base-cal',
+ calendar: {
+ sameDay: '[Today] HH:mm',
+ nextDay: '[Tomorrow] HH:mm',
+ nextWeek: '[Next week] HH:mm'
+ }
+ });
+
+ moment.locale('child-cal');
+ var anchor = moment.utc('2015-05-05T12:00:00', moment.ISO_8601);
+ assert.equal(anchor.clone().add(3, 'hours').calendar(anchor), 'Today 15:00', 'today uses child version');
+ assert.equal(anchor.clone().add(1, 'day').calendar(anchor), 'Tomorrow 12:00', 'tomorrow uses child version');
+ assert.equal(anchor.clone().add(3, 'days').calendar(anchor), 'Next week 12:00', 'next week uses child version');
+
+ assert.equal(anchor.clone().subtract(1, 'day').calendar(anchor), 'Yesterday at 12:00', 'yesterday uses parent version');
+ assert.equal(anchor.clone().subtract(3, 'days').calendar(anchor), 'Last week at 12:00', 'last week uses parent version');
+ assert.equal(anchor.clone().subtract(7, 'days').calendar(anchor), 'whatever', 'sameElse uses parent version -');
+ assert.equal(anchor.clone().add(7, 'days').calendar(anchor), 'whatever', 'sameElse uses parent version +');
+ });
+
+ test('missing', function (assert) {
+ moment.defineLocale('base-cal-2', {
+ calendar: {
+ sameDay: '[Today at] HH:mm',
+ nextDay: '[Tomorrow at] HH:mm',
+ nextWeek: '[Next week at] HH:mm',
+ lastDay: '[Yesterday at] HH:mm',
+ lastWeek: '[Last week at] HH:mm',
+ sameElse: '[whatever]'
+ }
+ });
+ moment.defineLocale('child-cal-2', {
+ parentLocale: 'base-cal-2'
+ });
+ moment.locale('child-cal-2');
+ var anchor = moment.utc('2015-05-05T12:00:00', moment.ISO_8601);
+ assert.equal(anchor.clone().add(3, 'hours').calendar(anchor), 'Today at 15:00', 'today uses parent version');
+ assert.equal(anchor.clone().add(1, 'day').calendar(anchor), 'Tomorrow at 12:00', 'tomorrow uses parent version');
+ assert.equal(anchor.clone().add(3, 'days').calendar(anchor), 'Next week at 12:00', 'next week uses parent version');
+ assert.equal(anchor.clone().subtract(1, 'day').calendar(anchor), 'Yesterday at 12:00', 'yesterday uses parent version');
+ assert.equal(anchor.clone().subtract(3, 'days').calendar(anchor), 'Last week at 12:00', 'last week uses parent version');
+ assert.equal(anchor.clone().subtract(7, 'days').calendar(anchor), 'whatever', 'sameElse uses parent version -');
+ assert.equal(anchor.clone().add(7, 'days').calendar(anchor), 'whatever', 'sameElse uses parent version +');
+ });
+
+ // Test function vs obj both directions
+
+ test('long date format', function (assert) {
+ moment.defineLocale('base-ldf', {
+ longDateFormat : {
+ LTS : 'h:mm:ss A',
+ LT : 'h:mm A',
+ L : 'MM/DD/YYYY',
+ LL : 'MMMM D, YYYY',
+ LLL : 'MMMM D, YYYY h:mm A',
+ LLLL : 'dddd, MMMM D, YYYY h:mm A'
+ }
+ });
+ moment.defineLocale('child-ldf', {
+ parentLocale: 'base-ldf',
+ longDateFormat: {
+ LLL : '[child] MMMM D, YYYY h:mm A',
+ LLLL : '[child] dddd, MMMM D, YYYY h:mm A'
+ }
+ });
+
+ moment.locale('child-ldf');
+ var anchor = moment.utc('2015-09-06T12:34:56', moment.ISO_8601);
+ assert.equal(anchor.format('LTS'), '12:34:56 PM', 'LTS uses base');
+ assert.equal(anchor.format('LT'), '12:34 PM', 'LT uses base');
+ assert.equal(anchor.format('L'), '09/06/2015', 'L uses base');
+ assert.equal(anchor.format('l'), '9/6/2015', 'l uses base');
+ assert.equal(anchor.format('LL'), 'September 6, 2015', 'LL uses base');
+ assert.equal(anchor.format('ll'), 'Sep 6, 2015', 'll uses base');
+ assert.equal(anchor.format('LLL'), 'child September 6, 2015 12:34 PM', 'LLL uses child');
+ assert.equal(anchor.format('lll'), 'child Sep 6, 2015 12:34 PM', 'lll uses child');
+ assert.equal(anchor.format('LLLL'), 'child Sunday, September 6, 2015 12:34 PM', 'LLLL uses child');
+ assert.equal(anchor.format('llll'), 'child Sun, Sep 6, 2015 12:34 PM', 'llll uses child');
+ });
+
+ test('ordinal', function (assert) {
+ moment.defineLocale('base-ordinal-1', {
+ ordinal : '%dx'
+ });
+ moment.defineLocale('child-ordinal-1', {
+ parentLocale: 'base-ordinal-1',
+ ordinal : '%dy'
+ });
+
+ assert.equal(moment.utc('2015-02-03', moment.ISO_8601).format('Do'), '3y', 'ordinal uses child string');
+
+ moment.defineLocale('base-ordinal-2', {
+ ordinal : '%dx'
+ });
+ moment.defineLocale('child-ordinal-2', {
+ parentLocale: 'base-ordinal-2',
+ ordinal : function (num) {
+ return num + 'y';
+ }
+ });
+
+ assert.equal(moment.utc('2015-02-03', moment.ISO_8601).format('Do'), '3y', 'ordinal uses child function');
+
+ moment.defineLocale('base-ordinal-3', {
+ ordinal : function (num) {
+ return num + 'x';
+ }
+ });
+ moment.defineLocale('child-ordinal-3', {
+ parentLocale: 'base-ordinal-3',
+ ordinal : '%dy'
+ });
+
+ assert.equal(moment.utc('2015-02-03', moment.ISO_8601).format('Do'), '3y', 'ordinal uses child string (overwrite parent function)');
+ });
+
+ test('ordinal parse', function (assert) {
+ moment.defineLocale('base-ordinal-parse-1', {
+ ordinalParse : /\d{1,2}x/
+ });
+ moment.defineLocale('child-ordinal-parse-1', {
+ parentLocale: 'base-ordinal-parse-1',
+ ordinalParse : /\d{1,2}y/
+ });
+
+ assert.ok(moment.utc('2015-01-1y', 'YYYY-MM-Do', true).isValid(), 'ordinal parse uses child');
+
+ moment.defineLocale('base-ordinal-parse-2', {
+ ordinalParse : /\d{1,2}x/
+ });
+ moment.defineLocale('child-ordinal-parse-2', {
+ parentLocale: 'base-ordinal-parse-2',
+ ordinalParse : null
+ });
+
+ assert.ok(moment.utc('2015-01-1', 'YYYY-MM-Do', true).isValid(), 'ordinal parse uses child (default)');
+ });
+
+ test('months', function (assert) {
+ moment.defineLocale('base-months', {
+ months : 'One_Two_Three_Four_Five_Six_Seven_Eight_Nine_Ten_Eleven_Twelve'.split('_')
+ });
+ moment.defineLocale('child-months', {
+ parentLocale: 'base-months',
+ months : 'First_Second_Third_Fourth_Fifth_Sixth_Seventh_Eighth_Ninth_Tenth_Eleventh_Twelveth '.split('_')
+ });
+ assert.ok(moment.utc('2015-01-01', 'YYYY-MM-DD').format('MMMM'), 'First', 'months uses child');
+ });
+
+}));
+
+;(function (global, factory) {
+ typeof exports === 'object' && typeof module !== 'undefined'
+ && typeof require === 'function' ? factory(require('../../moment')) :
+ typeof define === 'function' && define.amd ? define(['../../moment'], factory) :
+ factory(global.moment)
+}(this, function (moment) { 'use strict';
+
+ function each(array, callback) {
+ var i;
+ for (i = 0; i < array.length; i++) {
+ callback(array[i], i, array);
+ }
+ }
+
+ function objectKeys(obj) {
+ if (Object.keys) {
+ return Object.keys(obj);
+ } else {
+ // IE8
+ var res = [], i;
+ for (i in obj) {
+ if (obj.hasOwnProperty(i)) {
+ res.push(i);
+ }
+ }
+ return res;
+ }
+ }
+
+ // Pick the first defined of two or three arguments.
+ function defaults(a, b, c) {
+ if (a != null) {
+ return a;
+ }
+ if (b != null) {
+ return b;
+ }
+ return c;
+ }
+
+ function defineCommonLocaleTests(locale, options) {
+ test('lenient ordinal parsing', function (assert) {
+ var i, ordinalStr, testMoment;
+ for (i = 1; i <= 31; ++i) {
+ ordinalStr = moment([2014, 0, i]).format('YYYY MM Do');
+ testMoment = moment(ordinalStr, 'YYYY MM Do');
+ assert.equal(testMoment.year(), 2014,
+ 'lenient ordinal parsing ' + i + ' year check');
+ assert.equal(testMoment.month(), 0,
+ 'lenient ordinal parsing ' + i + ' month check');
+ assert.equal(testMoment.date(), i,
+ 'lenient ordinal parsing ' + i + ' date check');
+ }
+ });
+
+ test('lenient ordinal parsing of number', function (assert) {
+ var i, testMoment;
+ for (i = 1; i <= 31; ++i) {
+ testMoment = moment('2014 01 ' + i, 'YYYY MM Do');
+ assert.equal(testMoment.year(), 2014,
+ 'lenient ordinal parsing of number ' + i + ' year check');
+ assert.equal(testMoment.month(), 0,
+ 'lenient ordinal parsing of number ' + i + ' month check');
+ assert.equal(testMoment.date(), i,
+ 'lenient ordinal parsing of number ' + i + ' date check');
+ }
+ });
+
+ test('strict ordinal parsing', function (assert) {
+ var i, ordinalStr, testMoment;
+ for (i = 1; i <= 31; ++i) {
+ ordinalStr = moment([2014, 0, i]).format('YYYY MM Do');
+ testMoment = moment(ordinalStr, 'YYYY MM Do', true);
+ assert.ok(testMoment.isValid(), 'strict ordinal parsing ' + i);
+ }
+ });
+
+ test('meridiem invariant', function (assert) {
+ var h, m, t1, t2;
+ for (h = 0; h < 24; ++h) {
+ for (m = 0; m < 60; m += 15) {
+ t1 = moment.utc([2000, 0, 1, h, m]);
+ t2 = moment.utc(t1.format('A h:mm'), 'A h:mm');
+ assert.equal(t2.format('HH:mm'), t1.format('HH:mm'),
+ 'meridiem at ' + t1.format('HH:mm'));
+ }
+ }
+ });
+
+ test('date format correctness', function (assert) {
+ var data, tokens;
+ data = moment.localeData()._longDateFormat;
+ tokens = objectKeys(data);
+ each(tokens, function (srchToken) {
+ // Check each format string to make sure it does not contain any
+ // tokens that need to be expanded.
+ each(tokens, function (baseToken) {
+ // strip escaped sequences
+ var format = data[baseToken].replace(/(\[[^\]]*\])/g, '');
+ assert.equal(false, !!~format.indexOf(srchToken),
+ 'contains ' + srchToken + ' in ' + baseToken);
+ });
+ });
+ });
+
+ test('month parsing correctness', function (assert) {
+ var i, m;
+
+ if (locale === 'tr') {
+ // I can't fix it :(
+ expect(0);
+ return;
+ }
+ function tester(format) {
+ var r;
+ r = moment(m.format(format), format);
+ assert.equal(r.month(), m.month(), 'month ' + i + ' fmt ' + format);
+ r = moment(m.format(format).toLocaleUpperCase(), format);
+ assert.equal(r.month(), m.month(), 'month ' + i + ' fmt ' + format + ' upper');
+ r = moment(m.format(format).toLocaleLowerCase(), format);
+ assert.equal(r.month(), m.month(), 'month ' + i + ' fmt ' + format + ' lower');
+
+ r = moment(m.format(format), format, true);
+ assert.equal(r.month(), m.month(), 'month ' + i + ' fmt ' + format + ' strict');
+ r = moment(m.format(format).toLocaleUpperCase(), format, true);
+ assert.equal(r.month(), m.month(), 'month ' + i + ' fmt ' + format + ' upper strict');
+ r = moment(m.format(format).toLocaleLowerCase(), format, true);
+ assert.equal(r.month(), m.month(), 'month ' + i + ' fmt ' + format + ' lower strict');
+ }
+
+ for (i = 0; i < 12; ++i) {
+ m = moment([2015, i, 15, 18]);
+ tester('MMM');
+ tester('MMM.');
+ tester('MMMM');
+ tester('MMMM.');
+ }
+ });
+
+ test('weekday parsing correctness', function (assert) {
+ var i, m;
+
+ if (locale === 'tr' || locale === 'az') {
+ // There is a lower-case letter (ı), that converted to upper then
+ // lower changes to i
+ expect(0);
+ return;
+ }
+ function tester(format) {
+ var r, baseMsg = 'weekday ' + m.weekday() + ' fmt ' + format;
+ r = moment(m.format(format), format);
+ assert.equal(r.weekday(), m.weekday(), baseMsg);
+ r = moment(m.format(format).toLocaleUpperCase(), format);
+ assert.equal(r.weekday(), m.weekday(), baseMsg + ' upper');
+ r = moment(m.format(format).toLocaleLowerCase(), format);
+ assert.equal(r.weekday(), m.weekday(), baseMsg + ' lower');
+
+ r = moment(m.format(format), format, true);
+ assert.equal(r.weekday(), m.weekday(), baseMsg + ' strict');
+ r = moment(m.format(format).toLocaleUpperCase(), format, true);
+ assert.equal(r.weekday(), m.weekday(), baseMsg + ' upper strict');
+ r = moment(m.format(format).toLocaleLowerCase(), format, true);
+ assert.equal(r.weekday(), m.weekday(), baseMsg + ' lower strict');
+ }
+
+ for (i = 0; i < 7; ++i) {
+ m = moment.utc([2015, i, 15, 18]);
+ tester('dd');
+ tester('ddd');
+ tester('dddd');
+ }
+ });
+ }
+
+ function setupDeprecationHandler(test, moment, scope) {
+ test._expectedDeprecations = null;
+ test._observedDeprecations = null;
+ test._oldSupress = moment.suppressDeprecationWarnings;
+ moment.suppressDeprecationWarnings = true;
+ test.expectedDeprecations = function () {
+ test._expectedDeprecations = arguments;
+ test._observedDeprecations = [];
+ };
+ moment.deprecationHandler = function (name, msg) {
+ var deprecationId = matchedDeprecation(name, msg, test._expectedDeprecations);
+ if (deprecationId === -1) {
+ throw new Error('Unexpected deprecation thrown name=' +
+ name + ' msg=' + msg);
+ }
+ test._observedDeprecations[deprecationId] = 1;
+ };
+ }
+
+ function teardownDeprecationHandler(test, moment, scope) {
+ moment.suppressDeprecationWarnings = test._oldSupress;
+
+ if (test._expectedDeprecations != null) {
+ var missedDeprecations = [];
+ each(test._expectedDeprecations, function (deprecationPattern, id) {
+ if (test._observedDeprecations[id] !== 1) {
+ missedDeprecations.push(deprecationPattern);
+ }
+ });
+ if (missedDeprecations.length !== 0) {
+ throw new Error('Expected deprecation warnings did not happen: ' +
+ missedDeprecations.join(' '));
+ }
+ }
+ }
+
+ function matchedDeprecation(name, msg, deprecations) {
+ if (deprecations == null) {
+ return -1;
+ }
+ for (var i = 0; i < deprecations.length; ++i) {
+ if (name != null && name === deprecations[i]) {
+ return i;
+ }
+ if (msg != null && msg.substring(0, deprecations[i].length) === deprecations[i]) {
+ return i;
+ }
+ }
+ return -1;
+ }
+
+ /*global QUnit:false*/
+
+ var test = QUnit.test;
+
+ var expect = QUnit.expect;
+
+ function module (name, lifecycle) {
+ QUnit.module(name, {
+ setup : function () {
+ moment.locale('en');
+ moment.createFromInputFallback = function (config) {
+ throw new Error('input not handled by moment: ' + config._i);
+ };
+ setupDeprecationHandler(test, moment, 'core');
+ if (lifecycle && lifecycle.setup) {
+ lifecycle.setup();
+ }
+ },
+ teardown : function () {
+ teardownDeprecationHandler(test, moment, 'core');
+ if (lifecycle && lifecycle.teardown) {
+ lifecycle.teardown();
+ }
+ }
+ });
+ }
+
+ function localeModule (name, lifecycle) {
+ QUnit.module('locale:' + name, {
+ setup : function () {
+ moment.locale(name);
+ moment.createFromInputFallback = function (config) {
+ throw new Error('input not handled by moment: ' + config._i);
+ };
+ setupDeprecationHandler(test, moment, 'locale');
+ if (lifecycle && lifecycle.setup) {
+ lifecycle.setup();
+ }
+ },
+ teardown : function () {
+ moment.locale('en');
+ teardownDeprecationHandler(test, moment, 'locale');
+ if (lifecycle && lifecycle.teardown) {
+ lifecycle.teardown();
+ }
+ }
+ });
+ defineCommonLocaleTests(name, -1, -1);
+ }
+
+ module('locale update');
+
+ test('calendar', function (assert) {
+ moment.defineLocale('cal', null);
+ moment.defineLocale('cal', {
+ calendar : {
+ sameDay: '[Today at] HH:mm',
+ nextDay: '[Tomorrow at] HH:mm',
+ nextWeek: '[Next week at] HH:mm',
+ lastDay: '[Yesterday at] HH:mm',
+ lastWeek: '[Last week at] HH:mm',
+ sameElse: '[whatever]'
+ }
+ });
+ moment.updateLocale('cal', {
+ calendar: {
+ sameDay: '[Today] HH:mm',
+ nextDay: '[Tomorrow] HH:mm',
+ nextWeek: '[Next week] HH:mm'
+ }
+ });
+
+ moment.locale('cal');
+ var anchor = moment.utc('2015-05-05T12:00:00', moment.ISO_8601);
+ assert.equal(anchor.clone().add(3, 'hours').calendar(anchor), 'Today 15:00', 'today uses child version');
+ assert.equal(anchor.clone().add(1, 'day').calendar(anchor), 'Tomorrow 12:00', 'tomorrow uses child version');
+ assert.equal(anchor.clone().add(3, 'days').calendar(anchor), 'Next week 12:00', 'next week uses child version');
+
+ assert.equal(anchor.clone().subtract(1, 'day').calendar(anchor), 'Yesterday at 12:00', 'yesterday uses parent version');
+ assert.equal(anchor.clone().subtract(3, 'days').calendar(anchor), 'Last week at 12:00', 'last week uses parent version');
+ assert.equal(anchor.clone().subtract(7, 'days').calendar(anchor), 'whatever', 'sameElse uses parent version -');
+ assert.equal(anchor.clone().add(7, 'days').calendar(anchor), 'whatever', 'sameElse uses parent version +');
+ });
+
+ test('missing', function (assert) {
+ moment.defineLocale('cal-2', null);
+ moment.defineLocale('cal-2', {
+ calendar: {
+ sameDay: '[Today at] HH:mm',
+ nextDay: '[Tomorrow at] HH:mm',
+ nextWeek: '[Next week at] HH:mm',
+ lastDay: '[Yesterday at] HH:mm',
+ lastWeek: '[Last week at] HH:mm',
+ sameElse: '[whatever]'
+ }
+ });
+ moment.updateLocale('cal-2', {
+ });
+ moment.locale('cal-2');
+ var anchor = moment.utc('2015-05-05T12:00:00', moment.ISO_8601);
+ assert.equal(anchor.clone().add(3, 'hours').calendar(anchor), 'Today at 15:00', 'today uses parent version');
+ assert.equal(anchor.clone().add(1, 'day').calendar(anchor), 'Tomorrow at 12:00', 'tomorrow uses parent version');
+ assert.equal(anchor.clone().add(3, 'days').calendar(anchor), 'Next week at 12:00', 'next week uses parent version');
+ assert.equal(anchor.clone().subtract(1, 'day').calendar(anchor), 'Yesterday at 12:00', 'yesterday uses parent version');
+ assert.equal(anchor.clone().subtract(3, 'days').calendar(anchor), 'Last week at 12:00', 'last week uses parent version');
+ assert.equal(anchor.clone().subtract(7, 'days').calendar(anchor), 'whatever', 'sameElse uses parent version -');
+ assert.equal(anchor.clone().add(7, 'days').calendar(anchor), 'whatever', 'sameElse uses parent version +');
+ });
+
+ // Test function vs obj both directions
+
+ test('long date format', function (assert) {
+ moment.defineLocale('ldf', null);
+ moment.defineLocale('ldf', {
+ longDateFormat : {
+ LTS : 'h:mm:ss A',
+ LT : 'h:mm A',
+ L : 'MM/DD/YYYY',
+ LL : 'MMMM D, YYYY',
+ LLL : 'MMMM D, YYYY h:mm A',
+ LLLL : 'dddd, MMMM D, YYYY h:mm A'
+ }
+ });
+ moment.updateLocale('ldf', {
+ longDateFormat: {
+ LLL : '[child] MMMM D, YYYY h:mm A',
+ LLLL : '[child] dddd, MMMM D, YYYY h:mm A'
+ }
+ });
+
+ moment.locale('ldf');
+ var anchor = moment.utc('2015-09-06T12:34:56', moment.ISO_8601);
+ assert.equal(anchor.format('LTS'), '12:34:56 PM', 'LTS uses base');
+ assert.equal(anchor.format('LT'), '12:34 PM', 'LT uses base');
+ assert.equal(anchor.format('L'), '09/06/2015', 'L uses base');
+ assert.equal(anchor.format('l'), '9/6/2015', 'l uses base');
+ assert.equal(anchor.format('LL'), 'September 6, 2015', 'LL uses base');
+ assert.equal(anchor.format('ll'), 'Sep 6, 2015', 'll uses base');
+ assert.equal(anchor.format('LLL'), 'child September 6, 2015 12:34 PM', 'LLL uses child');
+ assert.equal(anchor.format('lll'), 'child Sep 6, 2015 12:34 PM', 'lll uses child');
+ assert.equal(anchor.format('LLLL'), 'child Sunday, September 6, 2015 12:34 PM', 'LLLL uses child');
+ assert.equal(anchor.format('llll'), 'child Sun, Sep 6, 2015 12:34 PM', 'llll uses child');
+ });
+
+ test('ordinal', function (assert) {
+ moment.defineLocale('ordinal-1', null);
+ moment.defineLocale('ordinal-1', {
+ ordinal : '%dx'
+ });
+ moment.updateLocale('ordinal-1', {
+ ordinal : '%dy'
+ });
+
+ assert.equal(moment.utc('2015-02-03', moment.ISO_8601).format('Do'), '3y', 'ordinal uses child string');
+
+ moment.defineLocale('ordinal-2', null);
+ moment.defineLocale('ordinal-2', {
+ ordinal : '%dx'
+ });
+ moment.updateLocale('ordinal-2', {
+ ordinal : function (num) {
+ return num + 'y';
+ }
+ });
+
+ assert.equal(moment.utc('2015-02-03', moment.ISO_8601).format('Do'), '3y', 'ordinal uses child function');
+
+ moment.defineLocale('ordinal-3', null);
+ moment.defineLocale('ordinal-3', {
+ ordinal : function (num) {
+ return num + 'x';
+ }
+ });
+ moment.updateLocale('ordinal-3', {
+ ordinal : '%dy'
+ });
+
+ assert.equal(moment.utc('2015-02-03', moment.ISO_8601).format('Do'), '3y', 'ordinal uses child string (overwrite parent function)');
+ });
+
+ test('ordinal parse', function (assert) {
+ moment.defineLocale('ordinal-parse-1', null);
+ moment.defineLocale('ordinal-parse-1', {
+ ordinalParse : /\d{1,2}x/
+ });
+ moment.updateLocale('ordinal-parse-1', {
+ ordinalParse : /\d{1,2}y/
+ });
+
+ assert.ok(moment.utc('2015-01-1y', 'YYYY-MM-Do', true).isValid(), 'ordinal parse uses child');
+
+ moment.defineLocale('ordinal-parse-2', null);
+ moment.defineLocale('ordinal-parse-2', {
+ ordinalParse : /\d{1,2}x/
+ });
+ moment.updateLocale('ordinal-parse-2', {
+ ordinalParse : null
+ });
+
+ assert.ok(moment.utc('2015-01-1', 'YYYY-MM-Do', true).isValid(), 'ordinal parse uses child (default)');
+ });
+
+ test('months', function (assert) {
+ moment.defineLocale('months', null);
+ moment.defineLocale('months', {
+ months : 'One_Two_Three_Four_Five_Six_Seven_Eight_Nine_Ten_Eleven_Twelve'.split('_')
+ });
+ moment.updateLocale('months', {
+ parentLocale: 'base-months',
+ months : 'First_Second_Third_Fourth_Fifth_Sixth_Seventh_Eighth_Ninth_Tenth_Eleventh_Twelveth '.split('_')
+ });
+ assert.ok(moment.utc('2015-01-01', 'YYYY-MM-DD').format('MMMM'), 'First', 'months uses child');
+ });
+
+}));
+
+;(function (global, factory) {
+ typeof exports === 'object' && typeof module !== 'undefined'
+ && typeof require === 'function' ? factory(require('../../moment')) :
+ typeof define === 'function' && define.amd ? define(['../../moment'], factory) :
+ factory(global.moment)
+}(this, function (moment) { 'use strict';
+
+ function each(array, callback) {
+ var i;
+ for (i = 0; i < array.length; i++) {
+ callback(array[i], i, array);
+ }
+ }
+
+ function objectKeys(obj) {
+ if (Object.keys) {
+ return Object.keys(obj);
+ } else {
+ // IE8
+ var res = [], i;
+ for (i in obj) {
+ if (obj.hasOwnProperty(i)) {
+ res.push(i);
+ }
+ }
+ return res;
+ }
+ }
+
+ // Pick the first defined of two or three arguments.
+ function defaults(a, b, c) {
+ if (a != null) {
+ return a;
+ }
+ if (b != null) {
+ return b;
+ }
+ return c;
+ }
+
+ function defineCommonLocaleTests(locale, options) {
+ test('lenient ordinal parsing', function (assert) {
+ var i, ordinalStr, testMoment;
+ for (i = 1; i <= 31; ++i) {
+ ordinalStr = moment([2014, 0, i]).format('YYYY MM Do');
+ testMoment = moment(ordinalStr, 'YYYY MM Do');
+ assert.equal(testMoment.year(), 2014,
+ 'lenient ordinal parsing ' + i + ' year check');
+ assert.equal(testMoment.month(), 0,
+ 'lenient ordinal parsing ' + i + ' month check');
+ assert.equal(testMoment.date(), i,
+ 'lenient ordinal parsing ' + i + ' date check');
+ }
+ });
+
+ test('lenient ordinal parsing of number', function (assert) {
+ var i, testMoment;
+ for (i = 1; i <= 31; ++i) {
+ testMoment = moment('2014 01 ' + i, 'YYYY MM Do');
+ assert.equal(testMoment.year(), 2014,
+ 'lenient ordinal parsing of number ' + i + ' year check');
+ assert.equal(testMoment.month(), 0,
+ 'lenient ordinal parsing of number ' + i + ' month check');
+ assert.equal(testMoment.date(), i,
+ 'lenient ordinal parsing of number ' + i + ' date check');
+ }
+ });
+
+ test('strict ordinal parsing', function (assert) {
+ var i, ordinalStr, testMoment;
+ for (i = 1; i <= 31; ++i) {
+ ordinalStr = moment([2014, 0, i]).format('YYYY MM Do');
+ testMoment = moment(ordinalStr, 'YYYY MM Do', true);
+ assert.ok(testMoment.isValid(), 'strict ordinal parsing ' + i);
+ }
+ });
+
+ test('meridiem invariant', function (assert) {
+ var h, m, t1, t2;
+ for (h = 0; h < 24; ++h) {
+ for (m = 0; m < 60; m += 15) {
+ t1 = moment.utc([2000, 0, 1, h, m]);
+ t2 = moment.utc(t1.format('A h:mm'), 'A h:mm');
+ assert.equal(t2.format('HH:mm'), t1.format('HH:mm'),
+ 'meridiem at ' + t1.format('HH:mm'));
+ }
+ }
+ });
+
+ test('date format correctness', function (assert) {
+ var data, tokens;
+ data = moment.localeData()._longDateFormat;
+ tokens = objectKeys(data);
+ each(tokens, function (srchToken) {
+ // Check each format string to make sure it does not contain any
+ // tokens that need to be expanded.
+ each(tokens, function (baseToken) {
+ // strip escaped sequences
+ var format = data[baseToken].replace(/(\[[^\]]*\])/g, '');
+ assert.equal(false, !!~format.indexOf(srchToken),
+ 'contains ' + srchToken + ' in ' + baseToken);
+ });
+ });
+ });
+
+ test('month parsing correctness', function (assert) {
+ var i, m;
+
+ if (locale === 'tr') {
+ // I can't fix it :(
+ expect(0);
+ return;
+ }
+ function tester(format) {
+ var r;
+ r = moment(m.format(format), format);
+ assert.equal(r.month(), m.month(), 'month ' + i + ' fmt ' + format);
+ r = moment(m.format(format).toLocaleUpperCase(), format);
+ assert.equal(r.month(), m.month(), 'month ' + i + ' fmt ' + format + ' upper');
+ r = moment(m.format(format).toLocaleLowerCase(), format);
+ assert.equal(r.month(), m.month(), 'month ' + i + ' fmt ' + format + ' lower');
+
+ r = moment(m.format(format), format, true);
+ assert.equal(r.month(), m.month(), 'month ' + i + ' fmt ' + format + ' strict');
+ r = moment(m.format(format).toLocaleUpperCase(), format, true);
+ assert.equal(r.month(), m.month(), 'month ' + i + ' fmt ' + format + ' upper strict');
+ r = moment(m.format(format).toLocaleLowerCase(), format, true);
+ assert.equal(r.month(), m.month(), 'month ' + i + ' fmt ' + format + ' lower strict');
+ }
+
+ for (i = 0; i < 12; ++i) {
+ m = moment([2015, i, 15, 18]);
+ tester('MMM');
+ tester('MMM.');
+ tester('MMMM');
+ tester('MMMM.');
+ }
+ });
+
+ test('weekday parsing correctness', function (assert) {
+ var i, m;
+
+ if (locale === 'tr' || locale === 'az') {
+ // There is a lower-case letter (ı), that converted to upper then
+ // lower changes to i
+ expect(0);
+ return;
+ }
+ function tester(format) {
+ var r, baseMsg = 'weekday ' + m.weekday() + ' fmt ' + format;
+ r = moment(m.format(format), format);
+ assert.equal(r.weekday(), m.weekday(), baseMsg);
+ r = moment(m.format(format).toLocaleUpperCase(), format);
+ assert.equal(r.weekday(), m.weekday(), baseMsg + ' upper');
+ r = moment(m.format(format).toLocaleLowerCase(), format);
+ assert.equal(r.weekday(), m.weekday(), baseMsg + ' lower');
+
+ r = moment(m.format(format), format, true);
+ assert.equal(r.weekday(), m.weekday(), baseMsg + ' strict');
+ r = moment(m.format(format).toLocaleUpperCase(), format, true);
+ assert.equal(r.weekday(), m.weekday(), baseMsg + ' upper strict');
+ r = moment(m.format(format).toLocaleLowerCase(), format, true);
+ assert.equal(r.weekday(), m.weekday(), baseMsg + ' lower strict');
+ }
+
+ for (i = 0; i < 7; ++i) {
+ m = moment.utc([2015, i, 15, 18]);
+ tester('dd');
+ tester('ddd');
+ tester('dddd');
+ }
+ });
+ }
+
+ function setupDeprecationHandler(test, moment, scope) {
+ test._expectedDeprecations = null;
+ test._observedDeprecations = null;
+ test._oldSupress = moment.suppressDeprecationWarnings;
+ moment.suppressDeprecationWarnings = true;
+ test.expectedDeprecations = function () {
+ test._expectedDeprecations = arguments;
+ test._observedDeprecations = [];
+ };
+ moment.deprecationHandler = function (name, msg) {
+ var deprecationId = matchedDeprecation(name, msg, test._expectedDeprecations);
+ if (deprecationId === -1) {
+ throw new Error('Unexpected deprecation thrown name=' +
+ name + ' msg=' + msg);
+ }
+ test._observedDeprecations[deprecationId] = 1;
+ };
+ }
+
+ function teardownDeprecationHandler(test, moment, scope) {
+ moment.suppressDeprecationWarnings = test._oldSupress;
+
+ if (test._expectedDeprecations != null) {
+ var missedDeprecations = [];
+ each(test._expectedDeprecations, function (deprecationPattern, id) {
+ if (test._observedDeprecations[id] !== 1) {
+ missedDeprecations.push(deprecationPattern);
+ }
+ });
+ if (missedDeprecations.length !== 0) {
+ throw new Error('Expected deprecation warnings did not happen: ' +
+ missedDeprecations.join(' '));
+ }
+ }
+ }
+
+ function matchedDeprecation(name, msg, deprecations) {
+ if (deprecations == null) {
+ return -1;
+ }
+ for (var i = 0; i < deprecations.length; ++i) {
+ if (name != null && name === deprecations[i]) {
+ return i;
+ }
+ if (msg != null && msg.substring(0, deprecations[i].length) === deprecations[i]) {
+ return i;
+ }
+ }
+ return -1;
+ }
+
+ /*global QUnit:false*/
+
+ var test = QUnit.test;
+
+ var expect = QUnit.expect;
+
+ function module (name, lifecycle) {
+ QUnit.module(name, {
+ setup : function () {
+ moment.locale('en');
+ moment.createFromInputFallback = function (config) {
+ throw new Error('input not handled by moment: ' + config._i);
+ };
+ setupDeprecationHandler(test, moment, 'core');
+ if (lifecycle && lifecycle.setup) {
+ lifecycle.setup();
+ }
+ },
+ teardown : function () {
+ teardownDeprecationHandler(test, moment, 'core');
+ if (lifecycle && lifecycle.teardown) {
+ lifecycle.teardown();
+ }
+ }
+ });
+ }
+
+ function localeModule (name, lifecycle) {
+ QUnit.module('locale:' + name, {
+ setup : function () {
+ moment.locale(name);
+ moment.createFromInputFallback = function (config) {
+ throw new Error('input not handled by moment: ' + config._i);
+ };
+ setupDeprecationHandler(test, moment, 'locale');
+ if (lifecycle && lifecycle.setup) {
+ lifecycle.setup();
+ }
+ },
+ teardown : function () {
+ moment.locale('en');
+ teardownDeprecationHandler(test, moment, 'locale');
+ if (lifecycle && lifecycle.teardown) {
+ lifecycle.teardown();
+ }
+ }
+ });
+ defineCommonLocaleTests(name, -1, -1);
}
module('min max');
@@ -42462,6 +64775,224 @@
factory(global.moment)
}(this, function (moment) { 'use strict';
+ function each(array, callback) {
+ var i;
+ for (i = 0; i < array.length; i++) {
+ callback(array[i], i, array);
+ }
+ }
+
+ function objectKeys(obj) {
+ if (Object.keys) {
+ return Object.keys(obj);
+ } else {
+ // IE8
+ var res = [], i;
+ for (i in obj) {
+ if (obj.hasOwnProperty(i)) {
+ res.push(i);
+ }
+ }
+ return res;
+ }
+ }
+
+ // Pick the first defined of two or three arguments.
+ function defaults(a, b, c) {
+ if (a != null) {
+ return a;
+ }
+ if (b != null) {
+ return b;
+ }
+ return c;
+ }
+
+ function defineCommonLocaleTests(locale, options) {
+ test('lenient ordinal parsing', function (assert) {
+ var i, ordinalStr, testMoment;
+ for (i = 1; i <= 31; ++i) {
+ ordinalStr = moment([2014, 0, i]).format('YYYY MM Do');
+ testMoment = moment(ordinalStr, 'YYYY MM Do');
+ assert.equal(testMoment.year(), 2014,
+ 'lenient ordinal parsing ' + i + ' year check');
+ assert.equal(testMoment.month(), 0,
+ 'lenient ordinal parsing ' + i + ' month check');
+ assert.equal(testMoment.date(), i,
+ 'lenient ordinal parsing ' + i + ' date check');
+ }
+ });
+
+ test('lenient ordinal parsing of number', function (assert) {
+ var i, testMoment;
+ for (i = 1; i <= 31; ++i) {
+ testMoment = moment('2014 01 ' + i, 'YYYY MM Do');
+ assert.equal(testMoment.year(), 2014,
+ 'lenient ordinal parsing of number ' + i + ' year check');
+ assert.equal(testMoment.month(), 0,
+ 'lenient ordinal parsing of number ' + i + ' month check');
+ assert.equal(testMoment.date(), i,
+ 'lenient ordinal parsing of number ' + i + ' date check');
+ }
+ });
+
+ test('strict ordinal parsing', function (assert) {
+ var i, ordinalStr, testMoment;
+ for (i = 1; i <= 31; ++i) {
+ ordinalStr = moment([2014, 0, i]).format('YYYY MM Do');
+ testMoment = moment(ordinalStr, 'YYYY MM Do', true);
+ assert.ok(testMoment.isValid(), 'strict ordinal parsing ' + i);
+ }
+ });
+
+ test('meridiem invariant', function (assert) {
+ var h, m, t1, t2;
+ for (h = 0; h < 24; ++h) {
+ for (m = 0; m < 60; m += 15) {
+ t1 = moment.utc([2000, 0, 1, h, m]);
+ t2 = moment.utc(t1.format('A h:mm'), 'A h:mm');
+ assert.equal(t2.format('HH:mm'), t1.format('HH:mm'),
+ 'meridiem at ' + t1.format('HH:mm'));
+ }
+ }
+ });
+
+ test('date format correctness', function (assert) {
+ var data, tokens;
+ data = moment.localeData()._longDateFormat;
+ tokens = objectKeys(data);
+ each(tokens, function (srchToken) {
+ // Check each format string to make sure it does not contain any
+ // tokens that need to be expanded.
+ each(tokens, function (baseToken) {
+ // strip escaped sequences
+ var format = data[baseToken].replace(/(\[[^\]]*\])/g, '');
+ assert.equal(false, !!~format.indexOf(srchToken),
+ 'contains ' + srchToken + ' in ' + baseToken);
+ });
+ });
+ });
+
+ test('month parsing correctness', function (assert) {
+ var i, m;
+
+ if (locale === 'tr') {
+ // I can't fix it :(
+ expect(0);
+ return;
+ }
+ function tester(format) {
+ var r;
+ r = moment(m.format(format), format);
+ assert.equal(r.month(), m.month(), 'month ' + i + ' fmt ' + format);
+ r = moment(m.format(format).toLocaleUpperCase(), format);
+ assert.equal(r.month(), m.month(), 'month ' + i + ' fmt ' + format + ' upper');
+ r = moment(m.format(format).toLocaleLowerCase(), format);
+ assert.equal(r.month(), m.month(), 'month ' + i + ' fmt ' + format + ' lower');
+
+ r = moment(m.format(format), format, true);
+ assert.equal(r.month(), m.month(), 'month ' + i + ' fmt ' + format + ' strict');
+ r = moment(m.format(format).toLocaleUpperCase(), format, true);
+ assert.equal(r.month(), m.month(), 'month ' + i + ' fmt ' + format + ' upper strict');
+ r = moment(m.format(format).toLocaleLowerCase(), format, true);
+ assert.equal(r.month(), m.month(), 'month ' + i + ' fmt ' + format + ' lower strict');
+ }
+
+ for (i = 0; i < 12; ++i) {
+ m = moment([2015, i, 15, 18]);
+ tester('MMM');
+ tester('MMM.');
+ tester('MMMM');
+ tester('MMMM.');
+ }
+ });
+
+ test('weekday parsing correctness', function (assert) {
+ var i, m;
+
+ if (locale === 'tr' || locale === 'az') {
+ // There is a lower-case letter (ı), that converted to upper then
+ // lower changes to i
+ expect(0);
+ return;
+ }
+ function tester(format) {
+ var r, baseMsg = 'weekday ' + m.weekday() + ' fmt ' + format;
+ r = moment(m.format(format), format);
+ assert.equal(r.weekday(), m.weekday(), baseMsg);
+ r = moment(m.format(format).toLocaleUpperCase(), format);
+ assert.equal(r.weekday(), m.weekday(), baseMsg + ' upper');
+ r = moment(m.format(format).toLocaleLowerCase(), format);
+ assert.equal(r.weekday(), m.weekday(), baseMsg + ' lower');
+
+ r = moment(m.format(format), format, true);
+ assert.equal(r.weekday(), m.weekday(), baseMsg + ' strict');
+ r = moment(m.format(format).toLocaleUpperCase(), format, true);
+ assert.equal(r.weekday(), m.weekday(), baseMsg + ' upper strict');
+ r = moment(m.format(format).toLocaleLowerCase(), format, true);
+ assert.equal(r.weekday(), m.weekday(), baseMsg + ' lower strict');
+ }
+
+ for (i = 0; i < 7; ++i) {
+ m = moment.utc([2015, i, 15, 18]);
+ tester('dd');
+ tester('ddd');
+ tester('dddd');
+ }
+ });
+ }
+
+ function setupDeprecationHandler(test, moment, scope) {
+ test._expectedDeprecations = null;
+ test._observedDeprecations = null;
+ test._oldSupress = moment.suppressDeprecationWarnings;
+ moment.suppressDeprecationWarnings = true;
+ test.expectedDeprecations = function () {
+ test._expectedDeprecations = arguments;
+ test._observedDeprecations = [];
+ };
+ moment.deprecationHandler = function (name, msg) {
+ var deprecationId = matchedDeprecation(name, msg, test._expectedDeprecations);
+ if (deprecationId === -1) {
+ throw new Error('Unexpected deprecation thrown name=' +
+ name + ' msg=' + msg);
+ }
+ test._observedDeprecations[deprecationId] = 1;
+ };
+ }
+
+ function teardownDeprecationHandler(test, moment, scope) {
+ moment.suppressDeprecationWarnings = test._oldSupress;
+
+ if (test._expectedDeprecations != null) {
+ var missedDeprecations = [];
+ each(test._expectedDeprecations, function (deprecationPattern, id) {
+ if (test._observedDeprecations[id] !== 1) {
+ missedDeprecations.push(deprecationPattern);
+ }
+ });
+ if (missedDeprecations.length !== 0) {
+ throw new Error('Expected deprecation warnings did not happen: ' +
+ missedDeprecations.join(' '));
+ }
+ }
+ }
+
+ function matchedDeprecation(name, msg, deprecations) {
+ if (deprecations == null) {
+ return -1;
+ }
+ for (var i = 0; i < deprecations.length; ++i) {
+ if (name != null && name === deprecations[i]) {
+ return i;
+ }
+ if (msg != null && msg.substring(0, deprecations[i].length) === deprecations[i]) {
+ return i;
+ }
+ }
+ return -1;
+ }
+
/*global QUnit:false*/
var test = QUnit.test;
@@ -42475,11 +65006,13 @@
moment.createFromInputFallback = function (config) {
throw new Error('input not handled by moment: ' + config._i);
};
+ setupDeprecationHandler(test, moment, 'core');
if (lifecycle && lifecycle.setup) {
lifecycle.setup();
}
},
teardown : function () {
+ teardownDeprecationHandler(test, moment, 'core');
if (lifecycle && lifecycle.teardown) {
lifecycle.teardown();
}
@@ -42494,17 +65027,20 @@
moment.createFromInputFallback = function (config) {
throw new Error('input not handled by moment: ' + config._i);
};
+ setupDeprecationHandler(test, moment, 'locale');
if (lifecycle && lifecycle.setup) {
lifecycle.setup();
}
},
teardown : function () {
moment.locale('en');
+ teardownDeprecationHandler(test, moment, 'locale');
if (lifecycle && lifecycle.teardown) {
lifecycle.teardown();
}
}
});
+ defineCommonLocaleTests(name, -1, -1);
}
module('mutable');
@@ -42540,6 +65076,224 @@
factory(global.moment)
}(this, function (moment) { 'use strict';
+ function each(array, callback) {
+ var i;
+ for (i = 0; i < array.length; i++) {
+ callback(array[i], i, array);
+ }
+ }
+
+ function objectKeys(obj) {
+ if (Object.keys) {
+ return Object.keys(obj);
+ } else {
+ // IE8
+ var res = [], i;
+ for (i in obj) {
+ if (obj.hasOwnProperty(i)) {
+ res.push(i);
+ }
+ }
+ return res;
+ }
+ }
+
+ // Pick the first defined of two or three arguments.
+ function defaults(a, b, c) {
+ if (a != null) {
+ return a;
+ }
+ if (b != null) {
+ return b;
+ }
+ return c;
+ }
+
+ function defineCommonLocaleTests(locale, options) {
+ test('lenient ordinal parsing', function (assert) {
+ var i, ordinalStr, testMoment;
+ for (i = 1; i <= 31; ++i) {
+ ordinalStr = moment([2014, 0, i]).format('YYYY MM Do');
+ testMoment = moment(ordinalStr, 'YYYY MM Do');
+ assert.equal(testMoment.year(), 2014,
+ 'lenient ordinal parsing ' + i + ' year check');
+ assert.equal(testMoment.month(), 0,
+ 'lenient ordinal parsing ' + i + ' month check');
+ assert.equal(testMoment.date(), i,
+ 'lenient ordinal parsing ' + i + ' date check');
+ }
+ });
+
+ test('lenient ordinal parsing of number', function (assert) {
+ var i, testMoment;
+ for (i = 1; i <= 31; ++i) {
+ testMoment = moment('2014 01 ' + i, 'YYYY MM Do');
+ assert.equal(testMoment.year(), 2014,
+ 'lenient ordinal parsing of number ' + i + ' year check');
+ assert.equal(testMoment.month(), 0,
+ 'lenient ordinal parsing of number ' + i + ' month check');
+ assert.equal(testMoment.date(), i,
+ 'lenient ordinal parsing of number ' + i + ' date check');
+ }
+ });
+
+ test('strict ordinal parsing', function (assert) {
+ var i, ordinalStr, testMoment;
+ for (i = 1; i <= 31; ++i) {
+ ordinalStr = moment([2014, 0, i]).format('YYYY MM Do');
+ testMoment = moment(ordinalStr, 'YYYY MM Do', true);
+ assert.ok(testMoment.isValid(), 'strict ordinal parsing ' + i);
+ }
+ });
+
+ test('meridiem invariant', function (assert) {
+ var h, m, t1, t2;
+ for (h = 0; h < 24; ++h) {
+ for (m = 0; m < 60; m += 15) {
+ t1 = moment.utc([2000, 0, 1, h, m]);
+ t2 = moment.utc(t1.format('A h:mm'), 'A h:mm');
+ assert.equal(t2.format('HH:mm'), t1.format('HH:mm'),
+ 'meridiem at ' + t1.format('HH:mm'));
+ }
+ }
+ });
+
+ test('date format correctness', function (assert) {
+ var data, tokens;
+ data = moment.localeData()._longDateFormat;
+ tokens = objectKeys(data);
+ each(tokens, function (srchToken) {
+ // Check each format string to make sure it does not contain any
+ // tokens that need to be expanded.
+ each(tokens, function (baseToken) {
+ // strip escaped sequences
+ var format = data[baseToken].replace(/(\[[^\]]*\])/g, '');
+ assert.equal(false, !!~format.indexOf(srchToken),
+ 'contains ' + srchToken + ' in ' + baseToken);
+ });
+ });
+ });
+
+ test('month parsing correctness', function (assert) {
+ var i, m;
+
+ if (locale === 'tr') {
+ // I can't fix it :(
+ expect(0);
+ return;
+ }
+ function tester(format) {
+ var r;
+ r = moment(m.format(format), format);
+ assert.equal(r.month(), m.month(), 'month ' + i + ' fmt ' + format);
+ r = moment(m.format(format).toLocaleUpperCase(), format);
+ assert.equal(r.month(), m.month(), 'month ' + i + ' fmt ' + format + ' upper');
+ r = moment(m.format(format).toLocaleLowerCase(), format);
+ assert.equal(r.month(), m.month(), 'month ' + i + ' fmt ' + format + ' lower');
+
+ r = moment(m.format(format), format, true);
+ assert.equal(r.month(), m.month(), 'month ' + i + ' fmt ' + format + ' strict');
+ r = moment(m.format(format).toLocaleUpperCase(), format, true);
+ assert.equal(r.month(), m.month(), 'month ' + i + ' fmt ' + format + ' upper strict');
+ r = moment(m.format(format).toLocaleLowerCase(), format, true);
+ assert.equal(r.month(), m.month(), 'month ' + i + ' fmt ' + format + ' lower strict');
+ }
+
+ for (i = 0; i < 12; ++i) {
+ m = moment([2015, i, 15, 18]);
+ tester('MMM');
+ tester('MMM.');
+ tester('MMMM');
+ tester('MMMM.');
+ }
+ });
+
+ test('weekday parsing correctness', function (assert) {
+ var i, m;
+
+ if (locale === 'tr' || locale === 'az') {
+ // There is a lower-case letter (ı), that converted to upper then
+ // lower changes to i
+ expect(0);
+ return;
+ }
+ function tester(format) {
+ var r, baseMsg = 'weekday ' + m.weekday() + ' fmt ' + format;
+ r = moment(m.format(format), format);
+ assert.equal(r.weekday(), m.weekday(), baseMsg);
+ r = moment(m.format(format).toLocaleUpperCase(), format);
+ assert.equal(r.weekday(), m.weekday(), baseMsg + ' upper');
+ r = moment(m.format(format).toLocaleLowerCase(), format);
+ assert.equal(r.weekday(), m.weekday(), baseMsg + ' lower');
+
+ r = moment(m.format(format), format, true);
+ assert.equal(r.weekday(), m.weekday(), baseMsg + ' strict');
+ r = moment(m.format(format).toLocaleUpperCase(), format, true);
+ assert.equal(r.weekday(), m.weekday(), baseMsg + ' upper strict');
+ r = moment(m.format(format).toLocaleLowerCase(), format, true);
+ assert.equal(r.weekday(), m.weekday(), baseMsg + ' lower strict');
+ }
+
+ for (i = 0; i < 7; ++i) {
+ m = moment.utc([2015, i, 15, 18]);
+ tester('dd');
+ tester('ddd');
+ tester('dddd');
+ }
+ });
+ }
+
+ function setupDeprecationHandler(test, moment, scope) {
+ test._expectedDeprecations = null;
+ test._observedDeprecations = null;
+ test._oldSupress = moment.suppressDeprecationWarnings;
+ moment.suppressDeprecationWarnings = true;
+ test.expectedDeprecations = function () {
+ test._expectedDeprecations = arguments;
+ test._observedDeprecations = [];
+ };
+ moment.deprecationHandler = function (name, msg) {
+ var deprecationId = matchedDeprecation(name, msg, test._expectedDeprecations);
+ if (deprecationId === -1) {
+ throw new Error('Unexpected deprecation thrown name=' +
+ name + ' msg=' + msg);
+ }
+ test._observedDeprecations[deprecationId] = 1;
+ };
+ }
+
+ function teardownDeprecationHandler(test, moment, scope) {
+ moment.suppressDeprecationWarnings = test._oldSupress;
+
+ if (test._expectedDeprecations != null) {
+ var missedDeprecations = [];
+ each(test._expectedDeprecations, function (deprecationPattern, id) {
+ if (test._observedDeprecations[id] !== 1) {
+ missedDeprecations.push(deprecationPattern);
+ }
+ });
+ if (missedDeprecations.length !== 0) {
+ throw new Error('Expected deprecation warnings did not happen: ' +
+ missedDeprecations.join(' '));
+ }
+ }
+ }
+
+ function matchedDeprecation(name, msg, deprecations) {
+ if (deprecations == null) {
+ return -1;
+ }
+ for (var i = 0; i < deprecations.length; ++i) {
+ if (name != null && name === deprecations[i]) {
+ return i;
+ }
+ if (msg != null && msg.substring(0, deprecations[i].length) === deprecations[i]) {
+ return i;
+ }
+ }
+ return -1;
+ }
+
/*global QUnit:false*/
var test = QUnit.test;
@@ -42553,11 +65307,13 @@
moment.createFromInputFallback = function (config) {
throw new Error('input not handled by moment: ' + config._i);
};
+ setupDeprecationHandler(test, moment, 'core');
if (lifecycle && lifecycle.setup) {
lifecycle.setup();
}
},
teardown : function () {
+ teardownDeprecationHandler(test, moment, 'core');
if (lifecycle && lifecycle.teardown) {
lifecycle.teardown();
}
@@ -42572,17 +65328,20 @@
moment.createFromInputFallback = function (config) {
throw new Error('input not handled by moment: ' + config._i);
};
+ setupDeprecationHandler(test, moment, 'locale');
if (lifecycle && lifecycle.setup) {
lifecycle.setup();
}
},
teardown : function () {
moment.locale('en');
+ teardownDeprecationHandler(test, moment, 'locale');
if (lifecycle && lifecycle.teardown) {
lifecycle.teardown();
}
}
});
+ defineCommonLocaleTests(name, -1, -1);
}
module('normalize units');
@@ -42623,6 +65382,224 @@
factory(global.moment)
}(this, function (moment) { 'use strict';
+ function each(array, callback) {
+ var i;
+ for (i = 0; i < array.length; i++) {
+ callback(array[i], i, array);
+ }
+ }
+
+ function objectKeys(obj) {
+ if (Object.keys) {
+ return Object.keys(obj);
+ } else {
+ // IE8
+ var res = [], i;
+ for (i in obj) {
+ if (obj.hasOwnProperty(i)) {
+ res.push(i);
+ }
+ }
+ return res;
+ }
+ }
+
+ // Pick the first defined of two or three arguments.
+ function defaults(a, b, c) {
+ if (a != null) {
+ return a;
+ }
+ if (b != null) {
+ return b;
+ }
+ return c;
+ }
+
+ function defineCommonLocaleTests(locale, options) {
+ test('lenient ordinal parsing', function (assert) {
+ var i, ordinalStr, testMoment;
+ for (i = 1; i <= 31; ++i) {
+ ordinalStr = moment([2014, 0, i]).format('YYYY MM Do');
+ testMoment = moment(ordinalStr, 'YYYY MM Do');
+ assert.equal(testMoment.year(), 2014,
+ 'lenient ordinal parsing ' + i + ' year check');
+ assert.equal(testMoment.month(), 0,
+ 'lenient ordinal parsing ' + i + ' month check');
+ assert.equal(testMoment.date(), i,
+ 'lenient ordinal parsing ' + i + ' date check');
+ }
+ });
+
+ test('lenient ordinal parsing of number', function (assert) {
+ var i, testMoment;
+ for (i = 1; i <= 31; ++i) {
+ testMoment = moment('2014 01 ' + i, 'YYYY MM Do');
+ assert.equal(testMoment.year(), 2014,
+ 'lenient ordinal parsing of number ' + i + ' year check');
+ assert.equal(testMoment.month(), 0,
+ 'lenient ordinal parsing of number ' + i + ' month check');
+ assert.equal(testMoment.date(), i,
+ 'lenient ordinal parsing of number ' + i + ' date check');
+ }
+ });
+
+ test('strict ordinal parsing', function (assert) {
+ var i, ordinalStr, testMoment;
+ for (i = 1; i <= 31; ++i) {
+ ordinalStr = moment([2014, 0, i]).format('YYYY MM Do');
+ testMoment = moment(ordinalStr, 'YYYY MM Do', true);
+ assert.ok(testMoment.isValid(), 'strict ordinal parsing ' + i);
+ }
+ });
+
+ test('meridiem invariant', function (assert) {
+ var h, m, t1, t2;
+ for (h = 0; h < 24; ++h) {
+ for (m = 0; m < 60; m += 15) {
+ t1 = moment.utc([2000, 0, 1, h, m]);
+ t2 = moment.utc(t1.format('A h:mm'), 'A h:mm');
+ assert.equal(t2.format('HH:mm'), t1.format('HH:mm'),
+ 'meridiem at ' + t1.format('HH:mm'));
+ }
+ }
+ });
+
+ test('date format correctness', function (assert) {
+ var data, tokens;
+ data = moment.localeData()._longDateFormat;
+ tokens = objectKeys(data);
+ each(tokens, function (srchToken) {
+ // Check each format string to make sure it does not contain any
+ // tokens that need to be expanded.
+ each(tokens, function (baseToken) {
+ // strip escaped sequences
+ var format = data[baseToken].replace(/(\[[^\]]*\])/g, '');
+ assert.equal(false, !!~format.indexOf(srchToken),
+ 'contains ' + srchToken + ' in ' + baseToken);
+ });
+ });
+ });
+
+ test('month parsing correctness', function (assert) {
+ var i, m;
+
+ if (locale === 'tr') {
+ // I can't fix it :(
+ expect(0);
+ return;
+ }
+ function tester(format) {
+ var r;
+ r = moment(m.format(format), format);
+ assert.equal(r.month(), m.month(), 'month ' + i + ' fmt ' + format);
+ r = moment(m.format(format).toLocaleUpperCase(), format);
+ assert.equal(r.month(), m.month(), 'month ' + i + ' fmt ' + format + ' upper');
+ r = moment(m.format(format).toLocaleLowerCase(), format);
+ assert.equal(r.month(), m.month(), 'month ' + i + ' fmt ' + format + ' lower');
+
+ r = moment(m.format(format), format, true);
+ assert.equal(r.month(), m.month(), 'month ' + i + ' fmt ' + format + ' strict');
+ r = moment(m.format(format).toLocaleUpperCase(), format, true);
+ assert.equal(r.month(), m.month(), 'month ' + i + ' fmt ' + format + ' upper strict');
+ r = moment(m.format(format).toLocaleLowerCase(), format, true);
+ assert.equal(r.month(), m.month(), 'month ' + i + ' fmt ' + format + ' lower strict');
+ }
+
+ for (i = 0; i < 12; ++i) {
+ m = moment([2015, i, 15, 18]);
+ tester('MMM');
+ tester('MMM.');
+ tester('MMMM');
+ tester('MMMM.');
+ }
+ });
+
+ test('weekday parsing correctness', function (assert) {
+ var i, m;
+
+ if (locale === 'tr' || locale === 'az') {
+ // There is a lower-case letter (ı), that converted to upper then
+ // lower changes to i
+ expect(0);
+ return;
+ }
+ function tester(format) {
+ var r, baseMsg = 'weekday ' + m.weekday() + ' fmt ' + format;
+ r = moment(m.format(format), format);
+ assert.equal(r.weekday(), m.weekday(), baseMsg);
+ r = moment(m.format(format).toLocaleUpperCase(), format);
+ assert.equal(r.weekday(), m.weekday(), baseMsg + ' upper');
+ r = moment(m.format(format).toLocaleLowerCase(), format);
+ assert.equal(r.weekday(), m.weekday(), baseMsg + ' lower');
+
+ r = moment(m.format(format), format, true);
+ assert.equal(r.weekday(), m.weekday(), baseMsg + ' strict');
+ r = moment(m.format(format).toLocaleUpperCase(), format, true);
+ assert.equal(r.weekday(), m.weekday(), baseMsg + ' upper strict');
+ r = moment(m.format(format).toLocaleLowerCase(), format, true);
+ assert.equal(r.weekday(), m.weekday(), baseMsg + ' lower strict');
+ }
+
+ for (i = 0; i < 7; ++i) {
+ m = moment.utc([2015, i, 15, 18]);
+ tester('dd');
+ tester('ddd');
+ tester('dddd');
+ }
+ });
+ }
+
+ function setupDeprecationHandler(test, moment, scope) {
+ test._expectedDeprecations = null;
+ test._observedDeprecations = null;
+ test._oldSupress = moment.suppressDeprecationWarnings;
+ moment.suppressDeprecationWarnings = true;
+ test.expectedDeprecations = function () {
+ test._expectedDeprecations = arguments;
+ test._observedDeprecations = [];
+ };
+ moment.deprecationHandler = function (name, msg) {
+ var deprecationId = matchedDeprecation(name, msg, test._expectedDeprecations);
+ if (deprecationId === -1) {
+ throw new Error('Unexpected deprecation thrown name=' +
+ name + ' msg=' + msg);
+ }
+ test._observedDeprecations[deprecationId] = 1;
+ };
+ }
+
+ function teardownDeprecationHandler(test, moment, scope) {
+ moment.suppressDeprecationWarnings = test._oldSupress;
+
+ if (test._expectedDeprecations != null) {
+ var missedDeprecations = [];
+ each(test._expectedDeprecations, function (deprecationPattern, id) {
+ if (test._observedDeprecations[id] !== 1) {
+ missedDeprecations.push(deprecationPattern);
+ }
+ });
+ if (missedDeprecations.length !== 0) {
+ throw new Error('Expected deprecation warnings did not happen: ' +
+ missedDeprecations.join(' '));
+ }
+ }
+ }
+
+ function matchedDeprecation(name, msg, deprecations) {
+ if (deprecations == null) {
+ return -1;
+ }
+ for (var i = 0; i < deprecations.length; ++i) {
+ if (name != null && name === deprecations[i]) {
+ return i;
+ }
+ if (msg != null && msg.substring(0, deprecations[i].length) === deprecations[i]) {
+ return i;
+ }
+ }
+ return -1;
+ }
+
/*global QUnit:false*/
var test = QUnit.test;
@@ -42636,11 +65613,13 @@
moment.createFromInputFallback = function (config) {
throw new Error('input not handled by moment: ' + config._i);
};
+ setupDeprecationHandler(test, moment, 'core');
if (lifecycle && lifecycle.setup) {
lifecycle.setup();
}
},
teardown : function () {
+ teardownDeprecationHandler(test, moment, 'core');
if (lifecycle && lifecycle.teardown) {
lifecycle.teardown();
}
@@ -42655,17 +65634,20 @@
moment.createFromInputFallback = function (config) {
throw new Error('input not handled by moment: ' + config._i);
};
+ setupDeprecationHandler(test, moment, 'locale');
if (lifecycle && lifecycle.setup) {
lifecycle.setup();
}
},
teardown : function () {
moment.locale('en');
+ teardownDeprecationHandler(test, moment, 'locale');
if (lifecycle && lifecycle.teardown) {
lifecycle.teardown();
}
}
});
+ defineCommonLocaleTests(name, -1, -1);
}
module('now');
@@ -42677,6 +65659,31 @@
assert.ok(startOfTest <= momentNowTime, 'moment now() time should be now, not in the past');
assert.ok(momentNowTime <= afterMomentCreationTime, 'moment now() time should be now, not in the future');
+ });
+
+ test('now - Date mocked', function (assert) {
+ // We need to test mocking the global Date object, so disable 'Read Only' jshint check
+ /* jshint -W020 */
+ var RealDate = Date,
+ customTimeMs = moment('2015-01-01T01:30:00.000Z').valueOf();
+
+ function MockDate() {
+ return new RealDate(customTimeMs);
+ }
+
+ MockDate.now = function () {
+ return new MockDate().valueOf();
+ };
+
+ MockDate.prototype = RealDate.prototype;
+
+ Date = MockDate;
+
+ try {
+ assert.equal(moment().valueOf(), customTimeMs, 'moment now() time should use the global Date object');
+ } finally {
+ Date = RealDate;
+ }
});
test('now - custom value', function (assert) {
@@ -42705,6 +65712,224 @@
typeof define === 'function' && define.amd ? define(['../../moment'], factory) :
factory(global.moment)
}(this, function (moment) { 'use strict';
+
+ function each(array, callback) {
+ var i;
+ for (i = 0; i < array.length; i++) {
+ callback(array[i], i, array);
+ }
+ }
+
+ function objectKeys(obj) {
+ if (Object.keys) {
+ return Object.keys(obj);
+ } else {
+ // IE8
+ var res = [], i;
+ for (i in obj) {
+ if (obj.hasOwnProperty(i)) {
+ res.push(i);
+ }
+ }
+ return res;
+ }
+ }
+
+ // Pick the first defined of two or three arguments.
+ function defaults(a, b, c) {
+ if (a != null) {
+ return a;
+ }
+ if (b != null) {
+ return b;
+ }
+ return c;
+ }
+
+ function defineCommonLocaleTests(locale, options) {
+ test('lenient ordinal parsing', function (assert) {
+ var i, ordinalStr, testMoment;
+ for (i = 1; i <= 31; ++i) {
+ ordinalStr = moment([2014, 0, i]).format('YYYY MM Do');
+ testMoment = moment(ordinalStr, 'YYYY MM Do');
+ assert.equal(testMoment.year(), 2014,
+ 'lenient ordinal parsing ' + i + ' year check');
+ assert.equal(testMoment.month(), 0,
+ 'lenient ordinal parsing ' + i + ' month check');
+ assert.equal(testMoment.date(), i,
+ 'lenient ordinal parsing ' + i + ' date check');
+ }
+ });
+
+ test('lenient ordinal parsing of number', function (assert) {
+ var i, testMoment;
+ for (i = 1; i <= 31; ++i) {
+ testMoment = moment('2014 01 ' + i, 'YYYY MM Do');
+ assert.equal(testMoment.year(), 2014,
+ 'lenient ordinal parsing of number ' + i + ' year check');
+ assert.equal(testMoment.month(), 0,
+ 'lenient ordinal parsing of number ' + i + ' month check');
+ assert.equal(testMoment.date(), i,
+ 'lenient ordinal parsing of number ' + i + ' date check');
+ }
+ });
+
+ test('strict ordinal parsing', function (assert) {
+ var i, ordinalStr, testMoment;
+ for (i = 1; i <= 31; ++i) {
+ ordinalStr = moment([2014, 0, i]).format('YYYY MM Do');
+ testMoment = moment(ordinalStr, 'YYYY MM Do', true);
+ assert.ok(testMoment.isValid(), 'strict ordinal parsing ' + i);
+ }
+ });
+
+ test('meridiem invariant', function (assert) {
+ var h, m, t1, t2;
+ for (h = 0; h < 24; ++h) {
+ for (m = 0; m < 60; m += 15) {
+ t1 = moment.utc([2000, 0, 1, h, m]);
+ t2 = moment.utc(t1.format('A h:mm'), 'A h:mm');
+ assert.equal(t2.format('HH:mm'), t1.format('HH:mm'),
+ 'meridiem at ' + t1.format('HH:mm'));
+ }
+ }
+ });
+
+ test('date format correctness', function (assert) {
+ var data, tokens;
+ data = moment.localeData()._longDateFormat;
+ tokens = objectKeys(data);
+ each(tokens, function (srchToken) {
+ // Check each format string to make sure it does not contain any
+ // tokens that need to be expanded.
+ each(tokens, function (baseToken) {
+ // strip escaped sequences
+ var format = data[baseToken].replace(/(\[[^\]]*\])/g, '');
+ assert.equal(false, !!~format.indexOf(srchToken),
+ 'contains ' + srchToken + ' in ' + baseToken);
+ });
+ });
+ });
+
+ test('month parsing correctness', function (assert) {
+ var i, m;
+
+ if (locale === 'tr') {
+ // I can't fix it :(
+ expect(0);
+ return;
+ }
+ function tester(format) {
+ var r;
+ r = moment(m.format(format), format);
+ assert.equal(r.month(), m.month(), 'month ' + i + ' fmt ' + format);
+ r = moment(m.format(format).toLocaleUpperCase(), format);
+ assert.equal(r.month(), m.month(), 'month ' + i + ' fmt ' + format + ' upper');
+ r = moment(m.format(format).toLocaleLowerCase(), format);
+ assert.equal(r.month(), m.month(), 'month ' + i + ' fmt ' + format + ' lower');
+
+ r = moment(m.format(format), format, true);
+ assert.equal(r.month(), m.month(), 'month ' + i + ' fmt ' + format + ' strict');
+ r = moment(m.format(format).toLocaleUpperCase(), format, true);
+ assert.equal(r.month(), m.month(), 'month ' + i + ' fmt ' + format + ' upper strict');
+ r = moment(m.format(format).toLocaleLowerCase(), format, true);
+ assert.equal(r.month(), m.month(), 'month ' + i + ' fmt ' + format + ' lower strict');
+ }
+
+ for (i = 0; i < 12; ++i) {
+ m = moment([2015, i, 15, 18]);
+ tester('MMM');
+ tester('MMM.');
+ tester('MMMM');
+ tester('MMMM.');
+ }
+ });
+
+ test('weekday parsing correctness', function (assert) {
+ var i, m;
+
+ if (locale === 'tr' || locale === 'az') {
+ // There is a lower-case letter (ı), that converted to upper then
+ // lower changes to i
+ expect(0);
+ return;
+ }
+ function tester(format) {
+ var r, baseMsg = 'weekday ' + m.weekday() + ' fmt ' + format;
+ r = moment(m.format(format), format);
+ assert.equal(r.weekday(), m.weekday(), baseMsg);
+ r = moment(m.format(format).toLocaleUpperCase(), format);
+ assert.equal(r.weekday(), m.weekday(), baseMsg + ' upper');
+ r = moment(m.format(format).toLocaleLowerCase(), format);
+ assert.equal(r.weekday(), m.weekday(), baseMsg + ' lower');
+
+ r = moment(m.format(format), format, true);
+ assert.equal(r.weekday(), m.weekday(), baseMsg + ' strict');
+ r = moment(m.format(format).toLocaleUpperCase(), format, true);
+ assert.equal(r.weekday(), m.weekday(), baseMsg + ' upper strict');
+ r = moment(m.format(format).toLocaleLowerCase(), format, true);
+ assert.equal(r.weekday(), m.weekday(), baseMsg + ' lower strict');
+ }
+
+ for (i = 0; i < 7; ++i) {
+ m = moment.utc([2015, i, 15, 18]);
+ tester('dd');
+ tester('ddd');
+ tester('dddd');
+ }
+ });
+ }
+
+ function setupDeprecationHandler(test, moment, scope) {
+ test._expectedDeprecations = null;
+ test._observedDeprecations = null;
+ test._oldSupress = moment.suppressDeprecationWarnings;
+ moment.suppressDeprecationWarnings = true;
+ test.expectedDeprecations = function () {
+ test._expectedDeprecations = arguments;
+ test._observedDeprecations = [];
+ };
+ moment.deprecationHandler = function (name, msg) {
+ var deprecationId = matchedDeprecation(name, msg, test._expectedDeprecations);
+ if (deprecationId === -1) {
+ throw new Error('Unexpected deprecation thrown name=' +
+ name + ' msg=' + msg);
+ }
+ test._observedDeprecations[deprecationId] = 1;
+ };
+ }
+
+ function teardownDeprecationHandler(test, moment, scope) {
+ moment.suppressDeprecationWarnings = test._oldSupress;
+
+ if (test._expectedDeprecations != null) {
+ var missedDeprecations = [];
+ each(test._expectedDeprecations, function (deprecationPattern, id) {
+ if (test._observedDeprecations[id] !== 1) {
+ missedDeprecations.push(deprecationPattern);
+ }
+ });
+ if (missedDeprecations.length !== 0) {
+ throw new Error('Expected deprecation warnings did not happen: ' +
+ missedDeprecations.join(' '));
+ }
+ }
+ }
+
+ function matchedDeprecation(name, msg, deprecations) {
+ if (deprecations == null) {
+ return -1;
+ }
+ for (var i = 0; i < deprecations.length; ++i) {
+ if (name != null && name === deprecations[i]) {
+ return i;
+ }
+ if (msg != null && msg.substring(0, deprecations[i].length) === deprecations[i]) {
+ return i;
+ }
+ }
+ return -1;
+ }
/*global QUnit:false*/
@@ -42719,11 +65944,13 @@
moment.createFromInputFallback = function (config) {
throw new Error('input not handled by moment: ' + config._i);
};
+ setupDeprecationHandler(test, moment, 'core');
if (lifecycle && lifecycle.setup) {
lifecycle.setup();
}
},
teardown : function () {
+ teardownDeprecationHandler(test, moment, 'core');
if (lifecycle && lifecycle.teardown) {
lifecycle.teardown();
}
@@ -42738,17 +65965,20 @@
moment.createFromInputFallback = function (config) {
throw new Error('input not handled by moment: ' + config._i);
};
+ setupDeprecationHandler(test, moment, 'locale');
if (lifecycle && lifecycle.setup) {
lifecycle.setup();
}
},
teardown : function () {
moment.locale('en');
+ teardownDeprecationHandler(test, moment, 'locale');
if (lifecycle && lifecycle.teardown) {
lifecycle.teardown();
}
}
});
+ defineCommonLocaleTests(name, -1, -1);
}
module('parsing flags');
@@ -42926,6 +66156,224 @@
factory(global.moment)
}(this, function (moment) { 'use strict';
+ function each(array, callback) {
+ var i;
+ for (i = 0; i < array.length; i++) {
+ callback(array[i], i, array);
+ }
+ }
+
+ function objectKeys(obj) {
+ if (Object.keys) {
+ return Object.keys(obj);
+ } else {
+ // IE8
+ var res = [], i;
+ for (i in obj) {
+ if (obj.hasOwnProperty(i)) {
+ res.push(i);
+ }
+ }
+ return res;
+ }
+ }
+
+ // Pick the first defined of two or three arguments.
+ function defaults(a, b, c) {
+ if (a != null) {
+ return a;
+ }
+ if (b != null) {
+ return b;
+ }
+ return c;
+ }
+
+ function defineCommonLocaleTests(locale, options) {
+ test('lenient ordinal parsing', function (assert) {
+ var i, ordinalStr, testMoment;
+ for (i = 1; i <= 31; ++i) {
+ ordinalStr = moment([2014, 0, i]).format('YYYY MM Do');
+ testMoment = moment(ordinalStr, 'YYYY MM Do');
+ assert.equal(testMoment.year(), 2014,
+ 'lenient ordinal parsing ' + i + ' year check');
+ assert.equal(testMoment.month(), 0,
+ 'lenient ordinal parsing ' + i + ' month check');
+ assert.equal(testMoment.date(), i,
+ 'lenient ordinal parsing ' + i + ' date check');
+ }
+ });
+
+ test('lenient ordinal parsing of number', function (assert) {
+ var i, testMoment;
+ for (i = 1; i <= 31; ++i) {
+ testMoment = moment('2014 01 ' + i, 'YYYY MM Do');
+ assert.equal(testMoment.year(), 2014,
+ 'lenient ordinal parsing of number ' + i + ' year check');
+ assert.equal(testMoment.month(), 0,
+ 'lenient ordinal parsing of number ' + i + ' month check');
+ assert.equal(testMoment.date(), i,
+ 'lenient ordinal parsing of number ' + i + ' date check');
+ }
+ });
+
+ test('strict ordinal parsing', function (assert) {
+ var i, ordinalStr, testMoment;
+ for (i = 1; i <= 31; ++i) {
+ ordinalStr = moment([2014, 0, i]).format('YYYY MM Do');
+ testMoment = moment(ordinalStr, 'YYYY MM Do', true);
+ assert.ok(testMoment.isValid(), 'strict ordinal parsing ' + i);
+ }
+ });
+
+ test('meridiem invariant', function (assert) {
+ var h, m, t1, t2;
+ for (h = 0; h < 24; ++h) {
+ for (m = 0; m < 60; m += 15) {
+ t1 = moment.utc([2000, 0, 1, h, m]);
+ t2 = moment.utc(t1.format('A h:mm'), 'A h:mm');
+ assert.equal(t2.format('HH:mm'), t1.format('HH:mm'),
+ 'meridiem at ' + t1.format('HH:mm'));
+ }
+ }
+ });
+
+ test('date format correctness', function (assert) {
+ var data, tokens;
+ data = moment.localeData()._longDateFormat;
+ tokens = objectKeys(data);
+ each(tokens, function (srchToken) {
+ // Check each format string to make sure it does not contain any
+ // tokens that need to be expanded.
+ each(tokens, function (baseToken) {
+ // strip escaped sequences
+ var format = data[baseToken].replace(/(\[[^\]]*\])/g, '');
+ assert.equal(false, !!~format.indexOf(srchToken),
+ 'contains ' + srchToken + ' in ' + baseToken);
+ });
+ });
+ });
+
+ test('month parsing correctness', function (assert) {
+ var i, m;
+
+ if (locale === 'tr') {
+ // I can't fix it :(
+ expect(0);
+ return;
+ }
+ function tester(format) {
+ var r;
+ r = moment(m.format(format), format);
+ assert.equal(r.month(), m.month(), 'month ' + i + ' fmt ' + format);
+ r = moment(m.format(format).toLocaleUpperCase(), format);
+ assert.equal(r.month(), m.month(), 'month ' + i + ' fmt ' + format + ' upper');
+ r = moment(m.format(format).toLocaleLowerCase(), format);
+ assert.equal(r.month(), m.month(), 'month ' + i + ' fmt ' + format + ' lower');
+
+ r = moment(m.format(format), format, true);
+ assert.equal(r.month(), m.month(), 'month ' + i + ' fmt ' + format + ' strict');
+ r = moment(m.format(format).toLocaleUpperCase(), format, true);
+ assert.equal(r.month(), m.month(), 'month ' + i + ' fmt ' + format + ' upper strict');
+ r = moment(m.format(format).toLocaleLowerCase(), format, true);
+ assert.equal(r.month(), m.month(), 'month ' + i + ' fmt ' + format + ' lower strict');
+ }
+
+ for (i = 0; i < 12; ++i) {
+ m = moment([2015, i, 15, 18]);
+ tester('MMM');
+ tester('MMM.');
+ tester('MMMM');
+ tester('MMMM.');
+ }
+ });
+
+ test('weekday parsing correctness', function (assert) {
+ var i, m;
+
+ if (locale === 'tr' || locale === 'az') {
+ // There is a lower-case letter (ı), that converted to upper then
+ // lower changes to i
+ expect(0);
+ return;
+ }
+ function tester(format) {
+ var r, baseMsg = 'weekday ' + m.weekday() + ' fmt ' + format;
+ r = moment(m.format(format), format);
+ assert.equal(r.weekday(), m.weekday(), baseMsg);
+ r = moment(m.format(format).toLocaleUpperCase(), format);
+ assert.equal(r.weekday(), m.weekday(), baseMsg + ' upper');
+ r = moment(m.format(format).toLocaleLowerCase(), format);
+ assert.equal(r.weekday(), m.weekday(), baseMsg + ' lower');
+
+ r = moment(m.format(format), format, true);
+ assert.equal(r.weekday(), m.weekday(), baseMsg + ' strict');
+ r = moment(m.format(format).toLocaleUpperCase(), format, true);
+ assert.equal(r.weekday(), m.weekday(), baseMsg + ' upper strict');
+ r = moment(m.format(format).toLocaleLowerCase(), format, true);
+ assert.equal(r.weekday(), m.weekday(), baseMsg + ' lower strict');
+ }
+
+ for (i = 0; i < 7; ++i) {
+ m = moment.utc([2015, i, 15, 18]);
+ tester('dd');
+ tester('ddd');
+ tester('dddd');
+ }
+ });
+ }
+
+ function setupDeprecationHandler(test, moment, scope) {
+ test._expectedDeprecations = null;
+ test._observedDeprecations = null;
+ test._oldSupress = moment.suppressDeprecationWarnings;
+ moment.suppressDeprecationWarnings = true;
+ test.expectedDeprecations = function () {
+ test._expectedDeprecations = arguments;
+ test._observedDeprecations = [];
+ };
+ moment.deprecationHandler = function (name, msg) {
+ var deprecationId = matchedDeprecation(name, msg, test._expectedDeprecations);
+ if (deprecationId === -1) {
+ throw new Error('Unexpected deprecation thrown name=' +
+ name + ' msg=' + msg);
+ }
+ test._observedDeprecations[deprecationId] = 1;
+ };
+ }
+
+ function teardownDeprecationHandler(test, moment, scope) {
+ moment.suppressDeprecationWarnings = test._oldSupress;
+
+ if (test._expectedDeprecations != null) {
+ var missedDeprecations = [];
+ each(test._expectedDeprecations, function (deprecationPattern, id) {
+ if (test._observedDeprecations[id] !== 1) {
+ missedDeprecations.push(deprecationPattern);
+ }
+ });
+ if (missedDeprecations.length !== 0) {
+ throw new Error('Expected deprecation warnings did not happen: ' +
+ missedDeprecations.join(' '));
+ }
+ }
+ }
+
+ function matchedDeprecation(name, msg, deprecations) {
+ if (deprecations == null) {
+ return -1;
+ }
+ for (var i = 0; i < deprecations.length; ++i) {
+ if (name != null && name === deprecations[i]) {
+ return i;
+ }
+ if (msg != null && msg.substring(0, deprecations[i].length) === deprecations[i]) {
+ return i;
+ }
+ }
+ return -1;
+ }
+
/*global QUnit:false*/
var test = QUnit.test;
@@ -42939,11 +66387,13 @@
moment.createFromInputFallback = function (config) {
throw new Error('input not handled by moment: ' + config._i);
};
+ setupDeprecationHandler(test, moment, 'core');
if (lifecycle && lifecycle.setup) {
lifecycle.setup();
}
},
teardown : function () {
+ teardownDeprecationHandler(test, moment, 'core');
if (lifecycle && lifecycle.teardown) {
lifecycle.teardown();
}
@@ -42958,17 +66408,20 @@
moment.createFromInputFallback = function (config) {
throw new Error('input not handled by moment: ' + config._i);
};
+ setupDeprecationHandler(test, moment, 'locale');
if (lifecycle && lifecycle.setup) {
lifecycle.setup();
}
},
teardown : function () {
moment.locale('en');
+ teardownDeprecationHandler(test, moment, 'locale');
if (lifecycle && lifecycle.teardown) {
lifecycle.teardown();
}
}
});
+ defineCommonLocaleTests(name, -1, -1);
}
var symbolMap = {
@@ -43011,6 +66464,9 @@
});
}
});
+ },
+ teardown: function () {
+ moment.defineLocale('symbol', null);
}
});
@@ -43029,14 +66485,14 @@
});
test('calendar day', function (assert) {
- var a = moment().hours(2).minutes(0).seconds(0);
-
- assert.equal(moment(a).calendar(), 'Today at @:)) AM', 'today at the same time');
- assert.equal(moment(a).add({m: 25}).calendar(), 'Today at @:@% AM', 'Now plus 25 min');
- assert.equal(moment(a).add({h: 1}).calendar(), 'Today at #:)) AM', 'Now plus 1 hour');
- assert.equal(moment(a).add({d: 1}).calendar(), 'Tomorrow at @:)) AM', 'tomorrow at the same time');
- assert.equal(moment(a).subtract({h: 1}).calendar(), 'Today at !:)) AM', 'Now minus 1 hour');
- assert.equal(moment(a).subtract({d: 1}).calendar(), 'Yesterday at @:)) AM', 'yesterday at the same time');
+ var a = moment().hours(12).minutes(0).seconds(0);
+
+ assert.equal(moment(a).calendar(), 'Today at !@:)) PM', 'today at the same time');
+ assert.equal(moment(a).add({m: 25}).calendar(), 'Today at !@:@% PM', 'Now plus 25 min');
+ assert.equal(moment(a).add({h: 1}).calendar(), 'Today at !:)) PM', 'Now plus 1 hour');
+ assert.equal(moment(a).add({d: 1}).calendar(), 'Tomorrow at !@:)) PM', 'tomorrow at the same time');
+ assert.equal(moment(a).subtract({h: 1}).calendar(), 'Today at !!:)) AM', 'Now minus 1 hour');
+ assert.equal(moment(a).subtract({d: 1}).calendar(), 'Yesterday at !@:)) PM', 'yesterday at the same time');
});
}));
@@ -43047,6 +66503,224 @@
typeof define === 'function' && define.amd ? define(['../../moment'], factory) :
factory(global.moment)
}(this, function (moment) { 'use strict';
+
+ function each(array, callback) {
+ var i;
+ for (i = 0; i < array.length; i++) {
+ callback(array[i], i, array);
+ }
+ }
+
+ function objectKeys(obj) {
+ if (Object.keys) {
+ return Object.keys(obj);
+ } else {
+ // IE8
+ var res = [], i;
+ for (i in obj) {
+ if (obj.hasOwnProperty(i)) {
+ res.push(i);
+ }
+ }
+ return res;
+ }
+ }
+
+ // Pick the first defined of two or three arguments.
+ function defaults(a, b, c) {
+ if (a != null) {
+ return a;
+ }
+ if (b != null) {
+ return b;
+ }
+ return c;
+ }
+
+ function defineCommonLocaleTests(locale, options) {
+ test('lenient ordinal parsing', function (assert) {
+ var i, ordinalStr, testMoment;
+ for (i = 1; i <= 31; ++i) {
+ ordinalStr = moment([2014, 0, i]).format('YYYY MM Do');
+ testMoment = moment(ordinalStr, 'YYYY MM Do');
+ assert.equal(testMoment.year(), 2014,
+ 'lenient ordinal parsing ' + i + ' year check');
+ assert.equal(testMoment.month(), 0,
+ 'lenient ordinal parsing ' + i + ' month check');
+ assert.equal(testMoment.date(), i,
+ 'lenient ordinal parsing ' + i + ' date check');
+ }
+ });
+
+ test('lenient ordinal parsing of number', function (assert) {
+ var i, testMoment;
+ for (i = 1; i <= 31; ++i) {
+ testMoment = moment('2014 01 ' + i, 'YYYY MM Do');
+ assert.equal(testMoment.year(), 2014,
+ 'lenient ordinal parsing of number ' + i + ' year check');
+ assert.equal(testMoment.month(), 0,
+ 'lenient ordinal parsing of number ' + i + ' month check');
+ assert.equal(testMoment.date(), i,
+ 'lenient ordinal parsing of number ' + i + ' date check');
+ }
+ });
+
+ test('strict ordinal parsing', function (assert) {
+ var i, ordinalStr, testMoment;
+ for (i = 1; i <= 31; ++i) {
+ ordinalStr = moment([2014, 0, i]).format('YYYY MM Do');
+ testMoment = moment(ordinalStr, 'YYYY MM Do', true);
+ assert.ok(testMoment.isValid(), 'strict ordinal parsing ' + i);
+ }
+ });
+
+ test('meridiem invariant', function (assert) {
+ var h, m, t1, t2;
+ for (h = 0; h < 24; ++h) {
+ for (m = 0; m < 60; m += 15) {
+ t1 = moment.utc([2000, 0, 1, h, m]);
+ t2 = moment.utc(t1.format('A h:mm'), 'A h:mm');
+ assert.equal(t2.format('HH:mm'), t1.format('HH:mm'),
+ 'meridiem at ' + t1.format('HH:mm'));
+ }
+ }
+ });
+
+ test('date format correctness', function (assert) {
+ var data, tokens;
+ data = moment.localeData()._longDateFormat;
+ tokens = objectKeys(data);
+ each(tokens, function (srchToken) {
+ // Check each format string to make sure it does not contain any
+ // tokens that need to be expanded.
+ each(tokens, function (baseToken) {
+ // strip escaped sequences
+ var format = data[baseToken].replace(/(\[[^\]]*\])/g, '');
+ assert.equal(false, !!~format.indexOf(srchToken),
+ 'contains ' + srchToken + ' in ' + baseToken);
+ });
+ });
+ });
+
+ test('month parsing correctness', function (assert) {
+ var i, m;
+
+ if (locale === 'tr') {
+ // I can't fix it :(
+ expect(0);
+ return;
+ }
+ function tester(format) {
+ var r;
+ r = moment(m.format(format), format);
+ assert.equal(r.month(), m.month(), 'month ' + i + ' fmt ' + format);
+ r = moment(m.format(format).toLocaleUpperCase(), format);
+ assert.equal(r.month(), m.month(), 'month ' + i + ' fmt ' + format + ' upper');
+ r = moment(m.format(format).toLocaleLowerCase(), format);
+ assert.equal(r.month(), m.month(), 'month ' + i + ' fmt ' + format + ' lower');
+
+ r = moment(m.format(format), format, true);
+ assert.equal(r.month(), m.month(), 'month ' + i + ' fmt ' + format + ' strict');
+ r = moment(m.format(format).toLocaleUpperCase(), format, true);
+ assert.equal(r.month(), m.month(), 'month ' + i + ' fmt ' + format + ' upper strict');
+ r = moment(m.format(format).toLocaleLowerCase(), format, true);
+ assert.equal(r.month(), m.month(), 'month ' + i + ' fmt ' + format + ' lower strict');
+ }
+
+ for (i = 0; i < 12; ++i) {
+ m = moment([2015, i, 15, 18]);
+ tester('MMM');
+ tester('MMM.');
+ tester('MMMM');
+ tester('MMMM.');
+ }
+ });
+
+ test('weekday parsing correctness', function (assert) {
+ var i, m;
+
+ if (locale === 'tr' || locale === 'az') {
+ // There is a lower-case letter (ı), that converted to upper then
+ // lower changes to i
+ expect(0);
+ return;
+ }
+ function tester(format) {
+ var r, baseMsg = 'weekday ' + m.weekday() + ' fmt ' + format;
+ r = moment(m.format(format), format);
+ assert.equal(r.weekday(), m.weekday(), baseMsg);
+ r = moment(m.format(format).toLocaleUpperCase(), format);
+ assert.equal(r.weekday(), m.weekday(), baseMsg + ' upper');
+ r = moment(m.format(format).toLocaleLowerCase(), format);
+ assert.equal(r.weekday(), m.weekday(), baseMsg + ' lower');
+
+ r = moment(m.format(format), format, true);
+ assert.equal(r.weekday(), m.weekday(), baseMsg + ' strict');
+ r = moment(m.format(format).toLocaleUpperCase(), format, true);
+ assert.equal(r.weekday(), m.weekday(), baseMsg + ' upper strict');
+ r = moment(m.format(format).toLocaleLowerCase(), format, true);
+ assert.equal(r.weekday(), m.weekday(), baseMsg + ' lower strict');
+ }
+
+ for (i = 0; i < 7; ++i) {
+ m = moment.utc([2015, i, 15, 18]);
+ tester('dd');
+ tester('ddd');
+ tester('dddd');
+ }
+ });
+ }
+
+ function setupDeprecationHandler(test, moment, scope) {
+ test._expectedDeprecations = null;
+ test._observedDeprecations = null;
+ test._oldSupress = moment.suppressDeprecationWarnings;
+ moment.suppressDeprecationWarnings = true;
+ test.expectedDeprecations = function () {
+ test._expectedDeprecations = arguments;
+ test._observedDeprecations = [];
+ };
+ moment.deprecationHandler = function (name, msg) {
+ var deprecationId = matchedDeprecation(name, msg, test._expectedDeprecations);
+ if (deprecationId === -1) {
+ throw new Error('Unexpected deprecation thrown name=' +
+ name + ' msg=' + msg);
+ }
+ test._observedDeprecations[deprecationId] = 1;
+ };
+ }
+
+ function teardownDeprecationHandler(test, moment, scope) {
+ moment.suppressDeprecationWarnings = test._oldSupress;
+
+ if (test._expectedDeprecations != null) {
+ var missedDeprecations = [];
+ each(test._expectedDeprecations, function (deprecationPattern, id) {
+ if (test._observedDeprecations[id] !== 1) {
+ missedDeprecations.push(deprecationPattern);
+ }
+ });
+ if (missedDeprecations.length !== 0) {
+ throw new Error('Expected deprecation warnings did not happen: ' +
+ missedDeprecations.join(' '));
+ }
+ }
+ }
+
+ function matchedDeprecation(name, msg, deprecations) {
+ if (deprecations == null) {
+ return -1;
+ }
+ for (var i = 0; i < deprecations.length; ++i) {
+ if (name != null && name === deprecations[i]) {
+ return i;
+ }
+ if (msg != null && msg.substring(0, deprecations[i].length) === deprecations[i]) {
+ return i;
+ }
+ }
+ return -1;
+ }
/*global QUnit:false*/
@@ -43061,11 +66735,13 @@
moment.createFromInputFallback = function (config) {
throw new Error('input not handled by moment: ' + config._i);
};
+ setupDeprecationHandler(test, moment, 'core');
if (lifecycle && lifecycle.setup) {
lifecycle.setup();
}
},
teardown : function () {
+ teardownDeprecationHandler(test, moment, 'core');
if (lifecycle && lifecycle.teardown) {
lifecycle.teardown();
}
@@ -43080,17 +66756,20 @@
moment.createFromInputFallback = function (config) {
throw new Error('input not handled by moment: ' + config._i);
};
+ setupDeprecationHandler(test, moment, 'locale');
if (lifecycle && lifecycle.setup) {
lifecycle.setup();
}
},
teardown : function () {
moment.locale('en');
+ teardownDeprecationHandler(test, moment, 'locale');
if (lifecycle && lifecycle.teardown) {
lifecycle.teardown();
}
}
});
+ defineCommonLocaleTests(name, -1, -1);
}
module('quarter');
@@ -43201,6 +66880,224 @@
factory(global.moment)
}(this, function (moment) { 'use strict';
+ function each(array, callback) {
+ var i;
+ for (i = 0; i < array.length; i++) {
+ callback(array[i], i, array);
+ }
+ }
+
+ function objectKeys(obj) {
+ if (Object.keys) {
+ return Object.keys(obj);
+ } else {
+ // IE8
+ var res = [], i;
+ for (i in obj) {
+ if (obj.hasOwnProperty(i)) {
+ res.push(i);
+ }
+ }
+ return res;
+ }
+ }
+
+ // Pick the first defined of two or three arguments.
+ function defaults(a, b, c) {
+ if (a != null) {
+ return a;
+ }
+ if (b != null) {
+ return b;
+ }
+ return c;
+ }
+
+ function defineCommonLocaleTests(locale, options) {
+ test('lenient ordinal parsing', function (assert) {
+ var i, ordinalStr, testMoment;
+ for (i = 1; i <= 31; ++i) {
+ ordinalStr = moment([2014, 0, i]).format('YYYY MM Do');
+ testMoment = moment(ordinalStr, 'YYYY MM Do');
+ assert.equal(testMoment.year(), 2014,
+ 'lenient ordinal parsing ' + i + ' year check');
+ assert.equal(testMoment.month(), 0,
+ 'lenient ordinal parsing ' + i + ' month check');
+ assert.equal(testMoment.date(), i,
+ 'lenient ordinal parsing ' + i + ' date check');
+ }
+ });
+
+ test('lenient ordinal parsing of number', function (assert) {
+ var i, testMoment;
+ for (i = 1; i <= 31; ++i) {
+ testMoment = moment('2014 01 ' + i, 'YYYY MM Do');
+ assert.equal(testMoment.year(), 2014,
+ 'lenient ordinal parsing of number ' + i + ' year check');
+ assert.equal(testMoment.month(), 0,
+ 'lenient ordinal parsing of number ' + i + ' month check');
+ assert.equal(testMoment.date(), i,
+ 'lenient ordinal parsing of number ' + i + ' date check');
+ }
+ });
+
+ test('strict ordinal parsing', function (assert) {
+ var i, ordinalStr, testMoment;
+ for (i = 1; i <= 31; ++i) {
+ ordinalStr = moment([2014, 0, i]).format('YYYY MM Do');
+ testMoment = moment(ordinalStr, 'YYYY MM Do', true);
+ assert.ok(testMoment.isValid(), 'strict ordinal parsing ' + i);
+ }
+ });
+
+ test('meridiem invariant', function (assert) {
+ var h, m, t1, t2;
+ for (h = 0; h < 24; ++h) {
+ for (m = 0; m < 60; m += 15) {
+ t1 = moment.utc([2000, 0, 1, h, m]);
+ t2 = moment.utc(t1.format('A h:mm'), 'A h:mm');
+ assert.equal(t2.format('HH:mm'), t1.format('HH:mm'),
+ 'meridiem at ' + t1.format('HH:mm'));
+ }
+ }
+ });
+
+ test('date format correctness', function (assert) {
+ var data, tokens;
+ data = moment.localeData()._longDateFormat;
+ tokens = objectKeys(data);
+ each(tokens, function (srchToken) {
+ // Check each format string to make sure it does not contain any
+ // tokens that need to be expanded.
+ each(tokens, function (baseToken) {
+ // strip escaped sequences
+ var format = data[baseToken].replace(/(\[[^\]]*\])/g, '');
+ assert.equal(false, !!~format.indexOf(srchToken),
+ 'contains ' + srchToken + ' in ' + baseToken);
+ });
+ });
+ });
+
+ test('month parsing correctness', function (assert) {
+ var i, m;
+
+ if (locale === 'tr') {
+ // I can't fix it :(
+ expect(0);
+ return;
+ }
+ function tester(format) {
+ var r;
+ r = moment(m.format(format), format);
+ assert.equal(r.month(), m.month(), 'month ' + i + ' fmt ' + format);
+ r = moment(m.format(format).toLocaleUpperCase(), format);
+ assert.equal(r.month(), m.month(), 'month ' + i + ' fmt ' + format + ' upper');
+ r = moment(m.format(format).toLocaleLowerCase(), format);
+ assert.equal(r.month(), m.month(), 'month ' + i + ' fmt ' + format + ' lower');
+
+ r = moment(m.format(format), format, true);
+ assert.equal(r.month(), m.month(), 'month ' + i + ' fmt ' + format + ' strict');
+ r = moment(m.format(format).toLocaleUpperCase(), format, true);
+ assert.equal(r.month(), m.month(), 'month ' + i + ' fmt ' + format + ' upper strict');
+ r = moment(m.format(format).toLocaleLowerCase(), format, true);
+ assert.equal(r.month(), m.month(), 'month ' + i + ' fmt ' + format + ' lower strict');
+ }
+
+ for (i = 0; i < 12; ++i) {
+ m = moment([2015, i, 15, 18]);
+ tester('MMM');
+ tester('MMM.');
+ tester('MMMM');
+ tester('MMMM.');
+ }
+ });
+
+ test('weekday parsing correctness', function (assert) {
+ var i, m;
+
+ if (locale === 'tr' || locale === 'az') {
+ // There is a lower-case letter (ı), that converted to upper then
+ // lower changes to i
+ expect(0);
+ return;
+ }
+ function tester(format) {
+ var r, baseMsg = 'weekday ' + m.weekday() + ' fmt ' + format;
+ r = moment(m.format(format), format);
+ assert.equal(r.weekday(), m.weekday(), baseMsg);
+ r = moment(m.format(format).toLocaleUpperCase(), format);
+ assert.equal(r.weekday(), m.weekday(), baseMsg + ' upper');
+ r = moment(m.format(format).toLocaleLowerCase(), format);
+ assert.equal(r.weekday(), m.weekday(), baseMsg + ' lower');
+
+ r = moment(m.format(format), format, true);
+ assert.equal(r.weekday(), m.weekday(), baseMsg + ' strict');
+ r = moment(m.format(format).toLocaleUpperCase(), format, true);
+ assert.equal(r.weekday(), m.weekday(), baseMsg + ' upper strict');
+ r = moment(m.format(format).toLocaleLowerCase(), format, true);
+ assert.equal(r.weekday(), m.weekday(), baseMsg + ' lower strict');
+ }
+
+ for (i = 0; i < 7; ++i) {
+ m = moment.utc([2015, i, 15, 18]);
+ tester('dd');
+ tester('ddd');
+ tester('dddd');
+ }
+ });
+ }
+
+ function setupDeprecationHandler(test, moment, scope) {
+ test._expectedDeprecations = null;
+ test._observedDeprecations = null;
+ test._oldSupress = moment.suppressDeprecationWarnings;
+ moment.suppressDeprecationWarnings = true;
+ test.expectedDeprecations = function () {
+ test._expectedDeprecations = arguments;
+ test._observedDeprecations = [];
+ };
+ moment.deprecationHandler = function (name, msg) {
+ var deprecationId = matchedDeprecation(name, msg, test._expectedDeprecations);
+ if (deprecationId === -1) {
+ throw new Error('Unexpected deprecation thrown name=' +
+ name + ' msg=' + msg);
+ }
+ test._observedDeprecations[deprecationId] = 1;
+ };
+ }
+
+ function teardownDeprecationHandler(test, moment, scope) {
+ moment.suppressDeprecationWarnings = test._oldSupress;
+
+ if (test._expectedDeprecations != null) {
+ var missedDeprecations = [];
+ each(test._expectedDeprecations, function (deprecationPattern, id) {
+ if (test._observedDeprecations[id] !== 1) {
+ missedDeprecations.push(deprecationPattern);
+ }
+ });
+ if (missedDeprecations.length !== 0) {
+ throw new Error('Expected deprecation warnings did not happen: ' +
+ missedDeprecations.join(' '));
+ }
+ }
+ }
+
+ function matchedDeprecation(name, msg, deprecations) {
+ if (deprecations == null) {
+ return -1;
+ }
+ for (var i = 0; i < deprecations.length; ++i) {
+ if (name != null && name === deprecations[i]) {
+ return i;
+ }
+ if (msg != null && msg.substring(0, deprecations[i].length) === deprecations[i]) {
+ return i;
+ }
+ }
+ return -1;
+ }
+
/*global QUnit:false*/
var test = QUnit.test;
@@ -43214,11 +67111,13 @@
moment.createFromInputFallback = function (config) {
throw new Error('input not handled by moment: ' + config._i);
};
+ setupDeprecationHandler(test, moment, 'core');
if (lifecycle && lifecycle.setup) {
lifecycle.setup();
}
},
teardown : function () {
+ teardownDeprecationHandler(test, moment, 'core');
if (lifecycle && lifecycle.teardown) {
lifecycle.teardown();
}
@@ -43233,17 +67132,20 @@
moment.createFromInputFallback = function (config) {
throw new Error('input not handled by moment: ' + config._i);
};
+ setupDeprecationHandler(test, moment, 'locale');
if (lifecycle && lifecycle.setup) {
lifecycle.setup();
}
},
teardown : function () {
moment.locale('en');
+ teardownDeprecationHandler(test, moment, 'locale');
if (lifecycle && lifecycle.teardown) {
lifecycle.teardown();
}
}
});
+ defineCommonLocaleTests(name, -1, -1);
}
module('relative time');
@@ -43400,6 +67302,224 @@
factory(global.moment)
}(this, function (moment) { 'use strict';
+ function each(array, callback) {
+ var i;
+ for (i = 0; i < array.length; i++) {
+ callback(array[i], i, array);
+ }
+ }
+
+ function objectKeys(obj) {
+ if (Object.keys) {
+ return Object.keys(obj);
+ } else {
+ // IE8
+ var res = [], i;
+ for (i in obj) {
+ if (obj.hasOwnProperty(i)) {
+ res.push(i);
+ }
+ }
+ return res;
+ }
+ }
+
+ // Pick the first defined of two or three arguments.
+ function defaults(a, b, c) {
+ if (a != null) {
+ return a;
+ }
+ if (b != null) {
+ return b;
+ }
+ return c;
+ }
+
+ function defineCommonLocaleTests(locale, options) {
+ test('lenient ordinal parsing', function (assert) {
+ var i, ordinalStr, testMoment;
+ for (i = 1; i <= 31; ++i) {
+ ordinalStr = moment([2014, 0, i]).format('YYYY MM Do');
+ testMoment = moment(ordinalStr, 'YYYY MM Do');
+ assert.equal(testMoment.year(), 2014,
+ 'lenient ordinal parsing ' + i + ' year check');
+ assert.equal(testMoment.month(), 0,
+ 'lenient ordinal parsing ' + i + ' month check');
+ assert.equal(testMoment.date(), i,
+ 'lenient ordinal parsing ' + i + ' date check');
+ }
+ });
+
+ test('lenient ordinal parsing of number', function (assert) {
+ var i, testMoment;
+ for (i = 1; i <= 31; ++i) {
+ testMoment = moment('2014 01 ' + i, 'YYYY MM Do');
+ assert.equal(testMoment.year(), 2014,
+ 'lenient ordinal parsing of number ' + i + ' year check');
+ assert.equal(testMoment.month(), 0,
+ 'lenient ordinal parsing of number ' + i + ' month check');
+ assert.equal(testMoment.date(), i,
+ 'lenient ordinal parsing of number ' + i + ' date check');
+ }
+ });
+
+ test('strict ordinal parsing', function (assert) {
+ var i, ordinalStr, testMoment;
+ for (i = 1; i <= 31; ++i) {
+ ordinalStr = moment([2014, 0, i]).format('YYYY MM Do');
+ testMoment = moment(ordinalStr, 'YYYY MM Do', true);
+ assert.ok(testMoment.isValid(), 'strict ordinal parsing ' + i);
+ }
+ });
+
+ test('meridiem invariant', function (assert) {
+ var h, m, t1, t2;
+ for (h = 0; h < 24; ++h) {
+ for (m = 0; m < 60; m += 15) {
+ t1 = moment.utc([2000, 0, 1, h, m]);
+ t2 = moment.utc(t1.format('A h:mm'), 'A h:mm');
+ assert.equal(t2.format('HH:mm'), t1.format('HH:mm'),
+ 'meridiem at ' + t1.format('HH:mm'));
+ }
+ }
+ });
+
+ test('date format correctness', function (assert) {
+ var data, tokens;
+ data = moment.localeData()._longDateFormat;
+ tokens = objectKeys(data);
+ each(tokens, function (srchToken) {
+ // Check each format string to make sure it does not contain any
+ // tokens that need to be expanded.
+ each(tokens, function (baseToken) {
+ // strip escaped sequences
+ var format = data[baseToken].replace(/(\[[^\]]*\])/g, '');
+ assert.equal(false, !!~format.indexOf(srchToken),
+ 'contains ' + srchToken + ' in ' + baseToken);
+ });
+ });
+ });
+
+ test('month parsing correctness', function (assert) {
+ var i, m;
+
+ if (locale === 'tr') {
+ // I can't fix it :(
+ expect(0);
+ return;
+ }
+ function tester(format) {
+ var r;
+ r = moment(m.format(format), format);
+ assert.equal(r.month(), m.month(), 'month ' + i + ' fmt ' + format);
+ r = moment(m.format(format).toLocaleUpperCase(), format);
+ assert.equal(r.month(), m.month(), 'month ' + i + ' fmt ' + format + ' upper');
+ r = moment(m.format(format).toLocaleLowerCase(), format);
+ assert.equal(r.month(), m.month(), 'month ' + i + ' fmt ' + format + ' lower');
+
+ r = moment(m.format(format), format, true);
+ assert.equal(r.month(), m.month(), 'month ' + i + ' fmt ' + format + ' strict');
+ r = moment(m.format(format).toLocaleUpperCase(), format, true);
+ assert.equal(r.month(), m.month(), 'month ' + i + ' fmt ' + format + ' upper strict');
+ r = moment(m.format(format).toLocaleLowerCase(), format, true);
+ assert.equal(r.month(), m.month(), 'month ' + i + ' fmt ' + format + ' lower strict');
+ }
+
+ for (i = 0; i < 12; ++i) {
+ m = moment([2015, i, 15, 18]);
+ tester('MMM');
+ tester('MMM.');
+ tester('MMMM');
+ tester('MMMM.');
+ }
+ });
+
+ test('weekday parsing correctness', function (assert) {
+ var i, m;
+
+ if (locale === 'tr' || locale === 'az') {
+ // There is a lower-case letter (ı), that converted to upper then
+ // lower changes to i
+ expect(0);
+ return;
+ }
+ function tester(format) {
+ var r, baseMsg = 'weekday ' + m.weekday() + ' fmt ' + format;
+ r = moment(m.format(format), format);
+ assert.equal(r.weekday(), m.weekday(), baseMsg);
+ r = moment(m.format(format).toLocaleUpperCase(), format);
+ assert.equal(r.weekday(), m.weekday(), baseMsg + ' upper');
+ r = moment(m.format(format).toLocaleLowerCase(), format);
+ assert.equal(r.weekday(), m.weekday(), baseMsg + ' lower');
+
+ r = moment(m.format(format), format, true);
+ assert.equal(r.weekday(), m.weekday(), baseMsg + ' strict');
+ r = moment(m.format(format).toLocaleUpperCase(), format, true);
+ assert.equal(r.weekday(), m.weekday(), baseMsg + ' upper strict');
+ r = moment(m.format(format).toLocaleLowerCase(), format, true);
+ assert.equal(r.weekday(), m.weekday(), baseMsg + ' lower strict');
+ }
+
+ for (i = 0; i < 7; ++i) {
+ m = moment.utc([2015, i, 15, 18]);
+ tester('dd');
+ tester('ddd');
+ tester('dddd');
+ }
+ });
+ }
+
+ function setupDeprecationHandler(test, moment, scope) {
+ test._expectedDeprecations = null;
+ test._observedDeprecations = null;
+ test._oldSupress = moment.suppressDeprecationWarnings;
+ moment.suppressDeprecationWarnings = true;
+ test.expectedDeprecations = function () {
+ test._expectedDeprecations = arguments;
+ test._observedDeprecations = [];
+ };
+ moment.deprecationHandler = function (name, msg) {
+ var deprecationId = matchedDeprecation(name, msg, test._expectedDeprecations);
+ if (deprecationId === -1) {
+ throw new Error('Unexpected deprecation thrown name=' +
+ name + ' msg=' + msg);
+ }
+ test._observedDeprecations[deprecationId] = 1;
+ };
+ }
+
+ function teardownDeprecationHandler(test, moment, scope) {
+ moment.suppressDeprecationWarnings = test._oldSupress;
+
+ if (test._expectedDeprecations != null) {
+ var missedDeprecations = [];
+ each(test._expectedDeprecations, function (deprecationPattern, id) {
+ if (test._observedDeprecations[id] !== 1) {
+ missedDeprecations.push(deprecationPattern);
+ }
+ });
+ if (missedDeprecations.length !== 0) {
+ throw new Error('Expected deprecation warnings did not happen: ' +
+ missedDeprecations.join(' '));
+ }
+ }
+ }
+
+ function matchedDeprecation(name, msg, deprecations) {
+ if (deprecations == null) {
+ return -1;
+ }
+ for (var i = 0; i < deprecations.length; ++i) {
+ if (name != null && name === deprecations[i]) {
+ return i;
+ }
+ if (msg != null && msg.substring(0, deprecations[i].length) === deprecations[i]) {
+ return i;
+ }
+ }
+ return -1;
+ }
+
/*global QUnit:false*/
var test = QUnit.test;
@@ -43413,11 +67533,13 @@
moment.createFromInputFallback = function (config) {
throw new Error('input not handled by moment: ' + config._i);
};
+ setupDeprecationHandler(test, moment, 'core');
if (lifecycle && lifecycle.setup) {
lifecycle.setup();
}
},
teardown : function () {
+ teardownDeprecationHandler(test, moment, 'core');
if (lifecycle && lifecycle.teardown) {
lifecycle.teardown();
}
@@ -43432,17 +67554,20 @@
moment.createFromInputFallback = function (config) {
throw new Error('input not handled by moment: ' + config._i);
};
+ setupDeprecationHandler(test, moment, 'locale');
if (lifecycle && lifecycle.setup) {
lifecycle.setup();
}
},
teardown : function () {
moment.locale('en');
+ teardownDeprecationHandler(test, moment, 'locale');
if (lifecycle && lifecycle.teardown) {
lifecycle.teardown();
}
}
});
+ defineCommonLocaleTests(name, -1, -1);
}
module('start and end of units');
@@ -43633,6 +67758,35 @@
assert.equal(m.milliseconds(), 999, 'set the seconds');
});
+ test('start of date', function (assert) {
+ var m = moment(new Date(2011, 1, 2, 3, 4, 5, 6)).startOf('date'),
+ ms = moment(new Date(2011, 1, 2, 3, 4, 5, 6)).startOf('dates');
+
+ assert.equal(+m, +ms, 'Plural or singular should work');
+ assert.equal(m.year(), 2011, 'keep the year');
+ assert.equal(m.month(), 1, 'keep the month');
+ assert.equal(m.date(), 2, 'keep the day');
+ assert.equal(m.hours(), 0, 'strip out the hours');
+ assert.equal(m.minutes(), 0, 'strip out the minutes');
+ assert.equal(m.seconds(), 0, 'strip out the seconds');
+ assert.equal(m.milliseconds(), 0, 'strip out the milliseconds');
+ });
+
+ test('end of date', function (assert) {
+ var m = moment(new Date(2011, 1, 2, 3, 4, 5, 6)).endOf('date'),
+ ms = moment(new Date(2011, 1, 2, 3, 4, 5, 6)).endOf('dates');
+
+ assert.equal(+m, +ms, 'Plural or singular should work');
+ assert.equal(m.year(), 2011, 'keep the year');
+ assert.equal(m.month(), 1, 'keep the month');
+ assert.equal(m.date(), 2, 'keep the day');
+ assert.equal(m.hours(), 23, 'set the hours');
+ assert.equal(m.minutes(), 59, 'set the minutes');
+ assert.equal(m.seconds(), 59, 'set the seconds');
+ assert.equal(m.milliseconds(), 999, 'set the seconds');
+ });
+
+
test('start of hour', function (assert) {
var m = moment(new Date(2011, 1, 2, 3, 4, 5, 6)).startOf('hour'),
ms = moment(new Date(2011, 1, 2, 3, 4, 5, 6)).startOf('hours'),
@@ -43738,6 +67892,10 @@
};
m = moment('2014-03-15T00:00:00-07:00').parseZone();
+ m.startOf('y');
+ assert.equal(m.format(), '2014-01-01T00:00:00-08:00', 'startOf(\'year\') across +1');
+
+ m = moment('2014-03-15T00:00:00-07:00').parseZone();
m.startOf('M');
assert.equal(m.format(), '2014-03-01T00:00:00-08:00', 'startOf(\'month\') across +1');
@@ -43771,6 +67929,10 @@
mom.utcOffset(-8, keepTime);
}
};
+
+ m = moment('2014-11-15T00:00:00-08:00').parseZone();
+ m.startOf('y');
+ assert.equal(m.format(), '2014-01-01T00:00:00-07:00', 'startOf(\'year\') across -1');
m = moment('2014-11-15T00:00:00-08:00').parseZone();
m.startOf('M');
@@ -43809,6 +67971,224 @@
typeof define === 'function' && define.amd ? define(['../../moment'], factory) :
factory(global.moment)
}(this, function (moment) { 'use strict';
+
+ function each(array, callback) {
+ var i;
+ for (i = 0; i < array.length; i++) {
+ callback(array[i], i, array);
+ }
+ }
+
+ function objectKeys(obj) {
+ if (Object.keys) {
+ return Object.keys(obj);
+ } else {
+ // IE8
+ var res = [], i;
+ for (i in obj) {
+ if (obj.hasOwnProperty(i)) {
+ res.push(i);
+ }
+ }
+ return res;
+ }
+ }
+
+ // Pick the first defined of two or three arguments.
+ function defaults(a, b, c) {
+ if (a != null) {
+ return a;
+ }
+ if (b != null) {
+ return b;
+ }
+ return c;
+ }
+
+ function defineCommonLocaleTests(locale, options) {
+ test('lenient ordinal parsing', function (assert) {
+ var i, ordinalStr, testMoment;
+ for (i = 1; i <= 31; ++i) {
+ ordinalStr = moment([2014, 0, i]).format('YYYY MM Do');
+ testMoment = moment(ordinalStr, 'YYYY MM Do');
+ assert.equal(testMoment.year(), 2014,
+ 'lenient ordinal parsing ' + i + ' year check');
+ assert.equal(testMoment.month(), 0,
+ 'lenient ordinal parsing ' + i + ' month check');
+ assert.equal(testMoment.date(), i,
+ 'lenient ordinal parsing ' + i + ' date check');
+ }
+ });
+
+ test('lenient ordinal parsing of number', function (assert) {
+ var i, testMoment;
+ for (i = 1; i <= 31; ++i) {
+ testMoment = moment('2014 01 ' + i, 'YYYY MM Do');
+ assert.equal(testMoment.year(), 2014,
+ 'lenient ordinal parsing of number ' + i + ' year check');
+ assert.equal(testMoment.month(), 0,
+ 'lenient ordinal parsing of number ' + i + ' month check');
+ assert.equal(testMoment.date(), i,
+ 'lenient ordinal parsing of number ' + i + ' date check');
+ }
+ });
+
+ test('strict ordinal parsing', function (assert) {
+ var i, ordinalStr, testMoment;
+ for (i = 1; i <= 31; ++i) {
+ ordinalStr = moment([2014, 0, i]).format('YYYY MM Do');
+ testMoment = moment(ordinalStr, 'YYYY MM Do', true);
+ assert.ok(testMoment.isValid(), 'strict ordinal parsing ' + i);
+ }
+ });
+
+ test('meridiem invariant', function (assert) {
+ var h, m, t1, t2;
+ for (h = 0; h < 24; ++h) {
+ for (m = 0; m < 60; m += 15) {
+ t1 = moment.utc([2000, 0, 1, h, m]);
+ t2 = moment.utc(t1.format('A h:mm'), 'A h:mm');
+ assert.equal(t2.format('HH:mm'), t1.format('HH:mm'),
+ 'meridiem at ' + t1.format('HH:mm'));
+ }
+ }
+ });
+
+ test('date format correctness', function (assert) {
+ var data, tokens;
+ data = moment.localeData()._longDateFormat;
+ tokens = objectKeys(data);
+ each(tokens, function (srchToken) {
+ // Check each format string to make sure it does not contain any
+ // tokens that need to be expanded.
+ each(tokens, function (baseToken) {
+ // strip escaped sequences
+ var format = data[baseToken].replace(/(\[[^\]]*\])/g, '');
+ assert.equal(false, !!~format.indexOf(srchToken),
+ 'contains ' + srchToken + ' in ' + baseToken);
+ });
+ });
+ });
+
+ test('month parsing correctness', function (assert) {
+ var i, m;
+
+ if (locale === 'tr') {
+ // I can't fix it :(
+ expect(0);
+ return;
+ }
+ function tester(format) {
+ var r;
+ r = moment(m.format(format), format);
+ assert.equal(r.month(), m.month(), 'month ' + i + ' fmt ' + format);
+ r = moment(m.format(format).toLocaleUpperCase(), format);
+ assert.equal(r.month(), m.month(), 'month ' + i + ' fmt ' + format + ' upper');
+ r = moment(m.format(format).toLocaleLowerCase(), format);
+ assert.equal(r.month(), m.month(), 'month ' + i + ' fmt ' + format + ' lower');
+
+ r = moment(m.format(format), format, true);
+ assert.equal(r.month(), m.month(), 'month ' + i + ' fmt ' + format + ' strict');
+ r = moment(m.format(format).toLocaleUpperCase(), format, true);
+ assert.equal(r.month(), m.month(), 'month ' + i + ' fmt ' + format + ' upper strict');
+ r = moment(m.format(format).toLocaleLowerCase(), format, true);
+ assert.equal(r.month(), m.month(), 'month ' + i + ' fmt ' + format + ' lower strict');
+ }
+
+ for (i = 0; i < 12; ++i) {
+ m = moment([2015, i, 15, 18]);
+ tester('MMM');
+ tester('MMM.');
+ tester('MMMM');
+ tester('MMMM.');
+ }
+ });
+
+ test('weekday parsing correctness', function (assert) {
+ var i, m;
+
+ if (locale === 'tr' || locale === 'az') {
+ // There is a lower-case letter (ı), that converted to upper then
+ // lower changes to i
+ expect(0);
+ return;
+ }
+ function tester(format) {
+ var r, baseMsg = 'weekday ' + m.weekday() + ' fmt ' + format;
+ r = moment(m.format(format), format);
+ assert.equal(r.weekday(), m.weekday(), baseMsg);
+ r = moment(m.format(format).toLocaleUpperCase(), format);
+ assert.equal(r.weekday(), m.weekday(), baseMsg + ' upper');
+ r = moment(m.format(format).toLocaleLowerCase(), format);
+ assert.equal(r.weekday(), m.weekday(), baseMsg + ' lower');
+
+ r = moment(m.format(format), format, true);
+ assert.equal(r.weekday(), m.weekday(), baseMsg + ' strict');
+ r = moment(m.format(format).toLocaleUpperCase(), format, true);
+ assert.equal(r.weekday(), m.weekday(), baseMsg + ' upper strict');
+ r = moment(m.format(format).toLocaleLowerCase(), format, true);
+ assert.equal(r.weekday(), m.weekday(), baseMsg + ' lower strict');
+ }
+
+ for (i = 0; i < 7; ++i) {
+ m = moment.utc([2015, i, 15, 18]);
+ tester('dd');
+ tester('ddd');
+ tester('dddd');
+ }
+ });
+ }
+
+ function setupDeprecationHandler(test, moment, scope) {
+ test._expectedDeprecations = null;
+ test._observedDeprecations = null;
+ test._oldSupress = moment.suppressDeprecationWarnings;
+ moment.suppressDeprecationWarnings = true;
+ test.expectedDeprecations = function () {
+ test._expectedDeprecations = arguments;
+ test._observedDeprecations = [];
+ };
+ moment.deprecationHandler = function (name, msg) {
+ var deprecationId = matchedDeprecation(name, msg, test._expectedDeprecations);
+ if (deprecationId === -1) {
+ throw new Error('Unexpected deprecation thrown name=' +
+ name + ' msg=' + msg);
+ }
+ test._observedDeprecations[deprecationId] = 1;
+ };
+ }
+
+ function teardownDeprecationHandler(test, moment, scope) {
+ moment.suppressDeprecationWarnings = test._oldSupress;
+
+ if (test._expectedDeprecations != null) {
+ var missedDeprecations = [];
+ each(test._expectedDeprecations, function (deprecationPattern, id) {
+ if (test._observedDeprecations[id] !== 1) {
+ missedDeprecations.push(deprecationPattern);
+ }
+ });
+ if (missedDeprecations.length !== 0) {
+ throw new Error('Expected deprecation warnings did not happen: ' +
+ missedDeprecations.join(' '));
+ }
+ }
+ }
+
+ function matchedDeprecation(name, msg, deprecations) {
+ if (deprecations == null) {
+ return -1;
+ }
+ for (var i = 0; i < deprecations.length; ++i) {
+ if (name != null && name === deprecations[i]) {
+ return i;
+ }
+ if (msg != null && msg.substring(0, deprecations[i].length) === deprecations[i]) {
+ return i;
+ }
+ }
+ return -1;
+ }
/*global QUnit:false*/
@@ -43823,11 +68203,13 @@
moment.createFromInputFallback = function (config) {
throw new Error('input not handled by moment: ' + config._i);
};
+ setupDeprecationHandler(test, moment, 'core');
if (lifecycle && lifecycle.setup) {
lifecycle.setup();
}
},
teardown : function () {
+ teardownDeprecationHandler(test, moment, 'core');
if (lifecycle && lifecycle.teardown) {
lifecycle.teardown();
}
@@ -43842,17 +68224,20 @@
moment.createFromInputFallback = function (config) {
throw new Error('input not handled by moment: ' + config._i);
};
+ setupDeprecationHandler(test, moment, 'locale');
if (lifecycle && lifecycle.setup) {
lifecycle.setup();
}
},
teardown : function () {
moment.locale('en');
+ teardownDeprecationHandler(test, moment, 'locale');
if (lifecycle && lifecycle.teardown) {
lifecycle.teardown();
}
}
});
+ defineCommonLocaleTests(name, -1, -1);
}
module('string prototype');
@@ -43877,6 +68262,224 @@
typeof define === 'function' && define.amd ? define(['../../moment'], factory) :
factory(global.moment)
}(this, function (moment) { 'use strict';
+
+ function each(array, callback) {
+ var i;
+ for (i = 0; i < array.length; i++) {
+ callback(array[i], i, array);
+ }
+ }
+
+ function objectKeys(obj) {
+ if (Object.keys) {
+ return Object.keys(obj);
+ } else {
+ // IE8
+ var res = [], i;
+ for (i in obj) {
+ if (obj.hasOwnProperty(i)) {
+ res.push(i);
+ }
+ }
+ return res;
+ }
+ }
+
+ // Pick the first defined of two or three arguments.
+ function defaults(a, b, c) {
+ if (a != null) {
+ return a;
+ }
+ if (b != null) {
+ return b;
+ }
+ return c;
+ }
+
+ function defineCommonLocaleTests(locale, options) {
+ test('lenient ordinal parsing', function (assert) {
+ var i, ordinalStr, testMoment;
+ for (i = 1; i <= 31; ++i) {
+ ordinalStr = moment([2014, 0, i]).format('YYYY MM Do');
+ testMoment = moment(ordinalStr, 'YYYY MM Do');
+ assert.equal(testMoment.year(), 2014,
+ 'lenient ordinal parsing ' + i + ' year check');
+ assert.equal(testMoment.month(), 0,
+ 'lenient ordinal parsing ' + i + ' month check');
+ assert.equal(testMoment.date(), i,
+ 'lenient ordinal parsing ' + i + ' date check');
+ }
+ });
+
+ test('lenient ordinal parsing of number', function (assert) {
+ var i, testMoment;
+ for (i = 1; i <= 31; ++i) {
+ testMoment = moment('2014 01 ' + i, 'YYYY MM Do');
+ assert.equal(testMoment.year(), 2014,
+ 'lenient ordinal parsing of number ' + i + ' year check');
+ assert.equal(testMoment.month(), 0,
+ 'lenient ordinal parsing of number ' + i + ' month check');
+ assert.equal(testMoment.date(), i,
+ 'lenient ordinal parsing of number ' + i + ' date check');
+ }
+ });
+
+ test('strict ordinal parsing', function (assert) {
+ var i, ordinalStr, testMoment;
+ for (i = 1; i <= 31; ++i) {
+ ordinalStr = moment([2014, 0, i]).format('YYYY MM Do');
+ testMoment = moment(ordinalStr, 'YYYY MM Do', true);
+ assert.ok(testMoment.isValid(), 'strict ordinal parsing ' + i);
+ }
+ });
+
+ test('meridiem invariant', function (assert) {
+ var h, m, t1, t2;
+ for (h = 0; h < 24; ++h) {
+ for (m = 0; m < 60; m += 15) {
+ t1 = moment.utc([2000, 0, 1, h, m]);
+ t2 = moment.utc(t1.format('A h:mm'), 'A h:mm');
+ assert.equal(t2.format('HH:mm'), t1.format('HH:mm'),
+ 'meridiem at ' + t1.format('HH:mm'));
+ }
+ }
+ });
+
+ test('date format correctness', function (assert) {
+ var data, tokens;
+ data = moment.localeData()._longDateFormat;
+ tokens = objectKeys(data);
+ each(tokens, function (srchToken) {
+ // Check each format string to make sure it does not contain any
+ // tokens that need to be expanded.
+ each(tokens, function (baseToken) {
+ // strip escaped sequences
+ var format = data[baseToken].replace(/(\[[^\]]*\])/g, '');
+ assert.equal(false, !!~format.indexOf(srchToken),
+ 'contains ' + srchToken + ' in ' + baseToken);
+ });
+ });
+ });
+
+ test('month parsing correctness', function (assert) {
+ var i, m;
+
+ if (locale === 'tr') {
+ // I can't fix it :(
+ expect(0);
+ return;
+ }
+ function tester(format) {
+ var r;
+ r = moment(m.format(format), format);
+ assert.equal(r.month(), m.month(), 'month ' + i + ' fmt ' + format);
+ r = moment(m.format(format).toLocaleUpperCase(), format);
+ assert.equal(r.month(), m.month(), 'month ' + i + ' fmt ' + format + ' upper');
+ r = moment(m.format(format).toLocaleLowerCase(), format);
+ assert.equal(r.month(), m.month(), 'month ' + i + ' fmt ' + format + ' lower');
+
+ r = moment(m.format(format), format, true);
+ assert.equal(r.month(), m.month(), 'month ' + i + ' fmt ' + format + ' strict');
+ r = moment(m.format(format).toLocaleUpperCase(), format, true);
+ assert.equal(r.month(), m.month(), 'month ' + i + ' fmt ' + format + ' upper strict');
+ r = moment(m.format(format).toLocaleLowerCase(), format, true);
+ assert.equal(r.month(), m.month(), 'month ' + i + ' fmt ' + format + ' lower strict');
+ }
+
+ for (i = 0; i < 12; ++i) {
+ m = moment([2015, i, 15, 18]);
+ tester('MMM');
+ tester('MMM.');
+ tester('MMMM');
+ tester('MMMM.');
+ }
+ });
+
+ test('weekday parsing correctness', function (assert) {
+ var i, m;
+
+ if (locale === 'tr' || locale === 'az') {
+ // There is a lower-case letter (ı), that converted to upper then
+ // lower changes to i
+ expect(0);
+ return;
+ }
+ function tester(format) {
+ var r, baseMsg = 'weekday ' + m.weekday() + ' fmt ' + format;
+ r = moment(m.format(format), format);
+ assert.equal(r.weekday(), m.weekday(), baseMsg);
+ r = moment(m.format(format).toLocaleUpperCase(), format);
+ assert.equal(r.weekday(), m.weekday(), baseMsg + ' upper');
+ r = moment(m.format(format).toLocaleLowerCase(), format);
+ assert.equal(r.weekday(), m.weekday(), baseMsg + ' lower');
+
+ r = moment(m.format(format), format, true);
+ assert.equal(r.weekday(), m.weekday(), baseMsg + ' strict');
+ r = moment(m.format(format).toLocaleUpperCase(), format, true);
+ assert.equal(r.weekday(), m.weekday(), baseMsg + ' upper strict');
+ r = moment(m.format(format).toLocaleLowerCase(), format, true);
+ assert.equal(r.weekday(), m.weekday(), baseMsg + ' lower strict');
+ }
+
+ for (i = 0; i < 7; ++i) {
+ m = moment.utc([2015, i, 15, 18]);
+ tester('dd');
+ tester('ddd');
+ tester('dddd');
+ }
+ });
+ }
+
+ function setupDeprecationHandler(test, moment, scope) {
+ test._expectedDeprecations = null;
+ test._observedDeprecations = null;
+ test._oldSupress = moment.suppressDeprecationWarnings;
+ moment.suppressDeprecationWarnings = true;
+ test.expectedDeprecations = function () {
+ test._expectedDeprecations = arguments;
+ test._observedDeprecations = [];
+ };
+ moment.deprecationHandler = function (name, msg) {
+ var deprecationId = matchedDeprecation(name, msg, test._expectedDeprecations);
+ if (deprecationId === -1) {
+ throw new Error('Unexpected deprecation thrown name=' +
+ name + ' msg=' + msg);
+ }
+ test._observedDeprecations[deprecationId] = 1;
+ };
+ }
+
+ function teardownDeprecationHandler(test, moment, scope) {
+ moment.suppressDeprecationWarnings = test._oldSupress;
+
+ if (test._expectedDeprecations != null) {
+ var missedDeprecations = [];
+ each(test._expectedDeprecations, function (deprecationPattern, id) {
+ if (test._observedDeprecations[id] !== 1) {
+ missedDeprecations.push(deprecationPattern);
+ }
+ });
+ if (missedDeprecations.length !== 0) {
+ throw new Error('Expected deprecation warnings did not happen: ' +
+ missedDeprecations.join(' '));
+ }
+ }
+ }
+
+ function matchedDeprecation(name, msg, deprecations) {
+ if (deprecations == null) {
+ return -1;
+ }
+ for (var i = 0; i < deprecations.length; ++i) {
+ if (name != null && name === deprecations[i]) {
+ return i;
+ }
+ if (msg != null && msg.substring(0, deprecations[i].length) === deprecations[i]) {
+ return i;
+ }
+ }
+ return -1;
+ }
/*global QUnit:false*/
@@ -43891,11 +68494,13 @@
moment.createFromInputFallback = function (config) {
throw new Error('input not handled by moment: ' + config._i);
};
+ setupDeprecationHandler(test, moment, 'core');
if (lifecycle && lifecycle.setup) {
lifecycle.setup();
}
},
teardown : function () {
+ teardownDeprecationHandler(test, moment, 'core');
if (lifecycle && lifecycle.teardown) {
lifecycle.teardown();
}
@@ -43910,17 +68515,20 @@
moment.createFromInputFallback = function (config) {
throw new Error('input not handled by moment: ' + config._i);
};
+ setupDeprecationHandler(test, moment, 'locale');
if (lifecycle && lifecycle.setup) {
lifecycle.setup();
}
},
teardown : function () {
moment.locale('en');
+ teardownDeprecationHandler(test, moment, 'locale');
if (lifecycle && lifecycle.teardown) {
lifecycle.teardown();
}
}
});
+ defineCommonLocaleTests(name, -1, -1);
}
module('to type');
@@ -43952,6 +68560,224 @@
factory(global.moment)
}(this, function (moment) { 'use strict';
+ function each(array, callback) {
+ var i;
+ for (i = 0; i < array.length; i++) {
+ callback(array[i], i, array);
+ }
+ }
+
+ function objectKeys(obj) {
+ if (Object.keys) {
+ return Object.keys(obj);
+ } else {
+ // IE8
+ var res = [], i;
+ for (i in obj) {
+ if (obj.hasOwnProperty(i)) {
+ res.push(i);
+ }
+ }
+ return res;
+ }
+ }
+
+ // Pick the first defined of two or three arguments.
+ function defaults(a, b, c) {
+ if (a != null) {
+ return a;
+ }
+ if (b != null) {
+ return b;
+ }
+ return c;
+ }
+
+ function defineCommonLocaleTests(locale, options) {
+ test('lenient ordinal parsing', function (assert) {
+ var i, ordinalStr, testMoment;
+ for (i = 1; i <= 31; ++i) {
+ ordinalStr = moment([2014, 0, i]).format('YYYY MM Do');
+ testMoment = moment(ordinalStr, 'YYYY MM Do');
+ assert.equal(testMoment.year(), 2014,
+ 'lenient ordinal parsing ' + i + ' year check');
+ assert.equal(testMoment.month(), 0,
+ 'lenient ordinal parsing ' + i + ' month check');
+ assert.equal(testMoment.date(), i,
+ 'lenient ordinal parsing ' + i + ' date check');
+ }
+ });
+
+ test('lenient ordinal parsing of number', function (assert) {
+ var i, testMoment;
+ for (i = 1; i <= 31; ++i) {
+ testMoment = moment('2014 01 ' + i, 'YYYY MM Do');
+ assert.equal(testMoment.year(), 2014,
+ 'lenient ordinal parsing of number ' + i + ' year check');
+ assert.equal(testMoment.month(), 0,
+ 'lenient ordinal parsing of number ' + i + ' month check');
+ assert.equal(testMoment.date(), i,
+ 'lenient ordinal parsing of number ' + i + ' date check');
+ }
+ });
+
+ test('strict ordinal parsing', function (assert) {
+ var i, ordinalStr, testMoment;
+ for (i = 1; i <= 31; ++i) {
+ ordinalStr = moment([2014, 0, i]).format('YYYY MM Do');
+ testMoment = moment(ordinalStr, 'YYYY MM Do', true);
+ assert.ok(testMoment.isValid(), 'strict ordinal parsing ' + i);
+ }
+ });
+
+ test('meridiem invariant', function (assert) {
+ var h, m, t1, t2;
+ for (h = 0; h < 24; ++h) {
+ for (m = 0; m < 60; m += 15) {
+ t1 = moment.utc([2000, 0, 1, h, m]);
+ t2 = moment.utc(t1.format('A h:mm'), 'A h:mm');
+ assert.equal(t2.format('HH:mm'), t1.format('HH:mm'),
+ 'meridiem at ' + t1.format('HH:mm'));
+ }
+ }
+ });
+
+ test('date format correctness', function (assert) {
+ var data, tokens;
+ data = moment.localeData()._longDateFormat;
+ tokens = objectKeys(data);
+ each(tokens, function (srchToken) {
+ // Check each format string to make sure it does not contain any
+ // tokens that need to be expanded.
+ each(tokens, function (baseToken) {
+ // strip escaped sequences
+ var format = data[baseToken].replace(/(\[[^\]]*\])/g, '');
+ assert.equal(false, !!~format.indexOf(srchToken),
+ 'contains ' + srchToken + ' in ' + baseToken);
+ });
+ });
+ });
+
+ test('month parsing correctness', function (assert) {
+ var i, m;
+
+ if (locale === 'tr') {
+ // I can't fix it :(
+ expect(0);
+ return;
+ }
+ function tester(format) {
+ var r;
+ r = moment(m.format(format), format);
+ assert.equal(r.month(), m.month(), 'month ' + i + ' fmt ' + format);
+ r = moment(m.format(format).toLocaleUpperCase(), format);
+ assert.equal(r.month(), m.month(), 'month ' + i + ' fmt ' + format + ' upper');
+ r = moment(m.format(format).toLocaleLowerCase(), format);
+ assert.equal(r.month(), m.month(), 'month ' + i + ' fmt ' + format + ' lower');
+
+ r = moment(m.format(format), format, true);
+ assert.equal(r.month(), m.month(), 'month ' + i + ' fmt ' + format + ' strict');
+ r = moment(m.format(format).toLocaleUpperCase(), format, true);
+ assert.equal(r.month(), m.month(), 'month ' + i + ' fmt ' + format + ' upper strict');
+ r = moment(m.format(format).toLocaleLowerCase(), format, true);
+ assert.equal(r.month(), m.month(), 'month ' + i + ' fmt ' + format + ' lower strict');
+ }
+
+ for (i = 0; i < 12; ++i) {
+ m = moment([2015, i, 15, 18]);
+ tester('MMM');
+ tester('MMM.');
+ tester('MMMM');
+ tester('MMMM.');
+ }
+ });
+
+ test('weekday parsing correctness', function (assert) {
+ var i, m;
+
+ if (locale === 'tr' || locale === 'az') {
+ // There is a lower-case letter (ı), that converted to upper then
+ // lower changes to i
+ expect(0);
+ return;
+ }
+ function tester(format) {
+ var r, baseMsg = 'weekday ' + m.weekday() + ' fmt ' + format;
+ r = moment(m.format(format), format);
+ assert.equal(r.weekday(), m.weekday(), baseMsg);
+ r = moment(m.format(format).toLocaleUpperCase(), format);
+ assert.equal(r.weekday(), m.weekday(), baseMsg + ' upper');
+ r = moment(m.format(format).toLocaleLowerCase(), format);
+ assert.equal(r.weekday(), m.weekday(), baseMsg + ' lower');
+
+ r = moment(m.format(format), format, true);
+ assert.equal(r.weekday(), m.weekday(), baseMsg + ' strict');
+ r = moment(m.format(format).toLocaleUpperCase(), format, true);
+ assert.equal(r.weekday(), m.weekday(), baseMsg + ' upper strict');
+ r = moment(m.format(format).toLocaleLowerCase(), format, true);
+ assert.equal(r.weekday(), m.weekday(), baseMsg + ' lower strict');
+ }
+
+ for (i = 0; i < 7; ++i) {
+ m = moment.utc([2015, i, 15, 18]);
+ tester('dd');
+ tester('ddd');
+ tester('dddd');
+ }
+ });
+ }
+
+ function setupDeprecationHandler(test, moment, scope) {
+ test._expectedDeprecations = null;
+ test._observedDeprecations = null;
+ test._oldSupress = moment.suppressDeprecationWarnings;
+ moment.suppressDeprecationWarnings = true;
+ test.expectedDeprecations = function () {
+ test._expectedDeprecations = arguments;
+ test._observedDeprecations = [];
+ };
+ moment.deprecationHandler = function (name, msg) {
+ var deprecationId = matchedDeprecation(name, msg, test._expectedDeprecations);
+ if (deprecationId === -1) {
+ throw new Error('Unexpected deprecation thrown name=' +
+ name + ' msg=' + msg);
+ }
+ test._observedDeprecations[deprecationId] = 1;
+ };
+ }
+
+ function teardownDeprecationHandler(test, moment, scope) {
+ moment.suppressDeprecationWarnings = test._oldSupress;
+
+ if (test._expectedDeprecations != null) {
+ var missedDeprecations = [];
+ each(test._expectedDeprecations, function (deprecationPattern, id) {
+ if (test._observedDeprecations[id] !== 1) {
+ missedDeprecations.push(deprecationPattern);
+ }
+ });
+ if (missedDeprecations.length !== 0) {
+ throw new Error('Expected deprecation warnings did not happen: ' +
+ missedDeprecations.join(' '));
+ }
+ }
+ }
+
+ function matchedDeprecation(name, msg, deprecations) {
+ if (deprecations == null) {
+ return -1;
+ }
+ for (var i = 0; i < deprecations.length; ++i) {
+ if (name != null && name === deprecations[i]) {
+ return i;
+ }
+ if (msg != null && msg.substring(0, deprecations[i].length) === deprecations[i]) {
+ return i;
+ }
+ }
+ return -1;
+ }
+
/*global QUnit:false*/
var test = QUnit.test;
@@ -43965,11 +68791,13 @@
moment.createFromInputFallback = function (config) {
throw new Error('input not handled by moment: ' + config._i);
};
+ setupDeprecationHandler(test, moment, 'core');
if (lifecycle && lifecycle.setup) {
lifecycle.setup();
}
},
teardown : function () {
+ teardownDeprecationHandler(test, moment, 'core');
if (lifecycle && lifecycle.teardown) {
lifecycle.teardown();
}
@@ -43984,17 +68812,20 @@
moment.createFromInputFallback = function (config) {
throw new Error('input not handled by moment: ' + config._i);
};
+ setupDeprecationHandler(test, moment, 'locale');
if (lifecycle && lifecycle.setup) {
lifecycle.setup();
}
},
teardown : function () {
moment.locale('en');
+ teardownDeprecationHandler(test, moment, 'locale');
if (lifecycle && lifecycle.teardown) {
lifecycle.teardown();
}
}
});
+ defineCommonLocaleTests(name, -1, -1);
}
module('utc');
@@ -44009,7 +68840,7 @@
// local
m.local();
- if (m.zone() > 180) {
+ if (m.utcOffset() < -180) {
assert.equal(m.date(), 1, 'the date should be correct for local');
assert.equal(m.day(), 2, 'the day should be correct for local');
} else {
@@ -44081,6 +68912,224 @@
typeof define === 'function' && define.amd ? define(['../../moment'], factory) :
factory(global.moment)
}(this, function (moment) { 'use strict';
+
+ function each(array, callback) {
+ var i;
+ for (i = 0; i < array.length; i++) {
+ callback(array[i], i, array);
+ }
+ }
+
+ function objectKeys(obj) {
+ if (Object.keys) {
+ return Object.keys(obj);
+ } else {
+ // IE8
+ var res = [], i;
+ for (i in obj) {
+ if (obj.hasOwnProperty(i)) {
+ res.push(i);
+ }
+ }
+ return res;
+ }
+ }
+
+ // Pick the first defined of two or three arguments.
+ function defaults(a, b, c) {
+ if (a != null) {
+ return a;
+ }
+ if (b != null) {
+ return b;
+ }
+ return c;
+ }
+
+ function defineCommonLocaleTests(locale, options) {
+ test('lenient ordinal parsing', function (assert) {
+ var i, ordinalStr, testMoment;
+ for (i = 1; i <= 31; ++i) {
+ ordinalStr = moment([2014, 0, i]).format('YYYY MM Do');
+ testMoment = moment(ordinalStr, 'YYYY MM Do');
+ assert.equal(testMoment.year(), 2014,
+ 'lenient ordinal parsing ' + i + ' year check');
+ assert.equal(testMoment.month(), 0,
+ 'lenient ordinal parsing ' + i + ' month check');
+ assert.equal(testMoment.date(), i,
+ 'lenient ordinal parsing ' + i + ' date check');
+ }
+ });
+
+ test('lenient ordinal parsing of number', function (assert) {
+ var i, testMoment;
+ for (i = 1; i <= 31; ++i) {
+ testMoment = moment('2014 01 ' + i, 'YYYY MM Do');
+ assert.equal(testMoment.year(), 2014,
+ 'lenient ordinal parsing of number ' + i + ' year check');
+ assert.equal(testMoment.month(), 0,
+ 'lenient ordinal parsing of number ' + i + ' month check');
+ assert.equal(testMoment.date(), i,
+ 'lenient ordinal parsing of number ' + i + ' date check');
+ }
+ });
+
+ test('strict ordinal parsing', function (assert) {
+ var i, ordinalStr, testMoment;
+ for (i = 1; i <= 31; ++i) {
+ ordinalStr = moment([2014, 0, i]).format('YYYY MM Do');
+ testMoment = moment(ordinalStr, 'YYYY MM Do', true);
+ assert.ok(testMoment.isValid(), 'strict ordinal parsing ' + i);
+ }
+ });
+
+ test('meridiem invariant', function (assert) {
+ var h, m, t1, t2;
+ for (h = 0; h < 24; ++h) {
+ for (m = 0; m < 60; m += 15) {
+ t1 = moment.utc([2000, 0, 1, h, m]);
+ t2 = moment.utc(t1.format('A h:mm'), 'A h:mm');
+ assert.equal(t2.format('HH:mm'), t1.format('HH:mm'),
+ 'meridiem at ' + t1.format('HH:mm'));
+ }
+ }
+ });
+
+ test('date format correctness', function (assert) {
+ var data, tokens;
+ data = moment.localeData()._longDateFormat;
+ tokens = objectKeys(data);
+ each(tokens, function (srchToken) {
+ // Check each format string to make sure it does not contain any
+ // tokens that need to be expanded.
+ each(tokens, function (baseToken) {
+ // strip escaped sequences
+ var format = data[baseToken].replace(/(\[[^\]]*\])/g, '');
+ assert.equal(false, !!~format.indexOf(srchToken),
+ 'contains ' + srchToken + ' in ' + baseToken);
+ });
+ });
+ });
+
+ test('month parsing correctness', function (assert) {
+ var i, m;
+
+ if (locale === 'tr') {
+ // I can't fix it :(
+ expect(0);
+ return;
+ }
+ function tester(format) {
+ var r;
+ r = moment(m.format(format), format);
+ assert.equal(r.month(), m.month(), 'month ' + i + ' fmt ' + format);
+ r = moment(m.format(format).toLocaleUpperCase(), format);
+ assert.equal(r.month(), m.month(), 'month ' + i + ' fmt ' + format + ' upper');
+ r = moment(m.format(format).toLocaleLowerCase(), format);
+ assert.equal(r.month(), m.month(), 'month ' + i + ' fmt ' + format + ' lower');
+
+ r = moment(m.format(format), format, true);
+ assert.equal(r.month(), m.month(), 'month ' + i + ' fmt ' + format + ' strict');
+ r = moment(m.format(format).toLocaleUpperCase(), format, true);
+ assert.equal(r.month(), m.month(), 'month ' + i + ' fmt ' + format + ' upper strict');
+ r = moment(m.format(format).toLocaleLowerCase(), format, true);
+ assert.equal(r.month(), m.month(), 'month ' + i + ' fmt ' + format + ' lower strict');
+ }
+
+ for (i = 0; i < 12; ++i) {
+ m = moment([2015, i, 15, 18]);
+ tester('MMM');
+ tester('MMM.');
+ tester('MMMM');
+ tester('MMMM.');
+ }
+ });
+
+ test('weekday parsing correctness', function (assert) {
+ var i, m;
+
+ if (locale === 'tr' || locale === 'az') {
+ // There is a lower-case letter (ı), that converted to upper then
+ // lower changes to i
+ expect(0);
+ return;
+ }
+ function tester(format) {
+ var r, baseMsg = 'weekday ' + m.weekday() + ' fmt ' + format;
+ r = moment(m.format(format), format);
+ assert.equal(r.weekday(), m.weekday(), baseMsg);
+ r = moment(m.format(format).toLocaleUpperCase(), format);
+ assert.equal(r.weekday(), m.weekday(), baseMsg + ' upper');
+ r = moment(m.format(format).toLocaleLowerCase(), format);
+ assert.equal(r.weekday(), m.weekday(), baseMsg + ' lower');
+
+ r = moment(m.format(format), format, true);
+ assert.equal(r.weekday(), m.weekday(), baseMsg + ' strict');
+ r = moment(m.format(format).toLocaleUpperCase(), format, true);
+ assert.equal(r.weekday(), m.weekday(), baseMsg + ' upper strict');
+ r = moment(m.format(format).toLocaleLowerCase(), format, true);
+ assert.equal(r.weekday(), m.weekday(), baseMsg + ' lower strict');
+ }
+
+ for (i = 0; i < 7; ++i) {
+ m = moment.utc([2015, i, 15, 18]);
+ tester('dd');
+ tester('ddd');
+ tester('dddd');
+ }
+ });
+ }
+
+ function setupDeprecationHandler(test, moment, scope) {
+ test._expectedDeprecations = null;
+ test._observedDeprecations = null;
+ test._oldSupress = moment.suppressDeprecationWarnings;
+ moment.suppressDeprecationWarnings = true;
+ test.expectedDeprecations = function () {
+ test._expectedDeprecations = arguments;
+ test._observedDeprecations = [];
+ };
+ moment.deprecationHandler = function (name, msg) {
+ var deprecationId = matchedDeprecation(name, msg, test._expectedDeprecations);
+ if (deprecationId === -1) {
+ throw new Error('Unexpected deprecation thrown name=' +
+ name + ' msg=' + msg);
+ }
+ test._observedDeprecations[deprecationId] = 1;
+ };
+ }
+
+ function teardownDeprecationHandler(test, moment, scope) {
+ moment.suppressDeprecationWarnings = test._oldSupress;
+
+ if (test._expectedDeprecations != null) {
+ var missedDeprecations = [];
+ each(test._expectedDeprecations, function (deprecationPattern, id) {
+ if (test._observedDeprecations[id] !== 1) {
+ missedDeprecations.push(deprecationPattern);
+ }
+ });
+ if (missedDeprecations.length !== 0) {
+ throw new Error('Expected deprecation warnings did not happen: ' +
+ missedDeprecations.join(' '));
+ }
+ }
+ }
+
+ function matchedDeprecation(name, msg, deprecations) {
+ if (deprecations == null) {
+ return -1;
+ }
+ for (var i = 0; i < deprecations.length; ++i) {
+ if (name != null && name === deprecations[i]) {
+ return i;
+ }
+ if (msg != null && msg.substring(0, deprecations[i].length) === deprecations[i]) {
+ return i;
+ }
+ }
+ return -1;
+ }
/*global QUnit:false*/
@@ -44095,11 +69144,13 @@
moment.createFromInputFallback = function (config) {
throw new Error('input not handled by moment: ' + config._i);
};
+ setupDeprecationHandler(test, moment, 'core');
if (lifecycle && lifecycle.setup) {
lifecycle.setup();
}
},
teardown : function () {
+ teardownDeprecationHandler(test, moment, 'core');
if (lifecycle && lifecycle.teardown) {
lifecycle.teardown();
}
@@ -44114,17 +69165,20 @@
moment.createFromInputFallback = function (config) {
throw new Error('input not handled by moment: ' + config._i);
};
+ setupDeprecationHandler(test, moment, 'locale');
if (lifecycle && lifecycle.setup) {
lifecycle.setup();
}
},
teardown : function () {
moment.locale('en');
+ teardownDeprecationHandler(test, moment, 'locale');
if (lifecycle && lifecycle.teardown) {
lifecycle.teardown();
}
}
});
+ defineCommonLocaleTests(name, -1, -1);
}
module('utc offset');
@@ -44603,97 +69657,6 @@
assert.equal(moment().utcOffset(-120).format('ZZ'), '-0200', '+120 -> -0200');
});
- test('local to utc, keepLocalTime = true', function (assert) {
- var m = moment(),
- fmt = 'YYYY-DD-MM HH:mm:ss';
- assert.equal(m.clone().utc(true).format(fmt), m.format(fmt), 'local to utc failed to keep local time');
- });
-
- test('local to utc, keepLocalTime = false', function (assert) {
- var m = moment();
- assert.equal(m.clone().utc().valueOf(), m.valueOf(), 'local to utc failed to keep utc time (implicit)');
- assert.equal(m.clone().utc(false).valueOf(), m.valueOf(), 'local to utc failed to keep utc time (explicit)');
- });
-
- test('local to zone, keepLocalTime = true', function (assert) {
- var m = moment(),
- fmt = 'YYYY-DD-MM HH:mm:ss',
- z;
-
- // Apparently there is -12:00 and +14:00
- // http://en.wikipedia.org/wiki/UTC+14:00
- // http://en.wikipedia.org/wiki/UTC-12:00
- for (z = -12; z <= 14; ++z) {
- assert.equal(m.clone().utcOffset(z * 60, true).format(fmt),
- m.format(fmt),
- 'local to utcOffset(' + z + ':00) failed to keep local time');
- }
- });
-
- test('local to zone, keepLocalTime = false', function (assert) {
- var m = moment(),
- z;
-
- // Apparently there is -12:00 and +14:00
- // http://en.wikipedia.org/wiki/UTC+14:00
- // http://en.wikipedia.org/wiki/UTC-12:00
- for (z = -12; z <= 14; ++z) {
- assert.equal(m.clone().utcOffset(z * 60).valueOf(),
- m.valueOf(),
- 'local to utcOffset(' + z + ':00) failed to keep utc time (implicit)');
- assert.equal(m.clone().utcOffset(z * 60, false).valueOf(),
- m.valueOf(),
- 'local to utcOffset(' + z + ':00) failed to keep utc time (explicit)');
- }
- });
-
- test('utc to local, keepLocalTime = true', function (assert) {
- var um = moment.utc(),
- fmt = 'YYYY-DD-MM HH:mm:ss';
-
- assert.equal(um.clone().local(true).format(fmt), um.format(fmt), 'utc to local failed to keep local time');
- });
-
- test('utc to local, keepLocalTime = false', function (assert) {
- var um = moment.utc();
- assert.equal(um.clone().local().valueOf(), um.valueOf(), 'utc to local failed to keep utc time (implicit)');
- assert.equal(um.clone().local(false).valueOf(), um.valueOf(), 'utc to local failed to keep utc time (explicit)');
- });
-
- test('zone to local, keepLocalTime = true', function (assert) {
- var m = moment(),
- fmt = 'YYYY-DD-MM HH:mm:ss',
- z;
-
- // Apparently there is -12:00 and +14:00
- // http://en.wikipedia.org/wiki/UTC+14:00
- // http://en.wikipedia.org/wiki/UTC-12:00
- for (z = -12; z <= 14; ++z) {
- m.utcOffset(z * 60);
-
- assert.equal(m.clone().local(true).format(fmt),
- m.format(fmt),
- 'utcOffset(' + z + ':00) to local failed to keep local time');
- }
- });
-
- test('zone to local, keepLocalTime = false', function (assert) {
- var m = moment(),
- z;
-
- // Apparently there is -12:00 and +14:00
- // http://en.wikipedia.org/wiki/UTC+14:00
- // http://en.wikipedia.org/wiki/UTC-12:00
- for (z = -12; z <= 14; ++z) {
- m.utcOffset(z * 60);
-
- assert.equal(m.clone().local(false).valueOf(), m.valueOf(),
- 'utcOffset(' + z + ':00) to local failed to keep utc time (explicit)');
- assert.equal(m.clone().local().valueOf(), m.valueOf(),
- 'utcOffset(' + z + ':00) to local failed to keep utc time (implicit)');
- }
- });
-
}));
;(function (global, factory) {
@@ -44702,6 +69665,224 @@
typeof define === 'function' && define.amd ? define(['../../moment'], factory) :
factory(global.moment)
}(this, function (moment) { 'use strict';
+
+ function each(array, callback) {
+ var i;
+ for (i = 0; i < array.length; i++) {
+ callback(array[i], i, array);
+ }
+ }
+
+ function objectKeys(obj) {
+ if (Object.keys) {
+ return Object.keys(obj);
+ } else {
+ // IE8
+ var res = [], i;
+ for (i in obj) {
+ if (obj.hasOwnProperty(i)) {
+ res.push(i);
+ }
+ }
+ return res;
+ }
+ }
+
+ // Pick the first defined of two or three arguments.
+ function defaults(a, b, c) {
+ if (a != null) {
+ return a;
+ }
+ if (b != null) {
+ return b;
+ }
+ return c;
+ }
+
+ function defineCommonLocaleTests(locale, options) {
+ test('lenient ordinal parsing', function (assert) {
+ var i, ordinalStr, testMoment;
+ for (i = 1; i <= 31; ++i) {
+ ordinalStr = moment([2014, 0, i]).format('YYYY MM Do');
+ testMoment = moment(ordinalStr, 'YYYY MM Do');
+ assert.equal(testMoment.year(), 2014,
+ 'lenient ordinal parsing ' + i + ' year check');
+ assert.equal(testMoment.month(), 0,
+ 'lenient ordinal parsing ' + i + ' month check');
+ assert.equal(testMoment.date(), i,
+ 'lenient ordinal parsing ' + i + ' date check');
+ }
+ });
+
+ test('lenient ordinal parsing of number', function (assert) {
+ var i, testMoment;
+ for (i = 1; i <= 31; ++i) {
+ testMoment = moment('2014 01 ' + i, 'YYYY MM Do');
+ assert.equal(testMoment.year(), 2014,
+ 'lenient ordinal parsing of number ' + i + ' year check');
+ assert.equal(testMoment.month(), 0,
+ 'lenient ordinal parsing of number ' + i + ' month check');
+ assert.equal(testMoment.date(), i,
+ 'lenient ordinal parsing of number ' + i + ' date check');
+ }
+ });
+
+ test('strict ordinal parsing', function (assert) {
+ var i, ordinalStr, testMoment;
+ for (i = 1; i <= 31; ++i) {
+ ordinalStr = moment([2014, 0, i]).format('YYYY MM Do');
+ testMoment = moment(ordinalStr, 'YYYY MM Do', true);
+ assert.ok(testMoment.isValid(), 'strict ordinal parsing ' + i);
+ }
+ });
+
+ test('meridiem invariant', function (assert) {
+ var h, m, t1, t2;
+ for (h = 0; h < 24; ++h) {
+ for (m = 0; m < 60; m += 15) {
+ t1 = moment.utc([2000, 0, 1, h, m]);
+ t2 = moment.utc(t1.format('A h:mm'), 'A h:mm');
+ assert.equal(t2.format('HH:mm'), t1.format('HH:mm'),
+ 'meridiem at ' + t1.format('HH:mm'));
+ }
+ }
+ });
+
+ test('date format correctness', function (assert) {
+ var data, tokens;
+ data = moment.localeData()._longDateFormat;
+ tokens = objectKeys(data);
+ each(tokens, function (srchToken) {
+ // Check each format string to make sure it does not contain any
+ // tokens that need to be expanded.
+ each(tokens, function (baseToken) {
+ // strip escaped sequences
+ var format = data[baseToken].replace(/(\[[^\]]*\])/g, '');
+ assert.equal(false, !!~format.indexOf(srchToken),
+ 'contains ' + srchToken + ' in ' + baseToken);
+ });
+ });
+ });
+
+ test('month parsing correctness', function (assert) {
+ var i, m;
+
+ if (locale === 'tr') {
+ // I can't fix it :(
+ expect(0);
+ return;
+ }
+ function tester(format) {
+ var r;
+ r = moment(m.format(format), format);
+ assert.equal(r.month(), m.month(), 'month ' + i + ' fmt ' + format);
+ r = moment(m.format(format).toLocaleUpperCase(), format);
+ assert.equal(r.month(), m.month(), 'month ' + i + ' fmt ' + format + ' upper');
+ r = moment(m.format(format).toLocaleLowerCase(), format);
+ assert.equal(r.month(), m.month(), 'month ' + i + ' fmt ' + format + ' lower');
+
+ r = moment(m.format(format), format, true);
+ assert.equal(r.month(), m.month(), 'month ' + i + ' fmt ' + format + ' strict');
+ r = moment(m.format(format).toLocaleUpperCase(), format, true);
+ assert.equal(r.month(), m.month(), 'month ' + i + ' fmt ' + format + ' upper strict');
+ r = moment(m.format(format).toLocaleLowerCase(), format, true);
+ assert.equal(r.month(), m.month(), 'month ' + i + ' fmt ' + format + ' lower strict');
+ }
+
+ for (i = 0; i < 12; ++i) {
+ m = moment([2015, i, 15, 18]);
+ tester('MMM');
+ tester('MMM.');
+ tester('MMMM');
+ tester('MMMM.');
+ }
+ });
+
+ test('weekday parsing correctness', function (assert) {
+ var i, m;
+
+ if (locale === 'tr' || locale === 'az') {
+ // There is a lower-case letter (ı), that converted to upper then
+ // lower changes to i
+ expect(0);
+ return;
+ }
+ function tester(format) {
+ var r, baseMsg = 'weekday ' + m.weekday() + ' fmt ' + format;
+ r = moment(m.format(format), format);
+ assert.equal(r.weekday(), m.weekday(), baseMsg);
+ r = moment(m.format(format).toLocaleUpperCase(), format);
+ assert.equal(r.weekday(), m.weekday(), baseMsg + ' upper');
+ r = moment(m.format(format).toLocaleLowerCase(), format);
+ assert.equal(r.weekday(), m.weekday(), baseMsg + ' lower');
+
+ r = moment(m.format(format), format, true);
+ assert.equal(r.weekday(), m.weekday(), baseMsg + ' strict');
+ r = moment(m.format(format).toLocaleUpperCase(), format, true);
+ assert.equal(r.weekday(), m.weekday(), baseMsg + ' upper strict');
+ r = moment(m.format(format).toLocaleLowerCase(), format, true);
+ assert.equal(r.weekday(), m.weekday(), baseMsg + ' lower strict');
+ }
+
+ for (i = 0; i < 7; ++i) {
+ m = moment.utc([2015, i, 15, 18]);
+ tester('dd');
+ tester('ddd');
+ tester('dddd');
+ }
+ });
+ }
+
+ function setupDeprecationHandler(test, moment, scope) {
+ test._expectedDeprecations = null;
+ test._observedDeprecations = null;
+ test._oldSupress = moment.suppressDeprecationWarnings;
+ moment.suppressDeprecationWarnings = true;
+ test.expectedDeprecations = function () {
+ test._expectedDeprecations = arguments;
+ test._observedDeprecations = [];
+ };
+ moment.deprecationHandler = function (name, msg) {
+ var deprecationId = matchedDeprecation(name, msg, test._expectedDeprecations);
+ if (deprecationId === -1) {
+ throw new Error('Unexpected deprecation thrown name=' +
+ name + ' msg=' + msg);
+ }
+ test._observedDeprecations[deprecationId] = 1;
+ };
+ }
+
+ function teardownDeprecationHandler(test, moment, scope) {
+ moment.suppressDeprecationWarnings = test._oldSupress;
+
+ if (test._expectedDeprecations != null) {
+ var missedDeprecations = [];
+ each(test._expectedDeprecations, function (deprecationPattern, id) {
+ if (test._observedDeprecations[id] !== 1) {
+ missedDeprecations.push(deprecationPattern);
+ }
+ });
+ if (missedDeprecations.length !== 0) {
+ throw new Error('Expected deprecation warnings did not happen: ' +
+ missedDeprecations.join(' '));
+ }
+ }
+ }
+
+ function matchedDeprecation(name, msg, deprecations) {
+ if (deprecations == null) {
+ return -1;
+ }
+ for (var i = 0; i < deprecations.length; ++i) {
+ if (name != null && name === deprecations[i]) {
+ return i;
+ }
+ if (msg != null && msg.substring(0, deprecations[i].length) === deprecations[i]) {
+ return i;
+ }
+ }
+ return -1;
+ }
/*global QUnit:false*/
@@ -44716,11 +69897,13 @@
moment.createFromInputFallback = function (config) {
throw new Error('input not handled by moment: ' + config._i);
};
+ setupDeprecationHandler(test, moment, 'core');
if (lifecycle && lifecycle.setup) {
lifecycle.setup();
}
},
teardown : function () {
+ teardownDeprecationHandler(test, moment, 'core');
if (lifecycle && lifecycle.teardown) {
lifecycle.teardown();
}
@@ -44735,17 +69918,20 @@
moment.createFromInputFallback = function (config) {
throw new Error('input not handled by moment: ' + config._i);
};
+ setupDeprecationHandler(test, moment, 'locale');
if (lifecycle && lifecycle.setup) {
lifecycle.setup();
}
},
teardown : function () {
moment.locale('en');
+ teardownDeprecationHandler(test, moment, 'locale');
if (lifecycle && lifecycle.teardown) {
lifecycle.teardown();
}
}
});
+ defineCommonLocaleTests(name, -1, -1);
}
module('week year');
@@ -44813,16 +69999,18 @@
// Verifies that the week number, week day computation is correct for all dow, doy combinations
test('week year roundtrip', function (assert) {
- var dow, doy, wd, m;
+ var dow, doy, wd, m, localeName;
for (dow = 0; dow < 7; ++dow) {
for (doy = dow; doy < dow + 7; ++doy) {
for (wd = 0; wd < 7; ++wd) {
- moment.locale('dow: ' + dow + ', doy: ' + doy, {week: {dow: dow, doy: doy}});
+ localeName = 'dow: ' + dow + ', doy: ' + doy;
+ moment.locale(localeName, {week: {dow: dow, doy: doy}});
// We use the 10th week as the 1st one can spill to the previous year
m = moment('2015 10 ' + wd, 'gggg w d', true);
assert.equal(m.format('gggg w d'), '2015 10 ' + wd, 'dow: ' + dow + ' doy: ' + doy + ' wd: ' + wd);
m = moment('2015 10 ' + wd, 'gggg w e', true);
assert.equal(m.format('gggg w e'), '2015 10 ' + wd, 'dow: ' + dow + ' doy: ' + doy + ' wd: ' + wd);
+ moment.defineLocale(localeName, null);
}
}
}
@@ -44837,6 +70025,185 @@
assert.equal(2, moment('2013-01-11', 'YYYY-MM-DD').week(), '2013-01-11 is week 2'); // 53 -- should be 2
assert.equal(3, moment('2013-01-12', 'YYYY-MM-DD').week(), '2013-01-12 is week 3'); // 1 -- should be 3
assert.equal(52, moment('2012-01-01', 'YYYY-MM-DD').weeksInYear(), 'weeks in 2012 are 52'); // 52
+ moment.defineLocale('dow: 6, doy: 12', null);
+ });
+
+ test('weeks numbers dow:1 doy:4', function (assert) {
+ moment.locale('dow: 1, doy: 4', {week: {dow: 1, doy: 4}});
+ assert.equal(moment([2012, 0, 1]).week(), 52, 'Jan 1 2012 should be week 52');
+ assert.equal(moment([2012, 0, 2]).week(), 1, 'Jan 2 2012 should be week 1');
+ assert.equal(moment([2012, 0, 8]).week(), 1, 'Jan 8 2012 should be week 1');
+ assert.equal(moment([2012, 0, 9]).week(), 2, 'Jan 9 2012 should be week 2');
+ assert.equal(moment([2012, 0, 15]).week(), 2, 'Jan 15 2012 should be week 2');
+ assert.equal(moment([2007, 0, 1]).week(), 1, 'Jan 1 2007 should be week 1');
+ assert.equal(moment([2007, 0, 7]).week(), 1, 'Jan 7 2007 should be week 1');
+ assert.equal(moment([2007, 0, 8]).week(), 2, 'Jan 8 2007 should be week 2');
+ assert.equal(moment([2007, 0, 14]).week(), 2, 'Jan 14 2007 should be week 2');
+ assert.equal(moment([2007, 0, 15]).week(), 3, 'Jan 15 2007 should be week 3');
+ assert.equal(moment([2007, 11, 31]).week(), 1, 'Dec 31 2007 should be week 1');
+ assert.equal(moment([2008, 0, 1]).week(), 1, 'Jan 1 2008 should be week 1');
+ assert.equal(moment([2008, 0, 6]).week(), 1, 'Jan 6 2008 should be week 1');
+ assert.equal(moment([2008, 0, 7]).week(), 2, 'Jan 7 2008 should be week 2');
+ assert.equal(moment([2008, 0, 13]).week(), 2, 'Jan 13 2008 should be week 2');
+ assert.equal(moment([2008, 0, 14]).week(), 3, 'Jan 14 2008 should be week 3');
+ assert.equal(moment([2002, 11, 30]).week(), 1, 'Dec 30 2002 should be week 1');
+ assert.equal(moment([2003, 0, 1]).week(), 1, 'Jan 1 2003 should be week 1');
+ assert.equal(moment([2003, 0, 5]).week(), 1, 'Jan 5 2003 should be week 1');
+ assert.equal(moment([2003, 0, 6]).week(), 2, 'Jan 6 2003 should be week 2');
+ assert.equal(moment([2003, 0, 12]).week(), 2, 'Jan 12 2003 should be week 2');
+ assert.equal(moment([2003, 0, 13]).week(), 3, 'Jan 13 2003 should be week 3');
+ assert.equal(moment([2008, 11, 29]).week(), 1, 'Dec 29 2008 should be week 1');
+ assert.equal(moment([2009, 0, 1]).week(), 1, 'Jan 1 2009 should be week 1');
+ assert.equal(moment([2009, 0, 4]).week(), 1, 'Jan 4 2009 should be week 1');
+ assert.equal(moment([2009, 0, 5]).week(), 2, 'Jan 5 2009 should be week 2');
+ assert.equal(moment([2009, 0, 11]).week(), 2, 'Jan 11 2009 should be week 2');
+ assert.equal(moment([2009, 0, 13]).week(), 3, 'Jan 12 2009 should be week 3');
+ assert.equal(moment([2009, 11, 28]).week(), 53, 'Dec 28 2009 should be week 53');
+ assert.equal(moment([2010, 0, 1]).week(), 53, 'Jan 1 2010 should be week 53');
+ assert.equal(moment([2010, 0, 3]).week(), 53, 'Jan 3 2010 should be week 53');
+ assert.equal(moment([2010, 0, 4]).week(), 1, 'Jan 4 2010 should be week 1');
+ assert.equal(moment([2010, 0, 10]).week(), 1, 'Jan 10 2010 should be week 1');
+ assert.equal(moment([2010, 0, 11]).week(), 2, 'Jan 11 2010 should be week 2');
+ assert.equal(moment([2010, 11, 27]).week(), 52, 'Dec 27 2010 should be week 52');
+ assert.equal(moment([2011, 0, 1]).week(), 52, 'Jan 1 2011 should be week 52');
+ assert.equal(moment([2011, 0, 2]).week(), 52, 'Jan 2 2011 should be week 52');
+ assert.equal(moment([2011, 0, 3]).week(), 1, 'Jan 3 2011 should be week 1');
+ assert.equal(moment([2011, 0, 9]).week(), 1, 'Jan 9 2011 should be week 1');
+ assert.equal(moment([2011, 0, 10]).week(), 2, 'Jan 10 2011 should be week 2');
+ moment.defineLocale('dow: 1, doy: 4', null);
+ });
+
+ test('weeks numbers dow:6 doy:12', function (assert) {
+ moment.locale('dow: 6, doy: 12', {week: {dow: 6, doy: 12}});
+ assert.equal(moment([2011, 11, 31]).week(), 1, 'Dec 31 2011 should be week 1');
+ assert.equal(moment([2012, 0, 6]).week(), 1, 'Jan 6 2012 should be week 1');
+ assert.equal(moment([2012, 0, 7]).week(), 2, 'Jan 7 2012 should be week 2');
+ assert.equal(moment([2012, 0, 13]).week(), 2, 'Jan 13 2012 should be week 2');
+ assert.equal(moment([2012, 0, 14]).week(), 3, 'Jan 14 2012 should be week 3');
+ assert.equal(moment([2006, 11, 30]).week(), 1, 'Dec 30 2006 should be week 1');
+ assert.equal(moment([2007, 0, 5]).week(), 1, 'Jan 5 2007 should be week 1');
+ assert.equal(moment([2007, 0, 6]).week(), 2, 'Jan 6 2007 should be week 2');
+ assert.equal(moment([2007, 0, 12]).week(), 2, 'Jan 12 2007 should be week 2');
+ assert.equal(moment([2007, 0, 13]).week(), 3, 'Jan 13 2007 should be week 3');
+ assert.equal(moment([2007, 11, 29]).week(), 1, 'Dec 29 2007 should be week 1');
+ assert.equal(moment([2008, 0, 1]).week(), 1, 'Jan 1 2008 should be week 1');
+ assert.equal(moment([2008, 0, 4]).week(), 1, 'Jan 4 2008 should be week 1');
+ assert.equal(moment([2008, 0, 5]).week(), 2, 'Jan 5 2008 should be week 2');
+ assert.equal(moment([2008, 0, 11]).week(), 2, 'Jan 11 2008 should be week 2');
+ assert.equal(moment([2008, 0, 12]).week(), 3, 'Jan 12 2008 should be week 3');
+ assert.equal(moment([2002, 11, 28]).week(), 1, 'Dec 28 2002 should be week 1');
+ assert.equal(moment([2003, 0, 1]).week(), 1, 'Jan 1 2003 should be week 1');
+ assert.equal(moment([2003, 0, 3]).week(), 1, 'Jan 3 2003 should be week 1');
+ assert.equal(moment([2003, 0, 4]).week(), 2, 'Jan 4 2003 should be week 2');
+ assert.equal(moment([2003, 0, 10]).week(), 2, 'Jan 10 2003 should be week 2');
+ assert.equal(moment([2003, 0, 11]).week(), 3, 'Jan 11 2003 should be week 3');
+ assert.equal(moment([2008, 11, 27]).week(), 1, 'Dec 27 2008 should be week 1');
+ assert.equal(moment([2009, 0, 1]).week(), 1, 'Jan 1 2009 should be week 1');
+ assert.equal(moment([2009, 0, 2]).week(), 1, 'Jan 2 2009 should be week 1');
+ assert.equal(moment([2009, 0, 3]).week(), 2, 'Jan 3 2009 should be week 2');
+ assert.equal(moment([2009, 0, 9]).week(), 2, 'Jan 9 2009 should be week 2');
+ assert.equal(moment([2009, 0, 10]).week(), 3, 'Jan 10 2009 should be week 3');
+ assert.equal(moment([2009, 11, 26]).week(), 1, 'Dec 26 2009 should be week 1');
+ assert.equal(moment([2010, 0, 1]).week(), 1, 'Jan 1 2010 should be week 1');
+ assert.equal(moment([2010, 0, 2]).week(), 2, 'Jan 2 2010 should be week 2');
+ assert.equal(moment([2010, 0, 8]).week(), 2, 'Jan 8 2010 should be week 2');
+ assert.equal(moment([2010, 0, 9]).week(), 3, 'Jan 9 2010 should be week 3');
+ assert.equal(moment([2011, 0, 1]).week(), 1, 'Jan 1 2011 should be week 1');
+ assert.equal(moment([2011, 0, 7]).week(), 1, 'Jan 7 2011 should be week 1');
+ assert.equal(moment([2011, 0, 8]).week(), 2, 'Jan 8 2011 should be week 2');
+ assert.equal(moment([2011, 0, 14]).week(), 2, 'Jan 14 2011 should be week 2');
+ assert.equal(moment([2011, 0, 15]).week(), 3, 'Jan 15 2011 should be week 3');
+ moment.defineLocale('dow: 6, doy: 12', null);
+ });
+
+ test('weeks numbers dow:1 doy:7', function (assert) {
+ moment.locale('dow: 1, doy: 7', {week: {dow: 1, doy: 7}});
+ assert.equal(moment([2011, 11, 26]).week(), 1, 'Dec 26 2011 should be week 1');
+ assert.equal(moment([2012, 0, 1]).week(), 1, 'Jan 1 2012 should be week 1');
+ assert.equal(moment([2012, 0, 2]).week(), 2, 'Jan 2 2012 should be week 2');
+ assert.equal(moment([2012, 0, 8]).week(), 2, 'Jan 8 2012 should be week 2');
+ assert.equal(moment([2012, 0, 9]).week(), 3, 'Jan 9 2012 should be week 3');
+ assert.equal(moment([2007, 0, 1]).week(), 1, 'Jan 1 2007 should be week 1');
+ assert.equal(moment([2007, 0, 7]).week(), 1, 'Jan 7 2007 should be week 1');
+ assert.equal(moment([2007, 0, 8]).week(), 2, 'Jan 8 2007 should be week 2');
+ assert.equal(moment([2007, 0, 14]).week(), 2, 'Jan 14 2007 should be week 2');
+ assert.equal(moment([2007, 0, 15]).week(), 3, 'Jan 15 2007 should be week 3');
+ assert.equal(moment([2007, 11, 31]).week(), 1, 'Dec 31 2007 should be week 1');
+ assert.equal(moment([2008, 0, 1]).week(), 1, 'Jan 1 2008 should be week 1');
+ assert.equal(moment([2008, 0, 6]).week(), 1, 'Jan 6 2008 should be week 1');
+ assert.equal(moment([2008, 0, 7]).week(), 2, 'Jan 7 2008 should be week 2');
+ assert.equal(moment([2008, 0, 13]).week(), 2, 'Jan 13 2008 should be week 2');
+ assert.equal(moment([2008, 0, 14]).week(), 3, 'Jan 14 2008 should be week 3');
+ assert.equal(moment([2002, 11, 30]).week(), 1, 'Dec 30 2002 should be week 1');
+ assert.equal(moment([2003, 0, 1]).week(), 1, 'Jan 1 2003 should be week 1');
+ assert.equal(moment([2003, 0, 5]).week(), 1, 'Jan 5 2003 should be week 1');
+ assert.equal(moment([2003, 0, 6]).week(), 2, 'Jan 6 2003 should be week 2');
+ assert.equal(moment([2003, 0, 12]).week(), 2, 'Jan 12 2003 should be week 2');
+ assert.equal(moment([2003, 0, 13]).week(), 3, 'Jan 13 2003 should be week 3');
+ assert.equal(moment([2008, 11, 29]).week(), 1, 'Dec 29 2008 should be week 1');
+ assert.equal(moment([2009, 0, 1]).week(), 1, 'Jan 1 2009 should be week 1');
+ assert.equal(moment([2009, 0, 4]).week(), 1, 'Jan 4 2009 should be week 1');
+ assert.equal(moment([2009, 0, 5]).week(), 2, 'Jan 5 2009 should be week 2');
+ assert.equal(moment([2009, 0, 11]).week(), 2, 'Jan 11 2009 should be week 2');
+ assert.equal(moment([2009, 0, 12]).week(), 3, 'Jan 12 2009 should be week 3');
+ assert.equal(moment([2009, 11, 28]).week(), 1, 'Dec 28 2009 should be week 1');
+ assert.equal(moment([2010, 0, 1]).week(), 1, 'Jan 1 2010 should be week 1');
+ assert.equal(moment([2010, 0, 3]).week(), 1, 'Jan 3 2010 should be week 1');
+ assert.equal(moment([2010, 0, 4]).week(), 2, 'Jan 4 2010 should be week 2');
+ assert.equal(moment([2010, 0, 10]).week(), 2, 'Jan 10 2010 should be week 2');
+ assert.equal(moment([2010, 0, 11]).week(), 3, 'Jan 11 2010 should be week 3');
+ assert.equal(moment([2010, 11, 27]).week(), 1, 'Dec 27 2010 should be week 1');
+ assert.equal(moment([2011, 0, 1]).week(), 1, 'Jan 1 2011 should be week 1');
+ assert.equal(moment([2011, 0, 2]).week(), 1, 'Jan 2 2011 should be week 1');
+ assert.equal(moment([2011, 0, 3]).week(), 2, 'Jan 3 2011 should be week 2');
+ assert.equal(moment([2011, 0, 9]).week(), 2, 'Jan 9 2011 should be week 2');
+ assert.equal(moment([2011, 0, 10]).week(), 3, 'Jan 10 2011 should be week 3');
+ moment.defineLocale('dow: 1, doy: 7', null);
+ });
+
+ test('weeks numbers dow:0 doy:6', function (assert) {
+ moment.locale('dow: 0, doy: 6', {week: {dow: 0, doy: 6}});
+ assert.equal(moment([2012, 0, 1]).week(), 1, 'Jan 1 2012 should be week 1');
+ assert.equal(moment([2012, 0, 7]).week(), 1, 'Jan 7 2012 should be week 1');
+ assert.equal(moment([2012, 0, 8]).week(), 2, 'Jan 8 2012 should be week 2');
+ assert.equal(moment([2012, 0, 14]).week(), 2, 'Jan 14 2012 should be week 2');
+ assert.equal(moment([2012, 0, 15]).week(), 3, 'Jan 15 2012 should be week 3');
+ assert.equal(moment([2006, 11, 31]).week(), 1, 'Dec 31 2006 should be week 1');
+ assert.equal(moment([2007, 0, 1]).week(), 1, 'Jan 1 2007 should be week 1');
+ assert.equal(moment([2007, 0, 6]).week(), 1, 'Jan 6 2007 should be week 1');
+ assert.equal(moment([2007, 0, 7]).week(), 2, 'Jan 7 2007 should be week 2');
+ assert.equal(moment([2007, 0, 13]).week(), 2, 'Jan 13 2007 should be week 2');
+ assert.equal(moment([2007, 0, 14]).week(), 3, 'Jan 14 2007 should be week 3');
+ assert.equal(moment([2007, 11, 29]).week(), 52, 'Dec 29 2007 should be week 52');
+ assert.equal(moment([2008, 0, 1]).week(), 1, 'Jan 1 2008 should be week 1');
+ assert.equal(moment([2008, 0, 5]).week(), 1, 'Jan 5 2008 should be week 1');
+ assert.equal(moment([2008, 0, 6]).week(), 2, 'Jan 6 2008 should be week 2');
+ assert.equal(moment([2008, 0, 12]).week(), 2, 'Jan 12 2008 should be week 2');
+ assert.equal(moment([2008, 0, 13]).week(), 3, 'Jan 13 2008 should be week 3');
+ assert.equal(moment([2002, 11, 29]).week(), 1, 'Dec 29 2002 should be week 1');
+ assert.equal(moment([2003, 0, 1]).week(), 1, 'Jan 1 2003 should be week 1');
+ assert.equal(moment([2003, 0, 4]).week(), 1, 'Jan 4 2003 should be week 1');
+ assert.equal(moment([2003, 0, 5]).week(), 2, 'Jan 5 2003 should be week 2');
+ assert.equal(moment([2003, 0, 11]).week(), 2, 'Jan 11 2003 should be week 2');
+ assert.equal(moment([2003, 0, 12]).week(), 3, 'Jan 12 2003 should be week 3');
+ assert.equal(moment([2008, 11, 28]).week(), 1, 'Dec 28 2008 should be week 1');
+ assert.equal(moment([2009, 0, 1]).week(), 1, 'Jan 1 2009 should be week 1');
+ assert.equal(moment([2009, 0, 3]).week(), 1, 'Jan 3 2009 should be week 1');
+ assert.equal(moment([2009, 0, 4]).week(), 2, 'Jan 4 2009 should be week 2');
+ assert.equal(moment([2009, 0, 10]).week(), 2, 'Jan 10 2009 should be week 2');
+ assert.equal(moment([2009, 0, 11]).week(), 3, 'Jan 11 2009 should be week 3');
+ assert.equal(moment([2009, 11, 27]).week(), 1, 'Dec 27 2009 should be week 1');
+ assert.equal(moment([2010, 0, 1]).week(), 1, 'Jan 1 2010 should be week 1');
+ assert.equal(moment([2010, 0, 2]).week(), 1, 'Jan 2 2010 should be week 1');
+ assert.equal(moment([2010, 0, 3]).week(), 2, 'Jan 3 2010 should be week 2');
+ assert.equal(moment([2010, 0, 9]).week(), 2, 'Jan 9 2010 should be week 2');
+ assert.equal(moment([2010, 0, 10]).week(), 3, 'Jan 10 2010 should be week 3');
+ assert.equal(moment([2010, 11, 26]).week(), 1, 'Dec 26 2010 should be week 1');
+ assert.equal(moment([2011, 0, 1]).week(), 1, 'Jan 1 2011 should be week 1');
+ assert.equal(moment([2011, 0, 2]).week(), 2, 'Jan 2 2011 should be week 2');
+ assert.equal(moment([2011, 0, 8]).week(), 2, 'Jan 8 2011 should be week 2');
+ assert.equal(moment([2011, 0, 9]).week(), 3, 'Jan 9 2011 should be week 3');
+ moment.defineLocale('dow: 0, doy: 6', null);
});
test('week year overflows', function (assert) {
@@ -44881,6 +70248,224 @@
typeof define === 'function' && define.amd ? define(['../../moment'], factory) :
factory(global.moment)
}(this, function (moment) { 'use strict';
+
+ function each(array, callback) {
+ var i;
+ for (i = 0; i < array.length; i++) {
+ callback(array[i], i, array);
+ }
+ }
+
+ function objectKeys(obj) {
+ if (Object.keys) {
+ return Object.keys(obj);
+ } else {
+ // IE8
+ var res = [], i;
+ for (i in obj) {
+ if (obj.hasOwnProperty(i)) {
+ res.push(i);
+ }
+ }
+ return res;
+ }
+ }
+
+ // Pick the first defined of two or three arguments.
+ function defaults(a, b, c) {
+ if (a != null) {
+ return a;
+ }
+ if (b != null) {
+ return b;
+ }
+ return c;
+ }
+
+ function defineCommonLocaleTests(locale, options) {
+ test('lenient ordinal parsing', function (assert) {
+ var i, ordinalStr, testMoment;
+ for (i = 1; i <= 31; ++i) {
+ ordinalStr = moment([2014, 0, i]).format('YYYY MM Do');
+ testMoment = moment(ordinalStr, 'YYYY MM Do');
+ assert.equal(testMoment.year(), 2014,
+ 'lenient ordinal parsing ' + i + ' year check');
+ assert.equal(testMoment.month(), 0,
+ 'lenient ordinal parsing ' + i + ' month check');
+ assert.equal(testMoment.date(), i,
+ 'lenient ordinal parsing ' + i + ' date check');
+ }
+ });
+
+ test('lenient ordinal parsing of number', function (assert) {
+ var i, testMoment;
+ for (i = 1; i <= 31; ++i) {
+ testMoment = moment('2014 01 ' + i, 'YYYY MM Do');
+ assert.equal(testMoment.year(), 2014,
+ 'lenient ordinal parsing of number ' + i + ' year check');
+ assert.equal(testMoment.month(), 0,
+ 'lenient ordinal parsing of number ' + i + ' month check');
+ assert.equal(testMoment.date(), i,
+ 'lenient ordinal parsing of number ' + i + ' date check');
+ }
+ });
+
+ test('strict ordinal parsing', function (assert) {
+ var i, ordinalStr, testMoment;
+ for (i = 1; i <= 31; ++i) {
+ ordinalStr = moment([2014, 0, i]).format('YYYY MM Do');
+ testMoment = moment(ordinalStr, 'YYYY MM Do', true);
+ assert.ok(testMoment.isValid(), 'strict ordinal parsing ' + i);
+ }
+ });
+
+ test('meridiem invariant', function (assert) {
+ var h, m, t1, t2;
+ for (h = 0; h < 24; ++h) {
+ for (m = 0; m < 60; m += 15) {
+ t1 = moment.utc([2000, 0, 1, h, m]);
+ t2 = moment.utc(t1.format('A h:mm'), 'A h:mm');
+ assert.equal(t2.format('HH:mm'), t1.format('HH:mm'),
+ 'meridiem at ' + t1.format('HH:mm'));
+ }
+ }
+ });
+
+ test('date format correctness', function (assert) {
+ var data, tokens;
+ data = moment.localeData()._longDateFormat;
+ tokens = objectKeys(data);
+ each(tokens, function (srchToken) {
+ // Check each format string to make sure it does not contain any
+ // tokens that need to be expanded.
+ each(tokens, function (baseToken) {
+ // strip escaped sequences
+ var format = data[baseToken].replace(/(\[[^\]]*\])/g, '');
+ assert.equal(false, !!~format.indexOf(srchToken),
+ 'contains ' + srchToken + ' in ' + baseToken);
+ });
+ });
+ });
+
+ test('month parsing correctness', function (assert) {
+ var i, m;
+
+ if (locale === 'tr') {
+ // I can't fix it :(
+ expect(0);
+ return;
+ }
+ function tester(format) {
+ var r;
+ r = moment(m.format(format), format);
+ assert.equal(r.month(), m.month(), 'month ' + i + ' fmt ' + format);
+ r = moment(m.format(format).toLocaleUpperCase(), format);
+ assert.equal(r.month(), m.month(), 'month ' + i + ' fmt ' + format + ' upper');
+ r = moment(m.format(format).toLocaleLowerCase(), format);
+ assert.equal(r.month(), m.month(), 'month ' + i + ' fmt ' + format + ' lower');
+
+ r = moment(m.format(format), format, true);
+ assert.equal(r.month(), m.month(), 'month ' + i + ' fmt ' + format + ' strict');
+ r = moment(m.format(format).toLocaleUpperCase(), format, true);
+ assert.equal(r.month(), m.month(), 'month ' + i + ' fmt ' + format + ' upper strict');
+ r = moment(m.format(format).toLocaleLowerCase(), format, true);
+ assert.equal(r.month(), m.month(), 'month ' + i + ' fmt ' + format + ' lower strict');
+ }
+
+ for (i = 0; i < 12; ++i) {
+ m = moment([2015, i, 15, 18]);
+ tester('MMM');
+ tester('MMM.');
+ tester('MMMM');
+ tester('MMMM.');
+ }
+ });
+
+ test('weekday parsing correctness', function (assert) {
+ var i, m;
+
+ if (locale === 'tr' || locale === 'az') {
+ // There is a lower-case letter (ı), that converted to upper then
+ // lower changes to i
+ expect(0);
+ return;
+ }
+ function tester(format) {
+ var r, baseMsg = 'weekday ' + m.weekday() + ' fmt ' + format;
+ r = moment(m.format(format), format);
+ assert.equal(r.weekday(), m.weekday(), baseMsg);
+ r = moment(m.format(format).toLocaleUpperCase(), format);
+ assert.equal(r.weekday(), m.weekday(), baseMsg + ' upper');
+ r = moment(m.format(format).toLocaleLowerCase(), format);
+ assert.equal(r.weekday(), m.weekday(), baseMsg + ' lower');
+
+ r = moment(m.format(format), format, true);
+ assert.equal(r.weekday(), m.weekday(), baseMsg + ' strict');
+ r = moment(m.format(format).toLocaleUpperCase(), format, true);
+ assert.equal(r.weekday(), m.weekday(), baseMsg + ' upper strict');
+ r = moment(m.format(format).toLocaleLowerCase(), format, true);
+ assert.equal(r.weekday(), m.weekday(), baseMsg + ' lower strict');
+ }
+
+ for (i = 0; i < 7; ++i) {
+ m = moment.utc([2015, i, 15, 18]);
+ tester('dd');
+ tester('ddd');
+ tester('dddd');
+ }
+ });
+ }
+
+ function setupDeprecationHandler(test, moment, scope) {
+ test._expectedDeprecations = null;
+ test._observedDeprecations = null;
+ test._oldSupress = moment.suppressDeprecationWarnings;
+ moment.suppressDeprecationWarnings = true;
+ test.expectedDeprecations = function () {
+ test._expectedDeprecations = arguments;
+ test._observedDeprecations = [];
+ };
+ moment.deprecationHandler = function (name, msg) {
+ var deprecationId = matchedDeprecation(name, msg, test._expectedDeprecations);
+ if (deprecationId === -1) {
+ throw new Error('Unexpected deprecation thrown name=' +
+ name + ' msg=' + msg);
+ }
+ test._observedDeprecations[deprecationId] = 1;
+ };
+ }
+
+ function teardownDeprecationHandler(test, moment, scope) {
+ moment.suppressDeprecationWarnings = test._oldSupress;
+
+ if (test._expectedDeprecations != null) {
+ var missedDeprecations = [];
+ each(test._expectedDeprecations, function (deprecationPattern, id) {
+ if (test._observedDeprecations[id] !== 1) {
+ missedDeprecations.push(deprecationPattern);
+ }
+ });
+ if (missedDeprecations.length !== 0) {
+ throw new Error('Expected deprecation warnings did not happen: ' +
+ missedDeprecations.join(' '));
+ }
+ }
+ }
+
+ function matchedDeprecation(name, msg, deprecations) {
+ if (deprecations == null) {
+ return -1;
+ }
+ for (var i = 0; i < deprecations.length; ++i) {
+ if (name != null && name === deprecations[i]) {
+ return i;
+ }
+ if (msg != null && msg.substring(0, deprecations[i].length) === deprecations[i]) {
+ return i;
+ }
+ }
+ return -1;
+ }
/*global QUnit:false*/
@@ -44895,11 +70480,13 @@
moment.createFromInputFallback = function (config) {
throw new Error('input not handled by moment: ' + config._i);
};
+ setupDeprecationHandler(test, moment, 'core');
if (lifecycle && lifecycle.setup) {
lifecycle.setup();
}
},
teardown : function () {
+ teardownDeprecationHandler(test, moment, 'core');
if (lifecycle && lifecycle.teardown) {
lifecycle.teardown();
}
@@ -44914,17 +70501,20 @@
moment.createFromInputFallback = function (config) {
throw new Error('input not handled by moment: ' + config._i);
};
+ setupDeprecationHandler(test, moment, 'locale');
if (lifecycle && lifecycle.setup) {
lifecycle.setup();
}
},
teardown : function () {
moment.locale('en');
+ teardownDeprecationHandler(test, moment, 'locale');
if (lifecycle && lifecycle.teardown) {
lifecycle.teardown();
}
}
});
+ defineCommonLocaleTests(name, -1, -1);
}
module('week day');
@@ -45066,6 +70656,224 @@
factory(global.moment)
}(this, function (moment) { 'use strict';
+ function each(array, callback) {
+ var i;
+ for (i = 0; i < array.length; i++) {
+ callback(array[i], i, array);
+ }
+ }
+
+ function objectKeys(obj) {
+ if (Object.keys) {
+ return Object.keys(obj);
+ } else {
+ // IE8
+ var res = [], i;
+ for (i in obj) {
+ if (obj.hasOwnProperty(i)) {
+ res.push(i);
+ }
+ }
+ return res;
+ }
+ }
+
+ // Pick the first defined of two or three arguments.
+ function defaults(a, b, c) {
+ if (a != null) {
+ return a;
+ }
+ if (b != null) {
+ return b;
+ }
+ return c;
+ }
+
+ function defineCommonLocaleTests(locale, options) {
+ test('lenient ordinal parsing', function (assert) {
+ var i, ordinalStr, testMoment;
+ for (i = 1; i <= 31; ++i) {
+ ordinalStr = moment([2014, 0, i]).format('YYYY MM Do');
+ testMoment = moment(ordinalStr, 'YYYY MM Do');
+ assert.equal(testMoment.year(), 2014,
+ 'lenient ordinal parsing ' + i + ' year check');
+ assert.equal(testMoment.month(), 0,
+ 'lenient ordinal parsing ' + i + ' month check');
+ assert.equal(testMoment.date(), i,
+ 'lenient ordinal parsing ' + i + ' date check');
+ }
+ });
+
+ test('lenient ordinal parsing of number', function (assert) {
+ var i, testMoment;
+ for (i = 1; i <= 31; ++i) {
+ testMoment = moment('2014 01 ' + i, 'YYYY MM Do');
+ assert.equal(testMoment.year(), 2014,
+ 'lenient ordinal parsing of number ' + i + ' year check');
+ assert.equal(testMoment.month(), 0,
+ 'lenient ordinal parsing of number ' + i + ' month check');
+ assert.equal(testMoment.date(), i,
+ 'lenient ordinal parsing of number ' + i + ' date check');
+ }
+ });
+
+ test('strict ordinal parsing', function (assert) {
+ var i, ordinalStr, testMoment;
+ for (i = 1; i <= 31; ++i) {
+ ordinalStr = moment([2014, 0, i]).format('YYYY MM Do');
+ testMoment = moment(ordinalStr, 'YYYY MM Do', true);
+ assert.ok(testMoment.isValid(), 'strict ordinal parsing ' + i);
+ }
+ });
+
+ test('meridiem invariant', function (assert) {
+ var h, m, t1, t2;
+ for (h = 0; h < 24; ++h) {
+ for (m = 0; m < 60; m += 15) {
+ t1 = moment.utc([2000, 0, 1, h, m]);
+ t2 = moment.utc(t1.format('A h:mm'), 'A h:mm');
+ assert.equal(t2.format('HH:mm'), t1.format('HH:mm'),
+ 'meridiem at ' + t1.format('HH:mm'));
+ }
+ }
+ });
+
+ test('date format correctness', function (assert) {
+ var data, tokens;
+ data = moment.localeData()._longDateFormat;
+ tokens = objectKeys(data);
+ each(tokens, function (srchToken) {
+ // Check each format string to make sure it does not contain any
+ // tokens that need to be expanded.
+ each(tokens, function (baseToken) {
+ // strip escaped sequences
+ var format = data[baseToken].replace(/(\[[^\]]*\])/g, '');
+ assert.equal(false, !!~format.indexOf(srchToken),
+ 'contains ' + srchToken + ' in ' + baseToken);
+ });
+ });
+ });
+
+ test('month parsing correctness', function (assert) {
+ var i, m;
+
+ if (locale === 'tr') {
+ // I can't fix it :(
+ expect(0);
+ return;
+ }
+ function tester(format) {
+ var r;
+ r = moment(m.format(format), format);
+ assert.equal(r.month(), m.month(), 'month ' + i + ' fmt ' + format);
+ r = moment(m.format(format).toLocaleUpperCase(), format);
+ assert.equal(r.month(), m.month(), 'month ' + i + ' fmt ' + format + ' upper');
+ r = moment(m.format(format).toLocaleLowerCase(), format);
+ assert.equal(r.month(), m.month(), 'month ' + i + ' fmt ' + format + ' lower');
+
+ r = moment(m.format(format), format, true);
+ assert.equal(r.month(), m.month(), 'month ' + i + ' fmt ' + format + ' strict');
+ r = moment(m.format(format).toLocaleUpperCase(), format, true);
+ assert.equal(r.month(), m.month(), 'month ' + i + ' fmt ' + format + ' upper strict');
+ r = moment(m.format(format).toLocaleLowerCase(), format, true);
+ assert.equal(r.month(), m.month(), 'month ' + i + ' fmt ' + format + ' lower strict');
+ }
+
+ for (i = 0; i < 12; ++i) {
+ m = moment([2015, i, 15, 18]);
+ tester('MMM');
+ tester('MMM.');
+ tester('MMMM');
+ tester('MMMM.');
+ }
+ });
+
+ test('weekday parsing correctness', function (assert) {
+ var i, m;
+
+ if (locale === 'tr' || locale === 'az') {
+ // There is a lower-case letter (ı), that converted to upper then
+ // lower changes to i
+ expect(0);
+ return;
+ }
+ function tester(format) {
+ var r, baseMsg = 'weekday ' + m.weekday() + ' fmt ' + format;
+ r = moment(m.format(format), format);
+ assert.equal(r.weekday(), m.weekday(), baseMsg);
+ r = moment(m.format(format).toLocaleUpperCase(), format);
+ assert.equal(r.weekday(), m.weekday(), baseMsg + ' upper');
+ r = moment(m.format(format).toLocaleLowerCase(), format);
+ assert.equal(r.weekday(), m.weekday(), baseMsg + ' lower');
+
+ r = moment(m.format(format), format, true);
+ assert.equal(r.weekday(), m.weekday(), baseMsg + ' strict');
+ r = moment(m.format(format).toLocaleUpperCase(), format, true);
+ assert.equal(r.weekday(), m.weekday(), baseMsg + ' upper strict');
+ r = moment(m.format(format).toLocaleLowerCase(), format, true);
+ assert.equal(r.weekday(), m.weekday(), baseMsg + ' lower strict');
+ }
+
+ for (i = 0; i < 7; ++i) {
+ m = moment.utc([2015, i, 15, 18]);
+ tester('dd');
+ tester('ddd');
+ tester('dddd');
+ }
+ });
+ }
+
+ function setupDeprecationHandler(test, moment, scope) {
+ test._expectedDeprecations = null;
+ test._observedDeprecations = null;
+ test._oldSupress = moment.suppressDeprecationWarnings;
+ moment.suppressDeprecationWarnings = true;
+ test.expectedDeprecations = function () {
+ test._expectedDeprecations = arguments;
+ test._observedDeprecations = [];
+ };
+ moment.deprecationHandler = function (name, msg) {
+ var deprecationId = matchedDeprecation(name, msg, test._expectedDeprecations);
+ if (deprecationId === -1) {
+ throw new Error('Unexpected deprecation thrown name=' +
+ name + ' msg=' + msg);
+ }
+ test._observedDeprecations[deprecationId] = 1;
+ };
+ }
+
+ function teardownDeprecationHandler(test, moment, scope) {
+ moment.suppressDeprecationWarnings = test._oldSupress;
+
+ if (test._expectedDeprecations != null) {
+ var missedDeprecations = [];
+ each(test._expectedDeprecations, function (deprecationPattern, id) {
+ if (test._observedDeprecations[id] !== 1) {
+ missedDeprecations.push(deprecationPattern);
+ }
+ });
+ if (missedDeprecations.length !== 0) {
+ throw new Error('Expected deprecation warnings did not happen: ' +
+ missedDeprecations.join(' '));
+ }
+ }
+ }
+
+ function matchedDeprecation(name, msg, deprecations) {
+ if (deprecations == null) {
+ return -1;
+ }
+ for (var i = 0; i < deprecations.length; ++i) {
+ if (name != null && name === deprecations[i]) {
+ return i;
+ }
+ if (msg != null && msg.substring(0, deprecations[i].length) === deprecations[i]) {
+ return i;
+ }
+ }
+ return -1;
+ }
+
/*global QUnit:false*/
var test = QUnit.test;
@@ -45079,11 +70887,13 @@
moment.createFromInputFallback = function (config) {
throw new Error('input not handled by moment: ' + config._i);
};
+ setupDeprecationHandler(test, moment, 'core');
if (lifecycle && lifecycle.setup) {
lifecycle.setup();
}
},
teardown : function () {
+ teardownDeprecationHandler(test, moment, 'core');
if (lifecycle && lifecycle.teardown) {
lifecycle.teardown();
}
@@ -45098,17 +70908,20 @@
moment.createFromInputFallback = function (config) {
throw new Error('input not handled by moment: ' + config._i);
};
+ setupDeprecationHandler(test, moment, 'locale');
if (lifecycle && lifecycle.setup) {
lifecycle.setup();
}
},
teardown : function () {
moment.locale('en');
+ teardownDeprecationHandler(test, moment, 'locale');
if (lifecycle && lifecycle.teardown) {
lifecycle.teardown();
}
}
});
+ defineCommonLocaleTests(name, -1, -1);
}
module('weeks');
@@ -45342,6 +71155,224 @@
factory(global.moment)
}(this, function (moment) { 'use strict';
+ function each(array, callback) {
+ var i;
+ for (i = 0; i < array.length; i++) {
+ callback(array[i], i, array);
+ }
+ }
+
+ function objectKeys(obj) {
+ if (Object.keys) {
+ return Object.keys(obj);
+ } else {
+ // IE8
+ var res = [], i;
+ for (i in obj) {
+ if (obj.hasOwnProperty(i)) {
+ res.push(i);
+ }
+ }
+ return res;
+ }
+ }
+
+ // Pick the first defined of two or three arguments.
+ function defaults(a, b, c) {
+ if (a != null) {
+ return a;
+ }
+ if (b != null) {
+ return b;
+ }
+ return c;
+ }
+
+ function defineCommonLocaleTests(locale, options) {
+ test('lenient ordinal parsing', function (assert) {
+ var i, ordinalStr, testMoment;
+ for (i = 1; i <= 31; ++i) {
+ ordinalStr = moment([2014, 0, i]).format('YYYY MM Do');
+ testMoment = moment(ordinalStr, 'YYYY MM Do');
+ assert.equal(testMoment.year(), 2014,
+ 'lenient ordinal parsing ' + i + ' year check');
+ assert.equal(testMoment.month(), 0,
+ 'lenient ordinal parsing ' + i + ' month check');
+ assert.equal(testMoment.date(), i,
+ 'lenient ordinal parsing ' + i + ' date check');
+ }
+ });
+
+ test('lenient ordinal parsing of number', function (assert) {
+ var i, testMoment;
+ for (i = 1; i <= 31; ++i) {
+ testMoment = moment('2014 01 ' + i, 'YYYY MM Do');
+ assert.equal(testMoment.year(), 2014,
+ 'lenient ordinal parsing of number ' + i + ' year check');
+ assert.equal(testMoment.month(), 0,
+ 'lenient ordinal parsing of number ' + i + ' month check');
+ assert.equal(testMoment.date(), i,
+ 'lenient ordinal parsing of number ' + i + ' date check');
+ }
+ });
+
+ test('strict ordinal parsing', function (assert) {
+ var i, ordinalStr, testMoment;
+ for (i = 1; i <= 31; ++i) {
+ ordinalStr = moment([2014, 0, i]).format('YYYY MM Do');
+ testMoment = moment(ordinalStr, 'YYYY MM Do', true);
+ assert.ok(testMoment.isValid(), 'strict ordinal parsing ' + i);
+ }
+ });
+
+ test('meridiem invariant', function (assert) {
+ var h, m, t1, t2;
+ for (h = 0; h < 24; ++h) {
+ for (m = 0; m < 60; m += 15) {
+ t1 = moment.utc([2000, 0, 1, h, m]);
+ t2 = moment.utc(t1.format('A h:mm'), 'A h:mm');
+ assert.equal(t2.format('HH:mm'), t1.format('HH:mm'),
+ 'meridiem at ' + t1.format('HH:mm'));
+ }
+ }
+ });
+
+ test('date format correctness', function (assert) {
+ var data, tokens;
+ data = moment.localeData()._longDateFormat;
+ tokens = objectKeys(data);
+ each(tokens, function (srchToken) {
+ // Check each format string to make sure it does not contain any
+ // tokens that need to be expanded.
+ each(tokens, function (baseToken) {
+ // strip escaped sequences
+ var format = data[baseToken].replace(/(\[[^\]]*\])/g, '');
+ assert.equal(false, !!~format.indexOf(srchToken),
+ 'contains ' + srchToken + ' in ' + baseToken);
+ });
+ });
+ });
+
+ test('month parsing correctness', function (assert) {
+ var i, m;
+
+ if (locale === 'tr') {
+ // I can't fix it :(
+ expect(0);
+ return;
+ }
+ function tester(format) {
+ var r;
+ r = moment(m.format(format), format);
+ assert.equal(r.month(), m.month(), 'month ' + i + ' fmt ' + format);
+ r = moment(m.format(format).toLocaleUpperCase(), format);
+ assert.equal(r.month(), m.month(), 'month ' + i + ' fmt ' + format + ' upper');
+ r = moment(m.format(format).toLocaleLowerCase(), format);
+ assert.equal(r.month(), m.month(), 'month ' + i + ' fmt ' + format + ' lower');
+
+ r = moment(m.format(format), format, true);
+ assert.equal(r.month(), m.month(), 'month ' + i + ' fmt ' + format + ' strict');
+ r = moment(m.format(format).toLocaleUpperCase(), format, true);
+ assert.equal(r.month(), m.month(), 'month ' + i + ' fmt ' + format + ' upper strict');
+ r = moment(m.format(format).toLocaleLowerCase(), format, true);
+ assert.equal(r.month(), m.month(), 'month ' + i + ' fmt ' + format + ' lower strict');
+ }
+
+ for (i = 0; i < 12; ++i) {
+ m = moment([2015, i, 15, 18]);
+ tester('MMM');
+ tester('MMM.');
+ tester('MMMM');
+ tester('MMMM.');
+ }
+ });
+
+ test('weekday parsing correctness', function (assert) {
+ var i, m;
+
+ if (locale === 'tr' || locale === 'az') {
+ // There is a lower-case letter (ı), that converted to upper then
+ // lower changes to i
+ expect(0);
+ return;
+ }
+ function tester(format) {
+ var r, baseMsg = 'weekday ' + m.weekday() + ' fmt ' + format;
+ r = moment(m.format(format), format);
+ assert.equal(r.weekday(), m.weekday(), baseMsg);
+ r = moment(m.format(format).toLocaleUpperCase(), format);
+ assert.equal(r.weekday(), m.weekday(), baseMsg + ' upper');
+ r = moment(m.format(format).toLocaleLowerCase(), format);
+ assert.equal(r.weekday(), m.weekday(), baseMsg + ' lower');
+
+ r = moment(m.format(format), format, true);
+ assert.equal(r.weekday(), m.weekday(), baseMsg + ' strict');
+ r = moment(m.format(format).toLocaleUpperCase(), format, true);
+ assert.equal(r.weekday(), m.weekday(), baseMsg + ' upper strict');
+ r = moment(m.format(format).toLocaleLowerCase(), format, true);
+ assert.equal(r.weekday(), m.weekday(), baseMsg + ' lower strict');
+ }
+
+ for (i = 0; i < 7; ++i) {
+ m = moment.utc([2015, i, 15, 18]);
+ tester('dd');
+ tester('ddd');
+ tester('dddd');
+ }
+ });
+ }
+
+ function setupDeprecationHandler(test, moment, scope) {
+ test._expectedDeprecations = null;
+ test._observedDeprecations = null;
+ test._oldSupress = moment.suppressDeprecationWarnings;
+ moment.suppressDeprecationWarnings = true;
+ test.expectedDeprecations = function () {
+ test._expectedDeprecations = arguments;
+ test._observedDeprecations = [];
+ };
+ moment.deprecationHandler = function (name, msg) {
+ var deprecationId = matchedDeprecation(name, msg, test._expectedDeprecations);
+ if (deprecationId === -1) {
+ throw new Error('Unexpected deprecation thrown name=' +
+ name + ' msg=' + msg);
+ }
+ test._observedDeprecations[deprecationId] = 1;
+ };
+ }
+
+ function teardownDeprecationHandler(test, moment, scope) {
+ moment.suppressDeprecationWarnings = test._oldSupress;
+
+ if (test._expectedDeprecations != null) {
+ var missedDeprecations = [];
+ each(test._expectedDeprecations, function (deprecationPattern, id) {
+ if (test._observedDeprecations[id] !== 1) {
+ missedDeprecations.push(deprecationPattern);
+ }
+ });
+ if (missedDeprecations.length !== 0) {
+ throw new Error('Expected deprecation warnings did not happen: ' +
+ missedDeprecations.join(' '));
+ }
+ }
+ }
+
+ function matchedDeprecation(name, msg, deprecations) {
+ if (deprecations == null) {
+ return -1;
+ }
+ for (var i = 0; i < deprecations.length; ++i) {
+ if (name != null && name === deprecations[i]) {
+ return i;
+ }
+ if (msg != null && msg.substring(0, deprecations[i].length) === deprecations[i]) {
+ return i;
+ }
+ }
+ return -1;
+ }
+
/*global QUnit:false*/
var test = QUnit.test;
@@ -45355,11 +71386,13 @@
moment.createFromInputFallback = function (config) {
throw new Error('input not handled by moment: ' + config._i);
};
+ setupDeprecationHandler(test, moment, 'core');
if (lifecycle && lifecycle.setup) {
lifecycle.setup();
}
},
teardown : function () {
+ teardownDeprecationHandler(test, moment, 'core');
if (lifecycle && lifecycle.teardown) {
lifecycle.teardown();
}
@@ -45374,17 +71407,20 @@
moment.createFromInputFallback = function (config) {
throw new Error('input not handled by moment: ' + config._i);
};
+ setupDeprecationHandler(test, moment, 'locale');
if (lifecycle && lifecycle.setup) {
lifecycle.setup();
}
},
teardown : function () {
moment.locale('en');
+ teardownDeprecationHandler(test, moment, 'locale');
if (lifecycle && lifecycle.teardown) {
lifecycle.teardown();
}
}
});
+ defineCommonLocaleTests(name, -1, -1);
}
module('weeks in year');
@@ -45481,6 +71517,224 @@
factory(global.moment)
}(this, function (moment) { 'use strict';
+ function each(array, callback) {
+ var i;
+ for (i = 0; i < array.length; i++) {
+ callback(array[i], i, array);
+ }
+ }
+
+ function objectKeys(obj) {
+ if (Object.keys) {
+ return Object.keys(obj);
+ } else {
+ // IE8
+ var res = [], i;
+ for (i in obj) {
+ if (obj.hasOwnProperty(i)) {
+ res.push(i);
+ }
+ }
+ return res;
+ }
+ }
+
+ // Pick the first defined of two or three arguments.
+ function defaults(a, b, c) {
+ if (a != null) {
+ return a;
+ }
+ if (b != null) {
+ return b;
+ }
+ return c;
+ }
+
+ function defineCommonLocaleTests(locale, options) {
+ test('lenient ordinal parsing', function (assert) {
+ var i, ordinalStr, testMoment;
+ for (i = 1; i <= 31; ++i) {
+ ordinalStr = moment([2014, 0, i]).format('YYYY MM Do');
+ testMoment = moment(ordinalStr, 'YYYY MM Do');
+ assert.equal(testMoment.year(), 2014,
+ 'lenient ordinal parsing ' + i + ' year check');
+ assert.equal(testMoment.month(), 0,
+ 'lenient ordinal parsing ' + i + ' month check');
+ assert.equal(testMoment.date(), i,
+ 'lenient ordinal parsing ' + i + ' date check');
+ }
+ });
+
+ test('lenient ordinal parsing of number', function (assert) {
+ var i, testMoment;
+ for (i = 1; i <= 31; ++i) {
+ testMoment = moment('2014 01 ' + i, 'YYYY MM Do');
+ assert.equal(testMoment.year(), 2014,
+ 'lenient ordinal parsing of number ' + i + ' year check');
+ assert.equal(testMoment.month(), 0,
+ 'lenient ordinal parsing of number ' + i + ' month check');
+ assert.equal(testMoment.date(), i,
+ 'lenient ordinal parsing of number ' + i + ' date check');
+ }
+ });
+
+ test('strict ordinal parsing', function (assert) {
+ var i, ordinalStr, testMoment;
+ for (i = 1; i <= 31; ++i) {
+ ordinalStr = moment([2014, 0, i]).format('YYYY MM Do');
+ testMoment = moment(ordinalStr, 'YYYY MM Do', true);
+ assert.ok(testMoment.isValid(), 'strict ordinal parsing ' + i);
+ }
+ });
+
+ test('meridiem invariant', function (assert) {
+ var h, m, t1, t2;
+ for (h = 0; h < 24; ++h) {
+ for (m = 0; m < 60; m += 15) {
+ t1 = moment.utc([2000, 0, 1, h, m]);
+ t2 = moment.utc(t1.format('A h:mm'), 'A h:mm');
+ assert.equal(t2.format('HH:mm'), t1.format('HH:mm'),
+ 'meridiem at ' + t1.format('HH:mm'));
+ }
+ }
+ });
+
+ test('date format correctness', function (assert) {
+ var data, tokens;
+ data = moment.localeData()._longDateFormat;
+ tokens = objectKeys(data);
+ each(tokens, function (srchToken) {
+ // Check each format string to make sure it does not contain any
+ // tokens that need to be expanded.
+ each(tokens, function (baseToken) {
+ // strip escaped sequences
+ var format = data[baseToken].replace(/(\[[^\]]*\])/g, '');
+ assert.equal(false, !!~format.indexOf(srchToken),
+ 'contains ' + srchToken + ' in ' + baseToken);
+ });
+ });
+ });
+
+ test('month parsing correctness', function (assert) {
+ var i, m;
+
+ if (locale === 'tr') {
+ // I can't fix it :(
+ expect(0);
+ return;
+ }
+ function tester(format) {
+ var r;
+ r = moment(m.format(format), format);
+ assert.equal(r.month(), m.month(), 'month ' + i + ' fmt ' + format);
+ r = moment(m.format(format).toLocaleUpperCase(), format);
+ assert.equal(r.month(), m.month(), 'month ' + i + ' fmt ' + format + ' upper');
+ r = moment(m.format(format).toLocaleLowerCase(), format);
+ assert.equal(r.month(), m.month(), 'month ' + i + ' fmt ' + format + ' lower');
+
+ r = moment(m.format(format), format, true);
+ assert.equal(r.month(), m.month(), 'month ' + i + ' fmt ' + format + ' strict');
+ r = moment(m.format(format).toLocaleUpperCase(), format, true);
+ assert.equal(r.month(), m.month(), 'month ' + i + ' fmt ' + format + ' upper strict');
+ r = moment(m.format(format).toLocaleLowerCase(), format, true);
+ assert.equal(r.month(), m.month(), 'month ' + i + ' fmt ' + format + ' lower strict');
+ }
+
+ for (i = 0; i < 12; ++i) {
+ m = moment([2015, i, 15, 18]);
+ tester('MMM');
+ tester('MMM.');
+ tester('MMMM');
+ tester('MMMM.');
+ }
+ });
+
+ test('weekday parsing correctness', function (assert) {
+ var i, m;
+
+ if (locale === 'tr' || locale === 'az') {
+ // There is a lower-case letter (ı), that converted to upper then
+ // lower changes to i
+ expect(0);
+ return;
+ }
+ function tester(format) {
+ var r, baseMsg = 'weekday ' + m.weekday() + ' fmt ' + format;
+ r = moment(m.format(format), format);
+ assert.equal(r.weekday(), m.weekday(), baseMsg);
+ r = moment(m.format(format).toLocaleUpperCase(), format);
+ assert.equal(r.weekday(), m.weekday(), baseMsg + ' upper');
+ r = moment(m.format(format).toLocaleLowerCase(), format);
+ assert.equal(r.weekday(), m.weekday(), baseMsg + ' lower');
+
+ r = moment(m.format(format), format, true);
+ assert.equal(r.weekday(), m.weekday(), baseMsg + ' strict');
+ r = moment(m.format(format).toLocaleUpperCase(), format, true);
+ assert.equal(r.weekday(), m.weekday(), baseMsg + ' upper strict');
+ r = moment(m.format(format).toLocaleLowerCase(), format, true);
+ assert.equal(r.weekday(), m.weekday(), baseMsg + ' lower strict');
+ }
+
+ for (i = 0; i < 7; ++i) {
+ m = moment.utc([2015, i, 15, 18]);
+ tester('dd');
+ tester('ddd');
+ tester('dddd');
+ }
+ });
+ }
+
+ function setupDeprecationHandler(test, moment, scope) {
+ test._expectedDeprecations = null;
+ test._observedDeprecations = null;
+ test._oldSupress = moment.suppressDeprecationWarnings;
+ moment.suppressDeprecationWarnings = true;
+ test.expectedDeprecations = function () {
+ test._expectedDeprecations = arguments;
+ test._observedDeprecations = [];
+ };
+ moment.deprecationHandler = function (name, msg) {
+ var deprecationId = matchedDeprecation(name, msg, test._expectedDeprecations);
+ if (deprecationId === -1) {
+ throw new Error('Unexpected deprecation thrown name=' +
+ name + ' msg=' + msg);
+ }
+ test._observedDeprecations[deprecationId] = 1;
+ };
+ }
+
+ function teardownDeprecationHandler(test, moment, scope) {
+ moment.suppressDeprecationWarnings = test._oldSupress;
+
+ if (test._expectedDeprecations != null) {
+ var missedDeprecations = [];
+ each(test._expectedDeprecations, function (deprecationPattern, id) {
+ if (test._observedDeprecations[id] !== 1) {
+ missedDeprecations.push(deprecationPattern);
+ }
+ });
+ if (missedDeprecations.length !== 0) {
+ throw new Error('Expected deprecation warnings did not happen: ' +
+ missedDeprecations.join(' '));
+ }
+ }
+ }
+
+ function matchedDeprecation(name, msg, deprecations) {
+ if (deprecations == null) {
+ return -1;
+ }
+ for (var i = 0; i < deprecations.length; ++i) {
+ if (name != null && name === deprecations[i]) {
+ return i;
+ }
+ if (msg != null && msg.substring(0, deprecations[i].length) === deprecations[i]) {
+ return i;
+ }
+ }
+ return -1;
+ }
+
/*global QUnit:false*/
var test = QUnit.test;
@@ -45494,11 +71748,13 @@
moment.createFromInputFallback = function (config) {
throw new Error('input not handled by moment: ' + config._i);
};
+ setupDeprecationHandler(test, moment, 'core');
if (lifecycle && lifecycle.setup) {
lifecycle.setup();
}
},
teardown : function () {
+ teardownDeprecationHandler(test, moment, 'core');
if (lifecycle && lifecycle.teardown) {
lifecycle.teardown();
}
@@ -45513,17 +71769,24 @@
moment.createFromInputFallback = function (config) {
throw new Error('input not handled by moment: ' + config._i);
};
+ setupDeprecationHandler(test, moment, 'locale');
if (lifecycle && lifecycle.setup) {
lifecycle.setup();
}
},
teardown : function () {
moment.locale('en');
+ teardownDeprecationHandler(test, moment, 'locale');
if (lifecycle && lifecycle.teardown) {
lifecycle.teardown();
}
}
});
+ defineCommonLocaleTests(name, -1, -1);
+ }
+
+ function isNearSpringDST() {
+ return moment().subtract(1, 'day').utcOffset() !== moment().add(1, 'day').utcOffset();
}
module('zone switching');
@@ -45541,6 +71804,7 @@
});
test('local to zone, keepLocalTime = true', function (assert) {
+ test.expectedDeprecations('moment().zone');
var m = moment(),
fmt = 'YYYY-DD-MM HH:mm:ss',
z;
@@ -45555,6 +71819,7 @@
});
test('local to zone, keepLocalTime = false', function (assert) {
+ test.expectedDeprecations('moment().zone');
var m = moment(),
z;
@@ -45570,6 +71835,12 @@
});
test('utc to local, keepLocalTime = true', function (assert) {
+ // Don't test near the spring DST transition
+ if (isNearSpringDST()) {
+ expect(0);
+ return;
+ }
+
var um = moment.utc(),
fmt = 'YYYY-DD-MM HH:mm:ss';
@@ -45583,6 +71854,13 @@
});
test('zone to local, keepLocalTime = true', function (assert) {
+ test.expectedDeprecations('moment().zone');
+ // Don't test near the spring DST transition
+ if (isNearSpringDST()) {
+ expect(0);
+ return;
+ }
+
var m = moment(),
fmt = 'YYYY-DD-MM HH:mm:ss',
z;
@@ -45599,6 +71877,7 @@
});
test('zone to local, keepLocalTime = false', function (assert) {
+ test.expectedDeprecations('moment().zone');
var m = moment(),
z;
@@ -45623,6 +71902,224 @@
typeof define === 'function' && define.amd ? define(['../../moment'], factory) :
factory(global.moment)
}(this, function (moment) { 'use strict';
+
+ function each(array, callback) {
+ var i;
+ for (i = 0; i < array.length; i++) {
+ callback(array[i], i, array);
+ }
+ }
+
+ function objectKeys(obj) {
+ if (Object.keys) {
+ return Object.keys(obj);
+ } else {
+ // IE8
+ var res = [], i;
+ for (i in obj) {
+ if (obj.hasOwnProperty(i)) {
+ res.push(i);
+ }
+ }
+ return res;
+ }
+ }
+
+ // Pick the first defined of two or three arguments.
+ function defaults(a, b, c) {
+ if (a != null) {
+ return a;
+ }
+ if (b != null) {
+ return b;
+ }
+ return c;
+ }
+
+ function defineCommonLocaleTests(locale, options) {
+ test('lenient ordinal parsing', function (assert) {
+ var i, ordinalStr, testMoment;
+ for (i = 1; i <= 31; ++i) {
+ ordinalStr = moment([2014, 0, i]).format('YYYY MM Do');
+ testMoment = moment(ordinalStr, 'YYYY MM Do');
+ assert.equal(testMoment.year(), 2014,
+ 'lenient ordinal parsing ' + i + ' year check');
+ assert.equal(testMoment.month(), 0,
+ 'lenient ordinal parsing ' + i + ' month check');
+ assert.equal(testMoment.date(), i,
+ 'lenient ordinal parsing ' + i + ' date check');
+ }
+ });
+
+ test('lenient ordinal parsing of number', function (assert) {
+ var i, testMoment;
+ for (i = 1; i <= 31; ++i) {
+ testMoment = moment('2014 01 ' + i, 'YYYY MM Do');
+ assert.equal(testMoment.year(), 2014,
+ 'lenient ordinal parsing of number ' + i + ' year check');
+ assert.equal(testMoment.month(), 0,
+ 'lenient ordinal parsing of number ' + i + ' month check');
+ assert.equal(testMoment.date(), i,
+ 'lenient ordinal parsing of number ' + i + ' date check');
+ }
+ });
+
+ test('strict ordinal parsing', function (assert) {
+ var i, ordinalStr, testMoment;
+ for (i = 1; i <= 31; ++i) {
+ ordinalStr = moment([2014, 0, i]).format('YYYY MM Do');
+ testMoment = moment(ordinalStr, 'YYYY MM Do', true);
+ assert.ok(testMoment.isValid(), 'strict ordinal parsing ' + i);
+ }
+ });
+
+ test('meridiem invariant', function (assert) {
+ var h, m, t1, t2;
+ for (h = 0; h < 24; ++h) {
+ for (m = 0; m < 60; m += 15) {
+ t1 = moment.utc([2000, 0, 1, h, m]);
+ t2 = moment.utc(t1.format('A h:mm'), 'A h:mm');
+ assert.equal(t2.format('HH:mm'), t1.format('HH:mm'),
+ 'meridiem at ' + t1.format('HH:mm'));
+ }
+ }
+ });
+
+ test('date format correctness', function (assert) {
+ var data, tokens;
+ data = moment.localeData()._longDateFormat;
+ tokens = objectKeys(data);
+ each(tokens, function (srchToken) {
+ // Check each format string to make sure it does not contain any
+ // tokens that need to be expanded.
+ each(tokens, function (baseToken) {
+ // strip escaped sequences
+ var format = data[baseToken].replace(/(\[[^\]]*\])/g, '');
+ assert.equal(false, !!~format.indexOf(srchToken),
+ 'contains ' + srchToken + ' in ' + baseToken);
+ });
+ });
+ });
+
+ test('month parsing correctness', function (assert) {
+ var i, m;
+
+ if (locale === 'tr') {
+ // I can't fix it :(
+ expect(0);
+ return;
+ }
+ function tester(format) {
+ var r;
+ r = moment(m.format(format), format);
+ assert.equal(r.month(), m.month(), 'month ' + i + ' fmt ' + format);
+ r = moment(m.format(format).toLocaleUpperCase(), format);
+ assert.equal(r.month(), m.month(), 'month ' + i + ' fmt ' + format + ' upper');
+ r = moment(m.format(format).toLocaleLowerCase(), format);
+ assert.equal(r.month(), m.month(), 'month ' + i + ' fmt ' + format + ' lower');
+
+ r = moment(m.format(format), format, true);
+ assert.equal(r.month(), m.month(), 'month ' + i + ' fmt ' + format + ' strict');
+ r = moment(m.format(format).toLocaleUpperCase(), format, true);
+ assert.equal(r.month(), m.month(), 'month ' + i + ' fmt ' + format + ' upper strict');
+ r = moment(m.format(format).toLocaleLowerCase(), format, true);
+ assert.equal(r.month(), m.month(), 'month ' + i + ' fmt ' + format + ' lower strict');
+ }
+
+ for (i = 0; i < 12; ++i) {
+ m = moment([2015, i, 15, 18]);
+ tester('MMM');
+ tester('MMM.');
+ tester('MMMM');
+ tester('MMMM.');
+ }
+ });
+
+ test('weekday parsing correctness', function (assert) {
+ var i, m;
+
+ if (locale === 'tr' || locale === 'az') {
+ // There is a lower-case letter (ı), that converted to upper then
+ // lower changes to i
+ expect(0);
+ return;
+ }
+ function tester(format) {
+ var r, baseMsg = 'weekday ' + m.weekday() + ' fmt ' + format;
+ r = moment(m.format(format), format);
+ assert.equal(r.weekday(), m.weekday(), baseMsg);
+ r = moment(m.format(format).toLocaleUpperCase(), format);
+ assert.equal(r.weekday(), m.weekday(), baseMsg + ' upper');
+ r = moment(m.format(format).toLocaleLowerCase(), format);
+ assert.equal(r.weekday(), m.weekday(), baseMsg + ' lower');
+
+ r = moment(m.format(format), format, true);
+ assert.equal(r.weekday(), m.weekday(), baseMsg + ' strict');
+ r = moment(m.format(format).toLocaleUpperCase(), format, true);
+ assert.equal(r.weekday(), m.weekday(), baseMsg + ' upper strict');
+ r = moment(m.format(format).toLocaleLowerCase(), format, true);
+ assert.equal(r.weekday(), m.weekday(), baseMsg + ' lower strict');
+ }
+
+ for (i = 0; i < 7; ++i) {
+ m = moment.utc([2015, i, 15, 18]);
+ tester('dd');
+ tester('ddd');
+ tester('dddd');
+ }
+ });
+ }
+
+ function setupDeprecationHandler(test, moment, scope) {
+ test._expectedDeprecations = null;
+ test._observedDeprecations = null;
+ test._oldSupress = moment.suppressDeprecationWarnings;
+ moment.suppressDeprecationWarnings = true;
+ test.expectedDeprecations = function () {
+ test._expectedDeprecations = arguments;
+ test._observedDeprecations = [];
+ };
+ moment.deprecationHandler = function (name, msg) {
+ var deprecationId = matchedDeprecation(name, msg, test._expectedDeprecations);
+ if (deprecationId === -1) {
+ throw new Error('Unexpected deprecation thrown name=' +
+ name + ' msg=' + msg);
+ }
+ test._observedDeprecations[deprecationId] = 1;
+ };
+ }
+
+ function teardownDeprecationHandler(test, moment, scope) {
+ moment.suppressDeprecationWarnings = test._oldSupress;
+
+ if (test._expectedDeprecations != null) {
+ var missedDeprecations = [];
+ each(test._expectedDeprecations, function (deprecationPattern, id) {
+ if (test._observedDeprecations[id] !== 1) {
+ missedDeprecations.push(deprecationPattern);
+ }
+ });
+ if (missedDeprecations.length !== 0) {
+ throw new Error('Expected deprecation warnings did not happen: ' +
+ missedDeprecations.join(' '));
+ }
+ }
+ }
+
+ function matchedDeprecation(name, msg, deprecations) {
+ if (deprecations == null) {
+ return -1;
+ }
+ for (var i = 0; i < deprecations.length; ++i) {
+ if (name != null && name === deprecations[i]) {
+ return i;
+ }
+ if (msg != null && msg.substring(0, deprecations[i].length) === deprecations[i]) {
+ return i;
+ }
+ }
+ return -1;
+ }
/*global QUnit:false*/
@@ -45637,11 +72134,13 @@
moment.createFromInputFallback = function (config) {
throw new Error('input not handled by moment: ' + config._i);
};
+ setupDeprecationHandler(test, moment, 'core');
if (lifecycle && lifecycle.setup) {
lifecycle.setup();
}
},
teardown : function () {
+ teardownDeprecationHandler(test, moment, 'core');
if (lifecycle && lifecycle.teardown) {
lifecycle.teardown();
}
@@ -45656,20 +72155,27 @@
moment.createFromInputFallback = function (config) {
throw new Error('input not handled by moment: ' + config._i);
};
+ setupDeprecationHandler(test, moment, 'locale');
if (lifecycle && lifecycle.setup) {
lifecycle.setup();
}
},
teardown : function () {
moment.locale('en');
+ teardownDeprecationHandler(test, moment, 'locale');
if (lifecycle && lifecycle.teardown) {
lifecycle.teardown();
}
}
});
- }
-
- module('zones');
+ defineCommonLocaleTests(name, -1, -1);
+ }
+
+ module('zones', {
+ 'setup': function () {
+ test.expectedDeprecations('moment().zone');
+ }
+ });
test('set zone', function (assert) {
var zone = moment();
@@ -46028,6 +72534,7 @@
});
test('zone names', function (assert) {
+ test.expectedDeprecations();
assert.equal(moment().zoneAbbr(), '', 'Local zone abbr should be empty');
assert.equal(moment().format('z'), '', 'Local zone formatted abbr should be empty');
assert.equal(moment().zoneName(), '', 'Local zone name should be empty');
@@ -46090,6 +72597,7 @@
});
test('parse zone with more arguments', function (assert) {
+ test.expectedDeprecations();
var m;
m = moment.parseZone('2013 01 01 05 -13:00', 'YYYY MM DD HH ZZ');
assert.equal(m.format(), '2013-01-01T05:00:00-13:00', 'accept input and format');
diff --git a/moment.d.ts b/moment.d.ts
new file mode 100644
index 0000000..d6a26ed
--- /dev/null
+++ b/moment.d.ts
@@ -0,0 +1,512 @@
+declare function moment(): moment.Moment;
+declare function moment(date: number): moment.Moment;
+declare function moment(date: number[]): moment.Moment;
+declare function moment(date: string, format?: string, strict?: boolean): moment.Moment;
+declare function moment(date: string, format?: string, language?: string, strict?: boolean): moment.Moment;
+declare function moment(date: string, formats: string[], strict?: boolean): moment.Moment;
+declare function moment(date: string, formats: string[], language?: string, strict?: boolean): moment.Moment;
+declare function moment(date: string, specialFormat: () => void, strict?: boolean): moment.Moment;
+declare function moment(date: string, specialFormat: () => void, language?: string, strict?: boolean): moment.Moment;
+declare function moment(date: string, formatsIncludingSpecial: any[], strict?: boolean): moment.Moment;
+declare function moment(date: string, formatsIncludingSpecial: any[], language?: string, strict?: boolean): moment.Moment;
+declare function moment(date: Date): moment.Moment;
+declare function moment(date: moment.Moment): moment.Moment;
+declare function moment(date: Object): moment.Moment;
+
+declare namespace moment {
+ type formatFunction = () => string;
+
+ interface MomentDateObject {
+ years?: number;
+ /* One digit */
+ months?: number;
+ /* Day of the month */
+ date?: number;
+ hours?: number;
+ minutes?: number;
+ seconds?: number;
+ milliseconds?: number;
+ }
+
+ interface MomentLanguageData extends BaseMomentLanguage {
+ /**
+ * @param formatType should be L, LL, LLL, LLLL.
+ */
+ longDateFormat(formatType: string): string;
+ }
+
+ interface Duration {
+ humanize(withSuffix?: boolean): string;
+
+ as(units: string): number;
+
+ milliseconds(): number;
+ asMilliseconds(): number;
+
+ seconds(): number;
+ asSeconds(): number;
+
+ minutes(): number;
+ asMinutes(): number;
+
+ hours(): number;
+ asHours(): number;
+
+ days(): number;
+ asDays(): number;
+
+ months(): number;
+ asMonths(): number;
+
+ years(): number;
+ asYears(): number;
+
+ add(n: number, p: string): Duration;
+ add(n: number): Duration;
+ add(d: Duration): Duration;
+
+ subtract(n: number, p: string): Duration;
+ subtract(n: number): Duration;
+ subtract(d: Duration): Duration;
+
+ toISOString(): string;
+ toJSON(): string;
+ }
+
+ interface MomentInput {
+ /** Year */
+ years?: number;
+ /** Year */
+ year?: number;
+ /** Year */
+ y?: number;
+
+ /** Month */
+ months?: number;
+ /** Month */
+ month?: number;
+ /** Month */
+ M?: number;
+
+ /** Week */
+ weeks?: number;
+ /** Week */
+ week?: number;
+ /** Week */
+ w?: number;
+
+ /** Day/Date */
+ days?: number;
+ /** Day/Date */
+ day?: number;
+ /** Day/Date */
+ date?: number;
+ /** Day/Date */
+ d?: number;
+
+ /** Hour */
+ hours?: number;
+ /** Hour */
+ hour?: number;
+ /** Hour */
+ h?: number;
+
+ /** Minute */
+ minutes?: number;
+ /** Minute */
+ minute?: number;
+ /** Minute */
+ m?: number;
+
+ /** Second */
+ seconds?: number;
+ /** Second */
+ second?: number;
+ /** Second */
+ s?: number;
+
+ /** Millisecond */
+ milliseconds?: number;
+ /** Millisecond */
+ millisecond?: number;
+ /** Millisecond */
+ ms?: number;
+ }
+
+ interface MomentCalendar {
+ lastDay?: string | formatFunction;
+ sameDay?: string | formatFunction;
+ nextDay?: string | formatFunction;
+ lastWeek?: string | formatFunction;
+ nextWeek?: string | formatFunction;
+ sameElse?: string | formatFunction;
+ }
+
+ interface MomentRelativeTime {
+ future: any;
+ past: any;
+ s: any;
+ m: any;
+ mm: any;
+ h: any;
+ hh: any;
+ d: any;
+ dd: any;
+ M: any;
+ MM: any;
+ y: any;
+ yy: any;
+ }
+
+ interface MomentLongDateFormat {
+ L: string;
+ LL: string;
+ LLL: string;
+ LLLL: string;
+ LT: string;
+ LTS: string;
+ l?: string;
+ ll?: string;
+ lll?: string;
+ llll?: string;
+ lt?: string;
+ lts?: string;
+ }
+
+ interface MomentParsingFlags {
+ empty: boolean;
+ unusedTokens: string[];
+ unusedInput: string[];
+ overflow: number;
+ charsLeftOver: number;
+ nullInput: boolean;
+ invalidMonth?: string;
+ invalidFormat: boolean;
+ userInvalidated: boolean;
+ iso: boolean;
+ parsedDateParts: any[];
+ meridiem?: string;
+ }
+
+ interface BaseMomentLanguage {
+ months?: any;
+ monthsShort?: any;
+ weekdays?: any;
+ weekdaysShort?: any;
+ weekdaysMin?: any;
+ relativeTime?: MomentRelativeTime;
+ meridiem?: (hour: number, minute: number, isLowercase: boolean) => string;
+ calendar?: MomentCalendar;
+ ordinal?: (num: number) => string;
+ }
+
+ interface MomentLanguage extends BaseMomentLanguage {
+ longDateFormat?: MomentLongDateFormat;
+ }
+
+ interface Moment {
+ format(format: string): string;
+ format(): string;
+
+ fromNow(withoutSuffix?: boolean): string;
+
+ startOf(unitOfTime: string): Moment;
+ endOf(unitOfTime: string): Moment;
+
+ /**
+ * Mutates the original moment by adding time. (deprecated in 2.8.0)
+ *
+ * @param unitOfTime the unit of time you want to add (eg "years" / "hours" etc)
+ * @param amount the amount you want to add
+ */
+ add(unitOfTime: string, amount: number): Moment;
+ /**
+ * Mutates the original moment by adding time.
+ *
+ * @param amount the amount you want to add
+ * @param unitOfTime the unit of time you want to add (eg "years" / "hours" etc)
+ */
+ add(amount: number, unitOfTime: string): Moment;
+ /**
+ * Mutates the original moment by adding time. Note that the order of arguments can be flipped.
+ *
+ * @param amount the amount you want to add
+ * @param unitOfTime the unit of time you want to add (eg "years" / "hours" etc)
+ */
+ add(amount: string, unitOfTime: string): Moment;
+ /**
+ * Mutates the original moment by adding time.
+ *
+ * @param objectLiteral an object literal that describes multiple time units {days:7,months:1}
+ */
+ add(objectLiteral: MomentInput): Moment;
+ /**
+ * Mutates the original moment by adding time.
+ *
+ * @param duration a length of time
+ */
+ add(duration: Duration): Moment;
+
+ /**
+ * Mutates the original moment by subtracting time. (deprecated in 2.8.0)
+ *
+ * @param unitOfTime the unit of time you want to subtract (eg "years" / "hours" etc)
+ * @param amount the amount you want to subtract
+ */
+ subtract(unitOfTime: string, amount: number): Moment;
+ /**
+ * Mutates the original moment by subtracting time.
+ *
+ * @param unitOfTime the unit of time you want to subtract (eg "years" / "hours" etc)
+ * @param amount the amount you want to subtract
+ */
+ subtract(amount: number, unitOfTime: string): Moment;
+ /**
+ * Mutates the original moment by subtracting time. Note that the order of arguments can be flipped.
+ *
+ * @param amount the amount you want to add
+ * @param unitOfTime the unit of time you want to subtract (eg "years" / "hours" etc)
+ */
+ subtract(amount: string, unitOfTime: string): Moment;
+ /**
+ * Mutates the original moment by subtracting time.
+ *
+ * @param objectLiteral an object literal that describes multiple time units {days:7,months:1}
+ */
+ subtract(objectLiteral: MomentInput): Moment;
+ /**
+ * Mutates the original moment by subtracting time.
+ *
+ * @param duration a length of time
+ */
+ subtract(duration: Duration): Moment;
+
+ calendar(): string;
+ calendar(start: Moment): string;
+ calendar(start: Moment, formats: MomentCalendar): string;
+
+ clone(): Moment;
+
+ /**
+ * @return Unix timestamp, or milliseconds since the epoch.
+ */
+ valueOf(): number;
+
+ local(): Moment; // current date/time in local mode
+
+ utc(): Moment; // current date/time in UTC mode
+
+ isValid(): boolean;
+ invalidAt(): number;
+
+ parsingFlags(): MomentParsingFlags;
+
+ year(y: number): Moment;
+ year(): number;
+ quarter(): number;
+ quarter(q: number): Moment;
+ month(M: number): Moment;
+ month(M: string): Moment;
+ month(): number;
+ day(d: number): Moment;
+ day(d: string): Moment;
+ day(): number;
+ date(d: number): Moment;
+ date(): number;
+ hour(h: number): Moment;
+ hour(): number;
+ hours(h: number): Moment;
+ hours(): number;
+ minute(m: number): Moment;
+ minute(): number;
+ minutes(m: number): Moment;
+ minutes(): number;
+ second(s: number): Moment;
+ second(): number;
+ seconds(s: number): Moment;
+ seconds(): number;
+ millisecond(ms: number): Moment;
+ millisecond(): number;
+ milliseconds(ms: number): Moment;
+ milliseconds(): number;
+ weekday(): number;
+ weekday(d: number): Moment;
+ isoWeekday(): number;
+ isoWeekday(d: number): Moment;
+ weekYear(): number;
+ weekYear(d: number): Moment;
+ isoWeekYear(): number;
+ isoWeekYear(d: number): Moment;
+ week(): number;
+ week(d: number): Moment;
+ weeks(): number;
+ weeks(d: number): Moment;
+ isoWeek(): number;
+ isoWeek(d: number): Moment;
+ isoWeeks(): number;
+ isoWeeks(d: number): Moment;
+ weeksInYear(): number;
+ isoWeeksInYear(): number;
+ dayOfYear(): number;
+ dayOfYear(d: number): Moment;
+
+ from(f: Moment | string | number | Date | number[], suffix?: boolean): string;
+ to(f: Moment | string | number | Date | number[], suffix?: boolean): string;
+ toNow(withoutPrefix?: boolean): string;
+
+ diff(b: Moment): number;
+ diff(b: Moment, unitOfTime: string): number;
+ diff(b: Moment, unitOfTime: string, round: boolean): number;
+
+ toArray(): number[];
+ toDate(): Date;
+ toISOString(): string;
+ toJSON(): string;
+ unix(): number;
+
+ isLeapYear(): boolean;
+ zone(): number;
+ zone(b: number): Moment;
+ zone(b: string): Moment;
+ utcOffset(): number;
+ utcOffset(b: number): Moment;
+ utcOffset(b: string): Moment;
+ daysInMonth(): number;
+ isDST(): boolean;
+
+ isBefore(): boolean;
+ isBefore(b: Moment | string | number | Date | number[], granularity?: string): boolean;
+
+ isAfter(): boolean;
+ isAfter(b: Moment | string | number | Date | number[], granularity?: string): boolean;
+
+ isSame(b: Moment | string | number | Date | number[], granularity?: string): boolean;
+ isBetween(a: Moment | string | number | Date | number[], b: Moment | string | number | Date | number[], granularity?: string, inclusivity?: string): boolean;
+
+ // Deprecated as of 2.8.0.
+ lang(language: string): Moment;
+ lang(reset: boolean): Moment;
+ lang(): MomentLanguage;
+
+ locale(language: string): Moment;
+ locale(reset: boolean): Moment;
+ locale(): string;
+
+ localeData(language: string): Moment;
+ localeData(reset: boolean): Moment;
+ localeData(): MomentLanguage;
+
+ // Deprecated as of 2.7.0.
+ max(date: Moment | string | number | Date | any[]): Moment;
+ max(date: string, format: string): Moment;
+
+ // Deprecated as of 2.7.0.
+ min(date: Moment | string | number | Date | any[]): Moment;
+ min(date: string, format: string): Moment;
+
+ get(unit: string): number;
+ set(unit: string, value: number): Moment;
+ set(objectLiteral: MomentInput): Moment;
+
+ /*This returns an object containing year, month, day-of-month, hour, minute, seconds, milliseconds.*/
+ //Works with version 2.10.5+
+ toObject(): MomentDateObject;
+ }
+
+ export var version: string;
+ export var fn: Moment;
+
+ export function utc(): Moment;
+ export function utc(date: number): Moment;
+ export function utc(date: number[]): Moment;
+ export function utc(date: string, format?: string, strict?: boolean): Moment;
+ export function utc(date: string, format?: string, language?: string, strict?: boolean): Moment;
+ export function utc(date: string, formats: string[], strict?: boolean): Moment;
+ export function utc(date: string, formats: string[], language?: string, strict?: boolean): Moment;
+ export function utc(date: Date): Moment;
+ export function utc(date: Moment): Moment;
+ export function utc(date: Object): Moment;
+
+ export function unix(timestamp: number): Moment;
+
+ export function invalid(parsingFlags?: Object): Moment;
+ export function isMoment(): boolean;
+ export function isMoment(m: any): boolean;
+ export function isDate(m: any): boolean;
+ export function isDuration(): boolean;
+ export function isDuration(d: any): boolean;
+
+ // Deprecated in 2.8.0.
+ export function lang(language?: string): string;
+ export function lang(language?: string, definition?: MomentLanguage): string;
+
+ export function locale(language?: string): string;
+ export function locale(language?: string[]): string;
+ export function locale(language?: string, definition?: MomentLanguage): string;
+
+ export function localeData(language?: string): MomentLanguageData;
+
+ export var longDateFormat: any;
+ export var relativeTime: any;
+ export var meridiem: (hour: number, minute: number, isLowercase: boolean) => string;
+ export var calendar: any;
+ export var ordinal: (num: number) => string;
+
+ export function duration(milliseconds: Number): Duration;
+ export function duration(num: Number, unitOfTime: string): Duration;
+ export function duration(input: MomentInput): Duration;
+ export function duration(object: any): Duration;
+ export function duration(): Duration;
+
+ export function parseZone(date: string): Moment;
+
+ export function months(): string[];
+ export function months(index: number): string;
+ export function months(format: string): string[];
+ export function months(format: string, index: number): string;
+ export function monthsShort(): string[];
+ export function monthsShort(index: number): string;
+ export function monthsShort(format: string): string[];
+ export function monthsShort(format: string, index: number): string;
+
+ export function weekdays(): string[];
+ export function weekdays(index: number): string;
+ export function weekdays(format: string): string[];
+ export function weekdays(format: string, index: number): string;
+ export function weekdays(localeSorted: boolean): string[];
+ export function weekdays(localeSorted: boolean, index: number): string;
+ export function weekdays(localeSorted: boolean, format: string): string[];
+ export function weekdays(localeSorted: boolean, format: string, index: number): string;
+ export function weekdaysShort(): string[];
+ export function weekdaysShort(index: number): string;
+ export function weekdaysShort(format: string): string[];
+ export function weekdaysShort(format: string, index: number): string;
+ export function weekdaysShort(localeSorted: boolean): string[];
+ export function weekdaysShort(localeSorted: boolean, index: number): string;
+ export function weekdaysShort(localeSorted: boolean, format: string): string[];
+ export function weekdaysShort(localeSorted: boolean, format: string, index: number): string;
+ export function weekdaysMin(): string[];
+ export function weekdaysMin(index: number): string;
+ export function weekdaysMin(format: string): string[];
+ export function weekdaysMin(format: string, index: number): string;
+ export function weekdaysMin(localeSorted: boolean): string[];
+ export function weekdaysMin(localeSorted: boolean, index: number): string;
+ export function weekdaysMin(localeSorted: boolean, format: string): string[];
+ export function weekdaysMin(localeSorted: boolean, format: string, index: number): string;
+
+ export function min(...moments: Moment[]): Moment;
+ export function max(...moments: Moment[]): Moment;
+
+ export function normalizeUnits(unit: string): string;
+ export function relativeTimeThreshold(threshold: string): number | boolean;
+ export function relativeTimeThreshold(threshold: string, limit: number): boolean;
+
+ /**
+ * Constant used to enable explicit ISO_8601 format parsing.
+ */
+ export function ISO_8601(): void;
+
+ export var defaultFormat: string;
+}
+
+export = moment;
diff --git a/moment.js b/moment.js
index 91c7490..ed94e44 100644
--- a/moment.js
+++ b/moment.js
@@ -1,5 +1,5 @@
//! moment.js
-//! version : 2.11.0
+//! version : 2.13.0
//! authors : Tim Wood, Iskren Chernev, Moment.js contributors
//! license : MIT
//! momentjs.com
@@ -23,7 +23,7 @@
}
function isArray(input) {
- return Object.prototype.toString.call(input) === '[object Array]';
+ return input instanceof Array || Object.prototype.toString.call(input) === '[object Array]';
}
function isDate(input) {
@@ -76,7 +76,9 @@
invalidMonth : null,
invalidFormat : false,
userInvalidated : false,
- iso : false
+ iso : false,
+ parsedDateParts : [],
+ meridiem : null
};
}
@@ -87,9 +89,30 @@
return m._pf;
}
+ var some;
+ if (Array.prototype.some) {
+ some = Array.prototype.some;
+ } else {
+ some = function (fun) {
+ var t = Object(this);
+ var len = t.length >>> 0;
+
+ for (var i = 0; i < len; i++) {
+ if (i in t && fun.call(this, t[i], i, t)) {
+ return true;
+ }
+ }
+
+ return false;
+ };
+ }
+
function valid__isValid(m) {
if (m._isValid == null) {
var flags = getParsingFlags(m);
+ var parsedParts = some.call(flags.parsedDateParts, function (i) {
+ return i != null;
+ });
m._isValid = !isNaN(m._d.getTime()) &&
flags.overflow < 0 &&
!flags.empty &&
@@ -97,7 +120,8 @@
!flags.invalidWeekday &&
!flags.nullInput &&
!flags.invalidFormat &&
- !flags.userInvalidated;
+ !flags.userInvalidated &&
+ (!flags.meridiem || (flags.meridiem && parsedParts));
if (m._strict) {
m._isValid = m._isValid &&
@@ -229,7 +253,105 @@
return diffs + lengthDiff;
}
- function Locale() {
+ function warn(msg) {
+ if (utils_hooks__hooks.suppressDeprecationWarnings === false &&
+ (typeof console !== 'undefined') && console.warn) {
+ console.warn('Deprecation warning: ' + msg);
+ }
+ }
+
+ function deprecate(msg, fn) {
+ var firstTime = true;
+
+ return extend(function () {
+ if (utils_hooks__hooks.deprecationHandler != null) {
+ utils_hooks__hooks.deprecationHandler(null, msg);
+ }
+ if (firstTime) {
+ warn(msg + '\nArguments: ' + Array.prototype.slice.call(arguments).join(', ') + '\n' + (new Error()).stack);
+ firstTime = false;
+ }
+ return fn.apply(this, arguments);
+ }, fn);
+ }
+
+ var deprecations = {};
+
+ function deprecateSimple(name, msg) {
+ if (utils_hooks__hooks.deprecationHandler != null) {
+ utils_hooks__hooks.deprecationHandler(name, msg);
+ }
+ if (!deprecations[name]) {
+ warn(msg);
+ deprecations[name] = true;
+ }
+ }
+
+ utils_hooks__hooks.suppressDeprecationWarnings = false;
+ utils_hooks__hooks.deprecationHandler = null;
+
+ function isFunction(input) {
+ return input instanceof Function || Object.prototype.toString.call(input) === '[object Function]';
+ }
+
+ function isObject(input) {
+ return Object.prototype.toString.call(input) === '[object Object]';
+ }
+
+ function locale_set__set (config) {
+ var prop, i;
+ for (i in config) {
+ prop = config[i];
+ if (isFunction(prop)) {
+ this[i] = prop;
+ } else {
+ this['_' + i] = prop;
+ }
+ }
+ this._config = config;
+ // Lenient ordinal parsing accepts just a number in addition to
+ // number + (possibly) stuff coming from _ordinalParseLenient.
+ this._ordinalParseLenient = new RegExp(this._ordinalParse.source + '|' + (/\d{1,2}/).source);
+ }
+
+ function mergeConfigs(parentConfig, childConfig) {
+ var res = extend({}, parentConfig), prop;
+ for (prop in childConfig) {
+ if (hasOwnProp(childConfig, prop)) {
+ if (isObject(parentConfig[prop]) && isObject(childConfig[prop])) {
+ res[prop] = {};
+ extend(res[prop], parentConfig[prop]);
+ extend(res[prop], childConfig[prop]);
+ } else if (childConfig[prop] != null) {
+ res[prop] = childConfig[prop];
+ } else {
+ delete res[prop];
+ }
+ }
+ }
+ return res;
+ }
+
+ function Locale(config) {
+ if (config != null) {
+ this.set(config);
+ }
+ }
+
+ var keys;
+
+ if (Object.keys) {
+ keys = Object.keys;
+ } else {
+ keys = function (obj) {
+ var i, res = [];
+ for (i in obj) {
+ if (hasOwnProp(obj, i)) {
+ res.push(i);
+ }
+ }
+ return res;
+ };
}
// internal storage for locale config files
@@ -270,7 +392,7 @@
function loadLocale(name) {
var oldLocale = null;
// TODO: Find a better way to register and load all the locales in Node
- if (!locales[name] && !isUndefined(module) &&
+ if (!locales[name] && (typeof module !== 'undefined') &&
module && module.exports) {
try {
oldLocale = globalLocale._abbr;
@@ -305,11 +427,25 @@
return globalLocale._abbr;
}
- function defineLocale (name, values) {
- if (values !== null) {
- values.abbr = name;
- locales[name] = locales[name] || new Locale();
- locales[name].set(values);
+ function defineLocale (name, config) {
+ if (config !== null) {
+ config.abbr = name;
+ if (locales[name] != null) {
+ deprecateSimple('defineLocaleOverride',
+ 'use moment.updateLocale(localeName, config) to change ' +
+ 'an existing locale. moment.defineLocale(localeName, ' +
+ 'config) should only be used for creating a new locale');
+ config = mergeConfigs(locales[name]._config, config);
+ } else if (config.parentLocale != null) {
+ if (locales[config.parentLocale] != null) {
+ config = mergeConfigs(locales[config.parentLocale]._config, config);
+ } else {
+ // treat as if there is no base config
+ deprecateSimple('parentLocaleUndefined',
+ 'specified parentLocale is not defined yet');
+ }
+ }
+ locales[name] = new Locale(config);
// backwards compat for now: also set the locale
locale_locales__getSetGlobalLocale(name);
@@ -320,6 +456,31 @@
delete locales[name];
return null;
}
+ }
+
+ function updateLocale(name, config) {
+ if (config != null) {
+ var locale;
+ if (locales[name] != null) {
+ config = mergeConfigs(locales[name]._config, config);
+ }
+ locale = new Locale(config);
+ locale.parentLocale = locales[name];
+ locales[name] = locale;
+
+ // backwards compat for now: also set the locale
+ locale_locales__getSetGlobalLocale(name);
+ } else {
+ // pass null for config to unupdate, useful for tests
+ if (locales[name] != null) {
+ if (locales[name].parentLocale != null) {
+ locales[name] = locales[name].parentLocale;
+ } else if (locales[name] != null) {
+ delete locales[name];
+ }
+ }
+ }
+ return locales[name];
}
// returns locale data
@@ -344,6 +505,10 @@
}
return chooseLocale(key);
+ }
+
+ function locale_locales__listLocales() {
+ return keys(locales);
}
var aliases = {};
@@ -372,10 +537,6 @@
}
return normalizedInput;
- }
-
- function isFunction(input) {
- return input instanceof Function || Object.prototype.toString.call(input) === '[object Function]';
}
function makeGetSet (unit, keepTime) {
@@ -426,7 +587,7 @@
Math.pow(10, Math.max(0, zerosToFill)).toString().substr(1) + absNumber;
}
- var formattingTokens = /(\[[^\[]*\])|(\\)?([Hh]mm(ss)?|Mo|MM?M?M?|Do|DDDo|DD?D?D?|ddd?d?|do?|w[o|w]?|W[o|W]?|Qo?|YYYYYY|YYYYY|YYYY|YY|gg(ggg?)?|GG(GGG?)?|e|E|a|A|hh?|HH?|mm?|ss?|S{1,9}|x|X|zz?|ZZ?|.)/g;
+ var formattingTokens = /(\[[^\[]*\])|(\\)?([Hh]mm(ss)?|Mo|MM?M?M?|Do|DDDo|DD?D?D?|ddd?d?|do?|w[o|w]?|W[o|W]?|Qo?|YYYYYY|YYYYY|YYYY|YY|gg(ggg?)?|GG(GGG?)?|e|E|a|A|hh?|HH?|kk?|mm?|ss?|S{1,9}|x|X|zz?|ZZ?|.)/g;
var localFormattingTokens = /(\[[^\[]*\])|(\\)?(LTS|LT|LL?L?L?|l{1,4})/g;
@@ -479,7 +640,7 @@
}
return function (mom) {
- var output = '';
+ var output = '', i;
for (i = 0; i < length; i++) {
output += array[i] instanceof Function ? array[i].call(mom, format) : array[i];
}
@@ -538,13 +699,13 @@
// any word (or two) characters or numbers including two/three word month in arabic.
// includes scottish gaelic two word and hyphenated months
- var matchWord = /[0-9]*(a[mn]\s?)?['a-z\u00A0-\u05FF\u0700-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF\-]+|[\u0600-\u06FF\/]+(\s*?[\u0600-\u06FF]+){1,2}/i;
+ var matchWord = /[0-9]*['a-z\u00A0-\u05FF\u0700-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF]+|[\u0600-\u06FF\/]+(\s*?[\u0600-\u06FF]+){1,2}/i;
var regexes = {};
function addRegexToken (token, regex, strictRegex) {
- regexes[token] = isFunction(regex) ? regex : function (isStrict) {
+ regexes[token] = isFunction(regex) ? regex : function (isStrict, localeData) {
return (isStrict && strictRegex) ? strictRegex : regex;
};
}
@@ -559,9 +720,13 @@
// Code from http://stackoverflow.com/questions/3561493/is-there-a-regexp-escape-function-in-javascript
function unescapeFormat(s) {
- return s.replace('\\', '').replace(/\\(\[)|\\(\])|\[([^\]\[]*)\]|\\(.)/g, function (matched, p1, p2, p3, p4) {
+ return regexEscape(s.replace('\\', '').replace(/\\(\[)|\\(\])|\[([^\]\[]*)\]|\\(.)/g, function (matched, p1, p2, p3, p4) {
return p1 || p2 || p3 || p4;
- }).replace(/[-\/\\^$*+?.()|[\]{}]/g, '\\$&');
+ }));
+ }
+
+ function regexEscape(s) {
+ return s.replace(/[-\/\\^$*+?.()|[\]{}]/g, '\\$&');
}
var tokens = {};
@@ -604,6 +769,23 @@
var WEEK = 7;
var WEEKDAY = 8;
+ var indexOf;
+
+ if (Array.prototype.indexOf) {
+ indexOf = Array.prototype.indexOf;
+ } else {
+ indexOf = function (o) {
+ // I know
+ var i;
+ for (i = 0; i < this.length; ++i) {
+ if (this[i] === o) {
+ return i;
+ }
+ }
+ return -1;
+ };
+ }
+
function daysInMonth(year, month) {
return new Date(Date.UTC(year, month + 1, 0)).getUTCDate();
}
@@ -630,8 +812,12 @@
addRegexToken('M', match1to2);
addRegexToken('MM', match1to2, match2);
- addRegexToken('MMM', matchWord);
- addRegexToken('MMMM', matchWord);
+ addRegexToken('MMM', function (isStrict, locale) {
+ return locale.monthsShortRegex(isStrict);
+ });
+ addRegexToken('MMMM', function (isStrict, locale) {
+ return locale.monthsRegex(isStrict);
+ });
addParseToken(['M', 'MM'], function (input, array) {
array[MONTH] = toInt(input) - 1;
@@ -656,14 +842,59 @@
this._months[MONTHS_IN_FORMAT.test(format) ? 'format' : 'standalone'][m.month()];
}
- var defaultLocaleMonthsShort = 'Jan_Feb_Mar_Apr_May_Jun_Jul_Aug_Sept_Oct_Nov_Dec'.split('_');
+ var defaultLocaleMonthsShort = 'Jan_Feb_Mar_Apr_May_Jun_Jul_Aug_Sep_Oct_Nov_Dec'.split('_');
function localeMonthsShort (m, format) {
return isArray(this._monthsShort) ? this._monthsShort[m.month()] :
this._monthsShort[MONTHS_IN_FORMAT.test(format) ? 'format' : 'standalone'][m.month()];
}
+ function units_month__handleStrictParse(monthName, format, strict) {
+ var i, ii, mom, llc = monthName.toLocaleLowerCase();
+ if (!this._monthsParse) {
+ // this is not used
+ this._monthsParse = [];
+ this._longMonthsParse = [];
+ this._shortMonthsParse = [];
+ for (i = 0; i < 12; ++i) {
+ mom = create_utc__createUTC([2000, i]);
+ this._shortMonthsParse[i] = this.monthsShort(mom, '').toLocaleLowerCase();
+ this._longMonthsParse[i] = this.months(mom, '').toLocaleLowerCase();
+ }
+ }
+
+ if (strict) {
+ if (format === 'MMM') {
+ ii = indexOf.call(this._shortMonthsParse, llc);
+ return ii !== -1 ? ii : null;
+ } else {
+ ii = indexOf.call(this._longMonthsParse, llc);
+ return ii !== -1 ? ii : null;
+ }
+ } else {
+ if (format === 'MMM') {
+ ii = indexOf.call(this._shortMonthsParse, llc);
+ if (ii !== -1) {
+ return ii;
+ }
+ ii = indexOf.call(this._longMonthsParse, llc);
+ return ii !== -1 ? ii : null;
+ } else {
+ ii = indexOf.call(this._longMonthsParse, llc);
+ if (ii !== -1) {
+ return ii;
+ }
+ ii = indexOf.call(this._shortMonthsParse, llc);
+ return ii !== -1 ? ii : null;
+ }
+ }
+ }
+
function localeMonthsParse (monthName, format, strict) {
var i, mom, regex;
+
+ if (this._monthsParseExact) {
+ return units_month__handleStrictParse.call(this, monthName, format, strict);
+ }
if (!this._monthsParse) {
this._monthsParse = [];
@@ -671,6 +902,9 @@
this._shortMonthsParse = [];
}
+ // TODO: add sorting
+ // Sorting makes sure if one month (or abbr) is a prefix of another
+ // see sorting in computeMonthsParse
for (i = 0; i < 12; i++) {
// make the regex if we don't have it already
mom = create_utc__createUTC([2000, i]);
@@ -703,12 +937,15 @@
return mom;
}
- // TODO: Move this out of here!
if (typeof value === 'string') {
- value = mom.localeData().monthsParse(value);
- // TODO: Another silent failure?
- if (typeof value !== 'number') {
- return mom;
+ if (/^\d+$/.test(value)) {
+ value = toInt(value);
+ } else {
+ value = mom.localeData().monthsParse(value);
+ // TODO: Another silent failure?
+ if (typeof value !== 'number') {
+ return mom;
+ }
}
}
@@ -729,6 +966,72 @@
function getDaysInMonth () {
return daysInMonth(this.year(), this.month());
+ }
+
+ var defaultMonthsShortRegex = matchWord;
+ function monthsShortRegex (isStrict) {
+ if (this._monthsParseExact) {
+ if (!hasOwnProp(this, '_monthsRegex')) {
+ computeMonthsParse.call(this);
+ }
+ if (isStrict) {
+ return this._monthsShortStrictRegex;
+ } else {
+ return this._monthsShortRegex;
+ }
+ } else {
+ return this._monthsShortStrictRegex && isStrict ?
+ this._monthsShortStrictRegex : this._monthsShortRegex;
+ }
+ }
+
+ var defaultMonthsRegex = matchWord;
+ function monthsRegex (isStrict) {
+ if (this._monthsParseExact) {
+ if (!hasOwnProp(this, '_monthsRegex')) {
+ computeMonthsParse.call(this);
+ }
+ if (isStrict) {
+ return this._monthsStrictRegex;
+ } else {
+ return this._monthsRegex;
+ }
+ } else {
+ return this._monthsStrictRegex && isStrict ?
+ this._monthsStrictRegex : this._monthsRegex;
+ }
+ }
+
+ function computeMonthsParse () {
+ function cmpLenRev(a, b) {
+ return b.length - a.length;
+ }
+
+ var shortPieces = [], longPieces = [], mixedPieces = [],
+ i, mom;
+ for (i = 0; i < 12; i++) {
+ // make the regex if we don't have it already
+ mom = create_utc__createUTC([2000, i]);
+ shortPieces.push(this.monthsShort(mom, ''));
+ longPieces.push(this.months(mom, ''));
+ mixedPieces.push(this.months(mom, ''));
+ mixedPieces.push(this.monthsShort(mom, ''));
+ }
+ // Sorting makes sure if one month (or abbr) is a prefix of another it
+ // will match the longer piece.
+ shortPieces.sort(cmpLenRev);
+ longPieces.sort(cmpLenRev);
+ mixedPieces.sort(cmpLenRev);
+ for (i = 0; i < 12; i++) {
+ shortPieces[i] = regexEscape(shortPieces[i]);
+ longPieces[i] = regexEscape(longPieces[i]);
+ mixedPieces[i] = regexEscape(mixedPieces[i]);
+ }
+
+ this._monthsRegex = new RegExp('^(' + mixedPieces.join('|') + ')', 'i');
+ this._monthsShortRegex = this._monthsRegex;
+ this._monthsStrictRegex = new RegExp('^(' + longPieces.join('|') + ')', 'i');
+ this._monthsShortStrictRegex = new RegExp('^(' + shortPieces.join('|') + ')', 'i');
}
function checkOverflow (m) {
@@ -760,35 +1063,6 @@
return m;
}
-
- function warn(msg) {
- if (utils_hooks__hooks.suppressDeprecationWarnings === false && !isUndefined(console) && console.warn) {
- console.warn('Deprecation warning: ' + msg);
- }
- }
-
- function deprecate(msg, fn) {
- var firstTime = true;
-
- return extend(function () {
- if (firstTime) {
- warn(msg + '\nArguments: ' + Array.prototype.slice.call(arguments).join(', ') + '\n' + (new Error()).stack);
- firstTime = false;
- }
- return fn.apply(this, arguments);
- }, fn);
- }
-
- var deprecations = {};
-
- function deprecateSimple(name, msg) {
- if (!deprecations[name]) {
- warn(msg);
- deprecations[name] = true;
- }
- }
-
- utils_hooks__hooks.suppressDeprecationWarnings = false;
// iso 8601 regex
// 0000-00-00 0000-W00 or 0000-W00-0 + T + 00 or 00:00 or 00:00:00 or 00:00:00.000 + +00:00 or +0000 or +00)
@@ -930,6 +1204,11 @@
// FORMATTING
+ addFormatToken('Y', 0, 0, function () {
+ var y = this.year();
+ return y <= 9999 ? '' + y : '+' + y;
+ });
+
addFormatToken(0, ['YY', 2], 0, function () {
return this.year() % 100;
});
@@ -957,6 +1236,9 @@
addParseToken('YY', function (input, array) {
array[YEAR] = utils_hooks__hooks.parseTwoDigitYear(input);
});
+ addParseToken('Y', function (input, array) {
+ array[YEAR] = parseInt(input, 10);
+ });
// HELPERS
@@ -976,7 +1258,7 @@
// MOMENTS
- var getSetYear = makeGetSet('FullYear', false);
+ var getSetYear = makeGetSet('FullYear', true);
function getIsLeapYear () {
return isLeapYear(this.year());
@@ -1208,6 +1490,8 @@
for (i = 0; i < tokens.length; i++) {
token = tokens[i];
parsedInput = (string.match(getParseRegexForToken(token, config)) || [])[0];
+ // console.log('token', token, 'parsedInput', parsedInput,
+ // 'regex', getParseRegexForToken(token, config));
if (parsedInput) {
skipped = string.substr(0, string.indexOf(parsedInput));
if (skipped.length > 0) {
@@ -1243,6 +1527,9 @@
config._a[HOUR] > 0) {
getParsingFlags(config).bigHour = undefined;
}
+
+ getParsingFlags(config).parsedDateParts = config._a.slice(0);
+ getParsingFlags(config).meridiem = config._meridiem;
// handle meridiem
config._a[HOUR] = meridiemFixWrap(config._locale, config._a[HOUR], config._meridiem);
@@ -1383,7 +1670,7 @@
if (input === undefined) {
config._d = new Date(utils_hooks__hooks.now());
} else if (isDate(input)) {
- config._d = new Date(+input);
+ config._d = new Date(input.valueOf());
} else if (typeof input === 'string') {
configFromString(config);
} else if (isArray(input)) {
@@ -1425,7 +1712,7 @@
}
var prototypeMin = deprecate(
- 'moment().min is deprecated, use moment.min instead. https://github.com/moment/moment/issues/1548',
+ 'moment().min is deprecated, use moment.max instead. https://github.com/moment/moment/issues/1548',
function () {
var other = local__createLocal.apply(null, arguments);
if (this.isValid() && other.isValid()) {
@@ -1437,7 +1724,7 @@
);
var prototypeMax = deprecate(
- 'moment().max is deprecated, use moment.max instead. https://github.com/moment/moment/issues/1548',
+ 'moment().max is deprecated, use moment.min instead. https://github.com/moment/moment/issues/1548',
function () {
var other = local__createLocal.apply(null, arguments);
if (this.isValid() && other.isValid()) {
@@ -1483,8 +1770,8 @@
return pickBy('isAfter', args);
}
- var now = Date.now || function () {
- return +(new Date());
+ var now = function () {
+ return Date.now ? Date.now() : +(new Date());
};
function Duration (duration) {
@@ -1503,7 +1790,7 @@
this._milliseconds = +milliseconds +
seconds * 1e3 + // 1000
minutes * 6e4 + // 1000 * 60
- hours * 36e5; // 1000 * 60 * 60
+ hours * 1000 * 60 * 60; //using 1000 * 60 * 60 instead of 36e5 to avoid floating point rounding errors https://github.com/moment/moment/issues/2978
// Because of dateAddRemove treats 24 hours as different from a
// day when working around DST, we need to store them separately
this._days = +days +
@@ -1573,9 +1860,9 @@
var res, diff;
if (model._isUTC) {
res = model.clone();
- diff = (isMoment(input) || isDate(input) ? +input : +local__createLocal(input)) - (+res);
+ diff = (isMoment(input) || isDate(input) ? input.valueOf() : local__createLocal(input).valueOf()) - res.valueOf();
// Use low-level api, because this fn is low-level api.
- res._d.setTime(+res._d + diff);
+ res._d.setTime(res._d.valueOf() + diff);
utils_hooks__hooks.updateOffset(res, false);
return res;
} else {
@@ -1731,11 +2018,12 @@
}
// ASP.NET json date format regex
- var aspNetRegex = /(\-)?(?:(\d*)[. ])?(\d+)\:(\d+)(?:\:(\d+)\.?(\d{3})?)?/;
+ var aspNetRegex = /^(\-)?(?:(\d*)[. ])?(\d+)\:(\d+)(?:\:(\d+)\.?(\d{3})?\d*)?$/;
// from http://docs.closure-library.googlecode.com/git/closure_goog_date_date.js.source.html
// somewhat more in line with 4.4.3.2 2004 spec, but allows decimal anywhere
- var isoRegex = /^(-)?P(?:(?:([0-9,.]*)Y)?(?:([0-9,.]*)M)?(?:([0-9,.]*)D)?(?:T(?:([0-9,.]*)H)?(?:([0-9,.]*)M)?(?:([0-9,.]*)S)?)?|([0-9,.]*)W)$/;
+ // and further modified to allow for strings containing both week and day
+ var isoRegex = /^(-)?P(?:(-?[0-9,.]*)Y)?(?:(-?[0-9,.]*)M)?(?:(-?[0-9,.]*)W)?(?:(-?[0-9,.]*)D)?(?:T(?:(-?[0-9,.]*)H)?(?:(-?[0-9,.]*)M)?(?:(-?[0-9,.]*)S)?)?$/;
function create__createDuration (input, key) {
var duration = input,
@@ -1773,11 +2061,11 @@
duration = {
y : parseIso(match[2], sign),
M : parseIso(match[3], sign),
- d : parseIso(match[4], sign),
- h : parseIso(match[5], sign),
- m : parseIso(match[6], sign),
- s : parseIso(match[7], sign),
- w : parseIso(match[8], sign)
+ w : parseIso(match[4], sign),
+ d : parseIso(match[5], sign),
+ h : parseIso(match[6], sign),
+ m : parseIso(match[7], sign),
+ s : parseIso(match[8], sign)
};
} else if (duration == null) {// checks for null or undefined
duration = {};
@@ -1839,6 +2127,14 @@
}
return res;
+ }
+
+ function absRound (number) {
+ if (number < 0) {
+ return Math.round(-1 * number) * -1;
+ } else {
+ return Math.round(number);
+ }
}
// TODO: remove 'name' arg after deprecation is removed
@@ -1860,8 +2156,8 @@
function add_subtract__addSubtract (mom, duration, isAdding, updateOffset) {
var milliseconds = duration._milliseconds,
- days = duration._days,
- months = duration._months;
+ days = absRound(duration._days),
+ months = absRound(duration._months);
if (!mom.isValid()) {
// No op
@@ -1871,7 +2167,7 @@
updateOffset = updateOffset == null ? true : updateOffset;
if (milliseconds) {
- mom._d.setTime(+mom._d + milliseconds * isAdding);
+ mom._d.setTime(mom._d.valueOf() + milliseconds * isAdding);
}
if (days) {
get_set__set(mom, 'Date', get_set__get(mom, 'Date') + days * isAdding);
@@ -1916,9 +2212,9 @@
}
units = normalizeUnits(!isUndefined(units) ? units : 'millisecond');
if (units === 'millisecond') {
- return +this > +localInput;
- } else {
- return +localInput < +this.clone().startOf(units);
+ return this.valueOf() > localInput.valueOf();
+ } else {
+ return localInput.valueOf() < this.clone().startOf(units).valueOf();
}
}
@@ -1929,14 +2225,16 @@
}
units = normalizeUnits(!isUndefined(units) ? units : 'millisecond');
if (units === 'millisecond') {
- return +this < +localInput;
- } else {
- return +this.clone().endOf(units) < +localInput;
- }
- }
-
- function isBetween (from, to, units) {
- return this.isAfter(from, units) && this.isBefore(to, units);
+ return this.valueOf() < localInput.valueOf();
+ } else {
+ return this.clone().endOf(units).valueOf() < localInput.valueOf();
+ }
+ }
+
+ function isBetween (from, to, units, inclusivity) {
+ inclusivity = inclusivity || '()';
+ return (inclusivity[0] === '(' ? this.isAfter(from, units) : !this.isBefore(from, units)) &&
+ (inclusivity[1] === ')' ? this.isBefore(to, units) : !this.isAfter(to, units));
}
function isSame (input, units) {
@@ -1947,10 +2245,10 @@
}
units = normalizeUnits(units || 'millisecond');
if (units === 'millisecond') {
- return +this === +localInput;
- } else {
- inputMs = +localInput;
- return +(this.clone().startOf(units)) <= inputMs && inputMs <= +(this.clone().endOf(units));
+ return this.valueOf() === localInput.valueOf();
+ } else {
+ inputMs = localInput.valueOf();
+ return this.clone().startOf(units).valueOf() <= inputMs && inputMs <= this.clone().endOf(units).valueOf();
}
}
@@ -2017,10 +2315,12 @@
adjust = (b - anchor) / (anchor2 - anchor);
}
- return -(wholeMonthDiff + adjust);
+ //check for negative zero, return zero if negative zero
+ return -(wholeMonthDiff + adjust) || 0;
}
utils_hooks__hooks.defaultFormat = 'YYYY-MM-DDTHH:mm:ssZ';
+ utils_hooks__hooks.defaultFormatUtc = 'YYYY-MM-DDTHH:mm:ss[Z]';
function toString () {
return this.clone().locale('en').format('ddd MMM DD YYYY HH:mm:ss [GMT]ZZ');
@@ -2041,7 +2341,10 @@
}
function format (inputString) {
- var output = formatMoment(this, inputString || utils_hooks__hooks.defaultFormat);
+ if (!inputString) {
+ inputString = this.isUtc() ? utils_hooks__hooks.defaultFormatUtc : utils_hooks__hooks.defaultFormat;
+ }
+ var output = formatMoment(this, inputString);
return this.localeData().postformat(output);
}
@@ -2120,6 +2423,7 @@
case 'week':
case 'isoWeek':
case 'day':
+ case 'date':
this.hours(0);
/* falls through */
case 'hour':
@@ -2153,19 +2457,25 @@
if (units === undefined || units === 'millisecond') {
return this;
}
+
+ // 'date' is an alias for 'day', so it should be considered as such.
+ if (units === 'date') {
+ units = 'day';
+ }
+
return this.startOf(units).add(1, (units === 'isoWeek' ? 'week' : units)).subtract(1, 'ms');
}
function to_type__valueOf () {
- return +this._d - ((this._offset || 0) * 60000);
+ return this._d.valueOf() - ((this._offset || 0) * 60000);
}
function unix () {
- return Math.floor(+this / 1000);
+ return Math.floor(this.valueOf() / 1000);
}
function toDate () {
- return this._offset ? new Date(+this) : this._d;
+ return this._offset ? new Date(this.valueOf()) : this._d;
}
function toArray () {
@@ -2187,8 +2497,8 @@
}
function toJSON () {
- // JSON.stringify(new Date(NaN)) === 'null'
- return this.isValid() ? this.toISOString() : 'null';
+ // new Date(NaN).toJSON() === null
+ return this.isValid() ? this.toISOString() : null;
}
function moment_valid__isValid () {
@@ -2298,7 +2608,6 @@
var dayOfYearData = dayOfYearFromWeeks(weekYear, week, weekday, dow, doy),
date = createUTCDate(dayOfYearData.year, 0, dayOfYearData.dayOfYear);
- // console.log("got", weekYear, week, weekday, "set", date.toISOString());
this.year(date.getUTCFullYear());
this.month(date.getUTCMonth());
this.date(date.getUTCDate());
@@ -2435,9 +2744,15 @@
addRegexToken('d', match1to2);
addRegexToken('e', match1to2);
addRegexToken('E', match1to2);
- addRegexToken('dd', matchWord);
- addRegexToken('ddd', matchWord);
- addRegexToken('dddd', matchWord);
+ addRegexToken('dd', function (isStrict, locale) {
+ return locale.weekdaysMinRegex(isStrict);
+ });
+ addRegexToken('ddd', function (isStrict, locale) {
+ return locale.weekdaysShortRegex(isStrict);
+ });
+ addRegexToken('dddd', function (isStrict, locale) {
+ return locale.weekdaysRegex(isStrict);
+ });
addWeekParseToken(['dd', 'ddd', 'dddd'], function (input, week, config, token) {
var weekday = config._locale.weekdaysParse(input, token, config._strict);
@@ -2490,8 +2805,76 @@
return this._weekdaysMin[m.day()];
}
+ function day_of_week__handleStrictParse(weekdayName, format, strict) {
+ var i, ii, mom, llc = weekdayName.toLocaleLowerCase();
+ if (!this._weekdaysParse) {
+ this._weekdaysParse = [];
+ this._shortWeekdaysParse = [];
+ this._minWeekdaysParse = [];
+
+ for (i = 0; i < 7; ++i) {
+ mom = create_utc__createUTC([2000, 1]).day(i);
+ this._minWeekdaysParse[i] = this.weekdaysMin(mom, '').toLocaleLowerCase();
+ this._shortWeekdaysParse[i] = this.weekdaysShort(mom, '').toLocaleLowerCase();
+ this._weekdaysParse[i] = this.weekdays(mom, '').toLocaleLowerCase();
+ }
+ }
+
+ if (strict) {
+ if (format === 'dddd') {
+ ii = indexOf.call(this._weekdaysParse, llc);
+ return ii !== -1 ? ii : null;
+ } else if (format === 'ddd') {
+ ii = indexOf.call(this._shortWeekdaysParse, llc);
+ return ii !== -1 ? ii : null;
+ } else {
+ ii = indexOf.call(this._minWeekdaysParse, llc);
+ return ii !== -1 ? ii : null;
+ }
+ } else {
+ if (format === 'dddd') {
+ ii = indexOf.call(this._weekdaysParse, llc);
+ if (ii !== -1) {
+ return ii;
+ }
+ ii = indexOf.call(this._shortWeekdaysParse, llc);
+ if (ii !== -1) {
+ return ii;
+ }
+ ii = indexOf.call(this._minWeekdaysParse, llc);
+ return ii !== -1 ? ii : null;
+ } else if (format === 'ddd') {
+ ii = indexOf.call(this._shortWeekdaysParse, llc);
+ if (ii !== -1) {
+ return ii;
+ }
+ ii = indexOf.call(this._weekdaysParse, llc);
+ if (ii !== -1) {
+ return ii;
+ }
+ ii = indexOf.call(this._minWeekdaysParse, llc);
+ return ii !== -1 ? ii : null;
+ } else {
+ ii = indexOf.call(this._minWeekdaysParse, llc);
+ if (ii !== -1) {
+ return ii;
+ }
+ ii = indexOf.call(this._weekdaysParse, llc);
+ if (ii !== -1) {
+ return ii;
+ }
+ ii = indexOf.call(this._shortWeekdaysParse, llc);
+ return ii !== -1 ? ii : null;
+ }
+ }
+ }
+
function localeWeekdaysParse (weekdayName, format, strict) {
var i, mom, regex;
+
+ if (this._weekdaysParseExact) {
+ return day_of_week__handleStrictParse.call(this, weekdayName, format, strict);
+ }
if (!this._weekdaysParse) {
this._weekdaysParse = [];
@@ -2503,7 +2886,7 @@
for (i = 0; i < 7; i++) {
// make the regex if we don't have it already
- mom = local__createLocal([2000, 1]).day(i);
+ mom = create_utc__createUTC([2000, 1]).day(i);
if (strict && !this._fullWeekdaysParse[i]) {
this._fullWeekdaysParse[i] = new RegExp('^' + this.weekdays(mom, '').replace('.', '\.?') + '$', 'i');
this._shortWeekdaysParse[i] = new RegExp('^' + this.weekdaysShort(mom, '').replace('.', '\.?') + '$', 'i');
@@ -2559,6 +2942,99 @@
return input == null ? this.day() || 7 : this.day(this.day() % 7 ? input : input - 7);
}
+ var defaultWeekdaysRegex = matchWord;
+ function weekdaysRegex (isStrict) {
+ if (this._weekdaysParseExact) {
+ if (!hasOwnProp(this, '_weekdaysRegex')) {
+ computeWeekdaysParse.call(this);
+ }
+ if (isStrict) {
+ return this._weekdaysStrictRegex;
+ } else {
+ return this._weekdaysRegex;
+ }
+ } else {
+ return this._weekdaysStrictRegex && isStrict ?
+ this._weekdaysStrictRegex : this._weekdaysRegex;
+ }
+ }
+
+ var defaultWeekdaysShortRegex = matchWord;
+ function weekdaysShortRegex (isStrict) {
+ if (this._weekdaysParseExact) {
+ if (!hasOwnProp(this, '_weekdaysRegex')) {
+ computeWeekdaysParse.call(this);
+ }
+ if (isStrict) {
+ return this._weekdaysShortStrictRegex;
+ } else {
+ return this._weekdaysShortRegex;
+ }
+ } else {
+ return this._weekdaysShortStrictRegex && isStrict ?
+ this._weekdaysShortStrictRegex : this._weekdaysShortRegex;
+ }
+ }
+
+ var defaultWeekdaysMinRegex = matchWord;
+ function weekdaysMinRegex (isStrict) {
+ if (this._weekdaysParseExact) {
+ if (!hasOwnProp(this, '_weekdaysRegex')) {
+ computeWeekdaysParse.call(this);
+ }
+ if (isStrict) {
+ return this._weekdaysMinStrictRegex;
+ } else {
+ return this._weekdaysMinRegex;
+ }
+ } else {
+ return this._weekdaysMinStrictRegex && isStrict ?
+ this._weekdaysMinStrictRegex : this._weekdaysMinRegex;
+ }
+ }
+
+
+ function computeWeekdaysParse () {
+ function cmpLenRev(a, b) {
+ return b.length - a.length;
+ }
+
+ var minPieces = [], shortPieces = [], longPieces = [], mixedPieces = [],
+ i, mom, minp, shortp, longp;
+ for (i = 0; i < 7; i++) {
+ // make the regex if we don't have it already
+ mom = create_utc__createUTC([2000, 1]).day(i);
+ minp = this.weekdaysMin(mom, '');
+ shortp = this.weekdaysShort(mom, '');
+ longp = this.weekdays(mom, '');
+ minPieces.push(minp);
+ shortPieces.push(shortp);
+ longPieces.push(longp);
+ mixedPieces.push(minp);
+ mixedPieces.push(shortp);
+ mixedPieces.push(longp);
+ }
+ // Sorting makes sure if one weekday (or abbr) is a prefix of another it
+ // will match the longer piece.
+ minPieces.sort(cmpLenRev);
+ shortPieces.sort(cmpLenRev);
+ longPieces.sort(cmpLenRev);
+ mixedPieces.sort(cmpLenRev);
+ for (i = 0; i < 7; i++) {
+ shortPieces[i] = regexEscape(shortPieces[i]);
+ longPieces[i] = regexEscape(longPieces[i]);
+ mixedPieces[i] = regexEscape(mixedPieces[i]);
+ }
+
+ this._weekdaysRegex = new RegExp('^(' + mixedPieces.join('|') + ')', 'i');
+ this._weekdaysShortRegex = this._weekdaysRegex;
+ this._weekdaysMinRegex = this._weekdaysRegex;
+
+ this._weekdaysStrictRegex = new RegExp('^(' + longPieces.join('|') + ')', 'i');
+ this._weekdaysShortStrictRegex = new RegExp('^(' + shortPieces.join('|') + ')', 'i');
+ this._weekdaysMinStrictRegex = new RegExp('^(' + minPieces.join('|') + ')', 'i');
+ }
+
// FORMATTING
addFormatToken('DDD', ['DDDD', 3], 'DDDo', 'dayOfYear');
@@ -2590,8 +3066,13 @@
return this.hours() % 12 || 12;
}
+ function kFormat() {
+ return this.hours() || 24;
+ }
+
addFormatToken('H', ['HH', 2], 0, 'hour');
addFormatToken('h', ['hh', 2], 0, hFormat);
+ addFormatToken('k', ['kk', 2], 0, kFormat);
addFormatToken('hmm', 0, 0, function () {
return '' + hFormat.apply(this) + zeroFill(this.minutes(), 2);
@@ -3008,21 +3489,6 @@
return isFunction(format) ? format(output) : format.replace(/%s/i, output);
}
- function locale_set__set (config) {
- var prop, i;
- for (i in config) {
- prop = config[i];
- if (isFunction(prop)) {
- this[i] = prop;
- } else {
- this['_' + i] = prop;
- }
- }
- // Lenient ordinal parsing accepts just a number in addition to
- // number + (possibly) stuff coming from _ordinalParseLenient.
- this._ordinalParseLenient = new RegExp(this._ordinalParse.source + '|' + (/\d{1,2}/).source);
- }
-
var prototype__proto = Locale.prototype;
prototype__proto._calendar = defaultCalendar;
@@ -3042,11 +3508,15 @@
prototype__proto.set = locale_set__set;
// Month
- prototype__proto.months = localeMonths;
- prototype__proto._months = defaultLocaleMonths;
- prototype__proto.monthsShort = localeMonthsShort;
- prototype__proto._monthsShort = defaultLocaleMonthsShort;
- prototype__proto.monthsParse = localeMonthsParse;
+ prototype__proto.months = localeMonths;
+ prototype__proto._months = defaultLocaleMonths;
+ prototype__proto.monthsShort = localeMonthsShort;
+ prototype__proto._monthsShort = defaultLocaleMonthsShort;
+ prototype__proto.monthsParse = localeMonthsParse;
+ prototype__proto._monthsRegex = defaultMonthsRegex;
+ prototype__proto.monthsRegex = monthsRegex;
+ prototype__proto._monthsShortRegex = defaultMonthsShortRegex;
+ prototype__proto.monthsShortRegex = monthsShortRegex;
// Week
prototype__proto.week = localeWeek;
@@ -3063,6 +3533,13 @@
prototype__proto._weekdaysShort = defaultLocaleWeekdaysShort;
prototype__proto.weekdaysParse = localeWeekdaysParse;
+ prototype__proto._weekdaysRegex = defaultWeekdaysRegex;
+ prototype__proto.weekdaysRegex = weekdaysRegex;
+ prototype__proto._weekdaysShortRegex = defaultWeekdaysShortRegex;
+ prototype__proto.weekdaysShortRegex = weekdaysShortRegex;
+ prototype__proto._weekdaysMinRegex = defaultWeekdaysMinRegex;
+ prototype__proto.weekdaysMinRegex = weekdaysMinRegex;
+
// Hours
prototype__proto.isPM = localeIsPM;
prototype__proto._meridiemParse = defaultLocaleMeridiemParse;
@@ -3074,7 +3551,7 @@
return locale[field](utc, format);
}
- function list (format, index, field, count, setter) {
+ function listMonthsImpl (format, index, field) {
if (typeof format === 'number') {
index = format;
format = undefined;
@@ -3083,41 +3560,82 @@
format = format || '';
if (index != null) {
- return lists__get(format, index, field, setter);
+ return lists__get(format, index, field, 'month');
}
var i;
var out = [];
- for (i = 0; i < count; i++) {
- out[i] = lists__get(format, i, field, setter);
+ for (i = 0; i < 12; i++) {
+ out[i] = lists__get(format, i, field, 'month');
}
return out;
}
+ // ()
+ // (5)
+ // (fmt, 5)
+ // (fmt)
+ // (true)
+ // (true, 5)
+ // (true, fmt, 5)
+ // (true, fmt)
+ function listWeekdaysImpl (localeSorted, format, index, field) {
+ if (typeof localeSorted === 'boolean') {
+ if (typeof format === 'number') {
+ index = format;
+ format = undefined;
+ }
+
+ format = format || '';
+ } else {
+ format = localeSorted;
+ index = format;
+ localeSorted = false;
+
+ if (typeof format === 'number') {
+ index = format;
+ format = undefined;
+ }
+
+ format = format || '';
+ }
+
+ var locale = locale_locales__getLocale(),
+ shift = localeSorted ? locale._week.dow : 0;
+
+ if (index != null) {
+ return lists__get(format, (index + shift) % 7, field, 'day');
+ }
+
+ var i;
+ var out = [];
+ for (i = 0; i < 7; i++) {
+ out[i] = lists__get(format, (i + shift) % 7, field, 'day');
+ }
+ return out;
+ }
+
function lists__listMonths (format, index) {
- return list(format, index, 'months', 12, 'month');
+ return listMonthsImpl(format, index, 'months');
}
function lists__listMonthsShort (format, index) {
- return list(format, index, 'monthsShort', 12, 'month');
- }
-
- function lists__listWeekdays (format, index) {
- return list(format, index, 'weekdays', 7, 'day');
- }
-
- function lists__listWeekdaysShort (format, index) {
- return list(format, index, 'weekdaysShort', 7, 'day');
- }
-
- function lists__listWeekdaysMin (format, index) {
- return list(format, index, 'weekdaysMin', 7, 'day');
+ return listMonthsImpl(format, index, 'monthsShort');
+ }
+
+ function lists__listWeekdays (localeSorted, format, index) {
+ return listWeekdaysImpl(localeSorted, format, index, 'weekdays');
+ }
+
+ function lists__listWeekdaysShort (localeSorted, format, index) {
+ return listWeekdaysImpl(localeSorted, format, index, 'weekdaysShort');
+ }
+
+ function lists__listWeekdaysMin (localeSorted, format, index) {
+ return listWeekdaysImpl(localeSorted, format, index, 'weekdaysMin');
}
locale_locales__getSetGlobalLocale('en', {
- monthsParse : [/^jan/i, /^feb/i, /^mar/i, /^apr/i, /^may/i, /^jun/i, /^jul/i, /^aug/i, /^sep/i, /^oct/i, /^nov/i, /^dec/i],
- longMonthsParse : [/^january$/i, /^february$/i, /^march$/i, /^april$/i, /^may$/i, /^june$/i, /^july$/i, /^august$/i, /^september$/i, /^october$/i, /^november$/i, /^december$/i],
- shortMonthsParse : [/^jan$/i, /^feb$/i, /^mar$/i, /^apr$/i, /^may$/i, /^jun$/i, /^jul$/i, /^aug/i, /^sept?$/i, /^oct$/i, /^nov$/i, /^dec$/i],
ordinalParse: /\d{1,2}(th|st|nd|rd)/,
ordinal : function (number) {
var b = number % 10,
@@ -3485,7 +4003,7 @@
// Side effect imports
- utils_hooks__hooks.version = '2.11.0';
+ utils_hooks__hooks.version = '2.13.0';
setHookCallback(local__createLocal);
@@ -3508,6 +4026,8 @@
utils_hooks__hooks.monthsShort = lists__listMonthsShort;
utils_hooks__hooks.weekdaysMin = lists__listWeekdaysMin;
utils_hooks__hooks.defineLocale = defineLocale;
+ utils_hooks__hooks.updateLocale = updateLocale;
+ utils_hooks__hooks.locales = locale_locales__listLocales;
utils_hooks__hooks.weekdaysShort = lists__listWeekdaysShort;
utils_hooks__hooks.normalizeUnits = normalizeUnits;
utils_hooks__hooks.relativeTimeThreshold = duration_humanize__getSetRelativeTimeThreshold;
diff --git a/package.json b/package.json
index 7c34eaf..24f7f0c 100644
--- a/package.json
+++ b/package.json
@@ -1,6 +1,6 @@
{
"name": "moment",
- "version": "2.11.0",
+ "version": "2.13.0",
"description": "Parse, validate, manipulate, and display dates",
"homepage": "http://momentjs.com",
"author": "Iskren Ivov Chernev (https://github.com/ichernev)",
@@ -23,6 +23,7 @@
"ender"
],
"main": "./moment.js",
+ "typings": "./moment.d.ts",
"engines": {
"node": "*"
},
@@ -37,7 +38,8 @@
"devDependencies": {
"uglify-js": "latest",
"es6-promise": "latest",
- "grunt": "latest",
+ "grunt": "~0.4",
+ "grunt-cli": "latest",
"benchmark": "latest",
"esperanto": "latest",
"grunt-contrib-clean": "latest",
diff --git a/scripts/npm_prepublish.sh b/scripts/npm_prepublish.sh
index a4889a5..ee2376c 100755
--- a/scripts/npm_prepublish.sh
+++ b/scripts/npm_prepublish.sh
@@ -32,11 +32,14 @@
cp $src/moment.js $dest
cp $src/package.json $dest
cp $src/README.md $dest
+cp $src/CHANGELOG.md $dest
cp $src/LICENSE $dest
cp -r $src/locale $dest
cp -r $src/min $dest
+cp -r $src/src $dest && rm -r $dest/src/test
cp $src/ender.js $dest
cp $src/package.js $dest
+cp $src/.npmignore $dest
rm -rf $src
diff --git a/src/lib/create/from-anything.js b/src/lib/create/from-anything.js
index 7b92587..022c6eb 100644
--- a/src/lib/create/from-anything.js
+++ b/src/lib/create/from-anything.js
@@ -63,7 +63,7 @@
if (input === undefined) {
config._d = new Date(hooks.now());
} else if (isDate(input)) {
- config._d = new Date(+input);
+ config._d = new Date(input.valueOf());
} else if (typeof input === 'string') {
configFromString(config);
} else if (isArray(input)) {
diff --git a/src/lib/create/from-string-and-format.js b/src/lib/create/from-string-and-format.js
index ae48b90..bbaab0d 100644
--- a/src/lib/create/from-string-and-format.js
+++ b/src/lib/create/from-string-and-format.js
@@ -33,6 +33,8 @@
for (i = 0; i < tokens.length; i++) {
token = tokens[i];
parsedInput = (string.match(getParseRegexForToken(token, config)) || [])[0];
+ // console.log('token', token, 'parsedInput', parsedInput,
+ // 'regex', getParseRegexForToken(token, config));
if (parsedInput) {
skipped = string.substr(0, string.indexOf(parsedInput));
if (skipped.length > 0) {
@@ -68,6 +70,9 @@
config._a[HOUR] > 0) {
getParsingFlags(config).bigHour = undefined;
}
+
+ getParsingFlags(config).parsedDateParts = config._a.slice(0);
+ getParsingFlags(config).meridiem = config._meridiem;
// handle meridiem
config._a[HOUR] = meridiemFixWrap(config._locale, config._a[HOUR], config._meridiem);
diff --git a/src/lib/create/parsing-flags.js b/src/lib/create/parsing-flags.js
index 2bfbcb3..5a42200 100644
--- a/src/lib/create/parsing-flags.js
+++ b/src/lib/create/parsing-flags.js
@@ -10,7 +10,9 @@
invalidMonth : null,
invalidFormat : false,
userInvalidated : false,
- iso : false
+ iso : false,
+ parsedDateParts : [],
+ meridiem : null
};
}
diff --git a/src/lib/create/valid.js b/src/lib/create/valid.js
index ad56bfe..4c62116 100644
--- a/src/lib/create/valid.js
+++ b/src/lib/create/valid.js
@@ -1,10 +1,14 @@
import extend from '../utils/extend';
import { createUTC } from './utc';
import getParsingFlags from '../create/parsing-flags';
+import some from '../utils/some';
export function isValid(m) {
if (m._isValid == null) {
var flags = getParsingFlags(m);
+ var parsedParts = some.call(flags.parsedDateParts, function (i) {
+ return i != null;
+ });
m._isValid = !isNaN(m._d.getTime()) &&
flags.overflow < 0 &&
!flags.empty &&
@@ -12,7 +16,8 @@
!flags.invalidWeekday &&
!flags.nullInput &&
!flags.invalidFormat &&
- !flags.userInvalidated;
+ !flags.userInvalidated &&
+ (!flags.meridiem || (flags.meridiem && parsedParts));
if (m._strict) {
m._isValid = m._isValid &&
diff --git a/src/lib/duration/constructor.js b/src/lib/duration/constructor.js
index 884c6f8..fb01c70 100644
--- a/src/lib/duration/constructor.js
+++ b/src/lib/duration/constructor.js
@@ -17,7 +17,7 @@
this._milliseconds = +milliseconds +
seconds * 1e3 + // 1000
minutes * 6e4 + // 1000 * 60
- hours * 36e5; // 1000 * 60 * 60
+ hours * 1000 * 60 * 60; //using 1000 * 60 * 60 instead of 36e5 to avoid floating point rounding errors https://github.com/moment/moment/issues/2978
// Because of dateAddRemove treats 24 hours as different from a
// day when working around DST, we need to store them separately
this._days = +days +
diff --git a/src/lib/duration/create.js b/src/lib/duration/create.js
index a79feea..24275d6 100644
--- a/src/lib/duration/create.js
+++ b/src/lib/duration/create.js
@@ -6,11 +6,12 @@
import { createLocal } from '../create/local';
// ASP.NET json date format regex
-var aspNetRegex = /(\-)?(?:(\d*)[. ])?(\d+)\:(\d+)(?:\:(\d+)\.?(\d{3})?)?/;
+var aspNetRegex = /^(\-)?(?:(\d*)[. ])?(\d+)\:(\d+)(?:\:(\d+)\.?(\d{3})?\d*)?$/;
// from http://docs.closure-library.googlecode.com/git/closure_goog_date_date.js.source.html
// somewhat more in line with 4.4.3.2 2004 spec, but allows decimal anywhere
-var isoRegex = /^(-)?P(?:(?:([0-9,.]*)Y)?(?:([0-9,.]*)M)?(?:([0-9,.]*)D)?(?:T(?:([0-9,.]*)H)?(?:([0-9,.]*)M)?(?:([0-9,.]*)S)?)?|([0-9,.]*)W)$/;
+// and further modified to allow for strings containing both week and day
+var isoRegex = /^(-)?P(?:(-?[0-9,.]*)Y)?(?:(-?[0-9,.]*)M)?(?:(-?[0-9,.]*)W)?(?:(-?[0-9,.]*)D)?(?:T(?:(-?[0-9,.]*)H)?(?:(-?[0-9,.]*)M)?(?:(-?[0-9,.]*)S)?)?$/;
export function createDuration (input, key) {
var duration = input,
@@ -48,11 +49,11 @@
duration = {
y : parseIso(match[2], sign),
M : parseIso(match[3], sign),
- d : parseIso(match[4], sign),
- h : parseIso(match[5], sign),
- m : parseIso(match[6], sign),
- s : parseIso(match[7], sign),
- w : parseIso(match[8], sign)
+ w : parseIso(match[4], sign),
+ d : parseIso(match[5], sign),
+ h : parseIso(match[6], sign),
+ m : parseIso(match[7], sign),
+ s : parseIso(match[8], sign)
};
} else if (duration == null) {// checks for null or undefined
duration = {};
diff --git a/src/lib/format/format.js b/src/lib/format/format.js
index a2b755d..33486f1 100644
--- a/src/lib/format/format.js
+++ b/src/lib/format/format.js
@@ -1,6 +1,6 @@
import zeroFill from '../utils/zero-fill';
-export var formattingTokens = /(\[[^\[]*\])|(\\)?([Hh]mm(ss)?|Mo|MM?M?M?|Do|DDDo|DD?D?D?|ddd?d?|do?|w[o|w]?|W[o|W]?|Qo?|YYYYYY|YYYYY|YYYY|YY|gg(ggg?)?|GG(GGG?)?|e|E|a|A|hh?|HH?|mm?|ss?|S{1,9}|x|X|zz?|ZZ?|.)/g;
+export var formattingTokens = /(\[[^\[]*\])|(\\)?([Hh]mm(ss)?|Mo|MM?M?M?|Do|DDDo|DD?D?D?|ddd?d?|do?|w[o|w]?|W[o|W]?|Qo?|YYYYYY|YYYYY|YYYY|YY|gg(ggg?)?|GG(GGG?)?|e|E|a|A|hh?|HH?|kk?|mm?|ss?|S{1,9}|x|X|zz?|ZZ?|.)/g;
var localFormattingTokens = /(\[[^\[]*\])|(\\)?(LTS|LT|LL?L?L?|l{1,4})/g;
@@ -53,7 +53,7 @@
}
return function (mom) {
- var output = '';
+ var output = '', i;
for (i = 0; i < length; i++) {
output += array[i] instanceof Function ? array[i].call(mom, format) : array[i];
}
@@ -89,4 +89,3 @@
return format;
}
-
diff --git a/src/lib/locale/constructor.js b/src/lib/locale/constructor.js
index 2c17b5d..c32b73e 100644
--- a/src/lib/locale/constructor.js
+++ b/src/lib/locale/constructor.js
@@ -1,2 +1,5 @@
-export function Locale() {
+export function Locale(config) {
+ if (config != null) {
+ this.set(config);
+ }
}
diff --git a/src/lib/locale/en.js b/src/lib/locale/en.js
index 30d95f2..20964cd 100644
--- a/src/lib/locale/en.js
+++ b/src/lib/locale/en.js
@@ -3,9 +3,6 @@
import toInt from '../utils/to-int';
getSetGlobalLocale('en', {
- monthsParse : [/^jan/i, /^feb/i, /^mar/i, /^apr/i, /^may/i, /^jun/i, /^jul/i, /^aug/i, /^sep/i, /^oct/i, /^nov/i, /^dec/i],
- longMonthsParse : [/^january$/i, /^february$/i, /^march$/i, /^april$/i, /^may$/i, /^june$/i, /^july$/i, /^august$/i, /^september$/i, /^october$/i, /^november$/i, /^december$/i],
- shortMonthsParse : [/^jan$/i, /^feb$/i, /^mar$/i, /^apr$/i, /^may$/i, /^jun$/i, /^jul$/i, /^aug/i, /^sept?$/i, /^oct$/i, /^nov$/i, /^dec$/i],
ordinalParse: /\d{1,2}(th|st|nd|rd)/,
ordinal : function (number) {
var b = number % 10,
diff --git a/src/lib/locale/lists.js b/src/lib/locale/lists.js
index ea0161a..4fced6e 100644
--- a/src/lib/locale/lists.js
+++ b/src/lib/locale/lists.js
@@ -7,7 +7,7 @@
return locale[field](utc, format);
}
-function list (format, index, field, count, setter) {
+function listMonthsImpl (format, index, field) {
if (typeof format === 'number') {
index = format;
format = undefined;
@@ -16,33 +16,77 @@
format = format || '';
if (index != null) {
- return get(format, index, field, setter);
+ return get(format, index, field, 'month');
}
var i;
var out = [];
- for (i = 0; i < count; i++) {
- out[i] = get(format, i, field, setter);
+ for (i = 0; i < 12; i++) {
+ out[i] = get(format, i, field, 'month');
+ }
+ return out;
+}
+
+// ()
+// (5)
+// (fmt, 5)
+// (fmt)
+// (true)
+// (true, 5)
+// (true, fmt, 5)
+// (true, fmt)
+function listWeekdaysImpl (localeSorted, format, index, field) {
+ if (typeof localeSorted === 'boolean') {
+ if (typeof format === 'number') {
+ index = format;
+ format = undefined;
+ }
+
+ format = format || '';
+ } else {
+ format = localeSorted;
+ index = format;
+ localeSorted = false;
+
+ if (typeof format === 'number') {
+ index = format;
+ format = undefined;
+ }
+
+ format = format || '';
+ }
+
+ var locale = getLocale(),
+ shift = localeSorted ? locale._week.dow : 0;
+
+ if (index != null) {
+ return get(format, (index + shift) % 7, field, 'day');
+ }
+
+ var i;
+ var out = [];
+ for (i = 0; i < 7; i++) {
+ out[i] = get(format, (i + shift) % 7, field, 'day');
}
return out;
}
export function listMonths (format, index) {
- return list(format, index, 'months', 12, 'month');
+ return listMonthsImpl(format, index, 'months');
}
export function listMonthsShort (format, index) {
- return list(format, index, 'monthsShort', 12, 'month');
+ return listMonthsImpl(format, index, 'monthsShort');
}
-export function listWeekdays (format, index) {
- return list(format, index, 'weekdays', 7, 'day');
+export function listWeekdays (localeSorted, format, index) {
+ return listWeekdaysImpl(localeSorted, format, index, 'weekdays');
}
-export function listWeekdaysShort (format, index) {
- return list(format, index, 'weekdaysShort', 7, 'day');
+export function listWeekdaysShort (localeSorted, format, index) {
+ return listWeekdaysImpl(localeSorted, format, index, 'weekdaysShort');
}
-export function listWeekdaysMin (format, index) {
- return list(format, index, 'weekdaysMin', 7, 'day');
+export function listWeekdaysMin (localeSorted, format, index) {
+ return listWeekdaysImpl(localeSorted, format, index, 'weekdaysMin');
}
diff --git a/src/lib/locale/locale.js b/src/lib/locale/locale.js
index 2fc3c46..ac9cebf 100644
--- a/src/lib/locale/locale.js
+++ b/src/lib/locale/locale.js
@@ -4,7 +4,9 @@
import {
getSetGlobalLocale,
defineLocale,
- getLocale
+ updateLocale,
+ getLocale,
+ listLocales
} from './locales';
import {
@@ -18,7 +20,9 @@
export {
getSetGlobalLocale,
defineLocale,
+ updateLocale,
getLocale,
+ listLocales,
listMonths,
listMonthsShort,
listWeekdays,
diff --git a/src/lib/locale/locales.js b/src/lib/locale/locales.js
index cf2c329..9cf6ef4 100644
--- a/src/lib/locale/locales.js
+++ b/src/lib/locale/locales.js
@@ -1,7 +1,10 @@
import isArray from '../utils/is-array';
import isUndefined from '../utils/is-undefined';
import compareArrays from '../utils/compare-arrays';
+import { deprecateSimple } from '../utils/deprecate';
+import { mergeConfigs } from './set';
import { Locale } from './constructor';
+import keys from '../utils/keys';
// internal storage for locale config files
var locales = {};
@@ -41,7 +44,7 @@
function loadLocale(name) {
var oldLocale = null;
// TODO: Find a better way to register and load all the locales in Node
- if (!locales[name] && !isUndefined(module) &&
+ if (!locales[name] && (typeof module !== 'undefined') &&
module && module.exports) {
try {
oldLocale = globalLocale._abbr;
@@ -76,11 +79,25 @@
return globalLocale._abbr;
}
-export function defineLocale (name, values) {
- if (values !== null) {
- values.abbr = name;
- locales[name] = locales[name] || new Locale();
- locales[name].set(values);
+export function defineLocale (name, config) {
+ if (config !== null) {
+ config.abbr = name;
+ if (locales[name] != null) {
+ deprecateSimple('defineLocaleOverride',
+ 'use moment.updateLocale(localeName, config) to change ' +
+ 'an existing locale. moment.defineLocale(localeName, ' +
+ 'config) should only be used for creating a new locale');
+ config = mergeConfigs(locales[name]._config, config);
+ } else if (config.parentLocale != null) {
+ if (locales[config.parentLocale] != null) {
+ config = mergeConfigs(locales[config.parentLocale]._config, config);
+ } else {
+ // treat as if there is no base config
+ deprecateSimple('parentLocaleUndefined',
+ 'specified parentLocale is not defined yet');
+ }
+ }
+ locales[name] = new Locale(config);
// backwards compat for now: also set the locale
getSetGlobalLocale(name);
@@ -91,6 +108,31 @@
delete locales[name];
return null;
}
+}
+
+export function updateLocale(name, config) {
+ if (config != null) {
+ var locale;
+ if (locales[name] != null) {
+ config = mergeConfigs(locales[name]._config, config);
+ }
+ locale = new Locale(config);
+ locale.parentLocale = locales[name];
+ locales[name] = locale;
+
+ // backwards compat for now: also set the locale
+ getSetGlobalLocale(name);
+ } else {
+ // pass null for config to unupdate, useful for tests
+ if (locales[name] != null) {
+ if (locales[name].parentLocale != null) {
+ locales[name] = locales[name].parentLocale;
+ } else if (locales[name] != null) {
+ delete locales[name];
+ }
+ }
+ }
+ return locales[name];
}
// returns locale data
@@ -116,3 +158,7 @@
return chooseLocale(key);
}
+
+export function listLocales() {
+ return keys(locales);
+}
diff --git a/src/lib/locale/prototype.js b/src/lib/locale/prototype.js
index ed02d4f..fd13458 100644
--- a/src/lib/locale/prototype.js
+++ b/src/lib/locale/prototype.js
@@ -30,14 +30,20 @@
import {
localeMonthsParse,
defaultLocaleMonths, localeMonths,
- defaultLocaleMonthsShort, localeMonthsShort
+ defaultLocaleMonthsShort, localeMonthsShort,
+ defaultMonthsRegex, monthsRegex,
+ defaultMonthsShortRegex, monthsShortRegex
} from '../units/month';
-proto.months = localeMonths;
-proto._months = defaultLocaleMonths;
-proto.monthsShort = localeMonthsShort;
-proto._monthsShort = defaultLocaleMonthsShort;
-proto.monthsParse = localeMonthsParse;
+proto.months = localeMonths;
+proto._months = defaultLocaleMonths;
+proto.monthsShort = localeMonthsShort;
+proto._monthsShort = defaultLocaleMonthsShort;
+proto.monthsParse = localeMonthsParse;
+proto._monthsRegex = defaultMonthsRegex;
+proto.monthsRegex = monthsRegex;
+proto._monthsShortRegex = defaultMonthsShortRegex;
+proto.monthsShortRegex = monthsShortRegex;
// Week
import { localeWeek, defaultLocaleWeek, localeFirstDayOfYear, localeFirstDayOfWeek } from '../units/week';
@@ -51,7 +57,11 @@
localeWeekdaysParse,
defaultLocaleWeekdays, localeWeekdays,
defaultLocaleWeekdaysMin, localeWeekdaysMin,
- defaultLocaleWeekdaysShort, localeWeekdaysShort
+ defaultLocaleWeekdaysShort, localeWeekdaysShort,
+
+ defaultWeekdaysRegex, weekdaysRegex,
+ defaultWeekdaysShortRegex, weekdaysShortRegex,
+ defaultWeekdaysMinRegex, weekdaysMinRegex
} from '../units/day-of-week';
proto.weekdays = localeWeekdays;
@@ -62,6 +72,13 @@
proto._weekdaysShort = defaultLocaleWeekdaysShort;
proto.weekdaysParse = localeWeekdaysParse;
+proto._weekdaysRegex = defaultWeekdaysRegex;
+proto.weekdaysRegex = weekdaysRegex;
+proto._weekdaysShortRegex = defaultWeekdaysShortRegex;
+proto.weekdaysShortRegex = weekdaysShortRegex;
+proto._weekdaysMinRegex = defaultWeekdaysMinRegex;
+proto.weekdaysMinRegex = weekdaysMinRegex;
+
// Hours
import { localeIsPM, defaultLocaleMeridiemParse, localeMeridiem } from '../units/hour';
diff --git a/src/lib/locale/set.js b/src/lib/locale/set.js
index 062e842..1fd1389 100644
--- a/src/lib/locale/set.js
+++ b/src/lib/locale/set.js
@@ -1,4 +1,7 @@
import isFunction from '../utils/is-function';
+import extend from '../utils/extend';
+import isObject from '../utils/is-object';
+import hasOwnProp from '../utils/has-own-prop';
export function set (config) {
var prop, i;
@@ -10,7 +13,26 @@
this['_' + i] = prop;
}
}
+ this._config = config;
// Lenient ordinal parsing accepts just a number in addition to
// number + (possibly) stuff coming from _ordinalParseLenient.
this._ordinalParseLenient = new RegExp(this._ordinalParse.source + '|' + (/\d{1,2}/).source);
}
+
+export function mergeConfigs(parentConfig, childConfig) {
+ var res = extend({}, parentConfig), prop;
+ for (prop in childConfig) {
+ if (hasOwnProp(childConfig, prop)) {
+ if (isObject(parentConfig[prop]) && isObject(childConfig[prop])) {
+ res[prop] = {};
+ extend(res[prop], parentConfig[prop]);
+ extend(res[prop], childConfig[prop]);
+ } else if (childConfig[prop] != null) {
+ res[prop] = childConfig[prop];
+ } else {
+ delete res[prop];
+ }
+ }
+ }
+ return res;
+}
diff --git a/src/lib/moment/add-subtract.js b/src/lib/moment/add-subtract.js
index 988eff3..588153b 100644
--- a/src/lib/moment/add-subtract.js
+++ b/src/lib/moment/add-subtract.js
@@ -3,6 +3,8 @@
import { createDuration } from '../duration/create';
import { deprecateSimple } from '../utils/deprecate';
import { hooks } from '../utils/hooks';
+import absRound from '../utils/abs-round';
+
// TODO: remove 'name' arg after deprecation is removed
function createAdder(direction, name) {
@@ -23,8 +25,8 @@
export function addSubtract (mom, duration, isAdding, updateOffset) {
var milliseconds = duration._milliseconds,
- days = duration._days,
- months = duration._months;
+ days = absRound(duration._days),
+ months = absRound(duration._months);
if (!mom.isValid()) {
// No op
@@ -34,7 +36,7 @@
updateOffset = updateOffset == null ? true : updateOffset;
if (milliseconds) {
- mom._d.setTime(+mom._d + milliseconds * isAdding);
+ mom._d.setTime(mom._d.valueOf() + milliseconds * isAdding);
}
if (days) {
set(mom, 'Date', get(mom, 'Date') + days * isAdding);
diff --git a/src/lib/moment/compare.js b/src/lib/moment/compare.js
index d196a98..b26bac6 100644
--- a/src/lib/moment/compare.js
+++ b/src/lib/moment/compare.js
@@ -10,9 +10,9 @@
}
units = normalizeUnits(!isUndefined(units) ? units : 'millisecond');
if (units === 'millisecond') {
- return +this > +localInput;
+ return this.valueOf() > localInput.valueOf();
} else {
- return +localInput < +this.clone().startOf(units);
+ return localInput.valueOf() < this.clone().startOf(units).valueOf();
}
}
@@ -23,14 +23,16 @@
}
units = normalizeUnits(!isUndefined(units) ? units : 'millisecond');
if (units === 'millisecond') {
- return +this < +localInput;
+ return this.valueOf() < localInput.valueOf();
} else {
- return +this.clone().endOf(units) < +localInput;
+ return this.clone().endOf(units).valueOf() < localInput.valueOf();
}
}
-export function isBetween (from, to, units) {
- return this.isAfter(from, units) && this.isBefore(to, units);
+export function isBetween (from, to, units, inclusivity) {
+ inclusivity = inclusivity || '()';
+ return (inclusivity[0] === '(' ? this.isAfter(from, units) : !this.isBefore(from, units)) &&
+ (inclusivity[1] === ')' ? this.isBefore(to, units) : !this.isAfter(to, units));
}
export function isSame (input, units) {
@@ -41,10 +43,10 @@
}
units = normalizeUnits(units || 'millisecond');
if (units === 'millisecond') {
- return +this === +localInput;
+ return this.valueOf() === localInput.valueOf();
} else {
- inputMs = +localInput;
- return +(this.clone().startOf(units)) <= inputMs && inputMs <= +(this.clone().endOf(units));
+ inputMs = localInput.valueOf();
+ return this.clone().startOf(units).valueOf() <= inputMs && inputMs <= this.clone().endOf(units).valueOf();
}
}
diff --git a/src/lib/moment/diff.js b/src/lib/moment/diff.js
index 695fe20..9f43908 100644
--- a/src/lib/moment/diff.js
+++ b/src/lib/moment/diff.js
@@ -57,5 +57,6 @@
adjust = (b - anchor) / (anchor2 - anchor);
}
- return -(wholeMonthDiff + adjust);
+ //check for negative zero, return zero if negative zero
+ return -(wholeMonthDiff + adjust) || 0;
}
diff --git a/src/lib/moment/format.js b/src/lib/moment/format.js
index 7e93a0a..c7150e4 100644
--- a/src/lib/moment/format.js
+++ b/src/lib/moment/format.js
@@ -3,6 +3,7 @@
import isFunction from '../utils/is-function';
hooks.defaultFormat = 'YYYY-MM-DDTHH:mm:ssZ';
+hooks.defaultFormatUtc = 'YYYY-MM-DDTHH:mm:ss[Z]';
export function toString () {
return this.clone().locale('en').format('ddd MMM DD YYYY HH:mm:ss [GMT]ZZ');
@@ -23,6 +24,9 @@
}
export function format (inputString) {
- var output = formatMoment(this, inputString || hooks.defaultFormat);
+ if (!inputString) {
+ inputString = this.isUtc() ? hooks.defaultFormatUtc : hooks.defaultFormat;
+ }
+ var output = formatMoment(this, inputString);
return this.localeData().postformat(output);
}
diff --git a/src/lib/moment/min-max.js b/src/lib/moment/min-max.js
index e355883..aad6f6f 100644
--- a/src/lib/moment/min-max.js
+++ b/src/lib/moment/min-max.js
@@ -4,7 +4,7 @@
import { createInvalid } from '../create/valid';
export var prototypeMin = deprecate(
- 'moment().min is deprecated, use moment.min instead. https://github.com/moment/moment/issues/1548',
+ 'moment().min is deprecated, use moment.max instead. https://github.com/moment/moment/issues/1548',
function () {
var other = createLocal.apply(null, arguments);
if (this.isValid() && other.isValid()) {
@@ -16,7 +16,7 @@
);
export var prototypeMax = deprecate(
- 'moment().max is deprecated, use moment.max instead. https://github.com/moment/moment/issues/1548',
+ 'moment().max is deprecated, use moment.min instead. https://github.com/moment/moment/issues/1548',
function () {
var other = createLocal.apply(null, arguments);
if (this.isValid() && other.isValid()) {
diff --git a/src/lib/moment/now.js b/src/lib/moment/now.js
index 42631b5..0f4d0ae 100644
--- a/src/lib/moment/now.js
+++ b/src/lib/moment/now.js
@@ -1,3 +1,3 @@
-export var now = Date.now || function () {
- return +(new Date());
+export var now = function () {
+ return Date.now ? Date.now() : +(new Date());
};
diff --git a/src/lib/moment/start-end-of.js b/src/lib/moment/start-end-of.js
index 193c8b4..c8a68ac 100644
--- a/src/lib/moment/start-end-of.js
+++ b/src/lib/moment/start-end-of.js
@@ -15,6 +15,7 @@
case 'week':
case 'isoWeek':
case 'day':
+ case 'date':
this.hours(0);
/* falls through */
case 'hour':
@@ -48,5 +49,11 @@
if (units === undefined || units === 'millisecond') {
return this;
}
+
+ // 'date' is an alias for 'day', so it should be considered as such.
+ if (units === 'date') {
+ units = 'day';
+ }
+
return this.startOf(units).add(1, (units === 'isoWeek' ? 'week' : units)).subtract(1, 'ms');
}
diff --git a/src/lib/moment/to-type.js b/src/lib/moment/to-type.js
index b6787af..584348d 100644
--- a/src/lib/moment/to-type.js
+++ b/src/lib/moment/to-type.js
@@ -1,13 +1,13 @@
export function valueOf () {
- return +this._d - ((this._offset || 0) * 60000);
+ return this._d.valueOf() - ((this._offset || 0) * 60000);
}
export function unix () {
- return Math.floor(+this / 1000);
+ return Math.floor(this.valueOf() / 1000);
}
export function toDate () {
- return this._offset ? new Date(+this) : this._d;
+ return this._offset ? new Date(this.valueOf()) : this._d;
}
export function toArray () {
@@ -29,6 +29,6 @@
}
export function toJSON () {
- // JSON.stringify(new Date(NaN)) === 'null'
- return this.isValid() ? this.toISOString() : 'null';
+ // new Date(NaN).toJSON() === null
+ return this.isValid() ? this.toISOString() : null;
}
diff --git a/src/lib/parse/regex.js b/src/lib/parse/regex.js
index a168de6..b1dc752 100644
--- a/src/lib/parse/regex.js
+++ b/src/lib/parse/regex.js
@@ -20,7 +20,7 @@
// any word (or two) characters or numbers including two/three word month in arabic.
// includes scottish gaelic two word and hyphenated months
-export var matchWord = /[0-9]*(a[mn]\s?)?['a-z\u00A0-\u05FF\u0700-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF\-]+|[\u0600-\u06FF\/]+(\s*?[\u0600-\u06FF]+){1,2}/i;
+export var matchWord = /[0-9]*['a-z\u00A0-\u05FF\u0700-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF]+|[\u0600-\u06FF\/]+(\s*?[\u0600-\u06FF]+){1,2}/i;
import hasOwnProp from '../utils/has-own-prop';
@@ -29,7 +29,7 @@
var regexes = {};
export function addRegexToken (token, regex, strictRegex) {
- regexes[token] = isFunction(regex) ? regex : function (isStrict) {
+ regexes[token] = isFunction(regex) ? regex : function (isStrict, localeData) {
return (isStrict && strictRegex) ? strictRegex : regex;
};
}
@@ -44,7 +44,11 @@
// Code from http://stackoverflow.com/questions/3561493/is-there-a-regexp-escape-function-in-javascript
function unescapeFormat(s) {
- return s.replace('\\', '').replace(/\\(\[)|\\(\])|\[([^\]\[]*)\]|\\(.)/g, function (matched, p1, p2, p3, p4) {
+ return regexEscape(s.replace('\\', '').replace(/\\(\[)|\\(\])|\[([^\]\[]*)\]|\\(.)/g, function (matched, p1, p2, p3, p4) {
return p1 || p2 || p3 || p4;
- }).replace(/[-\/\\^$*+?.()|[\]{}]/g, '\\$&');
+ }));
}
+
+export function regexEscape(s) {
+ return s.replace(/[-\/\\^$*+?.()|[\]{}]/g, '\\$&');
+}
diff --git a/src/lib/units/day-of-week.js b/src/lib/units/day-of-week.js
index 2f0460a..18e2a42 100644
--- a/src/lib/units/day-of-week.js
+++ b/src/lib/units/day-of-week.js
@@ -1,10 +1,12 @@
import { addFormatToken } from '../format/format';
import { addUnitAlias } from './aliases';
-import { addRegexToken, match1to2, matchWord } from '../parse/regex';
+import { addRegexToken, match1to2, matchWord, regexEscape } from '../parse/regex';
import { addWeekParseToken } from '../parse/token';
import toInt from '../utils/to-int';
import isArray from '../utils/is-array';
-import { createLocal } from '../create/local';
+import indexOf from '../utils/index-of';
+import hasOwnProp from '../utils/has-own-prop';
+import { createUTC } from '../create/utc';
import getParsingFlags from '../create/parsing-flags';
// FORMATTING
@@ -37,9 +39,15 @@
addRegexToken('d', match1to2);
addRegexToken('e', match1to2);
addRegexToken('E', match1to2);
-addRegexToken('dd', matchWord);
-addRegexToken('ddd', matchWord);
-addRegexToken('dddd', matchWord);
+addRegexToken('dd', function (isStrict, locale) {
+ return locale.weekdaysMinRegex(isStrict);
+});
+addRegexToken('ddd', function (isStrict, locale) {
+ return locale.weekdaysShortRegex(isStrict);
+});
+addRegexToken('dddd', function (isStrict, locale) {
+ return locale.weekdaysRegex(isStrict);
+});
addWeekParseToken(['dd', 'ddd', 'dddd'], function (input, week, config, token) {
var weekday = config._locale.weekdaysParse(input, token, config._strict);
@@ -92,8 +100,76 @@
return this._weekdaysMin[m.day()];
}
+function handleStrictParse(weekdayName, format, strict) {
+ var i, ii, mom, llc = weekdayName.toLocaleLowerCase();
+ if (!this._weekdaysParse) {
+ this._weekdaysParse = [];
+ this._shortWeekdaysParse = [];
+ this._minWeekdaysParse = [];
+
+ for (i = 0; i < 7; ++i) {
+ mom = createUTC([2000, 1]).day(i);
+ this._minWeekdaysParse[i] = this.weekdaysMin(mom, '').toLocaleLowerCase();
+ this._shortWeekdaysParse[i] = this.weekdaysShort(mom, '').toLocaleLowerCase();
+ this._weekdaysParse[i] = this.weekdays(mom, '').toLocaleLowerCase();
+ }
+ }
+
+ if (strict) {
+ if (format === 'dddd') {
+ ii = indexOf.call(this._weekdaysParse, llc);
+ return ii !== -1 ? ii : null;
+ } else if (format === 'ddd') {
+ ii = indexOf.call(this._shortWeekdaysParse, llc);
+ return ii !== -1 ? ii : null;
+ } else {
+ ii = indexOf.call(this._minWeekdaysParse, llc);
+ return ii !== -1 ? ii : null;
+ }
+ } else {
+ if (format === 'dddd') {
+ ii = indexOf.call(this._weekdaysParse, llc);
+ if (ii !== -1) {
+ return ii;
+ }
+ ii = indexOf.call(this._shortWeekdaysParse, llc);
+ if (ii !== -1) {
+ return ii;
+ }
+ ii = indexOf.call(this._minWeekdaysParse, llc);
+ return ii !== -1 ? ii : null;
+ } else if (format === 'ddd') {
+ ii = indexOf.call(this._shortWeekdaysParse, llc);
+ if (ii !== -1) {
+ return ii;
+ }
+ ii = indexOf.call(this._weekdaysParse, llc);
+ if (ii !== -1) {
+ return ii;
+ }
+ ii = indexOf.call(this._minWeekdaysParse, llc);
+ return ii !== -1 ? ii : null;
+ } else {
+ ii = indexOf.call(this._minWeekdaysParse, llc);
+ if (ii !== -1) {
+ return ii;
+ }
+ ii = indexOf.call(this._weekdaysParse, llc);
+ if (ii !== -1) {
+ return ii;
+ }
+ ii = indexOf.call(this._shortWeekdaysParse, llc);
+ return ii !== -1 ? ii : null;
+ }
+ }
+}
+
export function localeWeekdaysParse (weekdayName, format, strict) {
var i, mom, regex;
+
+ if (this._weekdaysParseExact) {
+ return handleStrictParse.call(this, weekdayName, format, strict);
+ }
if (!this._weekdaysParse) {
this._weekdaysParse = [];
@@ -105,7 +181,7 @@
for (i = 0; i < 7; i++) {
// make the regex if we don't have it already
- mom = createLocal([2000, 1]).day(i);
+ mom = createUTC([2000, 1]).day(i);
if (strict && !this._fullWeekdaysParse[i]) {
this._fullWeekdaysParse[i] = new RegExp('^' + this.weekdays(mom, '').replace('.', '\.?') + '$', 'i');
this._shortWeekdaysParse[i] = new RegExp('^' + this.weekdaysShort(mom, '').replace('.', '\.?') + '$', 'i');
@@ -160,3 +236,96 @@
// as a setter, sunday should belong to the previous week.
return input == null ? this.day() || 7 : this.day(this.day() % 7 ? input : input - 7);
}
+
+export var defaultWeekdaysRegex = matchWord;
+export function weekdaysRegex (isStrict) {
+ if (this._weekdaysParseExact) {
+ if (!hasOwnProp(this, '_weekdaysRegex')) {
+ computeWeekdaysParse.call(this);
+ }
+ if (isStrict) {
+ return this._weekdaysStrictRegex;
+ } else {
+ return this._weekdaysRegex;
+ }
+ } else {
+ return this._weekdaysStrictRegex && isStrict ?
+ this._weekdaysStrictRegex : this._weekdaysRegex;
+ }
+}
+
+export var defaultWeekdaysShortRegex = matchWord;
+export function weekdaysShortRegex (isStrict) {
+ if (this._weekdaysParseExact) {
+ if (!hasOwnProp(this, '_weekdaysRegex')) {
+ computeWeekdaysParse.call(this);
+ }
+ if (isStrict) {
+ return this._weekdaysShortStrictRegex;
+ } else {
+ return this._weekdaysShortRegex;
+ }
+ } else {
+ return this._weekdaysShortStrictRegex && isStrict ?
+ this._weekdaysShortStrictRegex : this._weekdaysShortRegex;
+ }
+}
+
+export var defaultWeekdaysMinRegex = matchWord;
+export function weekdaysMinRegex (isStrict) {
+ if (this._weekdaysParseExact) {
+ if (!hasOwnProp(this, '_weekdaysRegex')) {
+ computeWeekdaysParse.call(this);
+ }
+ if (isStrict) {
+ return this._weekdaysMinStrictRegex;
+ } else {
+ return this._weekdaysMinRegex;
+ }
+ } else {
+ return this._weekdaysMinStrictRegex && isStrict ?
+ this._weekdaysMinStrictRegex : this._weekdaysMinRegex;
+ }
+}
+
+
+function computeWeekdaysParse () {
+ function cmpLenRev(a, b) {
+ return b.length - a.length;
+ }
+
+ var minPieces = [], shortPieces = [], longPieces = [], mixedPieces = [],
+ i, mom, minp, shortp, longp;
+ for (i = 0; i < 7; i++) {
+ // make the regex if we don't have it already
+ mom = createUTC([2000, 1]).day(i);
+ minp = this.weekdaysMin(mom, '');
+ shortp = this.weekdaysShort(mom, '');
+ longp = this.weekdays(mom, '');
+ minPieces.push(minp);
+ shortPieces.push(shortp);
+ longPieces.push(longp);
+ mixedPieces.push(minp);
+ mixedPieces.push(shortp);
+ mixedPieces.push(longp);
+ }
+ // Sorting makes sure if one weekday (or abbr) is a prefix of another it
+ // will match the longer piece.
+ minPieces.sort(cmpLenRev);
+ shortPieces.sort(cmpLenRev);
+ longPieces.sort(cmpLenRev);
+ mixedPieces.sort(cmpLenRev);
+ for (i = 0; i < 7; i++) {
+ shortPieces[i] = regexEscape(shortPieces[i]);
+ longPieces[i] = regexEscape(longPieces[i]);
+ mixedPieces[i] = regexEscape(mixedPieces[i]);
+ }
+
+ this._weekdaysRegex = new RegExp('^(' + mixedPieces.join('|') + ')', 'i');
+ this._weekdaysShortRegex = this._weekdaysRegex;
+ this._weekdaysMinRegex = this._weekdaysRegex;
+
+ this._weekdaysStrictRegex = new RegExp('^(' + longPieces.join('|') + ')', 'i');
+ this._weekdaysShortStrictRegex = new RegExp('^(' + shortPieces.join('|') + ')', 'i');
+ this._weekdaysMinStrictRegex = new RegExp('^(' + minPieces.join('|') + ')', 'i');
+}
diff --git a/src/lib/units/hour.js b/src/lib/units/hour.js
index 63919de..86f18ab 100644
--- a/src/lib/units/hour.js
+++ b/src/lib/units/hour.js
@@ -14,8 +14,13 @@
return this.hours() % 12 || 12;
}
+function kFormat() {
+ return this.hours() || 24;
+}
+
addFormatToken('H', ['HH', 2], 0, 'hour');
addFormatToken('h', ['hh', 2], 0, hFormat);
+addFormatToken('k', ['kk', 2], 0, kFormat);
addFormatToken('hmm', 0, 0, function () {
return '' + hFormat.apply(this) + zeroFill(this.minutes(), 2);
diff --git a/src/lib/units/month.js b/src/lib/units/month.js
index 3584f6b..f1cef15 100644
--- a/src/lib/units/month.js
+++ b/src/lib/units/month.js
@@ -1,12 +1,14 @@
import { get } from '../moment/get-set';
+import hasOwnProp from '../utils/has-own-prop';
import { addFormatToken } from '../format/format';
import { addUnitAlias } from './aliases';
-import { addRegexToken, match1to2, match2, matchWord } from '../parse/regex';
+import { addRegexToken, match1to2, match2, matchWord, regexEscape } from '../parse/regex';
import { addParseToken } from '../parse/token';
import { hooks } from '../utils/hooks';
import { MONTH } from './constants';
import toInt from '../utils/to-int';
import isArray from '../utils/is-array';
+import indexOf from '../utils/index-of';
import { createUTC } from '../create/utc';
import getParsingFlags from '../create/parsing-flags';
@@ -36,8 +38,12 @@
addRegexToken('M', match1to2);
addRegexToken('MM', match1to2, match2);
-addRegexToken('MMM', matchWord);
-addRegexToken('MMMM', matchWord);
+addRegexToken('MMM', function (isStrict, locale) {
+ return locale.monthsShortRegex(isStrict);
+});
+addRegexToken('MMMM', function (isStrict, locale) {
+ return locale.monthsRegex(isStrict);
+});
addParseToken(['M', 'MM'], function (input, array) {
array[MONTH] = toInt(input) - 1;
@@ -62,14 +68,59 @@
this._months[MONTHS_IN_FORMAT.test(format) ? 'format' : 'standalone'][m.month()];
}
-export var defaultLocaleMonthsShort = 'Jan_Feb_Mar_Apr_May_Jun_Jul_Aug_Sept_Oct_Nov_Dec'.split('_');
+export var defaultLocaleMonthsShort = 'Jan_Feb_Mar_Apr_May_Jun_Jul_Aug_Sep_Oct_Nov_Dec'.split('_');
export function localeMonthsShort (m, format) {
return isArray(this._monthsShort) ? this._monthsShort[m.month()] :
this._monthsShort[MONTHS_IN_FORMAT.test(format) ? 'format' : 'standalone'][m.month()];
}
+function handleStrictParse(monthName, format, strict) {
+ var i, ii, mom, llc = monthName.toLocaleLowerCase();
+ if (!this._monthsParse) {
+ // this is not used
+ this._monthsParse = [];
+ this._longMonthsParse = [];
+ this._shortMonthsParse = [];
+ for (i = 0; i < 12; ++i) {
+ mom = createUTC([2000, i]);
+ this._shortMonthsParse[i] = this.monthsShort(mom, '').toLocaleLowerCase();
+ this._longMonthsParse[i] = this.months(mom, '').toLocaleLowerCase();
+ }
+ }
+
+ if (strict) {
+ if (format === 'MMM') {
+ ii = indexOf.call(this._shortMonthsParse, llc);
+ return ii !== -1 ? ii : null;
+ } else {
+ ii = indexOf.call(this._longMonthsParse, llc);
+ return ii !== -1 ? ii : null;
+ }
+ } else {
+ if (format === 'MMM') {
+ ii = indexOf.call(this._shortMonthsParse, llc);
+ if (ii !== -1) {
+ return ii;
+ }
+ ii = indexOf.call(this._longMonthsParse, llc);
+ return ii !== -1 ? ii : null;
+ } else {
+ ii = indexOf.call(this._longMonthsParse, llc);
+ if (ii !== -1) {
+ return ii;
+ }
+ ii = indexOf.call(this._shortMonthsParse, llc);
+ return ii !== -1 ? ii : null;
+ }
+ }
+}
+
export function localeMonthsParse (monthName, format, strict) {
var i, mom, regex;
+
+ if (this._monthsParseExact) {
+ return handleStrictParse.call(this, monthName, format, strict);
+ }
if (!this._monthsParse) {
this._monthsParse = [];
@@ -77,6 +128,9 @@
this._shortMonthsParse = [];
}
+ // TODO: add sorting
+ // Sorting makes sure if one month (or abbr) is a prefix of another
+ // see sorting in computeMonthsParse
for (i = 0; i < 12; i++) {
// make the regex if we don't have it already
mom = createUTC([2000, i]);
@@ -109,12 +163,15 @@
return mom;
}
- // TODO: Move this out of here!
if (typeof value === 'string') {
- value = mom.localeData().monthsParse(value);
- // TODO: Another silent failure?
- if (typeof value !== 'number') {
- return mom;
+ if (/^\d+$/.test(value)) {
+ value = toInt(value);
+ } else {
+ value = mom.localeData().monthsParse(value);
+ // TODO: Another silent failure?
+ if (typeof value !== 'number') {
+ return mom;
+ }
}
}
@@ -136,3 +193,69 @@
export function getDaysInMonth () {
return daysInMonth(this.year(), this.month());
}
+
+export var defaultMonthsShortRegex = matchWord;
+export function monthsShortRegex (isStrict) {
+ if (this._monthsParseExact) {
+ if (!hasOwnProp(this, '_monthsRegex')) {
+ computeMonthsParse.call(this);
+ }
+ if (isStrict) {
+ return this._monthsShortStrictRegex;
+ } else {
+ return this._monthsShortRegex;
+ }
+ } else {
+ return this._monthsShortStrictRegex && isStrict ?
+ this._monthsShortStrictRegex : this._monthsShortRegex;
+ }
+}
+
+export var defaultMonthsRegex = matchWord;
+export function monthsRegex (isStrict) {
+ if (this._monthsParseExact) {
+ if (!hasOwnProp(this, '_monthsRegex')) {
+ computeMonthsParse.call(this);
+ }
+ if (isStrict) {
+ return this._monthsStrictRegex;
+ } else {
+ return this._monthsRegex;
+ }
+ } else {
+ return this._monthsStrictRegex && isStrict ?
+ this._monthsStrictRegex : this._monthsRegex;
+ }
+}
+
+function computeMonthsParse () {
+ function cmpLenRev(a, b) {
+ return b.length - a.length;
+ }
+
+ var shortPieces = [], longPieces = [], mixedPieces = [],
+ i, mom;
+ for (i = 0; i < 12; i++) {
+ // make the regex if we don't have it already
+ mom = createUTC([2000, i]);
+ shortPieces.push(this.monthsShort(mom, ''));
+ longPieces.push(this.months(mom, ''));
+ mixedPieces.push(this.months(mom, ''));
+ mixedPieces.push(this.monthsShort(mom, ''));
+ }
+ // Sorting makes sure if one month (or abbr) is a prefix of another it
+ // will match the longer piece.
+ shortPieces.sort(cmpLenRev);
+ longPieces.sort(cmpLenRev);
+ mixedPieces.sort(cmpLenRev);
+ for (i = 0; i < 12; i++) {
+ shortPieces[i] = regexEscape(shortPieces[i]);
+ longPieces[i] = regexEscape(longPieces[i]);
+ mixedPieces[i] = regexEscape(mixedPieces[i]);
+ }
+
+ this._monthsRegex = new RegExp('^(' + mixedPieces.join('|') + ')', 'i');
+ this._monthsShortRegex = this._monthsRegex;
+ this._monthsStrictRegex = new RegExp('^(' + longPieces.join('|') + ')', 'i');
+ this._monthsShortStrictRegex = new RegExp('^(' + shortPieces.join('|') + ')', 'i');
+}
diff --git a/src/lib/units/offset.js b/src/lib/units/offset.js
index 8723c87..22305d1 100644
--- a/src/lib/units/offset.js
+++ b/src/lib/units/offset.js
@@ -61,9 +61,9 @@
var res, diff;
if (model._isUTC) {
res = model.clone();
- diff = (isMoment(input) || isDate(input) ? +input : +createLocal(input)) - (+res);
+ diff = (isMoment(input) || isDate(input) ? input.valueOf() : createLocal(input).valueOf()) - res.valueOf();
// Use low-level api, because this fn is low-level api.
- res._d.setTime(+res._d + diff);
+ res._d.setTime(res._d.valueOf() + diff);
hooks.updateOffset(res, false);
return res;
} else {
diff --git a/src/lib/units/week-year.js b/src/lib/units/week-year.js
index 44c4f33..29d1fec 100644
--- a/src/lib/units/week-year.js
+++ b/src/lib/units/week-year.js
@@ -93,7 +93,6 @@
var dayOfYearData = dayOfYearFromWeeks(weekYear, week, weekday, dow, doy),
date = createUTCDate(dayOfYearData.year, 0, dayOfYearData.dayOfYear);
- // console.log("got", weekYear, week, weekday, "set", date.toISOString());
this.year(date.getUTCFullYear());
this.month(date.getUTCMonth());
this.date(date.getUTCDate());
diff --git a/src/lib/units/year.js b/src/lib/units/year.js
index cc32b55..b86df29 100644
--- a/src/lib/units/year.js
+++ b/src/lib/units/year.js
@@ -8,6 +8,11 @@
import toInt from '../utils/to-int';
// FORMATTING
+
+addFormatToken('Y', 0, 0, function () {
+ var y = this.year();
+ return y <= 9999 ? '' + y : '+' + y;
+});
addFormatToken(0, ['YY', 2], 0, function () {
return this.year() % 100;
@@ -36,6 +41,9 @@
addParseToken('YY', function (input, array) {
array[YEAR] = hooks.parseTwoDigitYear(input);
});
+addParseToken('Y', function (input, array) {
+ array[YEAR] = parseInt(input, 10);
+});
// HELPERS
@@ -55,7 +63,7 @@
// MOMENTS
-export var getSetYear = makeGetSet('FullYear', false);
+export var getSetYear = makeGetSet('FullYear', true);
export function getIsLeapYear () {
return isLeapYear(this.year());
diff --git a/src/lib/utils/abs-round.js b/src/lib/utils/abs-round.js
new file mode 100644
index 0000000..98f54bc
--- /dev/null
+++ b/src/lib/utils/abs-round.js
@@ -0,0 +1,7 @@
+export default function absRound (number) {
+ if (number < 0) {
+ return Math.round(-1 * number) * -1;
+ } else {
+ return Math.round(number);
+ }
+}
diff --git a/src/lib/utils/deprecate.js b/src/lib/utils/deprecate.js
index 1b78131..8ed45e5 100644
--- a/src/lib/utils/deprecate.js
+++ b/src/lib/utils/deprecate.js
@@ -3,7 +3,8 @@
import isUndefined from './is-undefined';
function warn(msg) {
- if (hooks.suppressDeprecationWarnings === false && !isUndefined(console) && console.warn) {
+ if (hooks.suppressDeprecationWarnings === false &&
+ (typeof console !== 'undefined') && console.warn) {
console.warn('Deprecation warning: ' + msg);
}
}
@@ -12,6 +13,9 @@
var firstTime = true;
return extend(function () {
+ if (hooks.deprecationHandler != null) {
+ hooks.deprecationHandler(null, msg);
+ }
if (firstTime) {
warn(msg + '\nArguments: ' + Array.prototype.slice.call(arguments).join(', ') + '\n' + (new Error()).stack);
firstTime = false;
@@ -23,6 +27,9 @@
var deprecations = {};
export function deprecateSimple(name, msg) {
+ if (hooks.deprecationHandler != null) {
+ hooks.deprecationHandler(name, msg);
+ }
if (!deprecations[name]) {
warn(msg);
deprecations[name] = true;
@@ -30,3 +37,4 @@
}
hooks.suppressDeprecationWarnings = false;
+hooks.deprecationHandler = null;
diff --git a/src/lib/utils/index-of.js b/src/lib/utils/index-of.js
new file mode 100644
index 0000000..92298cf
--- /dev/null
+++ b/src/lib/utils/index-of.js
@@ -0,0 +1,18 @@
+var indexOf;
+
+if (Array.prototype.indexOf) {
+ indexOf = Array.prototype.indexOf;
+} else {
+ indexOf = function (o) {
+ // I know
+ var i;
+ for (i = 0; i < this.length; ++i) {
+ if (this[i] === o) {
+ return i;
+ }
+ }
+ return -1;
+ };
+}
+
+export { indexOf as default };
diff --git a/src/lib/utils/is-array.js b/src/lib/utils/is-array.js
index 46bd6c6..2d0e0f3 100644
--- a/src/lib/utils/is-array.js
+++ b/src/lib/utils/is-array.js
@@ -1,3 +1,3 @@
export default function isArray(input) {
- return Object.prototype.toString.call(input) === '[object Array]';
+ return input instanceof Array || Object.prototype.toString.call(input) === '[object Array]';
}
diff --git a/src/lib/utils/is-object.js b/src/lib/utils/is-object.js
new file mode 100644
index 0000000..6018e12
--- /dev/null
+++ b/src/lib/utils/is-object.js
@@ -0,0 +1,3 @@
+export default function isObject(input) {
+ return Object.prototype.toString.call(input) === '[object Object]';
+}
diff --git a/src/lib/utils/keys.js b/src/lib/utils/keys.js
new file mode 100644
index 0000000..2da4e32
--- /dev/null
+++ b/src/lib/utils/keys.js
@@ -0,0 +1,19 @@
+import hasOwnProp from './has-own-prop';
+
+var keys;
+
+if (Object.keys) {
+ keys = Object.keys;
+} else {
+ keys = function (obj) {
+ var i, res = [];
+ for (i in obj) {
+ if (hasOwnProp(obj, i)) {
+ res.push(i);
+ }
+ }
+ return res;
+ };
+}
+
+export { keys as default };
diff --git a/src/lib/utils/some.js b/src/lib/utils/some.js
new file mode 100644
index 0000000..1bd3186
--- /dev/null
+++ b/src/lib/utils/some.js
@@ -0,0 +1,19 @@
+var some;
+if (Array.prototype.some) {
+ some = Array.prototype.some;
+} else {
+ some = function (fun) {
+ var t = Object(this);
+ var len = t.length >>> 0;
+
+ for (var i = 0; i < len; i++) {
+ if (i in t && fun.call(this, t[i], i, t)) {
+ return true;
+ }
+ }
+
+ return false;
+ };
+}
+
+export { some as default };
diff --git a/src/locale/ar-ma.js b/src/locale/ar-ma.js
index fe79651..efd39b4 100644
--- a/src/locale/ar-ma.js
+++ b/src/locale/ar-ma.js
@@ -11,6 +11,7 @@
weekdays : 'الأحد_الإتنين_الثلاثاء_الأربعاء_الخميس_الجمعة_السبت'.split('_'),
weekdaysShort : 'احد_اتنين_ثلاثاء_اربعاء_خميس_جمعة_سبت'.split('_'),
weekdaysMin : 'ح_ن_ث_ر_خ_ج_س'.split('_'),
+ weekdaysParseExact : true,
longDateFormat : {
LT : 'HH:mm',
LTS : 'HH:mm:ss',
diff --git a/src/locale/ar-sa.js b/src/locale/ar-sa.js
index d32b0ce..201b264 100644
--- a/src/locale/ar-sa.js
+++ b/src/locale/ar-sa.js
@@ -34,6 +34,7 @@
weekdays : 'الأحد_الإثنين_الثلاثاء_الأربعاء_الخميس_الجمعة_السبت'.split('_'),
weekdaysShort : 'أحد_إثنين_ثلاثاء_أربعاء_خميس_جمعة_سبت'.split('_'),
weekdaysMin : 'ح_ن_ث_ر_خ_ج_س'.split('_'),
+ weekdaysParseExact : true,
longDateFormat : {
LT : 'HH:mm',
LTS : 'HH:mm:ss',
diff --git a/src/locale/ar-tn.js b/src/locale/ar-tn.js
index 5dd0edb..98709c6 100644
--- a/src/locale/ar-tn.js
+++ b/src/locale/ar-tn.js
@@ -9,6 +9,7 @@
weekdays: 'الأحد_الإثنين_الثلاثاء_الأربعاء_الخميس_الجمعة_السبت'.split('_'),
weekdaysShort: 'أحد_إثنين_ثلاثاء_أربعاء_خميس_جمعة_سبت'.split('_'),
weekdaysMin: 'ح_ن_ث_ر_خ_ج_س'.split('_'),
+ weekdaysParseExact : true,
longDateFormat: {
LT: 'HH:mm',
LTS: 'HH:mm:ss',
diff --git a/src/locale/ar.js b/src/locale/ar.js
index e8555a0..4cdcdc2 100644
--- a/src/locale/ar.js
+++ b/src/locale/ar.js
@@ -67,6 +67,7 @@
weekdays : 'الأحد_الإثنين_الثلاثاء_الأربعاء_الخميس_الجمعة_السبت'.split('_'),
weekdaysShort : 'أحد_إثنين_ثلاثاء_أربعاء_خميس_جمعة_سبت'.split('_'),
weekdaysMin : 'ح_ن_ث_ر_خ_ج_س'.split('_'),
+ weekdaysParseExact : true,
longDateFormat : {
LT : 'HH:mm',
LTS : 'HH:mm:ss',
diff --git a/src/locale/az.js b/src/locale/az.js
index b30c12d..d26ade9 100644
--- a/src/locale/az.js
+++ b/src/locale/az.js
@@ -31,6 +31,7 @@
weekdays : 'Bazar_Bazar ertəsi_Çərşənbə axşamı_Çərşənbə_Cümə axşamı_Cümə_Şənbə'.split('_'),
weekdaysShort : 'Baz_BzE_ÇAx_Çər_CAx_Cüm_Şən'.split('_'),
weekdaysMin : 'Bz_BE_ÇA_Çə_CA_Cü_Şə'.split('_'),
+ weekdaysParseExact : true,
longDateFormat : {
LT : 'HH:mm',
LTS : 'HH:mm:ss',
diff --git a/src/locale/bn.js b/src/locale/bn.js
index 3ab629c..6d2f59d 100644
--- a/src/locale/bn.js
+++ b/src/locale/bn.js
@@ -77,12 +77,18 @@
});
},
meridiemParse: /রাত|সকাল|দুপুর|বিকাল|রাত/,
- isPM: function (input) {
- return /^(দুপুর|বিকাল|রাত)$/.test(input);
+ meridiemHour : function (hour, meridiem) {
+ if (hour === 12) {
+ hour = 0;
+ }
+ if ((meridiem === 'রাত' && hour >= 4) ||
+ (meridiem === 'দুপুর' && hour < 5) ||
+ meridiem === 'বিকাল') {
+ return hour + 12;
+ } else {
+ return hour;
+ }
},
- //Bengali is a vast language its spoken
- //in different forms in various parts of the world.
- //I have just generalized with most common one used
meridiem : function (hour, minute, isLower) {
if (hour < 4) {
return 'রাত';
diff --git a/src/locale/bo.js b/src/locale/bo.js
index 6da128d..05b1fdc 100644
--- a/src/locale/bo.js
+++ b/src/locale/bo.js
@@ -77,8 +77,17 @@
});
},
meridiemParse: /མཚན་མོ|ཞོགས་ཀས|ཉིན་གུང|དགོང་དག|མཚན་མོ/,
- isPM: function (input) {
- return /^(ཉིན་གུང|དགོང་དག|མཚན་མོ)$/.test(input);
+ meridiemHour : function (hour, meridiem) {
+ if (hour === 12) {
+ hour = 0;
+ }
+ if ((meridiem === 'མཚན་མོ' && hour >= 4) ||
+ (meridiem === 'ཉིན་གུང' && hour < 5) ||
+ meridiem === 'དགོང་དག') {
+ return hour + 12;
+ } else {
+ return hour;
+ }
},
meridiem : function (hour, minute, isLower) {
if (hour < 4) {
diff --git a/src/locale/br.js b/src/locale/br.js
index f95afb3..36d1e00 100644
--- a/src/locale/br.js
+++ b/src/locale/br.js
@@ -54,6 +54,7 @@
weekdays : 'Sul_Lun_Meurzh_Merc\'her_Yaou_Gwener_Sadorn'.split('_'),
weekdaysShort : 'Sul_Lun_Meu_Mer_Yao_Gwe_Sad'.split('_'),
weekdaysMin : 'Su_Lu_Me_Mer_Ya_Gw_Sa'.split('_'),
+ weekdaysParseExact : true,
longDateFormat : {
LT : 'h[e]mm A',
LTS : 'h[e]mm:ss A',
diff --git a/src/locale/bs.js b/src/locale/bs.js
index 8ac94f0..c1abbe9 100644
--- a/src/locale/bs.js
+++ b/src/locale/bs.js
@@ -61,9 +61,11 @@
export default moment.defineLocale('bs', {
months : 'januar_februar_mart_april_maj_juni_juli_august_septembar_oktobar_novembar_decembar'.split('_'),
monthsShort : 'jan._feb._mar._apr._maj._jun._jul._aug._sep._okt._nov._dec.'.split('_'),
+ monthsParseExact: true,
weekdays : 'nedjelja_ponedjeljak_utorak_srijeda_četvrtak_petak_subota'.split('_'),
weekdaysShort : 'ned._pon._uto._sri._čet._pet._sub.'.split('_'),
weekdaysMin : 'ne_po_ut_sr_če_pe_su'.split('_'),
+ weekdaysParseExact : true,
longDateFormat : {
LT : 'H:mm',
LTS : 'H:mm:ss',
diff --git a/src/locale/ca.js b/src/locale/ca.js
index 01204ae..6e5a793 100644
--- a/src/locale/ca.js
+++ b/src/locale/ca.js
@@ -7,9 +7,11 @@
export default moment.defineLocale('ca', {
months : 'gener_febrer_març_abril_maig_juny_juliol_agost_setembre_octubre_novembre_desembre'.split('_'),
monthsShort : 'gen._febr._mar._abr._mai._jun._jul._ag._set._oct._nov._des.'.split('_'),
+ monthsParseExact : true,
weekdays : 'diumenge_dilluns_dimarts_dimecres_dijous_divendres_dissabte'.split('_'),
weekdaysShort : 'dg._dl._dt._dc._dj._dv._ds.'.split('_'),
weekdaysMin : 'Dg_Dl_Dt_Dc_Dj_Dv_Ds'.split('_'),
+ weekdaysParseExact : true,
longDateFormat : {
LT : 'H:mm',
LTS : 'H:mm:ss',
diff --git a/src/locale/cy.js b/src/locale/cy.js
index b674ba4..93c8c85 100644
--- a/src/locale/cy.js
+++ b/src/locale/cy.js
@@ -10,6 +10,7 @@
weekdays: 'Dydd Sul_Dydd Llun_Dydd Mawrth_Dydd Mercher_Dydd Iau_Dydd Gwener_Dydd Sadwrn'.split('_'),
weekdaysShort: 'Sul_Llun_Maw_Mer_Iau_Gwe_Sad'.split('_'),
weekdaysMin: 'Su_Ll_Ma_Me_Ia_Gw_Sa'.split('_'),
+ weekdaysParseExact : true,
// time formats are the same as en-gb
longDateFormat: {
LT: 'HH:mm',
diff --git a/src/locale/de-at.js b/src/locale/de-at.js
index 04f213d..5207b79 100644
--- a/src/locale/de-at.js
+++ b/src/locale/de-at.js
@@ -24,9 +24,11 @@
export default moment.defineLocale('de-at', {
months : 'Jänner_Februar_März_April_Mai_Juni_Juli_August_September_Oktober_November_Dezember'.split('_'),
monthsShort : 'Jän._Febr._Mrz._Apr._Mai_Jun._Jul._Aug._Sept._Okt._Nov._Dez.'.split('_'),
+ monthsParseExact : true,
weekdays : 'Sonntag_Montag_Dienstag_Mittwoch_Donnerstag_Freitag_Samstag'.split('_'),
weekdaysShort : 'So._Mo._Di._Mi._Do._Fr._Sa.'.split('_'),
weekdaysMin : 'So_Mo_Di_Mi_Do_Fr_Sa'.split('_'),
+ weekdaysParseExact : true,
longDateFormat : {
LT: 'HH:mm',
LTS: 'HH:mm:ss',
diff --git a/src/locale/de.js b/src/locale/de.js
index e16d3fe..9230536 100644
--- a/src/locale/de.js
+++ b/src/locale/de.js
@@ -23,9 +23,11 @@
export default moment.defineLocale('de', {
months : 'Januar_Februar_März_April_Mai_Juni_Juli_August_September_Oktober_November_Dezember'.split('_'),
monthsShort : 'Jan._Febr._Mrz._Apr._Mai_Jun._Jul._Aug._Sept._Okt._Nov._Dez.'.split('_'),
+ monthsParseExact : true,
weekdays : 'Sonntag_Montag_Dienstag_Mittwoch_Donnerstag_Freitag_Samstag'.split('_'),
weekdaysShort : 'So._Mo._Di._Mi._Do._Fr._Sa.'.split('_'),
weekdaysMin : 'So_Mo_Di_Mi_Do_Fr_Sa'.split('_'),
+ weekdaysParseExact : true,
longDateFormat : {
LT: 'HH:mm',
LTS: 'HH:mm:ss',
diff --git a/src/locale/dv.js b/src/locale/dv.js
index 481237f..6e7a42d 100644
--- a/src/locale/dv.js
+++ b/src/locale/dv.js
@@ -44,7 +44,7 @@
},
meridiemParse: /މކ|މފ/,
isPM : function (input) {
- return '' === input;
+ return 'މފ' === input;
},
meridiem : function (hour, minute, isLower) {
if (hour < 12) {
diff --git a/src/locale/en-au.js b/src/locale/en-au.js
index d20c76b..13c4702 100644
--- a/src/locale/en-au.js
+++ b/src/locale/en-au.js
@@ -5,10 +5,7 @@
export default moment.defineLocale('en-au', {
months : 'January_February_March_April_May_June_July_August_September_October_November_December'.split('_'),
- monthsShort : 'Jan_Feb_Mar_Apr_May_Jun_Jul_Aug_Sept_Oct_Nov_Dec'.split('_'),
- monthsParse : [/^jan/i, /^feb/i, /^mar/i, /^apr/i, /^may/i, /^jun/i, /^jul/i, /^aug/i, /^sep/i, /^oct/i, /^nov/i, /^dec/i],
- longMonthsParse : [/^january$/i, /^february$/i, /^march$/i, /^april$/i, /^may$/i, /^june$/i, /^july$/i, /^august$/i, /^september$/i, /^october$/i, /^november$/i, /^december$/i],
- shortMonthsParse : [/^jan$/i, /^feb$/i, /^mar$/i, /^apr$/i, /^may$/i, /^jun$/i, /^jul$/i, /^aug/i, /^sept?$/i, /^oct$/i, /^nov$/i, /^dec$/i],
+ monthsShort : 'Jan_Feb_Mar_Apr_May_Jun_Jul_Aug_Sep_Oct_Nov_Dec'.split('_'),
weekdays : 'Sunday_Monday_Tuesday_Wednesday_Thursday_Friday_Saturday'.split('_'),
weekdaysShort : 'Sun_Mon_Tue_Wed_Thu_Fri_Sat'.split('_'),
weekdaysMin : 'Su_Mo_Tu_We_Th_Fr_Sa'.split('_'),
diff --git a/src/locale/en-ca.js b/src/locale/en-ca.js
index 22988a6..54b4981 100644
--- a/src/locale/en-ca.js
+++ b/src/locale/en-ca.js
@@ -6,10 +6,7 @@
export default moment.defineLocale('en-ca', {
months : 'January_February_March_April_May_June_July_August_September_October_November_December'.split('_'),
- monthsShort : 'Jan_Feb_Mar_Apr_May_Jun_Jul_Aug_Sept_Oct_Nov_Dec'.split('_'),
- monthsParse : [/^jan/i, /^feb/i, /^mar/i, /^apr/i, /^may/i, /^jun/i, /^jul/i, /^aug/i, /^sep/i, /^oct/i, /^nov/i, /^dec/i],
- longMonthsParse : [/^january$/i, /^february$/i, /^march$/i, /^april$/i, /^may$/i, /^june$/i, /^july$/i, /^august$/i, /^september$/i, /^october$/i, /^november$/i, /^december$/i],
- shortMonthsParse : [/^jan$/i, /^feb$/i, /^mar$/i, /^apr$/i, /^may$/i, /^jun$/i, /^jul$/i, /^aug/i, /^sept?$/i, /^oct$/i, /^nov$/i, /^dec$/i],
+ monthsShort : 'Jan_Feb_Mar_Apr_May_Jun_Jul_Aug_Sep_Oct_Nov_Dec'.split('_'),
weekdays : 'Sunday_Monday_Tuesday_Wednesday_Thursday_Friday_Saturday'.split('_'),
weekdaysShort : 'Sun_Mon_Tue_Wed_Thu_Fri_Sat'.split('_'),
weekdaysMin : 'Su_Mo_Tu_We_Th_Fr_Sa'.split('_'),
@@ -17,9 +14,9 @@
LT : 'h:mm A',
LTS : 'h:mm:ss A',
L : 'YYYY-MM-DD',
- LL : 'D MMMM, YYYY',
- LLL : 'D MMMM, YYYY h:mm A',
- LLLL : 'dddd, D MMMM, YYYY h:mm A'
+ LL : 'MMMM D, YYYY',
+ LLL : 'MMMM D, YYYY h:mm A',
+ LLLL : 'dddd, MMMM D, YYYY h:mm A'
},
calendar : {
sameDay : '[Today at] LT',
@@ -54,4 +51,3 @@
return number + output;
}
});
-
diff --git a/src/locale/en-gb.js b/src/locale/en-gb.js
index 160e7f1..82a643f 100644
--- a/src/locale/en-gb.js
+++ b/src/locale/en-gb.js
@@ -6,10 +6,7 @@
export default moment.defineLocale('en-gb', {
months : 'January_February_March_April_May_June_July_August_September_October_November_December'.split('_'),
- monthsShort : 'Jan_Feb_Mar_Apr_May_Jun_Jul_Aug_Sept_Oct_Nov_Dec'.split('_'),
- monthsParse : [/^jan/i, /^feb/i, /^mar/i, /^apr/i, /^may/i, /^jun/i, /^jul/i, /^aug/i, /^sep/i, /^oct/i, /^nov/i, /^dec/i],
- longMonthsParse : [/^january$/i, /^february$/i, /^march$/i, /^april$/i, /^may$/i, /^june$/i, /^july$/i, /^august$/i, /^september$/i, /^october$/i, /^november$/i, /^december$/i],
- shortMonthsParse : [/^jan$/i, /^feb$/i, /^mar$/i, /^apr$/i, /^may$/i, /^jun$/i, /^jul$/i, /^aug/i, /^sept?$/i, /^oct$/i, /^nov$/i, /^dec$/i],
+ monthsShort : 'Jan_Feb_Mar_Apr_May_Jun_Jul_Aug_Sep_Oct_Nov_Dec'.split('_'),
weekdays : 'Sunday_Monday_Tuesday_Wednesday_Thursday_Friday_Saturday'.split('_'),
weekdaysShort : 'Sun_Mon_Tue_Wed_Thu_Fri_Sat'.split('_'),
weekdaysMin : 'Su_Mo_Tu_We_Th_Fr_Sa'.split('_'),
diff --git a/src/locale/en-ie.js b/src/locale/en-ie.js
index 7316df2..cb3ae8f 100644
--- a/src/locale/en-ie.js
+++ b/src/locale/en-ie.js
@@ -7,9 +7,6 @@
export default moment.defineLocale('en-ie', {
months : 'January_February_March_April_May_June_July_August_September_October_November_December'.split('_'),
monthsShort : 'Jan_Feb_Mar_Apr_May_Jun_Jul_Aug_Sep_Oct_Nov_Dec'.split('_'),
- monthsParse : [/^jan/i, /^feb/i, /^mar/i, /^apr/i, /^may/i, /^jun/i, /^jul/i, /^aug/i, /^sep/i, /^oct/i, /^nov/i, /^dec/i],
- longMonthsParse : [/^january$/i, /^february$/i, /^march$/i, /^april$/i, /^may$/i, /^june$/i, /^july$/i, /^august$/i, /^september$/i, /^october$/i, /^november$/i, /^december$/i],
- shortMonthsParse : [/^jan$/i, /^feb$/i, /^mar$/i, /^apr$/i, /^may$/i, /^jun$/i, /^jul$/i, /^aug/i, /^sept?$/i, /^oct$/i, /^nov$/i, /^dec$/i],
weekdays : 'Sunday_Monday_Tuesday_Wednesday_Thursday_Friday_Saturday'.split('_'),
weekdaysShort : 'Sun_Mon_Tue_Wed_Thu_Fri_Sat'.split('_'),
weekdaysMin : 'Su_Mo_Tu_We_Th_Fr_Sa'.split('_'),
diff --git a/src/locale/en-nz.js b/src/locale/en-nz.js
index 2e22269..c6e9f18 100644
--- a/src/locale/en-nz.js
+++ b/src/locale/en-nz.js
@@ -5,10 +5,7 @@
export default moment.defineLocale('en-nz', {
months : 'January_February_March_April_May_June_July_August_September_October_November_December'.split('_'),
- monthsShort : 'Jan_Feb_Mar_Apr_May_Jun_Jul_Aug_Sept_Oct_Nov_Dec'.split('_'),
- monthsParse : [/^jan/i, /^feb/i, /^mar/i, /^apr/i, /^may/i, /^jun/i, /^jul/i, /^aug/i, /^sep/i, /^oct/i, /^nov/i, /^dec/i],
- longMonthsParse : [/^january$/i, /^february$/i, /^march$/i, /^april$/i, /^may$/i, /^june$/i, /^july$/i, /^august$/i, /^september$/i, /^october$/i, /^november$/i, /^december$/i],
- shortMonthsParse : [/^jan$/i, /^feb$/i, /^mar$/i, /^apr$/i, /^may$/i, /^jun$/i, /^jul$/i, /^aug/i, /^sept?$/i, /^oct$/i, /^nov$/i, /^dec$/i],
+ monthsShort : 'Jan_Feb_Mar_Apr_May_Jun_Jul_Aug_Sep_Oct_Nov_Dec'.split('_'),
weekdays : 'Sunday_Monday_Tuesday_Wednesday_Thursday_Friday_Saturday'.split('_'),
weekdaysShort : 'Sun_Mon_Tue_Wed_Thu_Fri_Sat'.split('_'),
weekdaysMin : 'Su_Mo_Tu_We_Th_Fr_Sa'.split('_'),
diff --git a/src/locale/es.js b/src/locale/es.js
index 47d5def..6a5fe48 100644
--- a/src/locale/es.js
+++ b/src/locale/es.js
@@ -16,9 +16,11 @@
return monthsShortDot[m.month()];
}
},
+ monthsParseExact : true,
weekdays : 'domingo_lunes_martes_miércoles_jueves_viernes_sábado'.split('_'),
weekdaysShort : 'dom._lun._mar._mié._jue._vie._sáb.'.split('_'),
weekdaysMin : 'do_lu_ma_mi_ju_vi_sá'.split('_'),
+ weekdaysParseExact : true,
longDateFormat : {
LT : 'H:mm',
LTS : 'H:mm:ss',
diff --git a/src/locale/eu.js b/src/locale/eu.js
index 08a006c..0302f2d 100644
--- a/src/locale/eu.js
+++ b/src/locale/eu.js
@@ -7,9 +7,11 @@
export default moment.defineLocale('eu', {
months : 'urtarrila_otsaila_martxoa_apirila_maiatza_ekaina_uztaila_abuztua_iraila_urria_azaroa_abendua'.split('_'),
monthsShort : 'urt._ots._mar._api._mai._eka._uzt._abu._ira._urr._aza._abe.'.split('_'),
+ monthsParseExact : true,
weekdays : 'igandea_astelehena_asteartea_asteazkena_osteguna_ostirala_larunbata'.split('_'),
weekdaysShort : 'ig._al._ar._az._og._ol._lr.'.split('_'),
weekdaysMin : 'ig_al_ar_az_og_ol_lr'.split('_'),
+ weekdaysParseExact : true,
longDateFormat : {
LT : 'HH:mm',
LTS : 'HH:mm:ss',
diff --git a/src/locale/fa.js b/src/locale/fa.js
index 96e670b..0a9d92c 100644
--- a/src/locale/fa.js
+++ b/src/locale/fa.js
@@ -34,6 +34,7 @@
weekdays : 'یک\u200cشنبه_دوشنبه_سه\u200cشنبه_چهارشنبه_پنج\u200cشنبه_جمعه_شنبه'.split('_'),
weekdaysShort : 'یک\u200cشنبه_دوشنبه_سه\u200cشنبه_چهارشنبه_پنج\u200cشنبه_جمعه_شنبه'.split('_'),
weekdaysMin : 'ی_د_س_چ_پ_ج_ش'.split('_'),
+ weekdaysParseExact : true,
longDateFormat : {
LT : 'HH:mm',
LTS : 'HH:mm:ss',
diff --git a/src/locale/fr-ca.js b/src/locale/fr-ca.js
index 9294b66..518081e 100644
--- a/src/locale/fr-ca.js
+++ b/src/locale/fr-ca.js
@@ -7,9 +7,11 @@
export default moment.defineLocale('fr-ca', {
months : 'janvier_février_mars_avril_mai_juin_juillet_août_septembre_octobre_novembre_décembre'.split('_'),
monthsShort : 'janv._févr._mars_avr._mai_juin_juil._août_sept._oct._nov._déc.'.split('_'),
+ monthsParseExact : true,
weekdays : 'dimanche_lundi_mardi_mercredi_jeudi_vendredi_samedi'.split('_'),
weekdaysShort : 'dim._lun._mar._mer._jeu._ven._sam.'.split('_'),
weekdaysMin : 'Di_Lu_Ma_Me_Je_Ve_Sa'.split('_'),
+ weekdaysParseExact : true,
longDateFormat : {
LT : 'HH:mm',
LTS : 'HH:mm:ss',
diff --git a/src/locale/fr-ch.js b/src/locale/fr-ch.js
index 3534365..f499158 100644
--- a/src/locale/fr-ch.js
+++ b/src/locale/fr-ch.js
@@ -7,9 +7,11 @@
export default moment.defineLocale('fr-ch', {
months : 'janvier_février_mars_avril_mai_juin_juillet_août_septembre_octobre_novembre_décembre'.split('_'),
monthsShort : 'janv._févr._mars_avr._mai_juin_juil._août_sept._oct._nov._déc.'.split('_'),
+ monthsParseExact : true,
weekdays : 'dimanche_lundi_mardi_mercredi_jeudi_vendredi_samedi'.split('_'),
weekdaysShort : 'dim._lun._mar._mer._jeu._ven._sam.'.split('_'),
weekdaysMin : 'Di_Lu_Ma_Me_Je_Ve_Sa'.split('_'),
+ weekdaysParseExact : true,
longDateFormat : {
LT : 'HH:mm',
LTS : 'HH:mm:ss',
diff --git a/src/locale/fr.js b/src/locale/fr.js
index deb2f63..3ff1c4b 100644
--- a/src/locale/fr.js
+++ b/src/locale/fr.js
@@ -7,9 +7,11 @@
export default moment.defineLocale('fr', {
months : 'janvier_février_mars_avril_mai_juin_juillet_août_septembre_octobre_novembre_décembre'.split('_'),
monthsShort : 'janv._févr._mars_avr._mai_juin_juil._août_sept._oct._nov._déc.'.split('_'),
+ monthsParseExact : true,
weekdays : 'dimanche_lundi_mardi_mercredi_jeudi_vendredi_samedi'.split('_'),
weekdaysShort : 'dim._lun._mar._mer._jeu._ven._sam.'.split('_'),
weekdaysMin : 'Di_Lu_Ma_Me_Je_Ve_Sa'.split('_'),
+ weekdaysParseExact : true,
longDateFormat : {
LT : 'HH:mm',
LTS : 'HH:mm:ss',
diff --git a/src/locale/fy.js b/src/locale/fy.js
index 7c8af61..b84dbbe 100644
--- a/src/locale/fy.js
+++ b/src/locale/fy.js
@@ -16,9 +16,11 @@
return monthsShortWithDots[m.month()];
}
},
+ monthsParseExact : true,
weekdays : 'snein_moandei_tiisdei_woansdei_tongersdei_freed_sneon'.split('_'),
weekdaysShort : 'si._mo._ti._wo._to._fr._so.'.split('_'),
weekdaysMin : 'Si_Mo_Ti_Wo_To_Fr_So'.split('_'),
+ weekdaysParseExact : true,
longDateFormat : {
LT : 'HH:mm',
LTS : 'HH:mm:ss',
diff --git a/src/locale/gd.js b/src/locale/gd.js
index d4fdff1..b7689f9 100644
--- a/src/locale/gd.js
+++ b/src/locale/gd.js
@@ -5,18 +5,7 @@
import moment from '../moment';
var months = [
- 'Am Faoilleach',
- 'An Gearran',
- 'Am Màrt',
- 'An Giblean',
- 'An Cèitean',
- 'An t-Ògmhios',
- 'An t-Iuchar',
- 'An Lùnastal',
- 'An t-Sultain',
- 'An Dàmhair',
- 'An t-Samhain',
- 'An Dùbhlachd'
+ 'Am Faoilleach', 'An Gearran', 'Am Màrt', 'An Giblean', 'An Cèitean', 'An t-Ògmhios', 'An t-Iuchar', 'An Lùnastal', 'An t-Sultain', 'An Dàmhair', 'An t-Samhain', 'An Dùbhlachd'
];
var monthsShort = ['Faoi', 'Gear', 'Màrt', 'Gibl', 'Cèit', 'Ògmh', 'Iuch', 'Lùn', 'Sult', 'Dàmh', 'Samh', 'Dùbh'];
@@ -30,6 +19,7 @@
export default moment.defineLocale('gd', {
months : months,
monthsShort : monthsShort,
+ monthsParseExact : true,
weekdays : weekdays,
weekdaysShort : weekdaysShort,
weekdaysMin : weekdaysMin,
diff --git a/src/locale/gl.js b/src/locale/gl.js
index 02c652c..bdccae9 100644
--- a/src/locale/gl.js
+++ b/src/locale/gl.js
@@ -7,9 +7,11 @@
export default moment.defineLocale('gl', {
months : 'Xaneiro_Febreiro_Marzo_Abril_Maio_Xuño_Xullo_Agosto_Setembro_Outubro_Novembro_Decembro'.split('_'),
monthsShort : 'Xan._Feb._Mar._Abr._Mai._Xuñ._Xul._Ago._Set._Out._Nov._Dec.'.split('_'),
+ monthsParseExact: true,
weekdays : 'Domingo_Luns_Martes_Mércores_Xoves_Venres_Sábado'.split('_'),
weekdaysShort : 'Dom._Lun._Mar._Mér._Xov._Ven._Sáb.'.split('_'),
weekdaysMin : 'Do_Lu_Ma_Mé_Xo_Ve_Sá'.split('_'),
+ weekdaysParseExact : true,
longDateFormat : {
LT : 'H:mm',
LTS : 'H:mm:ss',
diff --git a/src/locale/he.js b/src/locale/he.js
index e353158..9f4be80 100644
--- a/src/locale/he.js
+++ b/src/locale/he.js
@@ -68,6 +68,23 @@
}
return number + ' שנים';
}
+ },
+ meridiemParse: /אחה"צ|לפנה"צ|אחרי הצהריים|לפני הצהריים|לפנות בוקר|בבוקר|בערב/i,
+ isPM : function (input) {
+ return /^(אחה"צ|אחרי הצהריים|בערב)$/.test(input);
+ },
+ meridiem : function (hour, minute, isLower) {
+ if (hour < 5) {
+ return 'לפנות בוקר';
+ } else if (hour < 10) {
+ return 'בבוקר';
+ } else if (hour < 12) {
+ return isLower ? 'לפנה"צ' : 'לפני הצהריים';
+ } else if (hour < 18) {
+ return isLower ? 'אחה"צ' : 'אחרי הצהריים';
+ } else {
+ return 'בערב';
+ }
}
});
diff --git a/src/locale/hi.js b/src/locale/hi.js
index 07eae1d..fdbf292 100644
--- a/src/locale/hi.js
+++ b/src/locale/hi.js
@@ -32,6 +32,7 @@
export default moment.defineLocale('hi', {
months : 'जनवरी_फ़रवरी_मार्च_अप्रैल_मई_जून_जुलाई_अगस्त_सितम्बर_अक्टूबर_नवम्बर_दिसम्बर'.split('_'),
monthsShort : 'जन._फ़र._मार्च_अप्रै._मई_जून_जुल._अग._सित._अक्टू._नव._दिस.'.split('_'),
+ monthsParseExact: true,
weekdays : 'रविवार_सोमवार_मंगलवार_बुधवार_गुरूवार_शुक्रवार_शनिवार'.split('_'),
weekdaysShort : 'रवि_सोम_मंगल_बुध_गुरू_शुक्र_शनि'.split('_'),
weekdaysMin : 'र_सो_मं_बु_गु_शु_श'.split('_'),
diff --git a/src/locale/hr.js b/src/locale/hr.js
index dc79287..7c41712 100644
--- a/src/locale/hr.js
+++ b/src/locale/hr.js
@@ -63,9 +63,11 @@
standalone: 'siječanj_veljača_ožujak_travanj_svibanj_lipanj_srpanj_kolovoz_rujan_listopad_studeni_prosinac'.split('_')
},
monthsShort : 'sij._velj._ožu._tra._svi._lip._srp._kol._ruj._lis._stu._pro.'.split('_'),
+ monthsParseExact: true,
weekdays : 'nedjelja_ponedjeljak_utorak_srijeda_četvrtak_petak_subota'.split('_'),
weekdaysShort : 'ned._pon._uto._sri._čet._pet._sub.'.split('_'),
weekdaysMin : 'ne_po_ut_sr_če_pe_su'.split('_'),
+ weekdaysParseExact : true,
longDateFormat : {
LT : 'H:mm',
LTS : 'H:mm:ss',
diff --git a/src/locale/is.js b/src/locale/is.js
index 833907d..5a452bd 100644
--- a/src/locale/is.js
+++ b/src/locale/is.js
@@ -80,7 +80,7 @@
longDateFormat : {
LT : 'H:mm',
LTS : 'H:mm:ss',
- L : 'DD/MM/YYYY',
+ L : 'DD.MM.YYYY',
LL : 'D. MMMM YYYY',
LLL : 'D. MMMM YYYY [kl.] H:mm',
LLLL : 'dddd, D. MMMM YYYY [kl.] H:mm'
diff --git a/src/locale/ja.js b/src/locale/ja.js
index 6cdc4fc..13944e4 100644
--- a/src/locale/ja.js
+++ b/src/locale/ja.js
@@ -37,6 +37,17 @@
lastWeek : '[前週]dddd LT',
sameElse : 'L'
},
+ ordinalParse : /\d{1,2}日/,
+ ordinal : function (number, period) {
+ switch (period) {
+ case 'd':
+ case 'D':
+ case 'DDD':
+ return number + '日';
+ default:
+ return number;
+ }
+ },
relativeTime : {
future : '%s後',
past : '%s前',
diff --git a/src/locale/kk.js b/src/locale/kk.js
index 3517ab4..85e7f9e 100644
--- a/src/locale/kk.js
+++ b/src/locale/kk.js
@@ -28,11 +28,11 @@
};
export default moment.defineLocale('kk', {
- months : 'Қаңтар_Ақпан_Наурыз_Сәуір_Мамыр_Маусым_Шілде_Тамыз_Қыркүйек_Қазан_Қараша_Желтоқсан'.split('_'),
- monthsShort : 'Қаң_Ақп_Нау_Сәу_Мам_Мау_Шіл_Там_Қыр_Қаз_Қар_Жел'.split('_'),
- weekdays : 'Жексенбі_Дүйсенбі_Сейсенбі_Сәрсенбі_Бейсенбі_Жұма_Сенбі'.split('_'),
- weekdaysShort : 'Жек_Дүй_Сей_Сәр_Бей_Жұм_Сен'.split('_'),
- weekdaysMin : 'Жк_Дй_Сй_Ср_Бй_Жм_Сн'.split('_'),
+ months : 'қаңтар_ақпан_наурыз_сәуір_мамыр_маусым_шілде_тамыз_қыркүйек_қазан_қараша_желтоқсан'.split('_'),
+ monthsShort : 'қаң_ақп_нау_сәу_мам_мау_шіл_там_қыр_қаз_қар_жел'.split('_'),
+ weekdays : 'жексенбі_дүйсенбі_сейсенбі_сәрсенбі_бейсенбі_жұма_сенбі'.split('_'),
+ weekdaysShort : 'жек_дүй_сей_сәр_бей_жұм_сен'.split('_'),
+ weekdaysMin : 'жк_дй_сй_ср_бй_жм_сн'.split('_'),
longDateFormat : {
LT : 'HH:mm',
LTS : 'HH:mm:ss',
diff --git a/src/locale/km.js b/src/locale/km.js
index 0d85f3f..c7cfbe8 100644
--- a/src/locale/km.js
+++ b/src/locale/km.js
@@ -5,8 +5,8 @@
import moment from '../moment';
export default moment.defineLocale('km', {
- months: 'មករា_កុម្ភៈ_មិនា_មេសា_ឧសភា_មិថុនា_កក្កដា_សីហា_កញ្ញា_តុលា_វិច្ឆិកា_ធ្នូ'.split('_'),
- monthsShort: 'មករា_កុម្ភៈ_មិនា_មេសា_ឧសភា_មិថុនា_កក្កដា_សីហា_កញ្ញា_តុលា_វិច្ឆិកា_ធ្នូ'.split('_'),
+ months: 'មករា_កុម្ភៈ_មីនា_មេសា_ឧសភា_មិថុនា_កក្កដា_សីហា_កញ្ញា_តុលា_វិច្ឆិកា_ធ្នូ'.split('_'),
+ monthsShort: 'មករា_កុម្ភៈ_មីនា_មេសា_ឧសភា_មិថុនា_កក្កដា_សីហា_កញ្ញា_តុលា_វិច្ឆិកា_ធ្នូ'.split('_'),
weekdays: 'អាទិត្យ_ច័ន្ទ_អង្គារ_ពុធ_ព្រហស្បតិ៍_សុក្រ_សៅរ៍'.split('_'),
weekdaysShort: 'អាទិត្យ_ច័ន្ទ_អង្គារ_ពុធ_ព្រហស្បតិ៍_សុក្រ_សៅរ៍'.split('_'),
weekdaysMin: 'អាទិត្យ_ច័ន្ទ_អង្គារ_ពុធ_ព្រហស្បតិ៍_សុក្រ_សៅរ៍'.split('_'),
diff --git a/src/locale/ko.js b/src/locale/ko.js
index 268e782..c6b4a63 100644
--- a/src/locale/ko.js
+++ b/src/locale/ko.js
@@ -33,17 +33,17 @@
relativeTime : {
future : '%s 후',
past : '%s 전',
- s : '몇초',
+ s : '몇 초',
ss : '%d초',
m : '일분',
mm : '%d분',
- h : '한시간',
+ h : '한 시간',
hh : '%d시간',
d : '하루',
dd : '%d일',
- M : '한달',
+ M : '한 달',
MM : '%d달',
- y : '일년',
+ y : '일 년',
yy : '%d년'
},
ordinalParse : /\d{1,2}일/,
diff --git a/src/locale/ky.js b/src/locale/ky.js
new file mode 100644
index 0000000..4ecb53c
--- /dev/null
+++ b/src/locale/ky.js
@@ -0,0 +1,78 @@
+//! moment.js locale configuration
+//! locale : kyrgyz (ky)
+//! author : Chyngyz Arystan uulu : https://github.com/chyngyz
+
+
+import moment from '../moment';
+
+var suffixes = {
+ 0: '-чү',
+ 1: '-чи',
+ 2: '-чи',
+ 3: '-чү',
+ 4: '-чү',
+ 5: '-чи',
+ 6: '-чы',
+ 7: '-чи',
+ 8: '-чи',
+ 9: '-чу',
+ 10: '-чу',
+ 20: '-чы',
+ 30: '-чу',
+ 40: '-чы',
+ 50: '-чү',
+ 60: '-чы',
+ 70: '-чи',
+ 80: '-чи',
+ 90: '-чу',
+ 100: '-чү'
+};
+
+export default moment.defineLocale('ky', {
+ months : 'январь_февраль_март_апрель_май_июнь_июль_август_сентябрь_октябрь_ноябрь_декабрь'.split('_'),
+ monthsShort : 'янв_фев_март_апр_май_июнь_июль_авг_сен_окт_ноя_дек'.split('_'),
+ weekdays : 'Жекшемби_Дүйшөмбү_Шейшемби_Шаршемби_Бейшемби_Жума_Ишемби'.split('_'),
+ weekdaysShort : 'Жек_Дүй_Шей_Шар_Бей_Жум_Ише'.split('_'),
+ weekdaysMin : 'Жк_Дй_Шй_Шр_Бй_Жм_Иш'.split('_'),
+ longDateFormat : {
+ LT : 'HH:mm',
+ LTS : 'HH:mm:ss',
+ L : 'DD.MM.YYYY',
+ LL : 'D MMMM YYYY',
+ LLL : 'D MMMM YYYY HH:mm',
+ LLLL : 'dddd, D MMMM YYYY HH:mm'
+ },
+ calendar : {
+ sameDay : '[Бүгүн саат] LT',
+ nextDay : '[Эртең саат] LT',
+ nextWeek : 'dddd [саат] LT',
+ lastDay : '[Кече саат] LT',
+ lastWeek : '[Өткен аптанын] dddd [күнү] [саат] LT',
+ sameElse : 'L'
+ },
+ relativeTime : {
+ future : '%s ичинде',
+ past : '%s мурун',
+ s : 'бирнече секунд',
+ m : 'бир мүнөт',
+ mm : '%d мүнөт',
+ h : 'бир саат',
+ hh : '%d саат',
+ d : 'бир күн',
+ dd : '%d күн',
+ M : 'бир ай',
+ MM : '%d ай',
+ y : 'бир жыл',
+ yy : '%d жыл'
+ },
+ ordinalParse: /\d{1,2}-(чи|чы|чү|чу)/,
+ ordinal : function (number) {
+ var a = number % 10,
+ b = number >= 100 ? 100 : null;
+ return number + (suffixes[number] || suffixes[a] || suffixes[b]);
+ },
+ week : {
+ dow : 1, // Monday is the first day of the week.
+ doy : 7 // The week that contains Jan 1st is the first week of the year.
+ }
+});
diff --git a/src/locale/lb.js b/src/locale/lb.js
index 3f20eea..55676e7 100644
--- a/src/locale/lb.js
+++ b/src/locale/lb.js
@@ -72,9 +72,11 @@
export default moment.defineLocale('lb', {
months: 'Januar_Februar_Mäerz_Abrëll_Mee_Juni_Juli_August_September_Oktober_November_Dezember'.split('_'),
monthsShort: 'Jan._Febr._Mrz._Abr._Mee_Jun._Jul._Aug._Sept._Okt._Nov._Dez.'.split('_'),
+ monthsParseExact : true,
weekdays: 'Sonndeg_Méindeg_Dënschdeg_Mëttwoch_Donneschdeg_Freideg_Samschdeg'.split('_'),
weekdaysShort: 'So._Mé._Dë._Më._Do._Fr._Sa.'.split('_'),
weekdaysMin: 'So_Mé_Dë_Më_Do_Fr_Sa'.split('_'),
+ weekdaysParseExact : true,
longDateFormat: {
LT: 'H:mm [Auer]',
LTS: 'H:mm:ss [Auer]',
diff --git a/src/locale/lo.js b/src/locale/lo.js
index aed4f46..34d7452 100644
--- a/src/locale/lo.js
+++ b/src/locale/lo.js
@@ -10,6 +10,7 @@
weekdays : 'ອາທິດ_ຈັນ_ອັງຄານ_ພຸດ_ພະຫັດ_ສຸກ_ເສົາ'.split('_'),
weekdaysShort : 'ທິດ_ຈັນ_ອັງຄານ_ພຸດ_ພະຫັດ_ສຸກ_ເສົາ'.split('_'),
weekdaysMin : 'ທ_ຈ_ອຄ_ພ_ພຫ_ສກ_ສ'.split('_'),
+ weekdaysParseExact : true,
longDateFormat : {
LT : 'HH:mm',
LTS : 'HH:mm:ss',
diff --git a/src/locale/lt.js b/src/locale/lt.js
index 81e7e81..b2900db 100644
--- a/src/locale/lt.js
+++ b/src/locale/lt.js
@@ -59,6 +59,7 @@
},
weekdaysShort : 'Sek_Pir_Ant_Tre_Ket_Pen_Šeš'.split('_'),
weekdaysMin : 'S_P_A_T_K_Pn_Š'.split('_'),
+ weekdaysParseExact : true,
longDateFormat : {
LT : 'HH:mm',
LTS : 'HH:mm:ss',
diff --git a/src/locale/lv.js b/src/locale/lv.js
index 53aec40..1ff0817 100644
--- a/src/locale/lv.js
+++ b/src/locale/lv.js
@@ -46,6 +46,7 @@
weekdays : 'svētdiena_pirmdiena_otrdiena_trešdiena_ceturtdiena_piektdiena_sestdiena'.split('_'),
weekdaysShort : 'Sv_P_O_T_C_Pk_S'.split('_'),
weekdaysMin : 'Sv_P_O_T_C_Pk_S'.split('_'),
+ weekdaysParseExact : true,
longDateFormat : {
LT : 'HH:mm',
LTS : 'HH:mm:ss',
diff --git a/src/locale/me.js b/src/locale/me.js
index a509658..41e5959 100644
--- a/src/locale/me.js
+++ b/src/locale/me.js
@@ -28,11 +28,13 @@
};
export default moment.defineLocale('me', {
- months: ['januar', 'februar', 'mart', 'april', 'maj', 'jun', 'jul', 'avgust', 'septembar', 'oktobar', 'novembar', 'decembar'],
- monthsShort: ['jan.', 'feb.', 'mar.', 'apr.', 'maj', 'jun', 'jul', 'avg.', 'sep.', 'okt.', 'nov.', 'dec.'],
- weekdays: ['nedjelja', 'ponedjeljak', 'utorak', 'srijeda', 'četvrtak', 'petak', 'subota'],
- weekdaysShort: ['ned.', 'pon.', 'uto.', 'sri.', 'čet.', 'pet.', 'sub.'],
- weekdaysMin: ['ne', 'po', 'ut', 'sr', 'če', 'pe', 'su'],
+ months: 'januar_februar_mart_april_maj_jun_jul_avgust_septembar_oktobar_novembar_decembar'.split('_'),
+ monthsShort: 'jan._feb._mar._apr._maj_jun_jul_avg._sep._okt._nov._dec.'.split('_'),
+ monthsParseExact : true,
+ weekdays: 'nedjelja_ponedjeljak_utorak_srijeda_četvrtak_petak_subota'.split('_'),
+ weekdaysShort: 'ned._pon._uto._sri._čet._pet._sub.'.split('_'),
+ weekdaysMin: 'ne_po_ut_sr_če_pe_su'.split('_'),
+ weekdaysParseExact : true,
longDateFormat: {
LT: 'H:mm',
LTS : 'H:mm:ss',
diff --git a/src/locale/ml.js b/src/locale/ml.js
index 7bafa7a..17db120 100644
--- a/src/locale/ml.js
+++ b/src/locale/ml.js
@@ -7,6 +7,7 @@
export default moment.defineLocale('ml', {
months : 'ജനുവരി_ഫെബ്രുവരി_മാർച്ച്_ഏപ്രിൽ_മേയ്_ജൂൺ_ജൂലൈ_ഓഗസ്റ്റ്_സെപ്റ്റംബർ_ഒക്ടോബർ_നവംബർ_ഡിസംബർ'.split('_'),
monthsShort : 'ജനു._ഫെബ്രു._മാർ._ഏപ്രി._മേയ്_ജൂൺ_ജൂലൈ._ഓഗ._സെപ്റ്റ._ഒക്ടോ._നവം._ഡിസം.'.split('_'),
+ monthsParseExact : true,
weekdays : 'ഞായറാഴ്ച_തിങ്കളാഴ്ച_ചൊവ്വാഴ്ച_ബുധനാഴ്ച_വ്യാഴാഴ്ച_വെള്ളിയാഴ്ച_ശനിയാഴ്ച'.split('_'),
weekdaysShort : 'ഞായർ_തിങ്കൾ_ചൊവ്വ_ബുധൻ_വ്യാഴം_വെള്ളി_ശനി'.split('_'),
weekdaysMin : 'ഞാ_തി_ചൊ_ബു_വ്യാ_വെ_ശ'.split('_'),
@@ -42,8 +43,17 @@
yy : '%d വർഷം'
},
meridiemParse: /രാത്രി|രാവിലെ|ഉച്ച കഴിഞ്ഞ്|വൈകുന്നേരം|രാത്രി/i,
- isPM : function (input) {
- return /^(ഉച്ച കഴിഞ്ഞ്|വൈകുന്നേരം|രാത്രി)$/.test(input);
+ meridiemHour : function (hour, meridiem) {
+ if (hour === 12) {
+ hour = 0;
+ }
+ if ((meridiem === 'രാത്രി' && hour >= 4) ||
+ meridiem === 'ഉച്ച കഴിഞ്ഞ്' ||
+ meridiem === 'വൈകുന്നേരം') {
+ return hour + 12;
+ } else {
+ return hour;
+ }
},
meridiem : function (hour, minute, isLower) {
if (hour < 4) {
diff --git a/src/locale/mr.js b/src/locale/mr.js
index dda9aaa..8701c1d 100644
--- a/src/locale/mr.js
+++ b/src/locale/mr.js
@@ -69,6 +69,7 @@
export default moment.defineLocale('mr', {
months : 'जानेवारी_फेब्रुवारी_मार्च_एप्रिल_मे_जून_जुलै_ऑगस्ट_सप्टेंबर_ऑक्टोबर_नोव्हेंबर_डिसेंबर'.split('_'),
monthsShort: 'जाने._फेब्रु._मार्च._एप्रि._मे._जून._जुलै._ऑग._सप्टें._ऑक्टो._नोव्हें._डिसें.'.split('_'),
+ monthsParseExact : true,
weekdays : 'रविवार_सोमवार_मंगळवार_बुधवार_गुरूवार_शुक्रवार_शनिवार'.split('_'),
weekdaysShort : 'रवि_सोम_मंगळ_बुध_गुरू_शुक्र_शनि'.split('_'),
weekdaysMin : 'र_सो_मं_बु_गु_शु_श'.split('_'),
diff --git a/src/locale/nb.js b/src/locale/nb.js
index 8595f01..f0215a0 100644
--- a/src/locale/nb.js
+++ b/src/locale/nb.js
@@ -8,9 +8,11 @@
export default moment.defineLocale('nb', {
months : 'januar_februar_mars_april_mai_juni_juli_august_september_oktober_november_desember'.split('_'),
monthsShort : 'jan._feb._mars_april_mai_juni_juli_aug._sep._okt._nov._des.'.split('_'),
+ monthsParseExact : true,
weekdays : 'søndag_mandag_tirsdag_onsdag_torsdag_fredag_lørdag'.split('_'),
weekdaysShort : 'sø._ma._ti._on._to._fr._lø.'.split('_'),
weekdaysMin : 'sø_ma_ti_on_to_fr_lø'.split('_'),
+ weekdaysParseExact : true,
longDateFormat : {
LT : 'HH:mm',
LTS : 'HH:mm:ss',
@@ -29,7 +31,7 @@
},
relativeTime : {
future : 'om %s',
- past : 'for %s siden',
+ past : '%s siden',
s : 'noen sekunder',
m : 'ett minutt',
mm : '%d minutter',
diff --git a/src/locale/ne.js b/src/locale/ne.js
index e2bc455..76dd1a2 100644
--- a/src/locale/ne.js
+++ b/src/locale/ne.js
@@ -32,9 +32,11 @@
export default moment.defineLocale('ne', {
months : 'जनवरी_फेब्रुवरी_मार्च_अप्रिल_मई_जुन_जुलाई_अगष्ट_सेप्टेम्बर_अक्टोबर_नोभेम्बर_डिसेम्बर'.split('_'),
monthsShort : 'जन._फेब्रु._मार्च_अप्रि._मई_जुन_जुलाई._अग._सेप्ट._अक्टो._नोभे._डिसे.'.split('_'),
+ monthsParseExact : true,
weekdays : 'आइतबार_सोमबार_मङ्गलबार_बुधबार_बिहिबार_शुक्रबार_शनिबार'.split('_'),
weekdaysShort : 'आइत._सोम._मङ्गल._बुध._बिहि._शुक्र._शनि.'.split('_'),
weekdaysMin : 'आ._सो._मं._बु._बि._शु._श.'.split('_'),
+ weekdaysParseExact : true,
longDateFormat : {
LT : 'Aको h:mm बजे',
LTS : 'Aको h:mm:ss बजे',
diff --git a/src/locale/nl.js b/src/locale/nl.js
index 6669531..1c6be4d 100644
--- a/src/locale/nl.js
+++ b/src/locale/nl.js
@@ -16,9 +16,11 @@
return monthsShortWithDots[m.month()];
}
},
+ monthsParseExact : true,
weekdays : 'zondag_maandag_dinsdag_woensdag_donderdag_vrijdag_zaterdag'.split('_'),
weekdaysShort : 'zo._ma._di._wo._do._vr._za.'.split('_'),
weekdaysMin : 'Zo_Ma_Di_Wo_Do_Vr_Za'.split('_'),
+ weekdaysParseExact : true,
longDateFormat : {
LT : 'HH:mm',
LTS : 'HH:mm:ss',
diff --git a/src/locale/nn.js b/src/locale/nn.js
index 822a44c..f341cb4 100644
--- a/src/locale/nn.js
+++ b/src/locale/nn.js
@@ -28,7 +28,7 @@
},
relativeTime : {
future : 'om %s',
- past : 'for %s sidan',
+ past : '%s sidan',
s : 'nokre sekund',
m : 'eit minutt',
mm : '%d minutt',
diff --git a/src/locale/pa-in.js b/src/locale/pa-in.js
new file mode 100644
index 0000000..5f2721a
--- /dev/null
+++ b/src/locale/pa-in.js
@@ -0,0 +1,115 @@
+//! moment.js locale configuration
+//! locale : punjabi india (pa-in)
+//! author : Harpreet Singh : https://github.com/harpreetkhalsagtbit
+
+import moment from '../moment';
+
+var symbolMap = {
+ '1': '੧',
+ '2': '੨',
+ '3': '੩',
+ '4': '੪',
+ '5': '੫',
+ '6': '੬',
+ '7': '੭',
+ '8': '੮',
+ '9': '੯',
+ '0': '੦'
+},
+numberMap = {
+ '੧': '1',
+ '੨': '2',
+ '੩': '3',
+ '੪': '4',
+ '੫': '5',
+ '੬': '6',
+ '੭': '7',
+ '੮': '8',
+ '੯': '9',
+ '੦': '0'
+};
+
+export default moment.defineLocale('pa-in', {
+ // There are months name as per Nanakshahi Calender but they are not used as rigidly in modern Punjabi.
+ months : 'ਜਨਵਰੀ_ਫ਼ਰਵਰੀ_ਮਾਰਚ_ਅਪ੍ਰੈਲ_ਮਈ_ਜੂਨ_ਜੁਲਾਈ_ਅਗਸਤ_ਸਤੰਬਰ_ਅਕਤੂਬਰ_ਨਵੰਬਰ_ਦਸੰਬਰ'.split('_'),
+ monthsShort : 'ਜਨਵਰੀ_ਫ਼ਰਵਰੀ_ਮਾਰਚ_ਅਪ੍ਰੈਲ_ਮਈ_ਜੂਨ_ਜੁਲਾਈ_ਅਗਸਤ_ਸਤੰਬਰ_ਅਕਤੂਬਰ_ਨਵੰਬਰ_ਦਸੰਬਰ'.split('_'),
+ weekdays : 'ਐਤਵਾਰ_ਸੋਮਵਾਰ_ਮੰਗਲਵਾਰ_ਬੁਧਵਾਰ_ਵੀਰਵਾਰ_ਸ਼ੁੱਕਰਵਾਰ_ਸ਼ਨੀਚਰਵਾਰ'.split('_'),
+ weekdaysShort : 'ਐਤ_ਸੋਮ_ਮੰਗਲ_ਬੁਧ_ਵੀਰ_ਸ਼ੁਕਰ_ਸ਼ਨੀ'.split('_'),
+ weekdaysMin : 'ਐਤ_ਸੋਮ_ਮੰਗਲ_ਬੁਧ_ਵੀਰ_ਸ਼ੁਕਰ_ਸ਼ਨੀ'.split('_'),
+ longDateFormat : {
+ LT : 'A h:mm ਵਜੇ',
+ LTS : 'A h:mm:ss ਵਜੇ',
+ L : 'DD/MM/YYYY',
+ LL : 'D MMMM YYYY',
+ LLL : 'D MMMM YYYY, A h:mm ਵਜੇ',
+ LLLL : 'dddd, D MMMM YYYY, A h:mm ਵਜੇ'
+ },
+ calendar : {
+ sameDay : '[ਅਜ] LT',
+ nextDay : '[ਕਲ] LT',
+ nextWeek : 'dddd, LT',
+ lastDay : '[ਕਲ] LT',
+ lastWeek : '[ਪਿਛਲੇ] dddd, LT',
+ sameElse : 'L'
+ },
+ relativeTime : {
+ future : '%s ਵਿੱਚ',
+ past : '%s ਪਿਛਲੇ',
+ s : 'ਕੁਝ ਸਕਿੰਟ',
+ m : 'ਇਕ ਮਿੰਟ',
+ mm : '%d ਮਿੰਟ',
+ h : 'ਇੱਕ ਘੰਟਾ',
+ hh : '%d ਘੰਟੇ',
+ d : 'ਇੱਕ ਦਿਨ',
+ dd : '%d ਦਿਨ',
+ M : 'ਇੱਕ ਮਹੀਨਾ',
+ MM : '%d ਮਹੀਨੇ',
+ y : 'ਇੱਕ ਸਾਲ',
+ yy : '%d ਸਾਲ'
+ },
+ preparse: function (string) {
+ return string.replace(/[੧੨੩੪੫੬੭੮੯੦]/g, function (match) {
+ return numberMap[match];
+ });
+ },
+ postformat: function (string) {
+ return string.replace(/\d/g, function (match) {
+ return symbolMap[match];
+ });
+ },
+ // Punjabi notation for meridiems are quite fuzzy in practice. While there exists
+ // a rigid notion of a 'Pahar' it is not used as rigidly in modern Punjabi.
+ meridiemParse: /ਰਾਤ|ਸਵੇਰ|ਦੁਪਹਿਰ|ਸ਼ਾਮ/,
+ meridiemHour : function (hour, meridiem) {
+ if (hour === 12) {
+ hour = 0;
+ }
+ if (meridiem === 'ਰਾਤ') {
+ return hour < 4 ? hour : hour + 12;
+ } else if (meridiem === 'ਸਵੇਰ') {
+ return hour;
+ } else if (meridiem === 'ਦੁਪਹਿਰ') {
+ return hour >= 10 ? hour : hour + 12;
+ } else if (meridiem === 'ਸ਼ਾਮ') {
+ return hour + 12;
+ }
+ },
+ meridiem : function (hour, minute, isLower) {
+ if (hour < 4) {
+ return 'ਰਾਤ';
+ } else if (hour < 10) {
+ return 'ਸਵੇਰ';
+ } else if (hour < 17) {
+ return 'ਦੁਪਹਿਰ';
+ } else if (hour < 20) {
+ return 'ਸ਼ਾਮ';
+ } else {
+ return 'ਰਾਤ';
+ }
+ },
+ week : {
+ dow : 0, // Sunday is the first day of the week.
+ doy : 6 // The week that contains Jan 1st is the first week of the year.
+ }
+});
+
diff --git a/src/locale/pt-br.js b/src/locale/pt-br.js
index c002fdb..50748fb 100644
--- a/src/locale/pt-br.js
+++ b/src/locale/pt-br.js
@@ -7,9 +7,10 @@
export default moment.defineLocale('pt-br', {
months : 'Janeiro_Fevereiro_Março_Abril_Maio_Junho_Julho_Agosto_Setembro_Outubro_Novembro_Dezembro'.split('_'),
monthsShort : 'Jan_Fev_Mar_Abr_Mai_Jun_Jul_Ago_Set_Out_Nov_Dez'.split('_'),
- weekdays : 'Domingo_Segunda-Feira_Terça-Feira_Quarta-Feira_Quinta-Feira_Sexta-Feira_Sábado'.split('_'),
+ weekdays : 'Domingo_Segunda-feira_Terça-feira_Quarta-feira_Quinta-feira_Sexta-feira_Sábado'.split('_'),
weekdaysShort : 'Dom_Seg_Ter_Qua_Qui_Sex_Sáb'.split('_'),
weekdaysMin : 'Dom_2ª_3ª_4ª_5ª_6ª_Sáb'.split('_'),
+ weekdaysParseExact : true,
longDateFormat : {
LT : 'HH:mm',
LTS : 'HH:mm:ss',
diff --git a/src/locale/pt.js b/src/locale/pt.js
index 0a38d46..db3ba64 100644
--- a/src/locale/pt.js
+++ b/src/locale/pt.js
@@ -10,6 +10,7 @@
weekdays : 'Domingo_Segunda-Feira_Terça-Feira_Quarta-Feira_Quinta-Feira_Sexta-Feira_Sábado'.split('_'),
weekdaysShort : 'Dom_Seg_Ter_Qua_Qui_Sex_Sáb'.split('_'),
weekdaysMin : 'Dom_2ª_3ª_4ª_5ª_6ª_Sáb'.split('_'),
+ weekdaysParseExact : true,
longDateFormat : {
LT : 'HH:mm',
LTS : 'HH:mm:ss',
diff --git a/src/locale/ro.js b/src/locale/ro.js
index 56413d8..1f26ac9 100644
--- a/src/locale/ro.js
+++ b/src/locale/ro.js
@@ -23,6 +23,7 @@
export default moment.defineLocale('ro', {
months : 'ianuarie_februarie_martie_aprilie_mai_iunie_iulie_august_septembrie_octombrie_noiembrie_decembrie'.split('_'),
monthsShort : 'ian._febr._mart._apr._mai_iun._iul._aug._sept._oct._nov._dec.'.split('_'),
+ monthsParseExact: true,
weekdays : 'duminică_luni_marți_miercuri_joi_vineri_sâmbătă'.split('_'),
weekdaysShort : 'Dum_Lun_Mar_Mie_Joi_Vin_Sâm'.split('_'),
weekdaysMin : 'Du_Lu_Ma_Mi_Jo_Vi_Sâ'.split('_'),
diff --git a/src/locale/ru.js b/src/locale/ru.js
index e9f0635..758d72b 100644
--- a/src/locale/ru.js
+++ b/src/locale/ru.js
@@ -2,6 +2,7 @@
//! locale : russian (ru)
//! author : Viktorminator : https://github.com/Viktorminator
//! Author : Menelion Elensúle : https://github.com/Oire
+//! author : Коренберг Марк : https://github.com/socketpair
import moment from '../moment';
@@ -24,27 +25,35 @@
return number + ' ' + plural(format[key], +number);
}
}
-var monthsParse = [/^янв/i, /^фев/i, /^мар/i, /^апр/i, /^ма[й|я]/i, /^июн/i, /^июл/i, /^авг/i, /^сен/i, /^окт/i, /^ноя/i, /^дек/i];
+var monthsParse = [/^янв/i, /^фев/i, /^мар/i, /^апр/i, /^ма[йя]/i, /^июн/i, /^июл/i, /^авг/i, /^сен/i, /^окт/i, /^ноя/i, /^дек/i];
+// http://new.gramota.ru/spravka/rules/139-prop : § 103
+// Сокращения месяцев: http://new.gramota.ru/spravka/buro/search-answer?s=242637
+// CLDR data: http://www.unicode.org/cldr/charts/28/summary/ru.html#1753
export default moment.defineLocale('ru', {
months : {
- format: 'Января_Февраля_Марта_Апреля_Мая_Июня_Июля_Августа_Сентября_Октября_Ноября_Декабря'.split('_'),
- standalone: 'Январь_Февраль_Март_Апрель_Май_Июнь_Июль_Август_Сентябрь_Октябрь_Ноябрь_Декабрь'.split('_')
+ format: 'января_февраля_марта_апреля_мая_июня_июля_августа_сентября_октября_ноября_декабря'.split('_'),
+ standalone: 'январь_февраль_март_апрель_май_июнь_июль_август_сентябрь_октябрь_ноябрь_декабрь'.split('_')
},
monthsShort : {
- format: 'янв_фев_мар_апр_мая_июня_июля_авг_сен_окт_ноя_дек'.split('_'),
- standalone: 'янв_фев_март_апр_май_июнь_июль_авг_сен_окт_ноя_дек'.split('_')
+ // по CLDR именно "июл." и "июн.", но какой смысл менять букву на точку ?
+ format: 'янв._февр._мар._апр._мая_июня_июля_авг._сент._окт._нояб._дек.'.split('_'),
+ standalone: 'янв._февр._март_апр._май_июнь_июль_авг._сент._окт._нояб._дек.'.split('_')
},
weekdays : {
- standalone: 'Воскресенье_Понедельник_Вторник_Среда_Четверг_Пятница_Суббота'.split('_'),
- format: 'Воскресенье_Понедельник_Вторник_Среду_Четверг_Пятницу_Субботу'.split('_'),
+ standalone: 'воскресенье_понедельник_вторник_среда_четверг_пятница_суббота'.split('_'),
+ format: 'воскресенье_понедельник_вторник_среду_четверг_пятницу_субботу'.split('_'),
isFormat: /\[ ?[Вв] ?(?:прошлую|следующую|эту)? ?\] ?dddd/
},
- weekdaysShort : 'Вс_Пн_Вт_Ср_Чт_Пт_Сб'.split('_'),
- weekdaysMin : 'Вс_Пн_Вт_Ср_Чт_Пт_Сб'.split('_'),
+ weekdaysShort : 'вс_пн_вт_ср_чт_пт_сб'.split('_'),
+ weekdaysMin : 'вс_пн_вт_ср_чт_пт_сб'.split('_'),
monthsParse : monthsParse,
longMonthsParse : monthsParse,
shortMonthsParse : monthsParse,
+ monthsRegex: /^(сентябр[яь]|октябр[яь]|декабр[яь]|феврал[яь]|январ[яь]|апрел[яь]|августа?|ноябр[яь]|сент\.|февр\.|нояб\.|июнь|янв.|июль|дек.|авг.|апр.|марта|мар[.т]|окт.|июн[яь]|июл[яь]|ма[яй])/i,
+ monthsShortRegex: /^(сентябр[яь]|октябр[яь]|декабр[яь]|феврал[яь]|январ[яь]|апрел[яь]|августа?|ноябр[яь]|сент\.|февр\.|нояб\.|июнь|янв.|июль|дек.|авг.|апр.|марта|мар[.т]|окт.|июн[яь]|июл[яь]|ма[яй])/i,
+ monthsStrictRegex: /^(сентябр[яь]|октябр[яь]|декабр[яь]|феврал[яь]|январ[яь]|апрел[яь]|августа?|ноябр[яь]|марта?|июн[яь]|июл[яь]|ма[яй])/i,
+ monthsShortStrictRegex: /^(нояб\.|февр\.|сент\.|июль|янв\.|июн[яь]|мар[.т]|авг\.|апр\.|окт\.|дек\.|ма[яй])/i,
longDateFormat : {
LT : 'HH:mm',
LTS : 'HH:mm:ss',
diff --git a/src/locale/si.js b/src/locale/si.js
index 15c9f15..10c728f 100644
--- a/src/locale/si.js
+++ b/src/locale/si.js
@@ -11,6 +11,7 @@
weekdays : 'ඉරිදා_සඳුදා_අඟහරුවාදා_බදාදා_බ්රහස්පතින්දා_සිකුරාදා_සෙනසුරාදා'.split('_'),
weekdaysShort : 'ඉරි_සඳු_අඟ_බදා_බ්රහ_සිකු_සෙන'.split('_'),
weekdaysMin : 'ඉ_ස_අ_බ_බ්ර_සි_සෙ'.split('_'),
+ weekdaysParseExact : true,
longDateFormat : {
LT : 'a h:mm',
LTS : 'a h:mm:ss',
@@ -46,6 +47,10 @@
ordinal : function (number) {
return number + ' වැනි';
},
+ meridiemParse : /පෙර වරු|පස් වරු|පෙ.ව|ප.ව./,
+ isPM : function (input) {
+ return input === 'ප.ව.' || input === 'පස් වරු';
+ },
meridiem : function (hours, minutes, isLower) {
if (hours > 11) {
return isLower ? 'ප.ව.' : 'පස් වරු';
diff --git a/src/locale/sl.js b/src/locale/sl.js
index 0cb6701..36b0e2e 100644
--- a/src/locale/sl.js
+++ b/src/locale/sl.js
@@ -78,9 +78,11 @@
export default moment.defineLocale('sl', {
months : 'januar_februar_marec_april_maj_junij_julij_avgust_september_oktober_november_december'.split('_'),
monthsShort : 'jan._feb._mar._apr._maj._jun._jul._avg._sep._okt._nov._dec.'.split('_'),
+ monthsParseExact: true,
weekdays : 'nedelja_ponedeljek_torek_sreda_četrtek_petek_sobota'.split('_'),
weekdaysShort : 'ned._pon._tor._sre._čet._pet._sob.'.split('_'),
weekdaysMin : 'ne_po_to_sr_če_pe_so'.split('_'),
+ weekdaysParseExact : true,
longDateFormat : {
LT : 'H:mm',
LTS : 'H:mm:ss',
diff --git a/src/locale/sq.js b/src/locale/sq.js
index d8a9c02..c5aeac3 100644
--- a/src/locale/sq.js
+++ b/src/locale/sq.js
@@ -12,6 +12,7 @@
weekdays : 'E Diel_E Hënë_E Martë_E Mërkurë_E Enjte_E Premte_E Shtunë'.split('_'),
weekdaysShort : 'Die_Hën_Mar_Mër_Enj_Pre_Sht'.split('_'),
weekdaysMin : 'D_H_Ma_Më_E_P_Sh'.split('_'),
+ weekdaysParseExact : true,
meridiemParse: /PD|MD/,
isPM: function (input) {
return input.charAt(0) === 'M';
diff --git a/src/locale/sr-cyrl.js b/src/locale/sr-cyrl.js
index 2ce8eea..af2a84d 100644
--- a/src/locale/sr-cyrl.js
+++ b/src/locale/sr-cyrl.js
@@ -28,11 +28,13 @@
};
export default moment.defineLocale('sr-cyrl', {
- months: ['јануар', 'фебруар', 'март', 'април', 'мај', 'јун', 'јул', 'август', 'септембар', 'октобар', 'новембар', 'децембар'],
- monthsShort: ['јан.', 'феб.', 'мар.', 'апр.', 'мај', 'јун', 'јул', 'авг.', 'сеп.', 'окт.', 'нов.', 'дец.'],
- weekdays: ['недеља', 'понедељак', 'уторак', 'среда', 'четвртак', 'петак', 'субота'],
- weekdaysShort: ['нед.', 'пон.', 'уто.', 'сре.', 'чет.', 'пет.', 'суб.'],
- weekdaysMin: ['не', 'по', 'ут', 'ср', 'че', 'пе', 'су'],
+ months: 'јануар_фебруар_март_април_мај_јун_јул_август_септембар_октобар_новембар_децембар'.split('_'),
+ monthsShort: 'јан._феб._мар._апр._мај_јун_јул_авг._сеп._окт._нов._дец.'.split('_'),
+ monthsParseExact: true,
+ weekdays: 'недеља_понедељак_уторак_среда_четвртак_петак_субота'.split('_'),
+ weekdaysShort: 'нед._пон._уто._сре._чет._пет._суб.'.split('_'),
+ weekdaysMin: 'не_по_ут_ср_че_пе_су'.split('_'),
+ weekdaysParseExact : true,
longDateFormat: {
LT: 'H:mm',
LTS : 'H:mm:ss',
diff --git a/src/locale/sr.js b/src/locale/sr.js
index 233e467..46fc749 100644
--- a/src/locale/sr.js
+++ b/src/locale/sr.js
@@ -28,11 +28,13 @@
};
export default moment.defineLocale('sr', {
- months: ['januar', 'februar', 'mart', 'april', 'maj', 'jun', 'jul', 'avgust', 'septembar', 'oktobar', 'novembar', 'decembar'],
- monthsShort: ['jan.', 'feb.', 'mar.', 'apr.', 'maj', 'jun', 'jul', 'avg.', 'sep.', 'okt.', 'nov.', 'dec.'],
- weekdays: ['nedelja', 'ponedeljak', 'utorak', 'sreda', 'četvrtak', 'petak', 'subota'],
- weekdaysShort: ['ned.', 'pon.', 'uto.', 'sre.', 'čet.', 'pet.', 'sub.'],
- weekdaysMin: ['ne', 'po', 'ut', 'sr', 'če', 'pe', 'su'],
+ months: 'januar_februar_mart_april_maj_jun_jul_avgust_septembar_oktobar_novembar_decembar'.split('_'),
+ monthsShort: 'jan._feb._mar._apr._maj_jun_jul_avg._sep._okt._nov._dec.'.split('_'),
+ monthsParseExact: true,
+ weekdays: 'nedelja_ponedeljak_utorak_sreda_četvrtak_petak_subota'.split('_'),
+ weekdaysShort: 'ned._pon._uto._sre._čet._pet._sub.'.split('_'),
+ weekdaysMin: 'ne_po_ut_sr_če_pe_su'.split('_'),
+ weekdaysParseExact : true,
longDateFormat: {
LT: 'H:mm',
LTS : 'H:mm:ss',
diff --git a/src/locale/ss.js b/src/locale/ss.js
new file mode 100644
index 0000000..fc1bcfb
--- /dev/null
+++ b/src/locale/ss.js
@@ -0,0 +1,80 @@
+//! moment.js locale configuration
+//! locale : siSwati (ss)
+//! author : Nicolai Davies : https://github.com/nicolaidavies
+
+
+import moment from '../moment';
+
+export default moment.defineLocale('ss', {
+ months : "Bhimbidvwane_Indlovana_Indlov'lenkhulu_Mabasa_Inkhwekhweti_Inhlaba_Kholwane_Ingci_Inyoni_Imphala_Lweti_Ingongoni".split('_'),
+ monthsShort : 'Bhi_Ina_Inu_Mab_Ink_Inh_Kho_Igc_Iny_Imp_Lwe_Igo'.split('_'),
+ weekdays : 'Lisontfo_Umsombuluko_Lesibili_Lesitsatfu_Lesine_Lesihlanu_Umgcibelo'.split('_'),
+ weekdaysShort : 'Lis_Umb_Lsb_Les_Lsi_Lsh_Umg'.split('_'),
+ weekdaysMin : 'Li_Us_Lb_Lt_Ls_Lh_Ug'.split('_'),
+ weekdaysParseExact : true,
+ longDateFormat : {
+ LT : 'h:mm A',
+ LTS : 'h:mm:ss A',
+ L : 'DD/MM/YYYY',
+ LL : 'D MMMM YYYY',
+ LLL : 'D MMMM YYYY h:mm A',
+ LLLL : 'dddd, D MMMM YYYY h:mm A'
+ },
+ calendar : {
+ sameDay : '[Namuhla nga] LT',
+ nextDay : '[Kusasa nga] LT',
+ nextWeek : 'dddd [nga] LT',
+ lastDay : '[Itolo nga] LT',
+ lastWeek : 'dddd [leliphelile] [nga] LT',
+ sameElse : 'L'
+ },
+ relativeTime : {
+ future : 'nga %s',
+ past : 'wenteka nga %s',
+ s : 'emizuzwana lomcane',
+ m : 'umzuzu',
+ mm : '%d emizuzu',
+ h : 'lihora',
+ hh : '%d emahora',
+ d : 'lilanga',
+ dd : '%d emalanga',
+ M : 'inyanga',
+ MM : '%d tinyanga',
+ y : 'umnyaka',
+ yy : '%d iminyaka'
+ },
+ meridiemParse: /ekuseni|emini|entsambama|ebusuku/,
+ meridiem : function (hours, minutes, isLower) {
+ if (hours < 11) {
+ return 'ekuseni';
+ } else if (hours < 15) {
+ return 'emini';
+ } else if (hours < 19) {
+ return 'entsambama';
+ } else {
+ return 'ebusuku';
+ }
+ },
+ meridiemHour : function (hour, meridiem) {
+ if (hour === 12) {
+ hour = 0;
+ }
+ if (meridiem === 'ekuseni') {
+ return hour;
+ } else if (meridiem === 'emini') {
+ return hour >= 11 ? hour : hour + 12;
+ } else if (meridiem === 'entsambama' || meridiem === 'ebusuku') {
+ if (hour === 0) {
+ return 0;
+ }
+ return hour + 12;
+ }
+ },
+ ordinalParse: /\d{1,2}/,
+ ordinal : '%d',
+ week : {
+ dow : 1, // Monday is the first day of the week.
+ doy : 4 // The week that contains Jan 4th is the first week of the year.
+ }
+});
+
diff --git a/src/locale/sv.js b/src/locale/sv.js
index 1e841f6..3354944 100644
--- a/src/locale/sv.js
+++ b/src/locale/sv.js
@@ -15,8 +15,10 @@
LTS : 'HH:mm:ss',
L : 'YYYY-MM-DD',
LL : 'D MMMM YYYY',
- LLL : 'D MMMM YYYY HH:mm',
- LLLL : 'dddd D MMMM YYYY HH:mm'
+ LLL : 'D MMMM YYYY [kl.] HH:mm',
+ LLLL : 'dddd D MMMM YYYY [kl.] HH:mm',
+ lll : 'D MMM YYYY HH:mm',
+ llll : 'ddd D MMM YYYY HH:mm'
},
calendar : {
sameDay: '[Idag] LT',
diff --git a/src/locale/sw.js b/src/locale/sw.js
index 0b7ae92..06850d6 100644
--- a/src/locale/sw.js
+++ b/src/locale/sw.js
@@ -10,6 +10,7 @@
weekdays : 'Jumapili_Jumatatu_Jumanne_Jumatano_Alhamisi_Ijumaa_Jumamosi'.split('_'),
weekdaysShort : 'Jpl_Jtat_Jnne_Jtan_Alh_Ijm_Jmos'.split('_'),
weekdaysMin : 'J2_J3_J4_J5_Al_Ij_J1'.split('_'),
+ weekdaysParseExact : true,
longDateFormat : {
LT : 'HH:mm',
LTS : 'HH:mm:ss',
diff --git a/src/locale/te.js b/src/locale/te.js
index 37daa5b..423c592 100644
--- a/src/locale/te.js
+++ b/src/locale/te.js
@@ -7,6 +7,7 @@
export default moment.defineLocale('te', {
months : 'జనవరి_ఫిబ్రవరి_మార్చి_ఏప్రిల్_మే_జూన్_జూలై_ఆగస్టు_సెప్టెంబర్_అక్టోబర్_నవంబర్_డిసెంబర్'.split('_'),
monthsShort : 'జన._ఫిబ్ర._మార్చి_ఏప్రి._మే_జూన్_జూలై_ఆగ._సెప్._అక్టో._నవ._డిసె.'.split('_'),
+ monthsParseExact : true,
weekdays : 'ఆదివారం_సోమవారం_మంగళవారం_బుధవారం_గురువారం_శుక్రవారం_శనివారం'.split('_'),
weekdaysShort : 'ఆది_సోమ_మంగళ_బుధ_గురు_శుక్ర_శని'.split('_'),
weekdaysMin : 'ఆ_సో_మం_బు_గు_శు_శ'.split('_'),
diff --git a/src/locale/th.js b/src/locale/th.js
index 265680c..107e0a9 100644
--- a/src/locale/th.js
+++ b/src/locale/th.js
@@ -7,9 +7,11 @@
export default moment.defineLocale('th', {
months : 'มกราคม_กุมภาพันธ์_มีนาคม_เมษายน_พฤษภาคม_มิถุนายน_กรกฎาคม_สิงหาคม_กันยายน_ตุลาคม_พฤศจิกายน_ธันวาคม'.split('_'),
monthsShort : 'มกรา_กุมภา_มีนา_เมษา_พฤษภา_มิถุนา_กรกฎา_สิงหา_กันยา_ตุลา_พฤศจิกา_ธันวา'.split('_'),
+ monthsParseExact: true,
weekdays : 'อาทิตย์_จันทร์_อังคาร_พุธ_พฤหัสบดี_ศุกร์_เสาร์'.split('_'),
weekdaysShort : 'อาทิตย์_จันทร์_อังคาร_พุธ_พฤหัส_ศุกร์_เสาร์'.split('_'), // yes, three characters difference
weekdaysMin : 'อา._จ._อ._พ._พฤ._ศ._ส.'.split('_'),
+ weekdaysParseExact : true,
longDateFormat : {
LT : 'H นาฬิกา m นาที',
LTS : 'H นาฬิกา m นาที s วินาที',
diff --git a/src/locale/tlh.js b/src/locale/tlh.js
index e8ffa2a..1e75f77 100644
--- a/src/locale/tlh.js
+++ b/src/locale/tlh.js
@@ -66,6 +66,7 @@
export default moment.defineLocale('tlh', {
months : 'tera’ jar wa’_tera’ jar cha’_tera’ jar wej_tera’ jar loS_tera’ jar vagh_tera’ jar jav_tera’ jar Soch_tera’ jar chorgh_tera’ jar Hut_tera’ jar wa’maH_tera’ jar wa’maH wa’_tera’ jar wa’maH cha’'.split('_'),
monthsShort : 'jar wa’_jar cha’_jar wej_jar loS_jar vagh_jar jav_jar Soch_jar chorgh_jar Hut_jar wa’maH_jar wa’maH wa’_jar wa’maH cha’'.split('_'),
+ monthsParseExact : true,
weekdays : 'lojmItjaj_DaSjaj_povjaj_ghItlhjaj_loghjaj_buqjaj_ghInjaj'.split('_'),
weekdaysShort : 'lojmItjaj_DaSjaj_povjaj_ghItlhjaj_loghjaj_buqjaj_ghInjaj'.split('_'),
weekdaysMin : 'lojmItjaj_DaSjaj_povjaj_ghItlhjaj_loghjaj_buqjaj_ghInjaj'.split('_'),
diff --git a/src/locale/tzl.js b/src/locale/tzl.js
index 7c2a77a..9f983f7 100644
--- a/src/locale/tzl.js
+++ b/src/locale/tzl.js
@@ -20,6 +20,10 @@
LL : 'D. MMMM [dallas] YYYY',
LLL : 'D. MMMM [dallas] YYYY HH.mm',
LLLL : 'dddd, [li] D. MMMM [dallas] YYYY HH.mm'
+ },
+ meridiemParse: /d\'o|d\'a/i,
+ isPM : function (input) {
+ return 'd\'o' === input.toLowerCase();
},
meridiem : function (hours, minutes, isLower) {
if (hours > 11) {
diff --git a/src/locale/vi.js b/src/locale/vi.js
index 0fafda7..34cc18d 100644
--- a/src/locale/vi.js
+++ b/src/locale/vi.js
@@ -7,9 +7,22 @@
export default moment.defineLocale('vi', {
months : 'tháng 1_tháng 2_tháng 3_tháng 4_tháng 5_tháng 6_tháng 7_tháng 8_tháng 9_tháng 10_tháng 11_tháng 12'.split('_'),
monthsShort : 'Th01_Th02_Th03_Th04_Th05_Th06_Th07_Th08_Th09_Th10_Th11_Th12'.split('_'),
+ monthsParseExact : true,
weekdays : 'chủ nhật_thứ hai_thứ ba_thứ tư_thứ năm_thứ sáu_thứ bảy'.split('_'),
weekdaysShort : 'CN_T2_T3_T4_T5_T6_T7'.split('_'),
weekdaysMin : 'CN_T2_T3_T4_T5_T6_T7'.split('_'),
+ weekdaysParseExact : true,
+ meridiemParse: /sa|ch/i,
+ isPM : function (input) {
+ return /^ch$/i.test(input);
+ },
+ meridiem : function (hours, minutes, isLower) {
+ if (hours < 12) {
+ return isLower ? 'sa' : 'SA';
+ } else {
+ return isLower ? 'ch' : 'CH';
+ }
+ },
longDateFormat : {
LT : 'HH:mm',
LTS : 'HH:mm:ss',
diff --git a/src/locale/x-pseudo.js b/src/locale/x-pseudo.js
new file mode 100644
index 0000000..3bcb80f
--- /dev/null
+++ b/src/locale/x-pseudo.js
@@ -0,0 +1,58 @@
+//! moment.js locale configuration
+//! locale : pseudo (x-pseudo)
+//! author : Andrew Hood : https://github.com/andrewhood125
+
+import moment from '../moment';
+
+export default moment.defineLocale('x-pseudo', {
+ months : 'J~áñúá~rý_F~ébrú~árý_~Márc~h_Áp~ríl_~Máý_~Júñé~_Júl~ý_Áú~gúst~_Sép~témb~ér_Ó~ctób~ér_Ñ~óvém~bér_~Décé~mbér'.split('_'),
+ monthsShort : 'J~áñ_~Féb_~Már_~Ápr_~Máý_~Júñ_~Júl_~Áúg_~Sép_~Óct_~Ñóv_~Déc'.split('_'),
+ monthsParseExact : true,
+ weekdays : 'S~úñdá~ý_Mó~ñdáý~_Túé~sdáý~_Wéd~ñésd~áý_T~húrs~dáý_~Fríd~áý_S~átúr~dáý'.split('_'),
+ weekdaysShort : 'S~úñ_~Móñ_~Túé_~Wéd_~Thú_~Frí_~Sát'.split('_'),
+ weekdaysMin : 'S~ú_Mó~_Tú_~Wé_T~h_Fr~_Sá'.split('_'),
+ weekdaysParseExact : true,
+ longDateFormat : {
+ LT : 'HH:mm',
+ L : 'DD/MM/YYYY',
+ LL : 'D MMMM YYYY',
+ LLL : 'D MMMM YYYY HH:mm',
+ LLLL : 'dddd, D MMMM YYYY HH:mm'
+ },
+ calendar : {
+ sameDay : '[T~ódá~ý át] LT',
+ nextDay : '[T~ómó~rró~w át] LT',
+ nextWeek : 'dddd [át] LT',
+ lastDay : '[Ý~ést~érdá~ý át] LT',
+ lastWeek : '[L~ást] dddd [át] LT',
+ sameElse : 'L'
+ },
+ relativeTime : {
+ future : 'í~ñ %s',
+ past : '%s á~gó',
+ s : 'á ~féw ~sécó~ñds',
+ m : 'á ~míñ~úté',
+ mm : '%d m~íñú~tés',
+ h : 'á~ñ hó~úr',
+ hh : '%d h~óúrs',
+ d : 'á ~dáý',
+ dd : '%d d~áýs',
+ M : 'á ~móñ~th',
+ MM : '%d m~óñt~hs',
+ y : 'á ~ýéár',
+ yy : '%d ý~éárs'
+ },
+ ordinalParse: /\d{1,2}(th|st|nd|rd)/,
+ ordinal : function (number) {
+ var b = number % 10,
+ output = (~~(number % 100 / 10) === 1) ? 'th' :
+ (b === 1) ? 'st' :
+ (b === 2) ? 'nd' :
+ (b === 3) ? 'rd' : 'th';
+ return number + output;
+ },
+ week : {
+ dow : 1, // Monday is the first day of the week.
+ doy : 4 // The week that contains Jan 4th is the first week of the year.
+ }
+});
diff --git a/src/locale/zh-cn.js b/src/locale/zh-cn.js
index 790ea8b..d9db717 100644
--- a/src/locale/zh-cn.js
+++ b/src/locale/zh-cn.js
@@ -67,7 +67,7 @@
nextWeek : function () {
var startOfWeek, prefix;
startOfWeek = moment().startOf('week');
- prefix = this.unix() - startOfWeek.unix() >= 7 * 24 * 3600 ? '[下]' : '[本]';
+ prefix = this.diff(startOfWeek, 'days') >= 7 ? '[下]' : '[本]';
return this.minutes() === 0 ? prefix + 'dddAh点整' : prefix + 'dddAh点mm';
},
lastWeek : function () {
diff --git a/src/locale/zh-tw.js b/src/locale/zh-tw.js
index 4ff48f8..c5e3b69 100644
--- a/src/locale/zh-tw.js
+++ b/src/locale/zh-tw.js
@@ -77,15 +77,15 @@
future : '%s內',
past : '%s前',
s : '幾秒',
- m : '一分鐘',
+ m : '1分鐘',
mm : '%d分鐘',
- h : '一小時',
+ h : '1小時',
hh : '%d小時',
- d : '一天',
+ d : '1天',
dd : '%d天',
- M : '一個月',
+ M : '1個月',
MM : '%d個月',
- y : '一年',
+ y : '1年',
yy : '%d年'
}
});
diff --git a/src/moment.js b/src/moment.js
index 840616a..ebe1752 100644
--- a/src/moment.js
+++ b/src/moment.js
@@ -1,12 +1,12 @@
//! moment.js
-//! version : 2.11.0
+//! version : 2.13.0
//! authors : Tim Wood, Iskren Chernev, Moment.js contributors
//! license : MIT
//! momentjs.com
import { hooks as moment, setHookCallback } from './lib/utils/hooks';
-moment.version = '2.11.0';
+moment.version = '2.13.0';
import {
min,
@@ -23,8 +23,10 @@
import {
defineLocale,
+ updateLocale,
getSetGlobalLocale as locale,
getLocale as localeData,
+ listLocales as locales,
listMonths as months,
listMonthsShort as monthsShort,
listWeekdays as weekdays,
@@ -63,6 +65,8 @@
moment.monthsShort = monthsShort;
moment.weekdaysMin = weekdaysMin;
moment.defineLocale = defineLocale;
+moment.updateLocale = updateLocale;
+moment.locales = locales;
moment.weekdaysShort = weekdaysShort;
moment.normalizeUnits = normalizeUnits;
moment.relativeTimeThreshold = relativeTimeThreshold;
diff --git a/src/test/helpers/common-locale.js b/src/test/helpers/common-locale.js
new file mode 100644
index 0000000..d641e04
--- /dev/null
+++ b/src/test/helpers/common-locale.js
@@ -0,0 +1,140 @@
+import { test, expect } from '../qunit';
+import each from './each';
+import objectKeys from './object-keys';
+import moment from '../../moment';
+import defaults from '../../lib/utils/defaults';
+
+export function defineCommonLocaleTests(locale, options) {
+ test('lenient ordinal parsing', function (assert) {
+ var i, ordinalStr, testMoment;
+ for (i = 1; i <= 31; ++i) {
+ ordinalStr = moment([2014, 0, i]).format('YYYY MM Do');
+ testMoment = moment(ordinalStr, 'YYYY MM Do');
+ assert.equal(testMoment.year(), 2014,
+ 'lenient ordinal parsing ' + i + ' year check');
+ assert.equal(testMoment.month(), 0,
+ 'lenient ordinal parsing ' + i + ' month check');
+ assert.equal(testMoment.date(), i,
+ 'lenient ordinal parsing ' + i + ' date check');
+ }
+ });
+
+ test('lenient ordinal parsing of number', function (assert) {
+ var i, testMoment;
+ for (i = 1; i <= 31; ++i) {
+ testMoment = moment('2014 01 ' + i, 'YYYY MM Do');
+ assert.equal(testMoment.year(), 2014,
+ 'lenient ordinal parsing of number ' + i + ' year check');
+ assert.equal(testMoment.month(), 0,
+ 'lenient ordinal parsing of number ' + i + ' month check');
+ assert.equal(testMoment.date(), i,
+ 'lenient ordinal parsing of number ' + i + ' date check');
+ }
+ });
+
+ test('strict ordinal parsing', function (assert) {
+ var i, ordinalStr, testMoment;
+ for (i = 1; i <= 31; ++i) {
+ ordinalStr = moment([2014, 0, i]).format('YYYY MM Do');
+ testMoment = moment(ordinalStr, 'YYYY MM Do', true);
+ assert.ok(testMoment.isValid(), 'strict ordinal parsing ' + i);
+ }
+ });
+
+ test('meridiem invariant', function (assert) {
+ var h, m, t1, t2;
+ for (h = 0; h < 24; ++h) {
+ for (m = 0; m < 60; m += 15) {
+ t1 = moment.utc([2000, 0, 1, h, m]);
+ t2 = moment.utc(t1.format('A h:mm'), 'A h:mm');
+ assert.equal(t2.format('HH:mm'), t1.format('HH:mm'),
+ 'meridiem at ' + t1.format('HH:mm'));
+ }
+ }
+ });
+
+ test('date format correctness', function (assert) {
+ var data, tokens;
+ data = moment.localeData()._longDateFormat;
+ tokens = objectKeys(data);
+ each(tokens, function (srchToken) {
+ // Check each format string to make sure it does not contain any
+ // tokens that need to be expanded.
+ each(tokens, function (baseToken) {
+ // strip escaped sequences
+ var format = data[baseToken].replace(/(\[[^\]]*\])/g, '');
+ assert.equal(false, !!~format.indexOf(srchToken),
+ 'contains ' + srchToken + ' in ' + baseToken);
+ });
+ });
+ });
+
+ test('month parsing correctness', function (assert) {
+ var i, m;
+
+ if (locale === 'tr') {
+ // I can't fix it :(
+ expect(0);
+ return;
+ }
+ function tester(format) {
+ var r;
+ r = moment(m.format(format), format);
+ assert.equal(r.month(), m.month(), 'month ' + i + ' fmt ' + format);
+ r = moment(m.format(format).toLocaleUpperCase(), format);
+ assert.equal(r.month(), m.month(), 'month ' + i + ' fmt ' + format + ' upper');
+ r = moment(m.format(format).toLocaleLowerCase(), format);
+ assert.equal(r.month(), m.month(), 'month ' + i + ' fmt ' + format + ' lower');
+
+ r = moment(m.format(format), format, true);
+ assert.equal(r.month(), m.month(), 'month ' + i + ' fmt ' + format + ' strict');
+ r = moment(m.format(format).toLocaleUpperCase(), format, true);
+ assert.equal(r.month(), m.month(), 'month ' + i + ' fmt ' + format + ' upper strict');
+ r = moment(m.format(format).toLocaleLowerCase(), format, true);
+ assert.equal(r.month(), m.month(), 'month ' + i + ' fmt ' + format + ' lower strict');
+ }
+
+ for (i = 0; i < 12; ++i) {
+ m = moment([2015, i, 15, 18]);
+ tester('MMM');
+ tester('MMM.');
+ tester('MMMM');
+ tester('MMMM.');
+ }
+ });
+
+ test('weekday parsing correctness', function (assert) {
+ var i, m;
+
+ if (locale === 'tr' || locale === 'az') {
+ // There is a lower-case letter (ı), that converted to upper then
+ // lower changes to i
+ expect(0);
+ return;
+ }
+ function tester(format) {
+ var r, baseMsg = 'weekday ' + m.weekday() + ' fmt ' + format;
+ r = moment(m.format(format), format);
+ assert.equal(r.weekday(), m.weekday(), baseMsg);
+ r = moment(m.format(format).toLocaleUpperCase(), format);
+ assert.equal(r.weekday(), m.weekday(), baseMsg + ' upper');
+ r = moment(m.format(format).toLocaleLowerCase(), format);
+ assert.equal(r.weekday(), m.weekday(), baseMsg + ' lower');
+
+ r = moment(m.format(format), format, true);
+ assert.equal(r.weekday(), m.weekday(), baseMsg + ' strict');
+ r = moment(m.format(format).toLocaleUpperCase(), format, true);
+ assert.equal(r.weekday(), m.weekday(), baseMsg + ' upper strict');
+ r = moment(m.format(format).toLocaleLowerCase(), format, true);
+ assert.equal(r.weekday(), m.weekday(), baseMsg + ' lower strict');
+ }
+
+ for (i = 0; i < 7; ++i) {
+ m = moment.utc([2015, i, 15, 18]);
+ tester('dd');
+ tester('ddd');
+ tester('dddd');
+ }
+ });
+}
+
diff --git a/src/test/helpers/deprecation-handler.js b/src/test/helpers/deprecation-handler.js
new file mode 100644
index 0000000..77e9f64
--- /dev/null
+++ b/src/test/helpers/deprecation-handler.js
@@ -0,0 +1,52 @@
+import each from './each';
+
+export function setupDeprecationHandler(test, moment, scope) {
+ test._expectedDeprecations = null;
+ test._observedDeprecations = null;
+ test._oldSupress = moment.suppressDeprecationWarnings;
+ moment.suppressDeprecationWarnings = true;
+ test.expectedDeprecations = function () {
+ test._expectedDeprecations = arguments;
+ test._observedDeprecations = [];
+ };
+ moment.deprecationHandler = function (name, msg) {
+ var deprecationId = matchedDeprecation(name, msg, test._expectedDeprecations);
+ if (deprecationId === -1) {
+ throw new Error('Unexpected deprecation thrown name=' +
+ name + ' msg=' + msg);
+ }
+ test._observedDeprecations[deprecationId] = 1;
+ };
+}
+
+export function teardownDeprecationHandler(test, moment, scope) {
+ moment.suppressDeprecationWarnings = test._oldSupress;
+
+ if (test._expectedDeprecations != null) {
+ var missedDeprecations = [];
+ each(test._expectedDeprecations, function (deprecationPattern, id) {
+ if (test._observedDeprecations[id] !== 1) {
+ missedDeprecations.push(deprecationPattern);
+ }
+ });
+ if (missedDeprecations.length !== 0) {
+ throw new Error('Expected deprecation warnings did not happen: ' +
+ missedDeprecations.join(' '));
+ }
+ }
+}
+
+function matchedDeprecation(name, msg, deprecations) {
+ if (deprecations == null) {
+ return -1;
+ }
+ for (var i = 0; i < deprecations.length; ++i) {
+ if (name != null && name === deprecations[i]) {
+ return i;
+ }
+ if (msg != null && msg.substring(0, deprecations[i].length) === deprecations[i]) {
+ return i;
+ }
+ }
+ return -1;
+}
diff --git a/src/test/helpers/dst.js b/src/test/helpers/dst.js
new file mode 100644
index 0000000..3bf09ee
--- /dev/null
+++ b/src/test/helpers/dst.js
@@ -0,0 +1,5 @@
+import moment from '../../moment';
+
+export function isNearSpringDST() {
+ return moment().subtract(1, 'day').utcOffset() !== moment().add(1, 'day').utcOffset();
+}
diff --git a/src/test/helpers/object-keys.js b/src/test/helpers/object-keys.js
new file mode 100644
index 0000000..bdc7364
--- /dev/null
+++ b/src/test/helpers/object-keys.js
@@ -0,0 +1,14 @@
+export default function objectKeys(obj) {
+ if (Object.keys) {
+ return Object.keys(obj);
+ } else {
+ // IE8
+ var res = [], i;
+ for (i in obj) {
+ if (obj.hasOwnProperty(i)) {
+ res.push(i);
+ }
+ }
+ return res;
+ }
+}
diff --git a/src/test/locale/af.js b/src/test/locale/af.js
index 3b15aa7..d396ee1 100644
--- a/src/test/locale/af.js
+++ b/src/test/locale/af.js
@@ -152,14 +152,14 @@
});
test('calendar day', function (assert) {
- var a = moment().hours(2).minutes(0).seconds(0);
-
- assert.equal(moment(a).calendar(), 'Vandag om 02:00', 'today at the same time');
- assert.equal(moment(a).add({m: 25}).calendar(), 'Vandag om 02:25', 'Now plus 25 min');
- assert.equal(moment(a).add({h: 1}).calendar(), 'Vandag om 03:00', 'Now plus 1 hour');
- assert.equal(moment(a).add({d: 1}).calendar(), 'Môre om 02:00', 'tomorrow at the same time');
- assert.equal(moment(a).subtract({h: 1}).calendar(), 'Vandag om 01:00', 'Now minus 1 hour');
- assert.equal(moment(a).subtract({d: 1}).calendar(), 'Gister om 02:00', 'yesterday at the same time');
+ var a = moment().hours(12).minutes(0).seconds(0);
+
+ assert.equal(moment(a).calendar(), 'Vandag om 12:00', 'today at the same time');
+ assert.equal(moment(a).add({m: 25}).calendar(), 'Vandag om 12:25', 'Now plus 25 min');
+ assert.equal(moment(a).add({h: 1}).calendar(), 'Vandag om 13:00', 'Now plus 1 hour');
+ assert.equal(moment(a).add({d: 1}).calendar(), 'Môre om 12:00', 'tomorrow at the same time');
+ assert.equal(moment(a).subtract({h: 1}).calendar(), 'Vandag om 11:00', 'Now minus 1 hour');
+ assert.equal(moment(a).subtract({d: 1}).calendar(), 'Gister om 12:00', 'yesterday at the same time');
});
test('calendar next week', function (assert) {
@@ -200,67 +200,6 @@
assert.equal(weeksFromNow.calendar(), weeksFromNow.format('L'), 'in 2 weeks');
});
-test('weeks year starting sunday', function (assert) {
- assert.equal(moment([2012, 0, 1]).week(), 52, 'Jan 1 2012 should be week 52');
- assert.equal(moment([2012, 0, 2]).week(), 1, 'Jan 2 2012 should be week 1');
- assert.equal(moment([2012, 0, 8]).week(), 1, 'Jan 8 2012 should be week 1');
- assert.equal(moment([2012, 0, 9]).week(), 2, 'Jan 9 2012 should be week 2');
- assert.equal(moment([2012, 0, 15]).week(), 2, 'Jan 15 2012 should be week 2');
-});
-
-test('weeks year starting monday', function (assert) {
- assert.equal(moment([2007, 0, 1]).week(), 1, 'Jan 1 2007 should be week 1');
- assert.equal(moment([2007, 0, 7]).week(), 1, 'Jan 7 2007 should be week 1');
- assert.equal(moment([2007, 0, 8]).week(), 2, 'Jan 8 2007 should be week 2');
- assert.equal(moment([2007, 0, 14]).week(), 2, 'Jan 14 2007 should be week 2');
- assert.equal(moment([2007, 0, 15]).week(), 3, 'Jan 15 2007 should be week 3');
-});
-
-test('weeks year starting tuesday', function (assert) {
- assert.equal(moment([2007, 11, 31]).week(), 1, 'Dec 31 2007 should be week 1');
- assert.equal(moment([2008, 0, 1]).week(), 1, 'Jan 1 2008 should be week 1');
- assert.equal(moment([2008, 0, 6]).week(), 1, 'Jan 6 2008 should be week 1');
- assert.equal(moment([2008, 0, 7]).week(), 2, 'Jan 7 2008 should be week 2');
- assert.equal(moment([2008, 0, 13]).week(), 2, 'Jan 13 2008 should be week 2');
- assert.equal(moment([2008, 0, 14]).week(), 3, 'Jan 14 2008 should be week 3');
-});
-
-test('weeks year starting wednesday', function (assert) {
- assert.equal(moment([2002, 11, 30]).week(), 1, 'Dec 30 2002 should be week 1');
- assert.equal(moment([2003, 0, 1]).week(), 1, 'Jan 1 2003 should be week 1');
- assert.equal(moment([2003, 0, 5]).week(), 1, 'Jan 5 2003 should be week 1');
- assert.equal(moment([2003, 0, 6]).week(), 2, 'Jan 6 2003 should be week 2');
- assert.equal(moment([2003, 0, 12]).week(), 2, 'Jan 12 2003 should be week 2');
- assert.equal(moment([2003, 0, 13]).week(), 3, 'Jan 13 2003 should be week 3');
-});
-
-test('weeks year starting thursday', function (assert) {
- assert.equal(moment([2008, 11, 29]).week(), 1, 'Dec 29 2008 should be week 1');
- assert.equal(moment([2009, 0, 1]).week(), 1, 'Jan 1 2009 should be week 1');
- assert.equal(moment([2009, 0, 4]).week(), 1, 'Jan 4 2009 should be week 1');
- assert.equal(moment([2009, 0, 5]).week(), 2, 'Jan 5 2009 should be week 2');
- assert.equal(moment([2009, 0, 11]).week(), 2, 'Jan 11 2009 should be week 2');
- assert.equal(moment([2009, 0, 13]).week(), 3, 'Jan 12 2009 should be week 3');
-});
-
-test('weeks year starting friday', function (assert) {
- assert.equal(moment([2009, 11, 28]).week(), 53, 'Dec 28 2009 should be week 53');
- assert.equal(moment([2010, 0, 1]).week(), 53, 'Jan 1 2010 should be week 53');
- assert.equal(moment([2010, 0, 3]).week(), 53, 'Jan 3 2010 should be week 53');
- assert.equal(moment([2010, 0, 4]).week(), 1, 'Jan 4 2010 should be week 1');
- assert.equal(moment([2010, 0, 10]).week(), 1, 'Jan 10 2010 should be week 1');
- assert.equal(moment([2010, 0, 11]).week(), 2, 'Jan 11 2010 should be week 2');
-});
-
-test('weeks year starting saturday', function (assert) {
- assert.equal(moment([2010, 11, 27]).week(), 52, 'Dec 27 2010 should be week 52');
- assert.equal(moment([2011, 0, 1]).week(), 52, 'Jan 1 2011 should be week 52');
- assert.equal(moment([2011, 0, 2]).week(), 52, 'Jan 2 2011 should be week 52');
- assert.equal(moment([2011, 0, 3]).week(), 1, 'Jan 3 2011 should be week 1');
- assert.equal(moment([2011, 0, 9]).week(), 1, 'Jan 9 2011 should be week 1');
- assert.equal(moment([2011, 0, 10]).week(), 2, 'Jan 10 2011 should be week 2');
-});
-
test('weeks year starting sunday formatted', function (assert) {
assert.equal(moment([2012, 0, 1]).format('w ww wo'), '52 52 52ste', 'Jan 1 2012 should be week 52');
assert.equal(moment([2012, 0, 2]).format('w ww wo'), '1 01 1ste', 'Jan 2 2012 should be week 1');
@@ -269,38 +208,3 @@
assert.equal(moment([2012, 0, 15]).format('w ww wo'), '2 02 2de', 'Jan 15 2012 should be week 2');
});
-test('lenient ordinal parsing', function (assert) {
- var i, ordinalStr, testMoment;
- for (i = 1; i <= 31; ++i) {
- ordinalStr = moment([2014, 0, i]).format('YYYY MM Do');
- testMoment = moment(ordinalStr, 'YYYY MM Do');
- assert.equal(testMoment.year(), 2014,
- 'lenient ordinal parsing ' + i + ' year check');
- assert.equal(testMoment.month(), 0,
- 'lenient ordinal parsing ' + i + ' month check');
- assert.equal(testMoment.date(), i,
- 'lenient ordinal parsing ' + i + ' date check');
- }
-});
-
-test('lenient ordinal parsing of number', function (assert) {
- var i, testMoment;
- for (i = 1; i <= 31; ++i) {
- testMoment = moment('2014 01 ' + i, 'YYYY MM Do');
- assert.equal(testMoment.year(), 2014,
- 'lenient ordinal parsing of number ' + i + ' year check');
- assert.equal(testMoment.month(), 0,
- 'lenient ordinal parsing of number ' + i + ' month check');
- assert.equal(testMoment.date(), i,
- 'lenient ordinal parsing of number ' + i + ' date check');
- }
-});
-
-test('strict ordinal parsing', function (assert) {
- var i, ordinalStr, testMoment;
- for (i = 1; i <= 31; ++i) {
- ordinalStr = moment([2014, 0, i]).format('YYYY MM Do');
- testMoment = moment(ordinalStr, 'YYYY MM Do', true);
- assert.ok(testMoment.isValid(), 'strict ordinal parsing ' + i);
- }
-});
diff --git a/src/test/locale/ar-ma.js b/src/test/locale/ar-ma.js
index 89f9655..4d6d829 100644
--- a/src/test/locale/ar-ma.js
+++ b/src/test/locale/ar-ma.js
@@ -152,14 +152,14 @@
});
test('calendar day', function (assert) {
- var a = moment().hours(2).minutes(0).seconds(0);
-
- assert.equal(moment(a).calendar(), 'اليوم على الساعة 02:00', 'today at the same time');
- assert.equal(moment(a).add({m: 25}).calendar(), 'اليوم على الساعة 02:25', 'Now plus 25 min');
- assert.equal(moment(a).add({h: 1}).calendar(), 'اليوم على الساعة 03:00', 'Now plus 1 hour');
- assert.equal(moment(a).add({d: 1}).calendar(), 'غدا على الساعة 02:00', 'tomorrow at the same time');
- assert.equal(moment(a).subtract({h: 1}).calendar(), 'اليوم على الساعة 01:00', 'Now minus 1 hour');
- assert.equal(moment(a).subtract({d: 1}).calendar(), 'أمس على الساعة 02:00', 'yesterday at the same time');
+ var a = moment().hours(12).minutes(0).seconds(0);
+
+ assert.equal(moment(a).calendar(), 'اليوم على الساعة 12:00', 'today at the same time');
+ assert.equal(moment(a).add({m: 25}).calendar(), 'اليوم على الساعة 12:25', 'Now plus 25 min');
+ assert.equal(moment(a).add({h: 1}).calendar(), 'اليوم على الساعة 13:00', 'Now plus 1 hour');
+ assert.equal(moment(a).add({d: 1}).calendar(), 'غدا على الساعة 12:00', 'tomorrow at the same time');
+ assert.equal(moment(a).subtract({h: 1}).calendar(), 'اليوم على الساعة 11:00', 'Now minus 1 hour');
+ assert.equal(moment(a).subtract({d: 1}).calendar(), 'أمس على الساعة 12:00', 'yesterday at the same time');
});
test('calendar next week', function (assert) {
@@ -200,65 +200,6 @@
assert.equal(weeksFromNow.calendar(), weeksFromNow.format('L'), 'in 2 weeks');
});
-test('weeks year starting sunday', function (assert) {
- assert.equal(moment([2011, 11, 31]).week(), 1, 'Dec 31 2011 should be week 1');
- assert.equal(moment([2012, 0, 6]).week(), 1, 'Jan 6 2012 should be week 1');
- assert.equal(moment([2012, 0, 7]).week(), 2, 'Jan 7 2012 should be week 2');
- assert.equal(moment([2012, 0, 13]).week(), 2, 'Jan 13 2012 should be week 2');
- assert.equal(moment([2012, 0, 14]).week(), 3, 'Jan 14 2012 should be week 3');
-});
-
-test('weeks year starting monday', function (assert) {
- assert.equal(moment([2006, 11, 30]).week(), 1, 'Dec 30 2006 should be week 1');
- assert.equal(moment([2007, 0, 5]).week(), 1, 'Jan 5 2007 should be week 1');
- assert.equal(moment([2007, 0, 6]).week(), 2, 'Jan 6 2007 should be week 2');
- assert.equal(moment([2007, 0, 12]).week(), 2, 'Jan 12 2007 should be week 2');
- assert.equal(moment([2007, 0, 13]).week(), 3, 'Jan 13 2007 should be week 3');
-});
-
-test('weeks year starting tuesday', function (assert) {
- assert.equal(moment([2007, 11, 29]).week(), 1, 'Dec 29 2007 should be week 1');
- assert.equal(moment([2008, 0, 1]).week(), 1, 'Jan 1 2008 should be week 1');
- assert.equal(moment([2008, 0, 4]).week(), 1, 'Jan 4 2008 should be week 1');
- assert.equal(moment([2008, 0, 5]).week(), 2, 'Jan 5 2008 should be week 2');
- assert.equal(moment([2008, 0, 11]).week(), 2, 'Jan 11 2008 should be week 2');
- assert.equal(moment([2008, 0, 12]).week(), 3, 'Jan 12 2008 should be week 3');
-});
-
-test('weeks year starting wednesday', function (assert) {
- assert.equal(moment([2002, 11, 28]).week(), 1, 'Dec 28 2002 should be week 1');
- assert.equal(moment([2003, 0, 1]).week(), 1, 'Jan 1 2003 should be week 1');
- assert.equal(moment([2003, 0, 3]).week(), 1, 'Jan 3 2003 should be week 1');
- assert.equal(moment([2003, 0, 4]).week(), 2, 'Jan 4 2003 should be week 2');
- assert.equal(moment([2003, 0, 10]).week(), 2, 'Jan 10 2003 should be week 2');
- assert.equal(moment([2003, 0, 11]).week(), 3, 'Jan 11 2003 should be week 3');
-});
-
-test('weeks year starting thursday', function (assert) {
- assert.equal(moment([2008, 11, 27]).week(), 1, 'Dec 27 2008 should be week 1');
- assert.equal(moment([2009, 0, 1]).week(), 1, 'Jan 1 2009 should be week 1');
- assert.equal(moment([2009, 0, 2]).week(), 1, 'Jan 2 2009 should be week 1');
- assert.equal(moment([2009, 0, 3]).week(), 2, 'Jan 3 2009 should be week 2');
- assert.equal(moment([2009, 0, 9]).week(), 2, 'Jan 9 2009 should be week 2');
- assert.equal(moment([2009, 0, 10]).week(), 3, 'Jan 10 2009 should be week 3');
-});
-
-test('weeks year starting friday', function (assert) {
- assert.equal(moment([2009, 11, 26]).week(), 1, 'Dec 26 2009 should be week 1');
- assert.equal(moment([2010, 0, 1]).week(), 1, 'Jan 1 2010 should be week 1');
- assert.equal(moment([2010, 0, 2]).week(), 2, 'Jan 2 2010 should be week 2');
- assert.equal(moment([2010, 0, 8]).week(), 2, 'Jan 8 2010 should be week 2');
- assert.equal(moment([2010, 0, 9]).week(), 3, 'Jan 9 2010 should be week 3');
-});
-
-test('weeks year starting saturday', function (assert) {
- assert.equal(moment([2011, 0, 1]).week(), 1, 'Jan 1 2011 should be week 1');
- assert.equal(moment([2011, 0, 7]).week(), 1, 'Jan 7 2011 should be week 1');
- assert.equal(moment([2011, 0, 8]).week(), 2, 'Jan 8 2011 should be week 2');
- assert.equal(moment([2011, 0, 14]).week(), 2, 'Jan 14 2011 should be week 2');
- assert.equal(moment([2011, 0, 15]).week(), 3, 'Jan 15 2011 should be week 3');
-});
-
test('weeks year starting sunday formatted', function (assert) {
assert.equal(moment([2011, 11, 31]).format('w ww wo'), '1 01 1', 'Dec 31 2011 should be week 1');
assert.equal(moment([2012, 0, 6]).format('w ww wo'), '1 01 1', 'Jan 6 2012 should be week 1');
@@ -267,38 +208,3 @@
assert.equal(moment([2012, 0, 14]).format('w ww wo'), '3 03 3', 'Jan 14 2012 should be week 3');
});
-test('lenient ordinal parsing', function (assert) {
- var i, ordinalStr, testMoment;
- for (i = 1; i <= 31; ++i) {
- ordinalStr = moment([2014, 0, i]).format('YYYY MM Do');
- testMoment = moment(ordinalStr, 'YYYY MM Do');
- assert.equal(testMoment.year(), 2014,
- 'lenient ordinal parsing ' + i + ' year check');
- assert.equal(testMoment.month(), 0,
- 'lenient ordinal parsing ' + i + ' month check');
- assert.equal(testMoment.date(), i,
- 'lenient ordinal parsing ' + i + ' date check');
- }
-});
-
-test('lenient ordinal parsing of number', function (assert) {
- var i, testMoment;
- for (i = 1; i <= 31; ++i) {
- testMoment = moment('2014 01 ' + i, 'YYYY MM Do');
- assert.equal(testMoment.year(), 2014,
- 'lenient ordinal parsing of number ' + i + ' year check');
- assert.equal(testMoment.month(), 0,
- 'lenient ordinal parsing of number ' + i + ' month check');
- assert.equal(testMoment.date(), i,
- 'lenient ordinal parsing of number ' + i + ' date check');
- }
-});
-
-test('strict ordinal parsing', function (assert) {
- var i, ordinalStr, testMoment;
- for (i = 1; i <= 31; ++i) {
- ordinalStr = moment([2014, 0, i]).format('YYYY MM Do');
- testMoment = moment(ordinalStr, 'YYYY MM Do', true);
- assert.ok(testMoment.isValid(), 'strict ordinal parsing ' + i);
- }
-});
diff --git a/src/test/locale/ar-sa.js b/src/test/locale/ar-sa.js
index ac870de..b519656 100644
--- a/src/test/locale/ar-sa.js
+++ b/src/test/locale/ar-sa.js
@@ -152,14 +152,14 @@
});
test('calendar day', function (assert) {
- var a = moment().hours(2).minutes(0).seconds(0);
-
- assert.equal(moment(a).calendar(), 'اليوم على الساعة ٠٢:٠٠', 'today at the same time');
- assert.equal(moment(a).add({m: 25}).calendar(), 'اليوم على الساعة ٠٢:٢٥', 'Now plus 25 min');
- assert.equal(moment(a).add({h: 1}).calendar(), 'اليوم على الساعة ٠٣:٠٠', 'Now plus 1 hour');
- assert.equal(moment(a).add({d: 1}).calendar(), 'غدا على الساعة ٠٢:٠٠', 'tomorrow at the same time');
- assert.equal(moment(a).subtract({h: 1}).calendar(), 'اليوم على الساعة ٠١:٠٠', 'Now minus 1 hour');
- assert.equal(moment(a).subtract({d: 1}).calendar(), 'أمس على الساعة ٠٢:٠٠', 'yesterday at the same time');
+ var a = moment().hours(12).minutes(0).seconds(0);
+
+ assert.equal(moment(a).calendar(), 'اليوم على الساعة ١٢:٠٠', 'today at the same time');
+ assert.equal(moment(a).add({m: 25}).calendar(), 'اليوم على الساعة ١٢:٢٥', 'Now plus 25 min');
+ assert.equal(moment(a).add({h: 1}).calendar(), 'اليوم على الساعة ١٣:٠٠', 'Now plus 1 hour');
+ assert.equal(moment(a).add({d: 1}).calendar(), 'غدا على الساعة ١٢:٠٠', 'tomorrow at the same time');
+ assert.equal(moment(a).subtract({h: 1}).calendar(), 'اليوم على الساعة ١١:٠٠', 'Now minus 1 hour');
+ assert.equal(moment(a).subtract({d: 1}).calendar(), 'أمس على الساعة ١٢:٠٠', 'yesterday at the same time');
});
test('calendar next week', function (assert) {
@@ -200,68 +200,11 @@
assert.equal(weeksFromNow.calendar(), weeksFromNow.format('L'), 'in 2 weeks');
});
-test('weeks year starting sunday', function (assert) {
- assert.equal(moment([2011, 11, 31]).week(), 1, 'Dec 31 2011 should be week 1');
- assert.equal(moment([2012, 0, 6]).week(), 1, 'Jan 6 2012 should be week 1');
- assert.equal(moment([2012, 0, 7]).week(), 2, 'Jan 7 2012 should be week 2');
- assert.equal(moment([2012, 0, 13]).week(), 2, 'Jan 13 2012 should be week 2');
- assert.equal(moment([2012, 0, 14]).week(), 3, 'Jan 14 2012 should be week 3');
-});
-
-test('weeks year starting monday', function (assert) {
- assert.equal(moment([2006, 11, 30]).week(), 1, 'Dec 30 2006 should be week 1');
- assert.equal(moment([2007, 0, 5]).week(), 1, 'Jan 5 2007 should be week 1');
- assert.equal(moment([2007, 0, 6]).week(), 2, 'Jan 6 2007 should be week 2');
- assert.equal(moment([2007, 0, 12]).week(), 2, 'Jan 12 2007 should be week 2');
- assert.equal(moment([2007, 0, 13]).week(), 3, 'Jan 13 2007 should be week 3');
-});
-
-test('weeks year starting tuesday', function (assert) {
- assert.equal(moment([2007, 11, 29]).week(), 1, 'Dec 29 2007 should be week 1');
- assert.equal(moment([2008, 0, 1]).week(), 1, 'Jan 1 2008 should be week 1');
- assert.equal(moment([2008, 0, 4]).week(), 1, 'Jan 4 2008 should be week 1');
- assert.equal(moment([2008, 0, 5]).week(), 2, 'Jan 5 2008 should be week 2');
- assert.equal(moment([2008, 0, 11]).week(), 2, 'Jan 11 2008 should be week 2');
- assert.equal(moment([2008, 0, 12]).week(), 3, 'Jan 12 2008 should be week 3');
-});
-
-test('weeks year starting wednesday', function (assert) {
- assert.equal(moment([2002, 11, 28]).week(), 1, 'Dec 28 2002 should be week 1');
- assert.equal(moment([2003, 0, 1]).week(), 1, 'Jan 1 2003 should be week 1');
- assert.equal(moment([2003, 0, 3]).week(), 1, 'Jan 3 2003 should be week 1');
- assert.equal(moment([2003, 0, 4]).week(), 2, 'Jan 4 2003 should be week 2');
- assert.equal(moment([2003, 0, 10]).week(), 2, 'Jan 10 2003 should be week 2');
- assert.equal(moment([2003, 0, 11]).week(), 3, 'Jan 11 2003 should be week 3');
-
+test('weeks year starting wednesday custom', function (assert) {
assert.equal(moment('2003 1 6', 'gggg w d').format('YYYY-MM-DD'), '٢٠٠٢-١٢-٢٨', 'Week 1 of 2003 should be Dec 28 2002');
assert.equal(moment('2003 1 0', 'gggg w e').format('YYYY-MM-DD'), '٢٠٠٢-١٢-٢٨', 'Week 1 of 2003 should be Dec 28 2002');
assert.equal(moment('2003 1 6', 'gggg w d').format('gggg w d'), '٢٠٠٣ ١ ٦', 'Saturday of week 1 of 2003 parsed should be formatted as 2003 1 6');
assert.equal(moment('2003 1 0', 'gggg w e').format('gggg w e'), '٢٠٠٣ ١ ٠', '1st day of week 1 of 2003 parsed should be formatted as 2003 1 0');
-});
-
-test('weeks year starting thursday', function (assert) {
- assert.equal(moment([2008, 11, 27]).week(), 1, 'Dec 27 2008 should be week 1');
- assert.equal(moment([2009, 0, 1]).week(), 1, 'Jan 1 2009 should be week 1');
- assert.equal(moment([2009, 0, 2]).week(), 1, 'Jan 2 2009 should be week 1');
- assert.equal(moment([2009, 0, 3]).week(), 2, 'Jan 3 2009 should be week 2');
- assert.equal(moment([2009, 0, 9]).week(), 2, 'Jan 9 2009 should be week 2');
- assert.equal(moment([2009, 0, 10]).week(), 3, 'Jan 10 2009 should be week 3');
-});
-
-test('weeks year starting friday', function (assert) {
- assert.equal(moment([2009, 11, 26]).week(), 1, 'Dec 26 2009 should be week 1');
- assert.equal(moment([2010, 0, 1]).week(), 1, 'Jan 1 2010 should be week 1');
- assert.equal(moment([2010, 0, 2]).week(), 2, 'Jan 2 2010 should be week 2');
- assert.equal(moment([2010, 0, 8]).week(), 2, 'Jan 8 2010 should be week 2');
- assert.equal(moment([2010, 0, 9]).week(), 3, 'Jan 9 2010 should be week 3');
-});
-
-test('weeks year starting saturday', function (assert) {
- assert.equal(moment([2011, 0, 1]).week(), 1, 'Jan 1 2011 should be week 1');
- assert.equal(moment([2011, 0, 7]).week(), 1, 'Jan 7 2011 should be week 1');
- assert.equal(moment([2011, 0, 8]).week(), 2, 'Jan 8 2011 should be week 2');
- assert.equal(moment([2011, 0, 14]).week(), 2, 'Jan 14 2011 should be week 2');
- assert.equal(moment([2011, 0, 15]).week(), 3, 'Jan 15 2011 should be week 3');
});
test('weeks year starting sunday formatted', function (assert) {
@@ -272,38 +215,3 @@
assert.equal(moment([2012, 0, 14]).format('w ww wo'), '٣ ٠٣ ٣', 'Jan 14 2012 should be week 3');
});
-test('lenient ordinal parsing', function (assert) {
- var i, ordinalStr, testMoment;
- for (i = 1; i <= 31; ++i) {
- ordinalStr = moment([2014, 0, i]).format('YYYY MM Do');
- testMoment = moment(ordinalStr, 'YYYY MM Do');
- assert.equal(testMoment.year(), 2014,
- 'lenient ordinal parsing ' + i + ' year check');
- assert.equal(testMoment.month(), 0,
- 'lenient ordinal parsing ' + i + ' month check');
- assert.equal(testMoment.date(), i,
- 'lenient ordinal parsing ' + i + ' date check');
- }
-});
-
-test('lenient ordinal parsing of number', function (assert) {
- var i, testMoment;
- for (i = 1; i <= 31; ++i) {
- testMoment = moment('2014 01 ' + i, 'YYYY MM Do');
- assert.equal(testMoment.year(), 2014,
- 'lenient ordinal parsing of number ' + i + ' year check');
- assert.equal(testMoment.month(), 0,
- 'lenient ordinal parsing of number ' + i + ' month check');
- assert.equal(testMoment.date(), i,
- 'lenient ordinal parsing of number ' + i + ' date check');
- }
-});
-
-test('strict ordinal parsing', function (assert) {
- var i, ordinalStr, testMoment;
- for (i = 1; i <= 31; ++i) {
- ordinalStr = moment([2014, 0, i]).format('YYYY MM Do');
- testMoment = moment(ordinalStr, 'YYYY MM Do', true);
- assert.ok(testMoment.isValid(), 'strict ordinal parsing ' + i);
- }
-});
diff --git a/src/test/locale/ar-tn.js b/src/test/locale/ar-tn.js
index d5900e8..942010f 100644
--- a/src/test/locale/ar-tn.js
+++ b/src/test/locale/ar-tn.js
@@ -216,24 +216,14 @@
});
test('calendar day', function (assert) {
- var a = moment().hours(2).minutes(0).seconds(0);
-
- assert.equal(moment(a).calendar(), 'اليوم على الساعة 02:00', 'today at the same time');
- assert.equal(moment(a).add({
- m: 25
- }).calendar(), 'اليوم على الساعة 02:25', 'Now plus 25 min');
- assert.equal(moment(a).add({
- h: 1
- }).calendar(), 'اليوم على الساعة 03:00', 'Now plus 1 hour');
- assert.equal(moment(a).add({
- d: 1
- }).calendar(), 'غدا على الساعة 02:00', 'tomorrow at the same time');
- assert.equal(moment(a).subtract({
- h: 1
- }).calendar(), 'اليوم على الساعة 01:00', 'Now minus 1 hour');
- assert.equal(moment(a).subtract({
- d: 1
- }).calendar(), 'أمس على الساعة 02:00', 'yesterday at the same time');
+ var a = moment().hours(12).minutes(0).seconds(0);
+
+ assert.equal(moment(a).calendar(), 'اليوم على الساعة 12:00', 'today at the same time');
+ assert.equal(moment(a).add({m: 25}).calendar(), 'اليوم على الساعة 12:25', 'Now plus 25 min');
+ assert.equal(moment(a).add({h: 1}).calendar(), 'اليوم على الساعة 13:00', 'Now plus 1 hour');
+ assert.equal(moment(a).add({d: 1}).calendar(), 'غدا على الساعة 12:00', 'tomorrow at the same time');
+ assert.equal(moment(a).subtract({h: 1}).calendar(), 'اليوم على الساعة 11:00', 'Now minus 1 hour');
+ assert.equal(moment(a).subtract({d: 1}).calendar(), 'أمس على الساعة 12:00', 'yesterday at the same time');
});
test('calendar next week', function (assert) {
@@ -286,67 +276,6 @@
assert.equal(weeksFromNow.calendar(), weeksFromNow.format('L'), 'in 2 weeks');
});
-test('weeks year starting sunday', function (assert) {
- assert.equal(moment([2012, 0, 1]).week(), 52, 'Jan 1 2012 should be week 52');
- assert.equal(moment([2012, 0, 2]).week(), 1, 'Jan 2 2012 should be week 1');
- assert.equal(moment([2012, 0, 8]).week(), 1, 'Jan 8 2012 should be week 1');
- assert.equal(moment([2012, 0, 9]).week(), 2, 'Jan 9 2012 should be week 2');
- assert.equal(moment([2012, 0, 15]).week(), 2, 'Jan 15 2012 should be week 2');
-});
-
-test('weeks year starting monday', function (assert) {
- assert.equal(moment([2007, 0, 1]).week(), 1, 'Jan 1 2007 should be week 1');
- assert.equal(moment([2007, 0, 7]).week(), 1, 'Jan 7 2007 should be week 1');
- assert.equal(moment([2007, 0, 8]).week(), 2, 'Jan 8 2007 should be week 2');
- assert.equal(moment([2007, 0, 14]).week(), 2, 'Jan 14 2007 should be week 2');
- assert.equal(moment([2007, 0, 15]).week(), 3, 'Jan 15 2007 should be week 3');
-});
-
-test('weeks year starting tuesday', function (assert) {
- assert.equal(moment([2007, 11, 31]).week(), 1, 'Dec 31 2007 should be week 1');
- assert.equal(moment([2008, 0, 1]).week(), 1, 'Jan 1 2008 should be week 1');
- assert.equal(moment([2008, 0, 6]).week(), 1, 'Jan 6 2008 should be week 1');
- assert.equal(moment([2008, 0, 7]).week(), 2, 'Jan 7 2008 should be week 2');
- assert.equal(moment([2008, 0, 13]).week(), 2, 'Jan 13 2008 should be week 2');
- assert.equal(moment([2008, 0, 14]).week(), 3, 'Jan 14 2008 should be week 3');
-});
-
-test('weeks year starting wednesday', function (assert) {
- assert.equal(moment([2002, 11, 30]).week(), 1, 'Dec 30 2002 should be week 1');
- assert.equal(moment([2003, 0, 1]).week(), 1, 'Jan 1 2003 should be week 1');
- assert.equal(moment([2003, 0, 5]).week(), 1, 'Jan 5 2003 should be week 1');
- assert.equal(moment([2003, 0, 6]).week(), 2, 'Jan 6 2003 should be week 2');
- assert.equal(moment([2003, 0, 12]).week(), 2, 'Jan 12 2003 should be week 2');
- assert.equal(moment([2003, 0, 13]).week(), 3, 'Jan 13 2003 should be week 3');
-});
-
-test('weeks year starting thursday', function (assert) {
- assert.equal(moment([2008, 11, 29]).week(), 1, 'Dec 29 2008 should be week 1');
- assert.equal(moment([2009, 0, 1]).week(), 1, 'Jan 1 2009 should be week 1');
- assert.equal(moment([2009, 0, 4]).week(), 1, 'Jan 4 2009 should be week 1');
- assert.equal(moment([2009, 0, 5]).week(), 2, 'Jan 5 2009 should be week 2');
- assert.equal(moment([2009, 0, 11]).week(), 2, 'Jan 11 2009 should be week 2');
- assert.equal(moment([2009, 0, 13]).week(), 3, 'Jan 12 2009 should be week 3');
-});
-
-test('weeks year starting friday', function (assert) {
- assert.equal(moment([2009, 11, 28]).week(), 53, 'Dec 28 2009 should be week 53');
- assert.equal(moment([2010, 0, 1]).week(), 53, 'Jan 1 2010 should be week 53');
- assert.equal(moment([2010, 0, 3]).week(), 53, 'Jan 3 2010 should be week 53');
- assert.equal(moment([2010, 0, 4]).week(), 1, 'Jan 4 2010 should be week 1');
- assert.equal(moment([2010, 0, 10]).week(), 1, 'Jan 10 2010 should be week 1');
- assert.equal(moment([2010, 0, 11]).week(), 2, 'Jan 11 2010 should be week 2');
-});
-
-test('weeks year starting saturday', function (assert) {
- assert.equal(moment([2010, 11, 27]).week(), 52, 'Dec 27 2010 should be week 52');
- assert.equal(moment([2011, 0, 1]).week(), 52, 'Jan 1 2011 should be week 52');
- assert.equal(moment([2011, 0, 2]).week(), 52, 'Jan 2 2011 should be week 52');
- assert.equal(moment([2011, 0, 3]).week(), 1, 'Jan 3 2011 should be week 1');
- assert.equal(moment([2011, 0, 9]).week(), 1, 'Jan 9 2011 should be week 1');
- assert.equal(moment([2011, 0, 10]).week(), 2, 'Jan 10 2011 should be week 2');
-});
-
test('weeks year starting sunday formatted', function (assert) {
assert.equal(moment([2012, 0, 1]).format('w ww wo'), '52 52 52', 'Jan 1 2012 should be week 52');
assert.equal(moment([2012, 0, 2]).format('w ww wo'), '1 01 1', 'Jan 2 2012 should be week 1');
@@ -355,38 +284,3 @@
assert.equal(moment([2012, 0, 15]).format('w ww wo'), '2 02 2', 'Jan 15 2012 should be week 2');
});
-test('lenient ordinal parsing', function (assert) {
- var i, ordinalStr, testMoment;
- for (i = 1; i <= 31; ++i) {
- ordinalStr = moment([2014, 0, i]).format('YYYY MM Do');
- testMoment = moment(ordinalStr, 'YYYY MM Do');
- assert.equal(testMoment.year(), 2014,
- 'lenient ordinal parsing ' + i + ' year check');
- assert.equal(testMoment.month(), 0,
- 'lenient ordinal parsing ' + i + ' month check');
- assert.equal(testMoment.date(), i,
- 'lenient ordinal parsing ' + i + ' date check');
- }
-});
-
-test('lenient ordinal parsing of number', function (assert) {
- var i, testMoment;
- for (i = 1; i <= 31; ++i) {
- testMoment = moment('2014 01 ' + i, 'YYYY MM Do');
- assert.equal(testMoment.year(), 2014,
- 'lenient ordinal parsing of number ' + i + ' year check');
- assert.equal(testMoment.month(), 0,
- 'lenient ordinal parsing of number ' + i + ' month check');
- assert.equal(testMoment.date(), i,
- 'lenient ordinal parsing of number ' + i + ' date check');
- }
-});
-
-test('strict ordinal parsing', function (assert) {
- var i, ordinalStr, testMoment;
- for (i = 1; i <= 31; ++i) {
- ordinalStr = moment([2014, 0, i]).format('YYYY MM Do');
- testMoment = moment(ordinalStr, 'YYYY MM Do', true);
- assert.ok(testMoment.isValid(), 'strict ordinal parsing ' + i);
- }
-});
diff --git a/src/test/locale/ar.js b/src/test/locale/ar.js
index 4cf1a64..dc847ab 100644
--- a/src/test/locale/ar.js
+++ b/src/test/locale/ar.js
@@ -167,14 +167,14 @@
});
test('calendar day', function (assert) {
- var a = moment().hours(2).minutes(0).seconds(0);
-
- assert.equal(moment(a).calendar(), 'اليوم عند الساعة ٠٢:٠٠', 'today at the same time');
- assert.equal(moment(a).add({m: 25}).calendar(), 'اليوم عند الساعة ٠٢:٢٥', 'Now plus 25 min');
- assert.equal(moment(a).add({h: 1}).calendar(), 'اليوم عند الساعة ٠٣:٠٠', 'Now plus 1 hour');
- assert.equal(moment(a).add({d: 1}).calendar(), 'غدًا عند الساعة ٠٢:٠٠', 'tomorrow at the same time');
- assert.equal(moment(a).subtract({h: 1}).calendar(), 'اليوم عند الساعة ٠١:٠٠', 'Now minus 1 hour');
- assert.equal(moment(a).subtract({d: 1}).calendar(), 'أمس عند الساعة ٠٢:٠٠', 'yesterday at the same time');
+ var a = moment().hours(12).minutes(0).seconds(0);
+
+ assert.equal(moment(a).calendar(), 'اليوم عند الساعة ١٢:٠٠', 'today at the same time');
+ assert.equal(moment(a).add({m: 25}).calendar(), 'اليوم عند الساعة ١٢:٢٥', 'Now plus 25 min');
+ assert.equal(moment(a).add({h: 1}).calendar(), 'اليوم عند الساعة ١٣:٠٠', 'Now plus 1 hour');
+ assert.equal(moment(a).add({d: 1}).calendar(), 'غدًا عند الساعة ١٢:٠٠', 'tomorrow at the same time');
+ assert.equal(moment(a).subtract({h: 1}).calendar(), 'اليوم عند الساعة ١١:٠٠', 'Now minus 1 hour');
+ assert.equal(moment(a).subtract({d: 1}).calendar(), 'أمس عند الساعة ١٢:٠٠', 'yesterday at the same time');
});
test('calendar next week', function (assert) {
@@ -215,68 +215,11 @@
assert.equal(weeksFromNow.calendar(), weeksFromNow.format('L'), 'in 2 weeks');
});
-test('weeks year starting sunday', function (assert) {
- assert.equal(moment([2011, 11, 31]).week(), 1, 'Dec 31 2011 should be week 1');
- assert.equal(moment([2012, 0, 6]).week(), 1, 'Jan 6 2012 should be week 1');
- assert.equal(moment([2012, 0, 7]).week(), 2, 'Jan 7 2012 should be week 2');
- assert.equal(moment([2012, 0, 13]).week(), 2, 'Jan 13 2012 should be week 2');
- assert.equal(moment([2012, 0, 14]).week(), 3, 'Jan 14 2012 should be week 3');
-});
-
-test('weeks year starting monday', function (assert) {
- assert.equal(moment([2006, 11, 30]).week(), 1, 'Dec 30 2006 should be week 1');
- assert.equal(moment([2007, 0, 5]).week(), 1, 'Jan 5 2007 should be week 1');
- assert.equal(moment([2007, 0, 6]).week(), 2, 'Jan 6 2007 should be week 2');
- assert.equal(moment([2007, 0, 12]).week(), 2, 'Jan 12 2007 should be week 2');
- assert.equal(moment([2007, 0, 13]).week(), 3, 'Jan 13 2007 should be week 3');
-});
-
-test('weeks year starting tuesday', function (assert) {
- assert.equal(moment([2007, 11, 29]).week(), 1, 'Dec 29 2007 should be week 1');
- assert.equal(moment([2008, 0, 1]).week(), 1, 'Jan 1 2008 should be week 1');
- assert.equal(moment([2008, 0, 4]).week(), 1, 'Jan 4 2008 should be week 1');
- assert.equal(moment([2008, 0, 5]).week(), 2, 'Jan 5 2008 should be week 2');
- assert.equal(moment([2008, 0, 11]).week(), 2, 'Jan 11 2008 should be week 2');
- assert.equal(moment([2008, 0, 12]).week(), 3, 'Jan 12 2008 should be week 3');
-});
-
-test('weeks year starting wednesday', function (assert) {
- assert.equal(moment([2002, 11, 28]).week(), 1, 'Dec 28 2002 should be week 1');
- assert.equal(moment([2003, 0, 1]).week(), 1, 'Jan 1 2003 should be week 1');
- assert.equal(moment([2003, 0, 3]).week(), 1, 'Jan 3 2003 should be week 1');
- assert.equal(moment([2003, 0, 4]).week(), 2, 'Jan 4 2003 should be week 2');
- assert.equal(moment([2003, 0, 10]).week(), 2, 'Jan 10 2003 should be week 2');
- assert.equal(moment([2003, 0, 11]).week(), 3, 'Jan 11 2003 should be week 3');
-
+test('weeks year starting wednesday custom', function (assert) {
assert.equal(moment('2003 1 6', 'gggg w d').format('YYYY-MM-DD'), '٢٠٠٢-١٢-٢٨', 'Week 1 of 2003 should be Dec 28 2002');
assert.equal(moment('2003 1 0', 'gggg w e').format('YYYY-MM-DD'), '٢٠٠٢-١٢-٢٨', 'Week 1 of 2003 should be Dec 28 2002');
assert.equal(moment('2003 1 6', 'gggg w d').format('gggg w d'), '٢٠٠٣ ١ ٦', 'Saturday of week 1 of 2003 parsed should be formatted as 2003 1 6');
assert.equal(moment('2003 1 0', 'gggg w e').format('gggg w e'), '٢٠٠٣ ١ ٠', '1st day of week 1 of 2003 parsed should be formatted as 2003 1 0');
-});
-
-test('weeks year starting thursday', function (assert) {
- assert.equal(moment([2008, 11, 27]).week(), 1, 'Dec 27 2008 should be week 1');
- assert.equal(moment([2009, 0, 1]).week(), 1, 'Jan 1 2009 should be week 1');
- assert.equal(moment([2009, 0, 2]).week(), 1, 'Jan 2 2009 should be week 1');
- assert.equal(moment([2009, 0, 3]).week(), 2, 'Jan 3 2009 should be week 2');
- assert.equal(moment([2009, 0, 9]).week(), 2, 'Jan 9 2009 should be week 2');
- assert.equal(moment([2009, 0, 10]).week(), 3, 'Jan 10 2009 should be week 3');
-});
-
-test('weeks year starting friday', function (assert) {
- assert.equal(moment([2009, 11, 26]).week(), 1, 'Dec 26 2009 should be week 1');
- assert.equal(moment([2010, 0, 1]).week(), 1, 'Jan 1 2010 should be week 1');
- assert.equal(moment([2010, 0, 2]).week(), 2, 'Jan 2 2010 should be week 2');
- assert.equal(moment([2010, 0, 8]).week(), 2, 'Jan 8 2010 should be week 2');
- assert.equal(moment([2010, 0, 9]).week(), 3, 'Jan 9 2010 should be week 3');
-});
-
-test('weeks year starting saturday', function (assert) {
- assert.equal(moment([2011, 0, 1]).week(), 1, 'Jan 1 2011 should be week 1');
- assert.equal(moment([2011, 0, 7]).week(), 1, 'Jan 7 2011 should be week 1');
- assert.equal(moment([2011, 0, 8]).week(), 2, 'Jan 8 2011 should be week 2');
- assert.equal(moment([2011, 0, 14]).week(), 2, 'Jan 14 2011 should be week 2');
- assert.equal(moment([2011, 0, 15]).week(), 3, 'Jan 15 2011 should be week 3');
});
test('weeks year starting sunday formatted', function (assert) {
@@ -285,42 +228,6 @@
assert.equal(moment([2012, 0, 7]).format('w ww wo'), '٢ ٠٢ ٢', 'Jan 7 2012 should be week 2');
assert.equal(moment([2012, 0, 13]).format('w ww wo'), '٢ ٠٢ ٢', 'Jan 13 2012 should be week 2');
assert.equal(moment([2012, 0, 14]).format('w ww wo'), '٣ ٠٣ ٣', 'Jan 14 2012 should be week 3');
-});
-
-test('lenient ordinal parsing', function (assert) {
- var i, ordinalStr, testMoment;
- for (i = 1; i <= 31; ++i) {
- ordinalStr = moment([2014, 0, i]).format('YYYY MM Do');
- testMoment = moment(ordinalStr, 'YYYY MM Do');
- assert.equal(testMoment.year(), 2014,
- 'lenient ordinal parsing ' + i + ' year check');
- assert.equal(testMoment.month(), 0,
- 'lenient ordinal parsing ' + i + ' month check');
- assert.equal(testMoment.date(), i,
- 'lenient ordinal parsing ' + i + ' date check');
- }
-});
-
-test('lenient ordinal parsing of number', function (assert) {
- var i, testMoment;
- for (i = 1; i <= 31; ++i) {
- testMoment = moment('2014 01 ' + i, 'YYYY MM Do');
- assert.equal(testMoment.year(), 2014,
- 'lenient ordinal parsing of number ' + i + ' year check');
- assert.equal(testMoment.month(), 0,
- 'lenient ordinal parsing of number ' + i + ' month check');
- assert.equal(testMoment.date(), i,
- 'lenient ordinal parsing of number ' + i + ' date check');
- }
-});
-
-test('strict ordinal parsing', function (assert) {
- var i, ordinalStr, testMoment;
- for (i = 1; i <= 31; ++i) {
- ordinalStr = moment([2014, 0, i]).format('YYYY MM Do');
- testMoment = moment(ordinalStr, 'YYYY MM Do', true);
- assert.ok(testMoment.isValid(), 'strict ordinal parsing ' + i);
- }
});
test('no leading zeros in long date formats', function (assert) {
diff --git a/src/test/locale/az.js b/src/test/locale/az.js
index 4475f08..b87736f 100644
--- a/src/test/locale/az.js
+++ b/src/test/locale/az.js
@@ -162,14 +162,14 @@
});
test('calendar day', function (assert) {
- var a = moment().hours(2).minutes(0).seconds(0);
-
- assert.equal(moment(a).calendar(), 'bugün saat 02:00', 'today at the same time');
- assert.equal(moment(a).add({m: 25}).calendar(), 'bugün saat 02:25', 'Now plus 25 min');
- assert.equal(moment(a).add({h: 1}).calendar(), 'bugün saat 03:00', 'Now plus 1 hour');
- assert.equal(moment(a).add({d: 1}).calendar(), 'sabah saat 02:00', 'tomorrow at the same time');
- assert.equal(moment(a).subtract({h: 1}).calendar(), 'bugün saat 01:00', 'Now minus 1 hour');
- assert.equal(moment(a).subtract({d: 1}).calendar(), 'dünən 02:00', 'yesterday at the same time');
+ var a = moment().hours(12).minutes(0).seconds(0);
+
+ assert.equal(moment(a).calendar(), 'bugün saat 12:00', 'today at the same time');
+ assert.equal(moment(a).add({m: 25}).calendar(), 'bugün saat 12:25', 'Now plus 25 min');
+ assert.equal(moment(a).add({h: 1}).calendar(), 'bugün saat 13:00', 'Now plus 1 hour');
+ assert.equal(moment(a).add({d: 1}).calendar(), 'sabah saat 12:00', 'tomorrow at the same time');
+ assert.equal(moment(a).subtract({h: 1}).calendar(), 'bugün saat 11:00', 'Now minus 1 hour');
+ assert.equal(moment(a).subtract({d: 1}).calendar(), 'dünən 12:00', 'yesterday at the same time');
});
test('calendar next week', function (assert) {
@@ -210,67 +210,6 @@
assert.equal(weeksFromNow.calendar(), weeksFromNow.format('L'), 'in 2 weeks');
});
-test('weeks year starting sunday', function (assert) {
- assert.equal(moment([2011, 11, 26]).week(), 1, 'Dec 26 2011 should be week 1');
- assert.equal(moment([2012, 0, 1]).week(), 1, 'Jan 1 2012 should be week 1');
- assert.equal(moment([2012, 0, 2]).week(), 2, 'Jan 2 2012 should be week 2');
- assert.equal(moment([2012, 0, 8]).week(), 2, 'Jan 8 2012 should be week 2');
- assert.equal(moment([2012, 0, 9]).week(), 3, 'Jan 9 2012 should be week 3');
-});
-
-test('weeks year starting monday', function (assert) {
- assert.equal(moment([2007, 0, 1]).week(), 1, 'Jan 1 2007 should be week 1');
- assert.equal(moment([2007, 0, 7]).week(), 1, 'Jan 7 2007 should be week 1');
- assert.equal(moment([2007, 0, 8]).week(), 2, 'Jan 8 2007 should be week 2');
- assert.equal(moment([2007, 0, 14]).week(), 2, 'Jan 14 2007 should be week 2');
- assert.equal(moment([2007, 0, 15]).week(), 3, 'Jan 15 2007 should be week 3');
-});
-
-test('weeks year starting tuesday', function (assert) {
- assert.equal(moment([2007, 11, 31]).week(), 1, 'Dec 31 2007 should be week 1');
- assert.equal(moment([2008, 0, 1]).week(), 1, 'Jan 1 2008 should be week 1');
- assert.equal(moment([2008, 0, 6]).week(), 1, 'Jan 6 2008 should be week 1');
- assert.equal(moment([2008, 0, 7]).week(), 2, 'Jan 7 2008 should be week 2');
- assert.equal(moment([2008, 0, 13]).week(), 2, 'Jan 13 2008 should be week 2');
- assert.equal(moment([2008, 0, 14]).week(), 3, 'Jan 14 2008 should be week 3');
-});
-
-test('weeks year starting wednesday', function (assert) {
- assert.equal(moment([2002, 11, 30]).week(), 1, 'Dec 30 2002 should be week 1');
- assert.equal(moment([2003, 0, 1]).week(), 1, 'Jan 1 2003 should be week 1');
- assert.equal(moment([2003, 0, 5]).week(), 1, 'Jan 5 2003 should be week 1');
- assert.equal(moment([2003, 0, 6]).week(), 2, 'Jan 6 2003 should be week 2');
- assert.equal(moment([2003, 0, 12]).week(), 2, 'Jan 12 2003 should be week 2');
- assert.equal(moment([2003, 0, 13]).week(), 3, 'Jan 13 2003 should be week 3');
-});
-
-test('weeks year starting thursday', function (assert) {
- assert.equal(moment([2008, 11, 29]).week(), 1, 'Dec 29 2008 should be week 1');
- assert.equal(moment([2009, 0, 1]).week(), 1, 'Jan 1 2009 should be week 1');
- assert.equal(moment([2009, 0, 4]).week(), 1, 'Jan 4 2009 should be week 1');
- assert.equal(moment([2009, 0, 5]).week(), 2, 'Jan 5 2009 should be week 2');
- assert.equal(moment([2009, 0, 11]).week(), 2, 'Jan 11 2009 should be week 2');
- assert.equal(moment([2009, 0, 12]).week(), 3, 'Jan 12 2009 should be week 3');
-});
-
-test('weeks year starting friday', function (assert) {
- assert.equal(moment([2009, 11, 28]).week(), 1, 'Dec 28 2009 should be week 1');
- assert.equal(moment([2010, 0, 1]).week(), 1, 'Jan 1 2010 should be week 1');
- assert.equal(moment([2010, 0, 3]).week(), 1, 'Jan 3 2010 should be week 1');
- assert.equal(moment([2010, 0, 4]).week(), 2, 'Jan 4 2010 should be week 2');
- assert.equal(moment([2010, 0, 10]).week(), 2, 'Jan 10 2010 should be week 2');
- assert.equal(moment([2010, 0, 11]).week(), 3, 'Jan 11 2010 should be week 3');
-});
-
-test('weeks year starting saturday', function (assert) {
- assert.equal(moment([2010, 11, 27]).week(), 1, 'Dec 27 2010 should be week 1');
- assert.equal(moment([2011, 0, 1]).week(), 1, 'Jan 1 2011 should be week 1');
- assert.equal(moment([2011, 0, 2]).week(), 1, 'Jan 2 2011 should be week 1');
- assert.equal(moment([2011, 0, 3]).week(), 2, 'Jan 3 2011 should be week 2');
- assert.equal(moment([2011, 0, 9]).week(), 2, 'Jan 9 2011 should be week 2');
- assert.equal(moment([2011, 0, 10]).week(), 3, 'Jan 10 2011 should be week 3');
-});
-
test('weeks year starting sunday formatted', function (assert) {
assert.equal(moment([2011, 11, 26]).format('w ww wo'), '1 01 1-inci', 'Dec 26 2011 should be week 1');
assert.equal(moment([2012, 0, 1]).format('w ww wo'), '1 01 1-inci', 'Jan 1 2012 should be week 1');
@@ -279,38 +218,3 @@
assert.equal(moment([2012, 0, 9]).format('w ww wo'), '3 03 3-üncü', 'Jan 9 2012 should be week 3');
});
-test('lenient ordinal parsing', function (assert) {
- var i, ordinalStr, testMoment;
- for (i = 1; i <= 31; ++i) {
- ordinalStr = moment([2014, 0, i]).format('YYYY MM Do');
- testMoment = moment(ordinalStr, 'YYYY MM Do');
- assert.equal(testMoment.year(), 2014,
- 'lenient ordinal parsing ' + i + ' year check');
- assert.equal(testMoment.month(), 0,
- 'lenient ordinal parsing ' + i + ' month check');
- assert.equal(testMoment.date(), i,
- 'lenient ordinal parsing ' + i + ' date check');
- }
-});
-
-test('lenient ordinal parsing of number', function (assert) {
- var i, testMoment;
- for (i = 1; i <= 31; ++i) {
- testMoment = moment('2014 01 ' + i, 'YYYY MM Do');
- assert.equal(testMoment.year(), 2014,
- 'lenient ordinal parsing of number ' + i + ' year check');
- assert.equal(testMoment.month(), 0,
- 'lenient ordinal parsing of number ' + i + ' month check');
- assert.equal(testMoment.date(), i,
- 'lenient ordinal parsing of number ' + i + ' date check');
- }
-});
-
-test('strict ordinal parsing', function (assert) {
- var i, ordinalStr, testMoment;
- for (i = 1; i <= 31; ++i) {
- ordinalStr = moment([2014, 0, i]).format('YYYY MM Do');
- testMoment = moment(ordinalStr, 'YYYY MM Do', true);
- assert.ok(testMoment.isValid(), 'strict ordinal parsing ' + i);
- }
-});
diff --git a/src/test/locale/be.js b/src/test/locale/be.js
index 4c4c740..275469c 100644
--- a/src/test/locale/be.js
+++ b/src/test/locale/be.js
@@ -188,14 +188,14 @@
});
test('calendar day', function (assert) {
- var a = moment().hours(2).minutes(0).seconds(0);
-
- assert.equal(moment(a).calendar(), 'Сёння ў 02:00', 'today at the same time');
- assert.equal(moment(a).add({m: 25}).calendar(), 'Сёння ў 02:25', 'Now plus 25 min');
- assert.equal(moment(a).add({h: 1}).calendar(), 'Сёння ў 03:00', 'Now plus 1 hour');
- assert.equal(moment(a).add({d: 1}).calendar(), 'Заўтра ў 02:00', 'tomorrow at the same time');
- assert.equal(moment(a).subtract({h: 1}).calendar(), 'Сёння ў 01:00', 'Now minus 1 hour');
- assert.equal(moment(a).subtract({d: 1}).calendar(), 'Учора ў 02:00', 'yesterday at the same time');
+ var a = moment().hours(12).minutes(0).seconds(0);
+
+ assert.equal(moment(a).calendar(), 'Сёння ў 12:00', 'today at the same time');
+ assert.equal(moment(a).add({m: 25}).calendar(), 'Сёння ў 12:25', 'Now plus 25 min');
+ assert.equal(moment(a).add({h: 1}).calendar(), 'Сёння ў 13:00', 'Now plus 1 hour');
+ assert.equal(moment(a).add({d: 1}).calendar(), 'Заўтра ў 12:00', 'tomorrow at the same time');
+ assert.equal(moment(a).subtract({h: 1}).calendar(), 'Сёння ў 11:00', 'Now minus 1 hour');
+ assert.equal(moment(a).subtract({d: 1}).calendar(), 'Учора ў 12:00', 'yesterday at the same time');
});
test('calendar next week', function (assert) {
@@ -255,67 +255,6 @@
assert.equal(weeksFromNow.calendar(), weeksFromNow.format('L'), 'in 2 weeks');
});
-test('weeks year starting sunday', function (assert) {
- assert.equal(moment([2011, 11, 26]).week(), 1, 'Dec 26 2011 should be week 1');
- assert.equal(moment([2012, 0, 1]).week(), 1, 'Jan 1 2012 should be week 1');
- assert.equal(moment([2012, 0, 2]).week(), 2, 'Jan 2 2012 should be week 2');
- assert.equal(moment([2012, 0, 8]).week(), 2, 'Jan 8 2012 should be week 2');
- assert.equal(moment([2012, 0, 9]).week(), 3, 'Jan 9 2012 should be week 3');
-});
-
-test('weeks year starting monday', function (assert) {
- assert.equal(moment([2007, 0, 1]).week(), 1, 'Jan 1 2007 should be week 1');
- assert.equal(moment([2007, 0, 7]).week(), 1, 'Jan 7 2007 should be week 1');
- assert.equal(moment([2007, 0, 8]).week(), 2, 'Jan 8 2007 should be week 2');
- assert.equal(moment([2007, 0, 14]).week(), 2, 'Jan 14 2007 should be week 2');
- assert.equal(moment([2007, 0, 15]).week(), 3, 'Jan 15 2007 should be week 3');
-});
-
-test('weeks year starting tuesday', function (assert) {
- assert.equal(moment([2007, 11, 31]).week(), 1, 'Dec 31 2007 should be week 1');
- assert.equal(moment([2008, 0, 1]).week(), 1, 'Jan 1 2008 should be week 1');
- assert.equal(moment([2008, 0, 6]).week(), 1, 'Jan 6 2008 should be week 1');
- assert.equal(moment([2008, 0, 7]).week(), 2, 'Jan 7 2008 should be week 2');
- assert.equal(moment([2008, 0, 13]).week(), 2, 'Jan 13 2008 should be week 2');
- assert.equal(moment([2008, 0, 14]).week(), 3, 'Jan 14 2008 should be week 3');
-});
-
-test('weeks year starting wednesday', function (assert) {
- assert.equal(moment([2002, 11, 30]).week(), 1, 'Dec 30 2002 should be week 1');
- assert.equal(moment([2003, 0, 1]).week(), 1, 'Jan 1 2003 should be week 1');
- assert.equal(moment([2003, 0, 5]).week(), 1, 'Jan 5 2003 should be week 1');
- assert.equal(moment([2003, 0, 6]).week(), 2, 'Jan 6 2003 should be week 2');
- assert.equal(moment([2003, 0, 12]).week(), 2, 'Jan 12 2003 should be week 2');
- assert.equal(moment([2003, 0, 13]).week(), 3, 'Jan 13 2003 should be week 3');
-});
-
-test('weeks year starting thursday', function (assert) {
- assert.equal(moment([2008, 11, 29]).week(), 1, 'Dec 29 2008 should be week 1');
- assert.equal(moment([2009, 0, 1]).week(), 1, 'Jan 1 2009 should be week 1');
- assert.equal(moment([2009, 0, 4]).week(), 1, 'Jan 4 2009 should be week 1');
- assert.equal(moment([2009, 0, 5]).week(), 2, 'Jan 5 2009 should be week 2');
- assert.equal(moment([2009, 0, 11]).week(), 2, 'Jan 11 2009 should be week 2');
- assert.equal(moment([2009, 0, 12]).week(), 3, 'Jan 12 2009 should be week 3');
-});
-
-test('weeks year starting friday', function (assert) {
- assert.equal(moment([2009, 11, 28]).week(), 1, 'Dec 28 2009 should be week 1');
- assert.equal(moment([2010, 0, 1]).week(), 1, 'Jan 1 2010 should be week 1');
- assert.equal(moment([2010, 0, 3]).week(), 1, 'Jan 3 2010 should be week 1');
- assert.equal(moment([2010, 0, 4]).week(), 2, 'Jan 4 2010 should be week 2');
- assert.equal(moment([2010, 0, 10]).week(), 2, 'Jan 10 2010 should be week 2');
- assert.equal(moment([2010, 0, 11]).week(), 3, 'Jan 11 2010 should be week 3');
-});
-
-test('weeks year starting saturday', function (assert) {
- assert.equal(moment([2010, 11, 27]).week(), 1, 'Dec 27 2010 should be week 1');
- assert.equal(moment([2011, 0, 1]).week(), 1, 'Jan 1 2011 should be week 1');
- assert.equal(moment([2011, 0, 2]).week(), 1, 'Jan 2 2011 should be week 1');
- assert.equal(moment([2011, 0, 3]).week(), 2, 'Jan 3 2011 should be week 2');
- assert.equal(moment([2011, 0, 9]).week(), 2, 'Jan 9 2011 should be week 2');
- assert.equal(moment([2011, 0, 10]).week(), 3, 'Jan 10 2011 should be week 3');
-});
-
test('weeks year starting sunday formatted', function (assert) {
assert.equal(moment([2011, 11, 26]).format('w ww wo'), '1 01 1-ы', 'Dec 26 2011 should be week 1');
assert.equal(moment([2012, 0, 1]).format('w ww wo'), '1 01 1-ы', 'Jan 1 2012 should be week 1');
@@ -324,38 +263,3 @@
assert.equal(moment([2012, 0, 9]).format('w ww wo'), '3 03 3-і', 'Jan 9 2012 should be week 3');
});
-test('lenient ordinal parsing', function (assert) {
- var i, ordinalStr, testMoment;
- for (i = 1; i <= 31; ++i) {
- ordinalStr = moment([2014, 0, i]).format('YYYY MM Do');
- testMoment = moment(ordinalStr, 'YYYY MM Do');
- assert.equal(testMoment.year(), 2014,
- 'lenient ordinal parsing ' + i + ' year check');
- assert.equal(testMoment.month(), 0,
- 'lenient ordinal parsing ' + i + ' month check');
- assert.equal(testMoment.date(), i,
- 'lenient ordinal parsing ' + i + ' date check');
- }
-});
-
-test('lenient ordinal parsing of number', function (assert) {
- var i, testMoment;
- for (i = 1; i <= 31; ++i) {
- testMoment = moment('2014 01 ' + i, 'YYYY MM Do');
- assert.equal(testMoment.year(), 2014,
- 'lenient ordinal parsing of number ' + i + ' year check');
- assert.equal(testMoment.month(), 0,
- 'lenient ordinal parsing of number ' + i + ' month check');
- assert.equal(testMoment.date(), i,
- 'lenient ordinal parsing of number ' + i + ' date check');
- }
-});
-
-test('strict ordinal parsing', function (assert) {
- var i, ordinalStr, testMoment;
- for (i = 1; i <= 31; ++i) {
- ordinalStr = moment([2014, 0, i]).format('YYYY MM Do');
- testMoment = moment(ordinalStr, 'YYYY MM Do', true);
- assert.ok(testMoment.isValid(), 'strict ordinal parsing ' + i);
- }
-});
diff --git a/src/test/locale/bg.js b/src/test/locale/bg.js
index 29e8e17..66c1bcd 100644
--- a/src/test/locale/bg.js
+++ b/src/test/locale/bg.js
@@ -152,14 +152,14 @@
});
test('calendar day', function (assert) {
- var a = moment().hours(2).minutes(0).seconds(0);
-
- assert.equal(moment(a).calendar(), 'Днес в 2:00', 'today at the same time');
- assert.equal(moment(a).add({m: 25}).calendar(), 'Днес в 2:25', 'Now plus 25 min');
- assert.equal(moment(a).add({h: 1}).calendar(), 'Днес в 3:00', 'Now plus 1 hour');
- assert.equal(moment(a).add({d: 1}).calendar(), 'Утре в 2:00', 'tomorrow at the same time');
- assert.equal(moment(a).subtract({h: 1}).calendar(), 'Днес в 1:00', 'Now minus 1 hour');
- assert.equal(moment(a).subtract({d: 1}).calendar(), 'Вчера в 2:00', 'yesterday at the same time');
+ var a = moment().hours(12).minutes(0).seconds(0);
+
+ assert.equal(moment(a).calendar(), 'Днес в 12:00', 'today at the same time');
+ assert.equal(moment(a).add({m: 25}).calendar(), 'Днес в 12:25', 'Now plus 25 min');
+ assert.equal(moment(a).add({h: 1}).calendar(), 'Днес в 13:00', 'Now plus 1 hour');
+ assert.equal(moment(a).add({d: 1}).calendar(), 'Утре в 12:00', 'tomorrow at the same time');
+ assert.equal(moment(a).subtract({h: 1}).calendar(), 'Днес в 11:00', 'Now minus 1 hour');
+ assert.equal(moment(a).subtract({d: 1}).calendar(), 'Вчера в 12:00', 'yesterday at the same time');
});
test('calendar next week', function (assert) {
@@ -215,67 +215,6 @@
assert.equal(weeksFromNow.calendar(), weeksFromNow.format('L'), 'in 2 weeks');
});
-test('weeks year starting sunday', function (assert) {
- assert.equal(moment([2011, 11, 26]).week(), 1, 'Dec 26 2011 should be week 1');
- assert.equal(moment([2012, 0, 1]).week(), 1, 'Jan 1 2012 should be week 1');
- assert.equal(moment([2012, 0, 2]).week(), 2, 'Jan 2 2012 should be week 2');
- assert.equal(moment([2012, 0, 8]).week(), 2, 'Jan 8 2012 should be week 2');
- assert.equal(moment([2012, 0, 9]).week(), 3, 'Jan 9 2012 should be week 3');
-});
-
-test('weeks year starting monday', function (assert) {
- assert.equal(moment([2007, 0, 1]).week(), 1, 'Jan 1 2007 should be week 1');
- assert.equal(moment([2007, 0, 7]).week(), 1, 'Jan 7 2007 should be week 1');
- assert.equal(moment([2007, 0, 8]).week(), 2, 'Jan 8 2007 should be week 2');
- assert.equal(moment([2007, 0, 14]).week(), 2, 'Jan 14 2007 should be week 2');
- assert.equal(moment([2007, 0, 15]).week(), 3, 'Jan 15 2007 should be week 3');
-});
-
-test('weeks year starting tuesday', function (assert) {
- assert.equal(moment([2007, 11, 31]).week(), 1, 'Dec 31 2007 should be week 1');
- assert.equal(moment([2008, 0, 1]).week(), 1, 'Jan 1 2008 should be week 1');
- assert.equal(moment([2008, 0, 6]).week(), 1, 'Jan 6 2008 should be week 1');
- assert.equal(moment([2008, 0, 7]).week(), 2, 'Jan 7 2008 should be week 2');
- assert.equal(moment([2008, 0, 13]).week(), 2, 'Jan 13 2008 should be week 2');
- assert.equal(moment([2008, 0, 14]).week(), 3, 'Jan 14 2008 should be week 3');
-});
-
-test('weeks year starting wednesday', function (assert) {
- assert.equal(moment([2002, 11, 30]).week(), 1, 'Dec 30 2002 should be week 1');
- assert.equal(moment([2003, 0, 1]).week(), 1, 'Jan 1 2003 should be week 1');
- assert.equal(moment([2003, 0, 5]).week(), 1, 'Jan 5 2003 should be week 1');
- assert.equal(moment([2003, 0, 6]).week(), 2, 'Jan 6 2003 should be week 2');
- assert.equal(moment([2003, 0, 12]).week(), 2, 'Jan 12 2003 should be week 2');
- assert.equal(moment([2003, 0, 13]).week(), 3, 'Jan 13 2003 should be week 3');
-});
-
-test('weeks year starting thursday', function (assert) {
- assert.equal(moment([2008, 11, 29]).week(), 1, 'Dec 29 2008 should be week 1');
- assert.equal(moment([2009, 0, 1]).week(), 1, 'Jan 1 2009 should be week 1');
- assert.equal(moment([2009, 0, 4]).week(), 1, 'Jan 4 2009 should be week 1');
- assert.equal(moment([2009, 0, 5]).week(), 2, 'Jan 5 2009 should be week 2');
- assert.equal(moment([2009, 0, 11]).week(), 2, 'Jan 11 2009 should be week 2');
- assert.equal(moment([2009, 0, 12]).week(), 3, 'Jan 12 2009 should be week 3');
-});
-
-test('weeks year starting friday', function (assert) {
- assert.equal(moment([2009, 11, 28]).week(), 1, 'Dec 28 2009 should be week 1');
- assert.equal(moment([2010, 0, 1]).week(), 1, 'Jan 1 2010 should be week 1');
- assert.equal(moment([2010, 0, 3]).week(), 1, 'Jan 3 2010 should be week 1');
- assert.equal(moment([2010, 0, 4]).week(), 2, 'Jan 4 2010 should be week 2');
- assert.equal(moment([2010, 0, 10]).week(), 2, 'Jan 10 2010 should be week 2');
- assert.equal(moment([2010, 0, 11]).week(), 3, 'Jan 11 2010 should be week 3');
-});
-
-test('weeks year starting saturday', function (assert) {
- assert.equal(moment([2010, 11, 27]).week(), 1, 'Dec 27 2010 should be week 1');
- assert.equal(moment([2011, 0, 1]).week(), 1, 'Jan 1 2011 should be week 1');
- assert.equal(moment([2011, 0, 2]).week(), 1, 'Jan 2 2011 should be week 1');
- assert.equal(moment([2011, 0, 3]).week(), 2, 'Jan 3 2011 should be week 2');
- assert.equal(moment([2011, 0, 9]).week(), 2, 'Jan 9 2011 should be week 2');
- assert.equal(moment([2011, 0, 10]).week(), 3, 'Jan 10 2011 should be week 3');
-});
-
test('weeks year starting sunday formatted', function (assert) {
assert.equal(moment([2011, 11, 26]).format('w ww wo'), '1 01 1-ви', 'Dec 26 2011 should be week 1');
assert.equal(moment([2012, 0, 1]).format('w ww wo'), '1 01 1-ви', 'Jan 1 2012 should be week 1');
@@ -284,38 +223,3 @@
assert.equal(moment([2012, 0, 9]).format('w ww wo'), '3 03 3-ти', 'Jan 9 2012 should be week 3');
});
-test('lenient ordinal parsing', function (assert) {
- var i, ordinalStr, testMoment;
- for (i = 1; i <= 31; ++i) {
- ordinalStr = moment([2014, 0, i]).format('YYYY MM Do');
- testMoment = moment(ordinalStr, 'YYYY MM Do');
- assert.equal(testMoment.year(), 2014,
- 'lenient ordinal parsing ' + i + ' year check');
- assert.equal(testMoment.month(), 0,
- 'lenient ordinal parsing ' + i + ' month check');
- assert.equal(testMoment.date(), i,
- 'lenient ordinal parsing ' + i + ' date check');
- }
-});
-
-test('lenient ordinal parsing of number', function (assert) {
- var i, testMoment;
- for (i = 1; i <= 31; ++i) {
- testMoment = moment('2014 01 ' + i, 'YYYY MM Do');
- assert.equal(testMoment.year(), 2014,
- 'lenient ordinal parsing of number ' + i + ' year check');
- assert.equal(testMoment.month(), 0,
- 'lenient ordinal parsing of number ' + i + ' month check');
- assert.equal(testMoment.date(), i,
- 'lenient ordinal parsing of number ' + i + ' date check');
- }
-});
-
-test('strict ordinal parsing', function (assert) {
- var i, ordinalStr, testMoment;
- for (i = 1; i <= 31; ++i) {
- ordinalStr = moment([2014, 0, i]).format('YYYY MM Do');
- testMoment = moment(ordinalStr, 'YYYY MM Do', true);
- assert.ok(testMoment.isValid(), 'strict ordinal parsing ' + i);
- }
-});
diff --git a/src/test/locale/bn.js b/src/test/locale/bn.js
index 5b4df01..20e4e05 100644
--- a/src/test/locale/bn.js
+++ b/src/test/locale/bn.js
@@ -150,14 +150,14 @@
});
test('calendar day', function (assert) {
- var a = moment().hours(2).minutes(0).seconds(0);
-
- assert.equal(moment(a).calendar(), 'আজ রাত ২:০০ সময়', 'today at the same time');
- assert.equal(moment(a).add({m: 25}).calendar(), 'আজ রাত ২:২৫ সময়', 'Now plus 25 min');
- assert.equal(moment(a).add({h: 3}).calendar(), 'আজ সকাল ৫:০০ সময়', 'Now plus 3 hour');
- assert.equal(moment(a).add({d: 1}).calendar(), 'আগামীকাল রাত ২:০০ সময়', 'tomorrow at the same time');
- assert.equal(moment(a).subtract({h: 1}).calendar(), 'আজ রাত ১:০০ সময়', 'Now minus 1 hour');
- assert.equal(moment(a).subtract({d: 1}).calendar(), 'গতকাল রাত ২:০০ সময়', 'yesterday at the same time');
+ var a = moment().hours(12).minutes(0).seconds(0);
+
+ assert.equal(moment(a).calendar(), 'আজ দুপুর ১২:০০ সময়', 'today at the same time');
+ assert.equal(moment(a).add({m: 25}).calendar(), 'আজ দুপুর ১২:২৫ সময়', 'Now plus 25 min');
+ assert.equal(moment(a).add({h: 3}).calendar(), 'আজ দুপুর ৩:০০ সময়', 'Now plus 3 hours');
+ assert.equal(moment(a).add({d: 1}).calendar(), 'আগামীকাল দুপুর ১২:০০ সময়', 'tomorrow at the same time');
+ assert.equal(moment(a).subtract({h: 1}).calendar(), 'আজ দুপুর ১১:০০ সময়', 'Now minus 1 hour');
+ assert.equal(moment(a).subtract({d: 1}).calendar(), 'গতকাল দুপুর ১২:০০ সময়', 'yesterday at the same time');
});
test('calendar next week', function (assert) {
@@ -215,67 +215,6 @@
assert.equal(moment([2011, 2, 23, 21, 20]).format('A'), 'রাত', 'night');
});
-test('weeks year starting sunday', function (assert) {
- assert.equal(moment([2012, 0, 1]).week(), 1, 'Jan 1 2012 should be week 1');
- assert.equal(moment([2012, 0, 7]).week(), 1, 'Jan 7 2012 should be week 1');
- assert.equal(moment([2012, 0, 8]).week(), 2, 'Jan 8 2012 should be week 2');
- assert.equal(moment([2012, 0, 14]).week(), 2, 'Jan 14 2012 should be week 2');
- assert.equal(moment([2012, 0, 15]).week(), 3, 'Jan 15 2012 should be week 3');
-});
-
-test('weeks year starting monday', function (assert) {
- assert.equal(moment([2006, 11, 31]).week(), 1, 'Dec 31 2006 should be week 1');
- assert.equal(moment([2007, 0, 1]).week(), 1, 'Jan 1 2007 should be week 1');
- assert.equal(moment([2007, 0, 6]).week(), 1, 'Jan 6 2007 should be week 1');
- assert.equal(moment([2007, 0, 7]).week(), 2, 'Jan 7 2007 should be week 2');
- assert.equal(moment([2007, 0, 13]).week(), 2, 'Jan 13 2007 should be week 2');
- assert.equal(moment([2007, 0, 14]).week(), 3, 'Jan 14 2007 should be week 3');
-});
-
-test('weeks year starting tuesday', function (assert) {
- assert.equal(moment([2007, 11, 29]).week(), 52, 'Dec 29 2007 should be week 52');
- assert.equal(moment([2008, 0, 1]).week(), 1, 'Jan 1 2008 should be week 1');
- assert.equal(moment([2008, 0, 5]).week(), 1, 'Jan 5 2008 should be week 1');
- assert.equal(moment([2008, 0, 6]).week(), 2, 'Jan 6 2008 should be week 2');
- assert.equal(moment([2008, 0, 12]).week(), 2, 'Jan 12 2008 should be week 2');
- assert.equal(moment([2008, 0, 13]).week(), 3, 'Jan 13 2008 should be week 3');
-});
-
-test('weeks year starting wednesday', function (assert) {
- assert.equal(moment([2002, 11, 29]).week(), 1, 'Dec 29 2002 should be week 1');
- assert.equal(moment([2003, 0, 1]).week(), 1, 'Jan 1 2003 should be week 1');
- assert.equal(moment([2003, 0, 4]).week(), 1, 'Jan 4 2003 should be week 1');
- assert.equal(moment([2003, 0, 5]).week(), 2, 'Jan 5 2003 should be week 2');
- assert.equal(moment([2003, 0, 11]).week(), 2, 'Jan 11 2003 should be week 2');
- assert.equal(moment([2003, 0, 12]).week(), 3, 'Jan 12 2003 should be week 3');
-});
-
-test('weeks year starting thursday', function (assert) {
- assert.equal(moment([2008, 11, 28]).week(), 1, 'Dec 28 2008 should be week 1');
- assert.equal(moment([2009, 0, 1]).week(), 1, 'Jan 1 2009 should be week 1');
- assert.equal(moment([2009, 0, 3]).week(), 1, 'Jan 3 2009 should be week 1');
- assert.equal(moment([2009, 0, 4]).week(), 2, 'Jan 4 2009 should be week 2');
- assert.equal(moment([2009, 0, 10]).week(), 2, 'Jan 10 2009 should be week 2');
- assert.equal(moment([2009, 0, 11]).week(), 3, 'Jan 11 2009 should be week 3');
-});
-
-test('weeks year starting friday', function (assert) {
- assert.equal(moment([2009, 11, 27]).week(), 1, 'Dec 27 2009 should be week 1');
- assert.equal(moment([2010, 0, 1]).week(), 1, 'Jan 1 2010 should be week 1');
- assert.equal(moment([2010, 0, 2]).week(), 1, 'Jan 2 2010 should be week 1');
- assert.equal(moment([2010, 0, 3]).week(), 2, 'Jan 3 2010 should be week 2');
- assert.equal(moment([2010, 0, 9]).week(), 2, 'Jan 9 2010 should be week 2');
- assert.equal(moment([2010, 0, 10]).week(), 3, 'Jan 10 2010 should be week 3');
-});
-
-test('weeks year starting saturday', function (assert) {
- assert.equal(moment([2010, 11, 26]).week(), 1, 'Dec 26 2010 should be week 1');
- assert.equal(moment([2011, 0, 1]).week(), 1, 'Jan 1 2011 should be week 1');
- assert.equal(moment([2011, 0, 2]).week(), 2, 'Jan 2 2011 should be week 2');
- assert.equal(moment([2011, 0, 8]).week(), 2, 'Jan 8 2011 should be week 2');
- assert.equal(moment([2011, 0, 9]).week(), 3, 'Jan 9 2011 should be week 3');
-});
-
test('weeks year starting sunday formatted', function (assert) {
assert.equal(moment([2012, 0, 1]).format('w ww wo'), '১ ০১ ১', 'Jan 1 2012 should be week 1');
assert.equal(moment([2012, 0, 7]).format('w ww wo'), '১ ০১ ১', 'Jan 7 2012 should be week 1');
@@ -284,38 +223,3 @@
assert.equal(moment([2012, 0, 15]).format('w ww wo'), '৩ ০৩ ৩', 'Jan 15 2012 should be week 3');
});
-test('lenient ordinal parsing', function (assert) {
- var i, ordinalStr, testMoment;
- for (i = 1; i <= 31; ++i) {
- ordinalStr = moment([2014, 0, i]).format('YYYY MM Do');
- testMoment = moment(ordinalStr, 'YYYY MM Do');
- assert.equal(testMoment.year(), 2014,
- 'lenient ordinal parsing ' + i + ' year check');
- assert.equal(testMoment.month(), 0,
- 'lenient ordinal parsing ' + i + ' month check');
- assert.equal(testMoment.date(), i,
- 'lenient ordinal parsing ' + i + ' date check');
- }
-});
-
-test('lenient ordinal parsing of number', function (assert) {
- var i, testMoment;
- for (i = 1; i <= 31; ++i) {
- testMoment = moment('2014 01 ' + i, 'YYYY MM Do');
- assert.equal(testMoment.year(), 2014,
- 'lenient ordinal parsing of number ' + i + ' year check');
- assert.equal(testMoment.month(), 0,
- 'lenient ordinal parsing of number ' + i + ' month check');
- assert.equal(testMoment.date(), i,
- 'lenient ordinal parsing of number ' + i + ' date check');
- }
-});
-
-test('strict ordinal parsing', function (assert) {
- var i, ordinalStr, testMoment;
- for (i = 1; i <= 31; ++i) {
- ordinalStr = moment([2014, 0, i]).format('YYYY MM Do');
- testMoment = moment(ordinalStr, 'YYYY MM Do', true);
- assert.ok(testMoment.isValid(), 'strict ordinal parsing ' + i);
- }
-});
diff --git a/src/test/locale/bo.js b/src/test/locale/bo.js
index 0f4038d..9fbcb44 100644
--- a/src/test/locale/bo.js
+++ b/src/test/locale/bo.js
@@ -151,14 +151,14 @@
});
test('calendar day', function (assert) {
- var a = moment().hours(2).minutes(0).seconds(0);
-
- assert.equal(moment(a).calendar(), 'དི་རིང མཚན་མོ ༢:༠༠', 'today at the same time');
- assert.equal(moment(a).add({m: 25}).calendar(), 'དི་རིང མཚན་མོ ༢:༢༥', 'Now plus 25 min');
- assert.equal(moment(a).add({h: 3}).calendar(), 'དི་རིང ཞོགས་ཀས ༥:༠༠', 'Now plus 3 hour');
- assert.equal(moment(a).add({d: 1}).calendar(), 'སང་ཉིན མཚན་མོ ༢:༠༠', 'tomorrow at the same time');
- assert.equal(moment(a).subtract({h: 1}).calendar(), 'དི་རིང མཚན་མོ ༡:༠༠', 'Now minus 1 hour');
- assert.equal(moment(a).subtract({d: 1}).calendar(), 'ཁ་སང མཚན་མོ ༢:༠༠', 'yesterday at the same time');
+ var a = moment().hours(12).minutes(0).seconds(0);
+
+ assert.equal(moment(a).calendar(), 'དི་རིང ཉིན་གུང ༡༢:༠༠', 'today at the same time');
+ assert.equal(moment(a).add({m: 25}).calendar(), 'དི་རིང ཉིན་གུང ༡༢:༢༥', 'Now plus 25 min');
+ assert.equal(moment(a).add({h: 3}).calendar(), 'དི་རིང ཉིན་གུང ༣:༠༠', 'Now plus 3 hours');
+ assert.equal(moment(a).add({d: 1}).calendar(), 'སང་ཉིན ཉིན་གུང ༡༢:༠༠', 'tomorrow at the same time');
+ assert.equal(moment(a).subtract({h: 1}).calendar(), 'དི་རིང ཉིན་གུང ༡༡:༠༠', 'Now minus 1 hour');
+ assert.equal(moment(a).subtract({d: 1}).calendar(), 'ཁ་སང ཉིན་གུང ༡༢:༠༠', 'yesterday at the same time');
});
test('calendar next week', function (assert) {
@@ -216,67 +216,6 @@
assert.equal(moment([2011, 2, 23, 21, 20]).format('A'), 'མཚན་མོ', 'night');
});
-test('weeks year starting sunday', function (assert) {
- assert.equal(moment([2012, 0, 1]).week(), 1, 'Jan 1 2012 should be week 1');
- assert.equal(moment([2012, 0, 7]).week(), 1, 'Jan 7 2012 should be week 1');
- assert.equal(moment([2012, 0, 8]).week(), 2, 'Jan 8 2012 should be week 2');
- assert.equal(moment([2012, 0, 14]).week(), 2, 'Jan 14 2012 should be week 2');
- assert.equal(moment([2012, 0, 15]).week(), 3, 'Jan 15 2012 should be week 3');
-});
-
-test('weeks year starting monday', function (assert) {
- assert.equal(moment([2006, 11, 31]).week(), 1, 'Dec 31 2006 should be week 1');
- assert.equal(moment([2007, 0, 1]).week(), 1, 'Jan 1 2007 should be week 1');
- assert.equal(moment([2007, 0, 6]).week(), 1, 'Jan 6 2007 should be week 1');
- assert.equal(moment([2007, 0, 7]).week(), 2, 'Jan 7 2007 should be week 2');
- assert.equal(moment([2007, 0, 13]).week(), 2, 'Jan 13 2007 should be week 2');
- assert.equal(moment([2007, 0, 14]).week(), 3, 'Jan 14 2007 should be week 3');
-});
-
-test('weeks year starting tuesday', function (assert) {
- assert.equal(moment([2007, 11, 29]).week(), 52, 'Dec 29 2007 should be week 52');
- assert.equal(moment([2008, 0, 1]).week(), 1, 'Jan 1 2008 should be week 1');
- assert.equal(moment([2008, 0, 5]).week(), 1, 'Jan 5 2008 should be week 1');
- assert.equal(moment([2008, 0, 6]).week(), 2, 'Jan 6 2008 should be week 2');
- assert.equal(moment([2008, 0, 12]).week(), 2, 'Jan 12 2008 should be week 2');
- assert.equal(moment([2008, 0, 13]).week(), 3, 'Jan 13 2008 should be week 3');
-});
-
-test('weeks year starting wednesday', function (assert) {
- assert.equal(moment([2002, 11, 29]).week(), 1, 'Dec 29 2002 should be week 1');
- assert.equal(moment([2003, 0, 1]).week(), 1, 'Jan 1 2003 should be week 1');
- assert.equal(moment([2003, 0, 4]).week(), 1, 'Jan 4 2003 should be week 1');
- assert.equal(moment([2003, 0, 5]).week(), 2, 'Jan 5 2003 should be week 2');
- assert.equal(moment([2003, 0, 11]).week(), 2, 'Jan 11 2003 should be week 2');
- assert.equal(moment([2003, 0, 12]).week(), 3, 'Jan 12 2003 should be week 3');
-});
-
-test('weeks year starting thursday', function (assert) {
- assert.equal(moment([2008, 11, 28]).week(), 1, 'Dec 28 2008 should be week 1');
- assert.equal(moment([2009, 0, 1]).week(), 1, 'Jan 1 2009 should be week 1');
- assert.equal(moment([2009, 0, 3]).week(), 1, 'Jan 3 2009 should be week 1');
- assert.equal(moment([2009, 0, 4]).week(), 2, 'Jan 4 2009 should be week 2');
- assert.equal(moment([2009, 0, 10]).week(), 2, 'Jan 10 2009 should be week 2');
- assert.equal(moment([2009, 0, 11]).week(), 3, 'Jan 11 2009 should be week 3');
-});
-
-test('weeks year starting friday', function (assert) {
- assert.equal(moment([2009, 11, 27]).week(), 1, 'Dec 27 2009 should be week 1');
- assert.equal(moment([2010, 0, 1]).week(), 1, 'Jan 1 2010 should be week 1');
- assert.equal(moment([2010, 0, 2]).week(), 1, 'Jan 2 2010 should be week 1');
- assert.equal(moment([2010, 0, 3]).week(), 2, 'Jan 3 2010 should be week 2');
- assert.equal(moment([2010, 0, 9]).week(), 2, 'Jan 9 2010 should be week 2');
- assert.equal(moment([2010, 0, 10]).week(), 3, 'Jan 10 2010 should be week 3');
-});
-
-test('weeks year starting saturday', function (assert) {
- assert.equal(moment([2010, 11, 26]).week(), 1, 'Dec 26 2010 should be week 1');
- assert.equal(moment([2011, 0, 1]).week(), 1, 'Jan 1 2011 should be week 1');
- assert.equal(moment([2011, 0, 2]).week(), 2, 'Jan 2 2011 should be week 2');
- assert.equal(moment([2011, 0, 8]).week(), 2, 'Jan 8 2011 should be week 2');
- assert.equal(moment([2011, 0, 9]).week(), 3, 'Jan 9 2011 should be week 3');
-});
-
test('weeks year starting sunday formatted', function (assert) {
assert.equal(moment([2012, 0, 1]).format('w ww wo'), '༡ ༠༡ ༡', 'Jan 1 2012 should be week 1');
assert.equal(moment([2012, 0, 7]).format('w ww wo'), '༡ ༠༡ ༡', 'Jan 7 2012 should be week 1');
@@ -285,38 +224,3 @@
assert.equal(moment([2012, 0, 15]).format('w ww wo'), '༣ ༠༣ ༣', 'Jan 15 2012 should be week 3');
});
-test('lenient ordinal parsing', function (assert) {
- var i, ordinalStr, testMoment;
- for (i = 1; i <= 31; ++i) {
- ordinalStr = moment([2014, 0, i]).format('YYYY MM Do');
- testMoment = moment(ordinalStr, 'YYYY MM Do');
- assert.equal(testMoment.year(), 2014,
- 'lenient ordinal parsing ' + i + ' year check');
- assert.equal(testMoment.month(), 0,
- 'lenient ordinal parsing ' + i + ' month check');
- assert.equal(testMoment.date(), i,
- 'lenient ordinal parsing ' + i + ' date check');
- }
-});
-
-test('lenient ordinal parsing of number', function (assert) {
- var i, testMoment;
- for (i = 1; i <= 31; ++i) {
- testMoment = moment('2014 01 ' + i, 'YYYY MM Do');
- assert.equal(testMoment.year(), 2014,
- 'lenient ordinal parsing of number ' + i + ' year check');
- assert.equal(testMoment.month(), 0,
- 'lenient ordinal parsing of number ' + i + ' month check');
- assert.equal(testMoment.date(), i,
- 'lenient ordinal parsing of number ' + i + ' date check');
- }
-});
-
-test('strict ordinal parsing', function (assert) {
- var i, ordinalStr, testMoment;
- for (i = 1; i <= 31; ++i) {
- ordinalStr = moment([2014, 0, i]).format('YYYY MM Do');
- testMoment = moment(ordinalStr, 'YYYY MM Do', true);
- assert.ok(testMoment.isValid(), 'strict ordinal parsing ' + i);
- }
-});
diff --git a/src/test/locale/br.js b/src/test/locale/br.js
index b886182..7fa5aee 100644
--- a/src/test/locale/br.js
+++ b/src/test/locale/br.js
@@ -155,14 +155,14 @@
test('calendar day', function (assert) {
moment.locale('br');
- var a = moment().hours(2).minutes(0).seconds(0);
-
- assert.equal(moment(a).calendar(), 'Hiziv da 2e00 AM', 'today at the same time');
- assert.equal(moment(a).add({m: 25}).calendar(), 'Hiziv da 2e25 AM', 'Now plus 25 min');
- assert.equal(moment(a).add({h: 1}).calendar(), 'Hiziv da 3e00 AM', 'Now plus 1 hour');
- assert.equal(moment(a).add({d: 1}).calendar(), 'Warc\'hoazh da 2e00 AM', 'tomorrow at the same time');
- assert.equal(moment(a).subtract({h: 1}).calendar(), 'Hiziv da 1e00 AM', 'Now minus 1 hour');
- assert.equal(moment(a).subtract({d: 1}).calendar(), 'Dec\'h da 2e00 AM', 'yesterday at the same time');
+ var a = moment().hours(12).minutes(0).seconds(0);
+
+ assert.equal(moment(a).calendar(), 'Hiziv da 12e00 PM', 'today at the same time');
+ assert.equal(moment(a).add({m: 25}).calendar(), 'Hiziv da 12e25 PM', 'Now plus 25 min');
+ assert.equal(moment(a).add({h: 1}).calendar(), 'Hiziv da 1e00 PM', 'Now plus 1 hour');
+ assert.equal(moment(a).add({d: 1}).calendar(), 'Warc\'hoazh da 12e00 PM', 'tomorrow at the same time');
+ assert.equal(moment(a).subtract({h: 1}).calendar(), 'Hiziv da 11e00 AM', 'Now minus 1 hour');
+ assert.equal(moment(a).subtract({d: 1}).calendar(), 'Dec\'h da 12e00 PM', 'yesterday at the same time');
});
test('calendar next week', function (assert) {
@@ -225,38 +225,3 @@
assert.equal(start.from(moment([2007, 1, 28]).add({y: 261}), true), '261 bloaz', 'mutation 261 years');
});
-test('lenient ordinal parsing', function (assert) {
- var i, ordinalStr, testMoment;
- for (i = 1; i <= 31; ++i) {
- ordinalStr = moment([2014, 0, i]).format('YYYY MM Do');
- testMoment = moment(ordinalStr, 'YYYY MM Do');
- assert.equal(testMoment.year(), 2014,
- 'lenient ordinal parsing ' + i + ' year check');
- assert.equal(testMoment.month(), 0,
- 'lenient ordinal parsing ' + i + ' month check');
- assert.equal(testMoment.date(), i,
- 'lenient ordinal parsing ' + i + ' date check');
- }
-});
-
-test('lenient ordinal parsing of number', function (assert) {
- var i, testMoment;
- for (i = 1; i <= 31; ++i) {
- testMoment = moment('2014 01 ' + i, 'YYYY MM Do');
- assert.equal(testMoment.year(), 2014,
- 'lenient ordinal parsing of number ' + i + ' year check');
- assert.equal(testMoment.month(), 0,
- 'lenient ordinal parsing of number ' + i + ' month check');
- assert.equal(testMoment.date(), i,
- 'lenient ordinal parsing of number ' + i + ' date check');
- }
-});
-
-test('strict ordinal parsing', function (assert) {
- var i, ordinalStr, testMoment;
- for (i = 1; i <= 31; ++i) {
- ordinalStr = moment([2014, 0, i]).format('YYYY MM Do');
- testMoment = moment(ordinalStr, 'YYYY MM Do', true);
- assert.ok(testMoment.isValid(), 'strict ordinal parsing ' + i);
- }
-});
diff --git a/src/test/locale/bs.js b/src/test/locale/bs.js
index 75eabd5..954a469 100644
--- a/src/test/locale/bs.js
+++ b/src/test/locale/bs.js
@@ -5,7 +5,7 @@
test('parse', function (assert) {
var tests = 'januar jan._februar feb._mart mar._april apr._maj maj._juni jun._juli jul._august aug._septembar sep._oktobar okt._novembar nov._decembar dec.'.split('_'), i;
function equalTest(input, mmm, i) {
- assert.equal(moment(input, mmm).month(), i, input + ' should be month ' + (i + 1));
+ assert.equal(moment(input, mmm).month(), i, input + ' should be month ' + (i + 1) + ' inp ' + mmm);
}
for (i = 0; i < 12; i++) {
tests[i] = tests[i].split(' ');
@@ -151,14 +151,14 @@
});
test('calendar day', function (assert) {
- var a = moment().hours(2).minutes(0).seconds(0);
-
- assert.equal(moment(a).calendar(), 'danas u 2:00', 'today at the same time');
- assert.equal(moment(a).add({m: 25}).calendar(), 'danas u 2:25', 'Now plus 25 min');
- assert.equal(moment(a).add({h: 1}).calendar(), 'danas u 3:00', 'Now plus 1 hour');
- assert.equal(moment(a).add({d: 1}).calendar(), 'sutra u 2:00', 'tomorrow at the same time');
- assert.equal(moment(a).subtract({h: 1}).calendar(), 'danas u 1:00', 'Now minus 1 hour');
- assert.equal(moment(a).subtract({d: 1}).calendar(), 'jučer u 2:00', 'yesterday at the same time');
+ var a = moment().hours(12).minutes(0).seconds(0);
+
+ assert.equal(moment(a).calendar(), 'danas u 12:00', 'today at the same time');
+ assert.equal(moment(a).add({m: 25}).calendar(), 'danas u 12:25', 'Now plus 25 min');
+ assert.equal(moment(a).add({h: 1}).calendar(), 'danas u 13:00', 'Now plus 1 hour');
+ assert.equal(moment(a).add({d: 1}).calendar(), 'sutra u 12:00', 'tomorrow at the same time');
+ assert.equal(moment(a).subtract({h: 1}).calendar(), 'danas u 11:00', 'Now minus 1 hour');
+ assert.equal(moment(a).subtract({d: 1}).calendar(), 'jučer u 12:00', 'yesterday at the same time');
});
test('calendar next week', function (assert) {
@@ -232,67 +232,6 @@
assert.equal(weeksFromNow.calendar(), weeksFromNow.format('L'), 'in 2 weeks');
});
-test('weeks year starting sunday', function (assert) {
- assert.equal(moment([2011, 11, 26]).week(), 1, 'Dec 26 2011 should be week 1');
- assert.equal(moment([2012, 0, 1]).week(), 1, 'Jan 1 2012 should be week 1');
- assert.equal(moment([2012, 0, 2]).week(), 2, 'Jan 2 2012 should be week 2');
- assert.equal(moment([2012, 0, 8]).week(), 2, 'Jan 8 2012 should be week 2');
- assert.equal(moment([2012, 0, 9]).week(), 3, 'Jan 9 2012 should be week 3');
-});
-
-test('weeks year starting monday', function (assert) {
- assert.equal(moment([2007, 0, 1]).week(), 1, 'Jan 1 2007 should be week 1');
- assert.equal(moment([2007, 0, 7]).week(), 1, 'Jan 7 2007 should be week 1');
- assert.equal(moment([2007, 0, 8]).week(), 2, 'Jan 8 2007 should be week 2');
- assert.equal(moment([2007, 0, 14]).week(), 2, 'Jan 14 2007 should be week 2');
- assert.equal(moment([2007, 0, 15]).week(), 3, 'Jan 15 2007 should be week 3');
-});
-
-test('weeks year starting tuesday', function (assert) {
- assert.equal(moment([2007, 11, 31]).week(), 1, 'Dec 31 2007 should be week 1');
- assert.equal(moment([2008, 0, 1]).week(), 1, 'Jan 1 2008 should be week 1');
- assert.equal(moment([2008, 0, 6]).week(), 1, 'Jan 6 2008 should be week 1');
- assert.equal(moment([2008, 0, 7]).week(), 2, 'Jan 7 2008 should be week 2');
- assert.equal(moment([2008, 0, 13]).week(), 2, 'Jan 13 2008 should be week 2');
- assert.equal(moment([2008, 0, 14]).week(), 3, 'Jan 14 2008 should be week 3');
-});
-
-test('weeks year starting wednesday', function (assert) {
- assert.equal(moment([2002, 11, 30]).week(), 1, 'Dec 30 2002 should be week 1');
- assert.equal(moment([2003, 0, 1]).week(), 1, 'Jan 1 2003 should be week 1');
- assert.equal(moment([2003, 0, 5]).week(), 1, 'Jan 5 2003 should be week 1');
- assert.equal(moment([2003, 0, 6]).week(), 2, 'Jan 6 2003 should be week 2');
- assert.equal(moment([2003, 0, 12]).week(), 2, 'Jan 12 2003 should be week 2');
- assert.equal(moment([2003, 0, 13]).week(), 3, 'Jan 13 2003 should be week 3');
-});
-
-test('weeks year starting thursday', function (assert) {
- assert.equal(moment([2008, 11, 29]).week(), 1, 'Dec 29 2008 should be week 1');
- assert.equal(moment([2009, 0, 1]).week(), 1, 'Jan 1 2009 should be week 1');
- assert.equal(moment([2009, 0, 4]).week(), 1, 'Jan 4 2009 should be week 1');
- assert.equal(moment([2009, 0, 5]).week(), 2, 'Jan 5 2009 should be week 2');
- assert.equal(moment([2009, 0, 11]).week(), 2, 'Jan 11 2009 should be week 2');
- assert.equal(moment([2009, 0, 12]).week(), 3, 'Jan 12 2009 should be week 3');
-});
-
-test('weeks year starting friday', function (assert) {
- assert.equal(moment([2009, 11, 28]).week(), 1, 'Dec 28 2009 should be week 1');
- assert.equal(moment([2010, 0, 1]).week(), 1, 'Jan 1 2010 should be week 1');
- assert.equal(moment([2010, 0, 3]).week(), 1, 'Jan 3 2010 should be week 1');
- assert.equal(moment([2010, 0, 4]).week(), 2, 'Jan 4 2010 should be week 2');
- assert.equal(moment([2010, 0, 10]).week(), 2, 'Jan 10 2010 should be week 2');
- assert.equal(moment([2010, 0, 11]).week(), 3, 'Jan 11 2010 should be week 3');
-});
-
-test('weeks year starting saturday', function (assert) {
- assert.equal(moment([2010, 11, 27]).week(), 1, 'Dec 27 2010 should be week 1');
- assert.equal(moment([2011, 0, 1]).week(), 1, 'Jan 1 2011 should be week 1');
- assert.equal(moment([2011, 0, 2]).week(), 1, 'Jan 2 2011 should be week 1');
- assert.equal(moment([2011, 0, 3]).week(), 2, 'Jan 3 2011 should be week 2');
- assert.equal(moment([2011, 0, 9]).week(), 2, 'Jan 9 2011 should be week 2');
- assert.equal(moment([2011, 0, 10]).week(), 3, 'Jan 10 2011 should be week 3');
-});
-
test('weeks year starting sunday formatted', function (assert) {
assert.equal(moment([2011, 11, 26]).format('w ww wo'), '1 01 1.', 'Dec 26 2011 should be week 1');
assert.equal(moment([2012, 0, 1]).format('w ww wo'), '1 01 1.', 'Jan 1 2012 should be week 1');
@@ -301,38 +240,3 @@
assert.equal(moment([2012, 0, 9]).format('w ww wo'), '3 03 3.', 'Jan 9 2012 should be week 3');
});
-test('lenient ordinal parsing', function (assert) {
- var i, ordinalStr, testMoment;
- for (i = 1; i <= 31; ++i) {
- ordinalStr = moment([2014, 0, i]).format('YYYY MM Do');
- testMoment = moment(ordinalStr, 'YYYY MM Do');
- assert.equal(testMoment.year(), 2014,
- 'lenient ordinal parsing ' + i + ' year check');
- assert.equal(testMoment.month(), 0,
- 'lenient ordinal parsing ' + i + ' month check');
- assert.equal(testMoment.date(), i,
- 'lenient ordinal parsing ' + i + ' date check');
- }
-});
-
-test('lenient ordinal parsing of number', function (assert) {
- var i, testMoment;
- for (i = 1; i <= 31; ++i) {
- testMoment = moment('2014 01 ' + i, 'YYYY MM Do');
- assert.equal(testMoment.year(), 2014,
- 'lenient ordinal parsing of number ' + i + ' year check');
- assert.equal(testMoment.month(), 0,
- 'lenient ordinal parsing of number ' + i + ' month check');
- assert.equal(testMoment.date(), i,
- 'lenient ordinal parsing of number ' + i + ' date check');
- }
-});
-
-test('strict ordinal parsing', function (assert) {
- var i, ordinalStr, testMoment;
- for (i = 1; i <= 31; ++i) {
- ordinalStr = moment([2014, 0, i]).format('YYYY MM Do');
- testMoment = moment(ordinalStr, 'YYYY MM Do', true);
- assert.ok(testMoment.isValid(), 'strict ordinal parsing ' + i);
- }
-});
diff --git a/src/test/locale/ca.js b/src/test/locale/ca.js
index eb65992..b769c82 100644
--- a/src/test/locale/ca.js
+++ b/src/test/locale/ca.js
@@ -151,15 +151,15 @@
});
test('calendar day', function (assert) {
- var a = moment().hours(2).minutes(0).seconds(0);
-
- assert.equal(moment(a).calendar(), 'avui a les 2:00', 'today at the same time');
- assert.equal(moment(a).add({m: 25}).calendar(), 'avui a les 2:25', 'Now plus 25 min');
- assert.equal(moment(a).add({h: 1}).calendar(), 'avui a les 3:00', 'Now plus 1 hour');
- assert.equal(moment(a).add({d: 1}).calendar(), 'demà a les 2:00', 'tomorrow at the same time');
- assert.equal(moment(a).add({d: 1, h : -1}).calendar(), 'demà a la 1:00', 'tomorrow minus 1 hour');
- assert.equal(moment(a).subtract({h: 1}).calendar(), 'avui a la 1:00', 'Now minus 1 hour');
- assert.equal(moment(a).subtract({d: 1}).calendar(), 'ahir a les 2:00', 'yesterday at the same time');
+ var a = moment().hours(12).minutes(0).seconds(0);
+
+ assert.equal(moment(a).calendar(), 'avui a les 12:00', 'today at the same time');
+ assert.equal(moment(a).add({m: 25}).calendar(), 'avui a les 12:25', 'Now plus 25 min');
+ assert.equal(moment(a).add({h: 1}).calendar(), 'avui a les 13:00', 'Now plus 1 hour');
+ assert.equal(moment(a).add({d: 1}).calendar(), 'demà a les 12:00', 'tomorrow at the same time');
+ assert.equal(moment(a).add({d: 1, h : -1}).calendar(), 'demà a les 11:00', 'tomorrow minus 1 hour');
+ assert.equal(moment(a).subtract({h: 1}).calendar(), 'avui a les 11:00', 'Now minus 1 hour');
+ assert.equal(moment(a).subtract({d: 1}).calendar(), 'ahir a les 12:00', 'yesterday at the same time');
});
test('calendar next week', function (assert) {
@@ -200,67 +200,6 @@
assert.equal(weeksFromNow.calendar(), weeksFromNow.format('L'), 'in 2 weeks');
});
-test('weeks year starting sunday', function (assert) {
- assert.equal(moment([2012, 0, 1]).week(), 52, 'Jan 1 2012 should be week 52');
- assert.equal(moment([2012, 0, 2]).week(), 1, 'Jan 2 2012 should be week 1');
- assert.equal(moment([2012, 0, 8]).week(), 1, 'Jan 8 2012 should be week 1');
- assert.equal(moment([2012, 0, 9]).week(), 2, 'Jan 9 2012 should be week 2');
- assert.equal(moment([2012, 0, 15]).week(), 2, 'Jan 15 2012 should be week 2');
-});
-
-test('weeks year starting monday', function (assert) {
- assert.equal(moment([2007, 0, 1]).week(), 1, 'Jan 1 2007 should be week 1');
- assert.equal(moment([2007, 0, 7]).week(), 1, 'Jan 7 2007 should be week 1');
- assert.equal(moment([2007, 0, 8]).week(), 2, 'Jan 8 2007 should be week 2');
- assert.equal(moment([2007, 0, 14]).week(), 2, 'Jan 14 2007 should be week 2');
- assert.equal(moment([2007, 0, 15]).week(), 3, 'Jan 15 2007 should be week 3');
-});
-
-test('weeks year starting tuesday', function (assert) {
- assert.equal(moment([2007, 11, 31]).week(), 1, 'Dec 31 2007 should be week 1');
- assert.equal(moment([2008, 0, 1]).week(), 1, 'Jan 1 2008 should be week 1');
- assert.equal(moment([2008, 0, 6]).week(), 1, 'Jan 6 2008 should be week 1');
- assert.equal(moment([2008, 0, 7]).week(), 2, 'Jan 7 2008 should be week 2');
- assert.equal(moment([2008, 0, 13]).week(), 2, 'Jan 13 2008 should be week 2');
- assert.equal(moment([2008, 0, 14]).week(), 3, 'Jan 14 2008 should be week 3');
-});
-
-test('weeks year starting wednesday', function (assert) {
- assert.equal(moment([2002, 11, 30]).week(), 1, 'Dec 30 2002 should be week 1');
- assert.equal(moment([2003, 0, 1]).week(), 1, 'Jan 1 2003 should be week 1');
- assert.equal(moment([2003, 0, 5]).week(), 1, 'Jan 5 2003 should be week 1');
- assert.equal(moment([2003, 0, 6]).week(), 2, 'Jan 6 2003 should be week 2');
- assert.equal(moment([2003, 0, 12]).week(), 2, 'Jan 12 2003 should be week 2');
- assert.equal(moment([2003, 0, 13]).week(), 3, 'Jan 13 2003 should be week 3');
-});
-
-test('weeks year starting thursday', function (assert) {
- assert.equal(moment([2008, 11, 29]).week(), 1, 'Dec 29 2008 should be week 1');
- assert.equal(moment([2009, 0, 1]).week(), 1, 'Jan 1 2009 should be week 1');
- assert.equal(moment([2009, 0, 4]).week(), 1, 'Jan 4 2009 should be week 1');
- assert.equal(moment([2009, 0, 5]).week(), 2, 'Jan 5 2009 should be week 2');
- assert.equal(moment([2009, 0, 11]).week(), 2, 'Jan 11 2009 should be week 2');
- assert.equal(moment([2009, 0, 13]).week(), 3, 'Jan 12 2009 should be week 3');
-});
-
-test('weeks year starting friday', function (assert) {
- assert.equal(moment([2009, 11, 28]).week(), 53, 'Dec 28 2009 should be week 53');
- assert.equal(moment([2010, 0, 1]).week(), 53, 'Jan 1 2010 should be week 53');
- assert.equal(moment([2010, 0, 3]).week(), 53, 'Jan 3 2010 should be week 53');
- assert.equal(moment([2010, 0, 4]).week(), 1, 'Jan 4 2010 should be week 1');
- assert.equal(moment([2010, 0, 10]).week(), 1, 'Jan 10 2010 should be week 1');
- assert.equal(moment([2010, 0, 11]).week(), 2, 'Jan 11 2010 should be week 2');
-});
-
-test('weeks year starting saturday', function (assert) {
- assert.equal(moment([2010, 11, 27]).week(), 52, 'Dec 27 2010 should be week 52');
- assert.equal(moment([2011, 0, 1]).week(), 52, 'Jan 1 2011 should be week 52');
- assert.equal(moment([2011, 0, 2]).week(), 52, 'Jan 2 2011 should be week 52');
- assert.equal(moment([2011, 0, 3]).week(), 1, 'Jan 3 2011 should be week 1');
- assert.equal(moment([2011, 0, 9]).week(), 1, 'Jan 9 2011 should be week 1');
- assert.equal(moment([2011, 0, 10]).week(), 2, 'Jan 10 2011 should be week 2');
-});
-
test('weeks year starting sunday formatted', function (assert) {
assert.equal(moment([2012, 0, 1]).format('w ww wo'), '52 52 52a', 'Jan 1 2012 should be week 52');
assert.equal(moment([2012, 0, 2]).format('w ww wo'), '1 01 1a', 'Jan 2 2012 should be week 1');
@@ -269,38 +208,3 @@
assert.equal(moment([2012, 0, 15]).format('w ww wo'), '2 02 2a', 'Jan 15 2012 should be week 2');
});
-test('lenient ordinal parsing', function (assert) {
- var i, ordinalStr, testMoment;
- for (i = 1; i <= 31; ++i) {
- ordinalStr = moment([2014, 0, i]).format('YYYY MM Do');
- testMoment = moment(ordinalStr, 'YYYY MM Do');
- assert.equal(testMoment.year(), 2014,
- 'lenient ordinal parsing ' + i + ' year check');
- assert.equal(testMoment.month(), 0,
- 'lenient ordinal parsing ' + i + ' month check');
- assert.equal(testMoment.date(), i,
- 'lenient ordinal parsing ' + i + ' date check');
- }
-});
-
-test('lenient ordinal parsing of number', function (assert) {
- var i, testMoment;
- for (i = 1; i <= 31; ++i) {
- testMoment = moment('2014 01 ' + i, 'YYYY MM Do');
- assert.equal(testMoment.year(), 2014,
- 'lenient ordinal parsing of number ' + i + ' year check');
- assert.equal(testMoment.month(), 0,
- 'lenient ordinal parsing of number ' + i + ' month check');
- assert.equal(testMoment.date(), i,
- 'lenient ordinal parsing of number ' + i + ' date check');
- }
-});
-
-test('strict ordinal parsing', function (assert) {
- var i, ordinalStr, testMoment;
- for (i = 1; i <= 31; ++i) {
- ordinalStr = moment([2014, 0, i]).format('YYYY MM Do');
- testMoment = moment(ordinalStr, 'YYYY MM Do', true);
- assert.ok(testMoment.isValid(), 'strict ordinal parsing ' + i);
- }
-});
diff --git a/src/test/locale/cs.js b/src/test/locale/cs.js
index 7cf98c7..440ea3b 100644
--- a/src/test/locale/cs.js
+++ b/src/test/locale/cs.js
@@ -194,14 +194,14 @@
});
test('calendar day', function (assert) {
- var a = moment().hours(2).minutes(0).seconds(0);
-
- assert.equal(moment(a).calendar(), 'dnes v 2:00', 'today at the same time');
- assert.equal(moment(a).add({m: 25}).calendar(), 'dnes v 2:25', 'Now plus 25 min');
- assert.equal(moment(a).add({h: 1}).calendar(), 'dnes v 3:00', 'Now plus 1 hour');
- assert.equal(moment(a).add({d: 1}).calendar(), 'zítra v 2:00', 'tomorrow at the same time');
- assert.equal(moment(a).subtract({h: 1}).calendar(), 'dnes v 1:00', 'Now minus 1 hour');
- assert.equal(moment(a).subtract({d: 1}).calendar(), 'včera v 2:00', 'yesterday at the same time');
+ var a = moment().hours(12).minutes(0).seconds(0);
+
+ assert.equal(moment(a).calendar(), 'dnes v 12:00', 'today at the same time');
+ assert.equal(moment(a).add({m: 25}).calendar(), 'dnes v 12:25', 'Now plus 25 min');
+ assert.equal(moment(a).add({h: 1}).calendar(), 'dnes v 13:00', 'Now plus 1 hour');
+ assert.equal(moment(a).add({d: 1}).calendar(), 'zítra v 12:00', 'tomorrow at the same time');
+ assert.equal(moment(a).subtract({h: 1}).calendar(), 'dnes v 11:00', 'Now minus 1 hour');
+ assert.equal(moment(a).subtract({d: 1}).calendar(), 'včera v 12:00', 'yesterday at the same time');
});
test('calendar next week', function (assert) {
@@ -297,67 +297,6 @@
assert.equal(moment.duration(-1, 'minutes').humanize(true), 'před minutou', 'a minute ago');
});
-test('weeks year starting sunday', function (assert) {
- assert.equal(moment([2012, 0, 1]).week(), 52, 'Jan 1 2012 should be week 52');
- assert.equal(moment([2012, 0, 2]).week(), 1, 'Jan 2 2012 should be week 1');
- assert.equal(moment([2012, 0, 8]).week(), 1, 'Jan 8 2012 should be week 1');
- assert.equal(moment([2012, 0, 9]).week(), 2, 'Jan 9 2012 should be week 2');
- assert.equal(moment([2012, 0, 15]).week(), 2, 'Jan 15 2012 should be week 2');
-});
-
-test('weeks year starting monday', function (assert) {
- assert.equal(moment([2007, 0, 1]).week(), 1, 'Jan 1 2007 should be week 1');
- assert.equal(moment([2007, 0, 7]).week(), 1, 'Jan 7 2007 should be week 1');
- assert.equal(moment([2007, 0, 8]).week(), 2, 'Jan 8 2007 should be week 2');
- assert.equal(moment([2007, 0, 14]).week(), 2, 'Jan 14 2007 should be week 2');
- assert.equal(moment([2007, 0, 15]).week(), 3, 'Jan 15 2007 should be week 3');
-});
-
-test('weeks year starting tuesday', function (assert) {
- assert.equal(moment([2007, 11, 31]).week(), 1, 'Dec 31 2007 should be week 1');
- assert.equal(moment([2008, 0, 1]).week(), 1, 'Jan 1 2008 should be week 1');
- assert.equal(moment([2008, 0, 6]).week(), 1, 'Jan 6 2008 should be week 1');
- assert.equal(moment([2008, 0, 7]).week(), 2, 'Jan 7 2008 should be week 2');
- assert.equal(moment([2008, 0, 13]).week(), 2, 'Jan 13 2008 should be week 2');
- assert.equal(moment([2008, 0, 14]).week(), 3, 'Jan 14 2008 should be week 3');
-});
-
-test('weeks year starting wednesday', function (assert) {
- assert.equal(moment([2002, 11, 30]).week(), 1, 'Dec 30 2002 should be week 1');
- assert.equal(moment([2003, 0, 1]).week(), 1, 'Jan 1 2003 should be week 1');
- assert.equal(moment([2003, 0, 5]).week(), 1, 'Jan 5 2003 should be week 1');
- assert.equal(moment([2003, 0, 6]).week(), 2, 'Jan 6 2003 should be week 2');
- assert.equal(moment([2003, 0, 12]).week(), 2, 'Jan 12 2003 should be week 2');
- assert.equal(moment([2003, 0, 13]).week(), 3, 'Jan 13 2003 should be week 3');
-});
-
-test('weeks year starting thursday', function (assert) {
- assert.equal(moment([2008, 11, 29]).week(), 1, 'Dec 29 2008 should be week 1');
- assert.equal(moment([2009, 0, 1]).week(), 1, 'Jan 1 2009 should be week 1');
- assert.equal(moment([2009, 0, 4]).week(), 1, 'Jan 4 2009 should be week 1');
- assert.equal(moment([2009, 0, 5]).week(), 2, 'Jan 5 2009 should be week 2');
- assert.equal(moment([2009, 0, 11]).week(), 2, 'Jan 11 2009 should be week 2');
- assert.equal(moment([2009, 0, 13]).week(), 3, 'Jan 12 2009 should be week 3');
-});
-
-test('weeks year starting friday', function (assert) {
- assert.equal(moment([2009, 11, 28]).week(), 53, 'Dec 28 2009 should be week 53');
- assert.equal(moment([2010, 0, 1]).week(), 53, 'Jan 1 2010 should be week 53');
- assert.equal(moment([2010, 0, 3]).week(), 53, 'Jan 3 2010 should be week 53');
- assert.equal(moment([2010, 0, 4]).week(), 1, 'Jan 4 2010 should be week 1');
- assert.equal(moment([2010, 0, 10]).week(), 1, 'Jan 10 2010 should be week 1');
- assert.equal(moment([2010, 0, 11]).week(), 2, 'Jan 11 2010 should be week 2');
-});
-
-test('weeks year starting saturday', function (assert) {
- assert.equal(moment([2010, 11, 27]).week(), 52, 'Dec 27 2010 should be week 52');
- assert.equal(moment([2011, 0, 1]).week(), 52, 'Jan 1 2011 should be week 52');
- assert.equal(moment([2011, 0, 2]).week(), 52, 'Jan 2 2011 should be week 52');
- assert.equal(moment([2011, 0, 3]).week(), 1, 'Jan 3 2011 should be week 1');
- assert.equal(moment([2011, 0, 9]).week(), 1, 'Jan 9 2011 should be week 1');
- assert.equal(moment([2011, 0, 10]).week(), 2, 'Jan 10 2011 should be week 2');
-});
-
test('weeks year starting sunday formatted', function (assert) {
assert.equal(moment([2012, 0, 1]).format('w ww wo'), '52 52 52.', 'Jan 1 2012 should be week 52');
assert.equal(moment([2012, 0, 2]).format('w ww wo'), '1 01 1.', 'Jan 2 2012 should be week 1');
@@ -366,38 +305,3 @@
assert.equal(moment([2012, 0, 15]).format('w ww wo'), '2 02 2.', 'Jan 15 2012 should be week 2');
});
-test('lenient ordinal parsing', function (assert) {
- var i, ordinalStr, testMoment;
- for (i = 1; i <= 31; ++i) {
- ordinalStr = moment([2014, 0, i]).format('YYYY MM Do');
- testMoment = moment(ordinalStr, 'YYYY MM Do');
- assert.equal(testMoment.year(), 2014,
- 'lenient ordinal parsing ' + i + ' year check');
- assert.equal(testMoment.month(), 0,
- 'lenient ordinal parsing ' + i + ' month check');
- assert.equal(testMoment.date(), i,
- 'lenient ordinal parsing ' + i + ' date check');
- }
-});
-
-test('lenient ordinal parsing of number', function (assert) {
- var i, testMoment;
- for (i = 1; i <= 31; ++i) {
- testMoment = moment('2014 01 ' + i, 'YYYY MM Do');
- assert.equal(testMoment.year(), 2014,
- 'lenient ordinal parsing of number ' + i + ' year check');
- assert.equal(testMoment.month(), 0,
- 'lenient ordinal parsing of number ' + i + ' month check');
- assert.equal(testMoment.date(), i,
- 'lenient ordinal parsing of number ' + i + ' date check');
- }
-});
-
-test('strict ordinal parsing', function (assert) {
- var i, ordinalStr, testMoment;
- for (i = 1; i <= 31; ++i) {
- ordinalStr = moment([2014, 0, i]).format('YYYY MM Do');
- testMoment = moment(ordinalStr, 'YYYY MM Do', true);
- assert.ok(testMoment.isValid(), 'strict ordinal parsing ' + i);
- }
-});
diff --git a/src/test/locale/cv.js b/src/test/locale/cv.js
index fa5acf3..fed9804 100644
--- a/src/test/locale/cv.js
+++ b/src/test/locale/cv.js
@@ -153,13 +153,13 @@
});
test('calendar day', function (assert) {
- var a = moment().hours(2).minutes(0).seconds(0);
- assert.equal(moment(a).calendar(), 'Паян 02:00 сехетре', 'today at the same time');
- assert.equal(moment(a).add({m: 25}).calendar(), 'Паян 02:25 сехетре', 'Now plus 25 min');
- assert.equal(moment(a).add({h: 1}).calendar(), 'Паян 03:00 сехетре', 'Now plus 1 hour');
- assert.equal(moment(a).add({d: 1}).calendar(), 'Ыран 02:00 сехетре', 'tomorrow at the same time');
- assert.equal(moment(a).subtract({h: 1}).calendar(), 'Паян 01:00 сехетре', 'Now minus 1 hour');
- assert.equal(moment(a).subtract({d: 1}).calendar(), 'Ӗнер 02:00 сехетре', 'yesterday at the same time');
+ var a = moment().hours(12).minutes(0).seconds(0);
+ assert.equal(moment(a).calendar(), 'Паян 12:00 сехетре', 'today at the same time');
+ assert.equal(moment(a).add({m: 25}).calendar(), 'Паян 12:25 сехетре', 'Now plus 25 min');
+ assert.equal(moment(a).add({h: 1}).calendar(), 'Паян 13:00 сехетре', 'Now plus 1 hour');
+ assert.equal(moment(a).add({d: 1}).calendar(), 'Ыран 12:00 сехетре', 'tomorrow at the same time');
+ assert.equal(moment(a).subtract({h: 1}).calendar(), 'Паян 11:00 сехетре', 'Now minus 1 hour');
+ assert.equal(moment(a).subtract({d: 1}).calendar(), 'Ӗнер 12:00 сехетре', 'yesterday at the same time');
});
test('calendar next week', function (assert) {
@@ -205,67 +205,6 @@
// Monday is the first day of the week.
// The week that contains Jan 1st is the first week of the year.
-test('weeks year starting sunday', function (assert) {
- assert.equal(moment([2011, 11, 26]).week(), 1, 'Dec 26 2011 should be week 1');
- assert.equal(moment([2012, 0, 1]).week(), 1, 'Jan 1 2012 should be week 1');
- assert.equal(moment([2012, 0, 2]).week(), 2, 'Jan 2 2012 should be week 2');
- assert.equal(moment([2012, 0, 8]).week(), 2, 'Jan 8 2012 should be week 2');
- assert.equal(moment([2012, 0, 9]).week(), 3, 'Jan 9 2012 should be week 3');
-});
-
-test('weeks year starting monday', function (assert) {
- assert.equal(moment([2007, 0, 1]).week(), 1, 'Jan 1 2007 should be week 1');
- assert.equal(moment([2007, 0, 7]).week(), 1, 'Jan 7 2007 should be week 1');
- assert.equal(moment([2007, 0, 8]).week(), 2, 'Jan 8 2007 should be week 2');
- assert.equal(moment([2007, 0, 14]).week(), 2, 'Jan 14 2007 should be week 2');
- assert.equal(moment([2007, 0, 15]).week(), 3, 'Jan 15 2007 should be week 3');
-});
-
-test('weeks year starting tuesday', function (assert) {
- assert.equal(moment([2007, 11, 31]).week(), 1, 'Dec 31 2007 should be week 1');
- assert.equal(moment([2008, 0, 1]).week(), 1, 'Jan 1 2008 should be week 1');
- assert.equal(moment([2008, 0, 6]).week(), 1, 'Jan 6 2008 should be week 1');
- assert.equal(moment([2008, 0, 7]).week(), 2, 'Jan 7 2008 should be week 2');
- assert.equal(moment([2008, 0, 13]).week(), 2, 'Jan 13 2008 should be week 2');
- assert.equal(moment([2008, 0, 14]).week(), 3, 'Jan 14 2008 should be week 3');
-});
-
-test('weeks year starting wednesday', function (assert) {
- assert.equal(moment([2002, 11, 30]).week(), 1, 'Dec 30 2002 should be week 1');
- assert.equal(moment([2003, 0, 1]).week(), 1, 'Jan 1 2003 should be week 1');
- assert.equal(moment([2003, 0, 5]).week(), 1, 'Jan 5 2003 should be week 1');
- assert.equal(moment([2003, 0, 6]).week(), 2, 'Jan 6 2003 should be week 2');
- assert.equal(moment([2003, 0, 12]).week(), 2, 'Jan 12 2003 should be week 2');
- assert.equal(moment([2003, 0, 13]).week(), 3, 'Jan 13 2003 should be week 3');
-});
-
-test('weeks year starting thursday', function (assert) {
- assert.equal(moment([2008, 11, 29]).week(), 1, 'Dec 29 2008 should be week 1');
- assert.equal(moment([2009, 0, 1]).week(), 1, 'Jan 1 2009 should be week 1');
- assert.equal(moment([2009, 0, 4]).week(), 1, 'Jan 4 2009 should be week 1');
- assert.equal(moment([2009, 0, 5]).week(), 2, 'Jan 5 2009 should be week 2');
- assert.equal(moment([2009, 0, 11]).week(), 2, 'Jan 11 2009 should be week 2');
- assert.equal(moment([2009, 0, 12]).week(), 3, 'Jan 12 2009 should be week 3');
-});
-
-test('weeks year starting friday', function (assert) {
- assert.equal(moment([2009, 11, 28]).week(), 1, 'Dec 28 2009 should be week 1');
- assert.equal(moment([2010, 0, 1]).week(), 1, 'Jan 1 2010 should be week 1');
- assert.equal(moment([2010, 0, 3]).week(), 1, 'Jan 3 2010 should be week 1');
- assert.equal(moment([2010, 0, 4]).week(), 2, 'Jan 4 2010 should be week 2');
- assert.equal(moment([2010, 0, 10]).week(), 2, 'Jan 10 2010 should be week 2');
- assert.equal(moment([2010, 0, 11]).week(), 3, 'Jan 11 2010 should be week 3');
-});
-
-test('weeks year starting saturday', function (assert) {
- assert.equal(moment([2010, 11, 27]).week(), 1, 'Dec 27 2010 should be week 1');
- assert.equal(moment([2011, 0, 1]).week(), 1, 'Jan 1 2011 should be week 1');
- assert.equal(moment([2011, 0, 2]).week(), 1, 'Jan 2 2011 should be week 1');
- assert.equal(moment([2011, 0, 3]).week(), 2, 'Jan 3 2011 should be week 2');
- assert.equal(moment([2011, 0, 9]).week(), 2, 'Jan 9 2011 should be week 2');
- assert.equal(moment([2011, 0, 10]).week(), 3, 'Jan 10 2011 should be week 3');
-});
-
test('weeks year starting sunday formatted', function (assert) {
assert.equal(moment([2011, 11, 26]).format('w ww wo'), '1 01 1-мӗш', 'Dec 26 2011 should be week 1');
assert.equal(moment([2012, 0, 1]).format('w ww wo'), '1 01 1-мӗш', 'Jan 1 2012 should be week 1');
@@ -274,38 +213,3 @@
assert.equal(moment([2012, 0, 9]).format('w ww wo'), '3 03 3-мӗш', 'Jan 9 2012 should be week 3');
});
-test('lenient ordinal parsing', function (assert) {
- var i, ordinalStr, testMoment;
- for (i = 1; i <= 31; ++i) {
- ordinalStr = moment([2014, 0, i]).format('YYYY MM Do');
- testMoment = moment(ordinalStr, 'YYYY MM Do');
- assert.equal(testMoment.year(), 2014,
- 'lenient ordinal parsing ' + i + ' year check');
- assert.equal(testMoment.month(), 0,
- 'lenient ordinal parsing ' + i + ' month check');
- assert.equal(testMoment.date(), i,
- 'lenient ordinal parsing ' + i + ' date check');
- }
-});
-
-test('lenient ordinal parsing of number', function (assert) {
- var i, testMoment;
- for (i = 1; i <= 31; ++i) {
- testMoment = moment('2014 01 ' + i, 'YYYY MM Do');
- assert.equal(testMoment.year(), 2014,
- 'lenient ordinal parsing of number ' + i + ' year check');
- assert.equal(testMoment.month(), 0,
- 'lenient ordinal parsing of number ' + i + ' month check');
- assert.equal(testMoment.date(), i,
- 'lenient ordinal parsing of number ' + i + ' date check');
- }
-});
-
-test('strict ordinal parsing', function (assert) {
- var i, ordinalStr, testMoment;
- for (i = 1; i <= 31; ++i) {
- ordinalStr = moment([2014, 0, i]).format('YYYY MM Do');
- testMoment = moment(ordinalStr, 'YYYY MM Do', true);
- assert.ok(testMoment.isValid(), 'strict ordinal parsing ' + i);
- }
-});
diff --git a/src/test/locale/cy.js b/src/test/locale/cy.js
index 334a6ce..d142de6 100644
--- a/src/test/locale/cy.js
+++ b/src/test/locale/cy.js
@@ -147,18 +147,18 @@
assert.equal(moment().add({d: 5}).fromNow(), 'mewn 5 diwrnod', 'in 5 days');
});
-test('same day', function (assert) {
- var a = moment().hours(2).minutes(0).seconds(0);
-
- assert.equal(moment(a).calendar(), 'Heddiw am 02:00', 'today at the same time');
- assert.equal(moment(a).add({m: 25}).calendar(), 'Heddiw am 02:25', 'Now plus 25 min');
- assert.equal(moment(a).add({h: 1}).calendar(), 'Heddiw am 03:00', 'Now plus 1 hour');
- assert.equal(moment(a).add({d: 1}).calendar(), 'Yfory am 02:00', 'tomorrow at the same time');
- assert.equal(moment(a).subtract({h: 1}).calendar(), 'Heddiw am 01:00', 'Now minus 1 hour');
- assert.equal(moment(a).subtract({d: 1}).calendar(), 'Ddoe am 02:00', 'yesterday at the same time');
-});
-
-test('same next week', function (assert) {
+test('calendar day', function (assert) {
+ var a = moment().hours(12).minutes(0).seconds(0);
+
+ assert.equal(moment(a).calendar(), 'Heddiw am 12:00', 'today at the same time');
+ assert.equal(moment(a).add({m: 25}).calendar(), 'Heddiw am 12:25', 'Now plus 25 min');
+ assert.equal(moment(a).add({h: 1}).calendar(), 'Heddiw am 13:00', 'Now plus 1 hour');
+ assert.equal(moment(a).add({d: 1}).calendar(), 'Yfory am 12:00', 'tomorrow at the same time');
+ assert.equal(moment(a).subtract({h: 1}).calendar(), 'Heddiw am 11:00', 'Now minus 1 hour');
+ assert.equal(moment(a).subtract({d: 1}).calendar(), 'Ddoe am 12:00', 'yesterday at the same time');
+});
+
+test('calendar next week', function (assert) {
var i, m;
for (i = 2; i < 7; i++) {
@@ -171,7 +171,7 @@
}
});
-test('same last week', function (assert) {
+test('calendar last week', function (assert) {
var i, m;
for (i = 2; i < 7; i++) {
@@ -184,7 +184,7 @@
}
});
-test('same all else', function (assert) {
+test('calendar all else', function (assert) {
var weeksAgo = moment().subtract({w: 1}),
weeksFromNow = moment().add({w: 1});
@@ -196,67 +196,6 @@
assert.equal(weeksAgo.calendar(), weeksAgo.format('L'), '2 weeks ago');
assert.equal(weeksFromNow.calendar(), weeksFromNow.format('L'), 'in 2 weeks');
-});
-
-test('weeks year starting sunday', function (assert) {
- assert.equal(moment([2012, 0, 1]).week(), 52, 'Jan 1 2012 should be week 52');
- assert.equal(moment([2012, 0, 2]).week(), 1, 'Jan 2 2012 should be week 1');
- assert.equal(moment([2012, 0, 8]).week(), 1, 'Jan 8 2012 should be week 1');
- assert.equal(moment([2012, 0, 9]).week(), 2, 'Jan 9 2012 should be week 2');
- assert.equal(moment([2012, 0, 15]).week(), 2, 'Jan 15 2012 should be week 2');
-});
-
-test('weeks year starting monday', function (assert) {
- assert.equal(moment([2007, 0, 1]).week(), 1, 'Jan 1 2007 should be week 1');
- assert.equal(moment([2007, 0, 7]).week(), 1, 'Jan 7 2007 should be week 1');
- assert.equal(moment([2007, 0, 8]).week(), 2, 'Jan 8 2007 should be week 2');
- assert.equal(moment([2007, 0, 14]).week(), 2, 'Jan 14 2007 should be week 2');
- assert.equal(moment([2007, 0, 15]).week(), 3, 'Jan 15 2007 should be week 3');
-});
-
-test('weeks year starting tuesday', function (assert) {
- assert.equal(moment([2007, 11, 31]).week(), 1, 'Dec 31 2007 should be week 1');
- assert.equal(moment([2008, 0, 1]).week(), 1, 'Jan 1 2008 should be week 1');
- assert.equal(moment([2008, 0, 6]).week(), 1, 'Jan 6 2008 should be week 1');
- assert.equal(moment([2008, 0, 7]).week(), 2, 'Jan 7 2008 should be week 2');
- assert.equal(moment([2008, 0, 13]).week(), 2, 'Jan 13 2008 should be week 2');
- assert.equal(moment([2008, 0, 14]).week(), 3, 'Jan 14 2008 should be week 3');
-});
-
-test('weeks year starting wednesday', function (assert) {
- assert.equal(moment([2002, 11, 30]).week(), 1, 'Dec 30 2002 should be week 1');
- assert.equal(moment([2003, 0, 1]).week(), 1, 'Jan 1 2003 should be week 1');
- assert.equal(moment([2003, 0, 5]).week(), 1, 'Jan 5 2003 should be week 1');
- assert.equal(moment([2003, 0, 6]).week(), 2, 'Jan 6 2003 should be week 2');
- assert.equal(moment([2003, 0, 12]).week(), 2, 'Jan 12 2003 should be week 2');
- assert.equal(moment([2003, 0, 13]).week(), 3, 'Jan 13 2003 should be week 3');
-});
-
-test('weeks year starting thursday', function (assert) {
- assert.equal(moment([2008, 11, 29]).week(), 1, 'Dec 29 2008 should be week 1');
- assert.equal(moment([2009, 0, 1]).week(), 1, 'Jan 1 2009 should be week 1');
- assert.equal(moment([2009, 0, 4]).week(), 1, 'Jan 4 2009 should be week 1');
- assert.equal(moment([2009, 0, 5]).week(), 2, 'Jan 5 2009 should be week 2');
- assert.equal(moment([2009, 0, 11]).week(), 2, 'Jan 11 2009 should be week 2');
- assert.equal(moment([2009, 0, 13]).week(), 3, 'Jan 12 2009 should be week 3');
-});
-
-test('weeks year starting friday', function (assert) {
- assert.equal(moment([2009, 11, 28]).week(), 53, 'Dec 28 2009 should be week 53');
- assert.equal(moment([2010, 0, 1]).week(), 53, 'Jan 1 2010 should be week 53');
- assert.equal(moment([2010, 0, 3]).week(), 53, 'Jan 3 2010 should be week 53');
- assert.equal(moment([2010, 0, 4]).week(), 1, 'Jan 4 2010 should be week 1');
- assert.equal(moment([2010, 0, 10]).week(), 1, 'Jan 10 2010 should be week 1');
- assert.equal(moment([2010, 0, 11]).week(), 2, 'Jan 11 2010 should be week 2');
-});
-
-test('weeks year starting saturday', function (assert) {
- assert.equal(moment([2010, 11, 27]).week(), 52, 'Dec 27 2010 should be week 52');
- assert.equal(moment([2011, 0, 1]).week(), 52, 'Jan 1 2011 should be week 52');
- assert.equal(moment([2011, 0, 2]).week(), 52, 'Jan 2 2011 should be week 52');
- assert.equal(moment([2011, 0, 3]).week(), 1, 'Jan 3 2011 should be week 1');
- assert.equal(moment([2011, 0, 9]).week(), 1, 'Jan 9 2011 should be week 1');
- assert.equal(moment([2011, 0, 10]).week(), 2, 'Jan 10 2011 should be week 2');
});
test('weeks year starting sunday formatted', function (assert) {
@@ -267,38 +206,3 @@
assert.equal(moment([2012, 0, 15]).format('w ww wo'), '2 02 2il', 'Jan 15 2012 should be week 2');
});
-test('lenient ordinal parsing', function (assert) {
- var i, ordinalStr, testMoment;
- for (i = 1; i <= 31; ++i) {
- ordinalStr = moment([2014, 0, i]).format('YYYY MM Do');
- testMoment = moment(ordinalStr, 'YYYY MM Do');
- assert.equal(testMoment.year(), 2014,
- 'lenient ordinal parsing ' + i + ' year check');
- assert.equal(testMoment.month(), 0,
- 'lenient ordinal parsing ' + i + ' month check');
- assert.equal(testMoment.date(), i,
- 'lenient ordinal parsing ' + i + ' date check');
- }
-});
-
-test('lenient ordinal parsing of number', function (assert) {
- var i, testMoment;
- for (i = 1; i <= 31; ++i) {
- testMoment = moment('2014 01 ' + i, 'YYYY MM Do');
- assert.equal(testMoment.year(), 2014,
- 'lenient ordinal parsing of number ' + i + ' year check');
- assert.equal(testMoment.month(), 0,
- 'lenient ordinal parsing of number ' + i + ' month check');
- assert.equal(testMoment.date(), i,
- 'lenient ordinal parsing of number ' + i + ' date check');
- }
-});
-
-test('strict ordinal parsing', function (assert) {
- var i, ordinalStr, testMoment;
- for (i = 1; i <= 31; ++i) {
- ordinalStr = moment([2014, 0, i]).format('YYYY MM Do');
- testMoment = moment(ordinalStr, 'YYYY MM Do', true);
- assert.ok(testMoment.isValid(), 'strict ordinal parsing ' + i);
- }
-});
diff --git a/src/test/locale/da.js b/src/test/locale/da.js
index 30a5d4d..fc982d4 100644
--- a/src/test/locale/da.js
+++ b/src/test/locale/da.js
@@ -150,65 +150,56 @@
assert.equal(moment().add({d: 5}).fromNow(), 'om 5 dage', 'in 5 days');
});
-test('weeks year starting sunday', function (assert) {
- assert.equal(moment([2012, 0, 1]).week(), 52, 'Jan 1 2012 should be week 52');
- assert.equal(moment([2012, 0, 2]).week(), 1, 'Jan 2 2012 should be week 1');
- assert.equal(moment([2012, 0, 8]).week(), 1, 'Jan 8 2012 should be week 1');
- assert.equal(moment([2012, 0, 9]).week(), 2, 'Jan 9 2012 should be week 2');
- assert.equal(moment([2012, 0, 15]).week(), 2, 'Jan 15 2012 should be week 2');
-});
-
-test('weeks year starting monday', function (assert) {
- assert.equal(moment([2007, 0, 1]).week(), 1, 'Jan 1 2007 should be week 1');
- assert.equal(moment([2007, 0, 7]).week(), 1, 'Jan 7 2007 should be week 1');
- assert.equal(moment([2007, 0, 8]).week(), 2, 'Jan 8 2007 should be week 2');
- assert.equal(moment([2007, 0, 14]).week(), 2, 'Jan 14 2007 should be week 2');
- assert.equal(moment([2007, 0, 15]).week(), 3, 'Jan 15 2007 should be week 3');
-});
-
-test('weeks year starting tuesday', function (assert) {
- assert.equal(moment([2007, 11, 31]).week(), 1, 'Dec 31 2007 should be week 1');
- assert.equal(moment([2008, 0, 1]).week(), 1, 'Jan 1 2008 should be week 1');
- assert.equal(moment([2008, 0, 6]).week(), 1, 'Jan 6 2008 should be week 1');
- assert.equal(moment([2008, 0, 7]).week(), 2, 'Jan 7 2008 should be week 2');
- assert.equal(moment([2008, 0, 13]).week(), 2, 'Jan 13 2008 should be week 2');
- assert.equal(moment([2008, 0, 14]).week(), 3, 'Jan 14 2008 should be week 3');
-});
-
-test('weeks year starting wednesday', function (assert) {
- assert.equal(moment([2002, 11, 30]).week(), 1, 'Dec 30 2002 should be week 1');
- assert.equal(moment([2003, 0, 1]).week(), 1, 'Jan 1 2003 should be week 1');
- assert.equal(moment([2003, 0, 5]).week(), 1, 'Jan 5 2003 should be week 1');
- assert.equal(moment([2003, 0, 6]).week(), 2, 'Jan 6 2003 should be week 2');
- assert.equal(moment([2003, 0, 12]).week(), 2, 'Jan 12 2003 should be week 2');
- assert.equal(moment([2003, 0, 13]).week(), 3, 'Jan 13 2003 should be week 3');
-});
-
-test('weeks year starting thursday', function (assert) {
- assert.equal(moment([2008, 11, 29]).week(), 1, 'Dec 29 2008 should be week 1');
- assert.equal(moment([2009, 0, 1]).week(), 1, 'Jan 1 2009 should be week 1');
- assert.equal(moment([2009, 0, 4]).week(), 1, 'Jan 4 2009 should be week 1');
- assert.equal(moment([2009, 0, 5]).week(), 2, 'Jan 5 2009 should be week 2');
- assert.equal(moment([2009, 0, 11]).week(), 2, 'Jan 11 2009 should be week 2');
- assert.equal(moment([2009, 0, 13]).week(), 3, 'Jan 12 2009 should be week 3');
-});
-
-test('weeks year starting friday', function (assert) {
- assert.equal(moment([2009, 11, 28]).week(), 53, 'Dec 28 2009 should be week 53');
- assert.equal(moment([2010, 0, 1]).week(), 53, 'Jan 1 2010 should be week 53');
- assert.equal(moment([2010, 0, 3]).week(), 53, 'Jan 3 2010 should be week 53');
- assert.equal(moment([2010, 0, 4]).week(), 1, 'Jan 4 2010 should be week 1');
- assert.equal(moment([2010, 0, 10]).week(), 1, 'Jan 10 2010 should be week 1');
- assert.equal(moment([2010, 0, 11]).week(), 2, 'Jan 11 2010 should be week 2');
-});
-
-test('weeks year starting saturday', function (assert) {
- assert.equal(moment([2010, 11, 27]).week(), 52, 'Dec 27 2010 should be week 52');
- assert.equal(moment([2011, 0, 1]).week(), 52, 'Jan 1 2011 should be week 52');
- assert.equal(moment([2011, 0, 2]).week(), 52, 'Jan 2 2011 should be week 52');
- assert.equal(moment([2011, 0, 3]).week(), 1, 'Jan 3 2011 should be week 1');
- assert.equal(moment([2011, 0, 9]).week(), 1, 'Jan 9 2011 should be week 1');
- assert.equal(moment([2011, 0, 10]).week(), 2, 'Jan 10 2011 should be week 2');
+
+test('calendar day', function (assert) {
+ var a = moment().hours(12).minutes(0).seconds(0);
+
+ assert.equal(moment(a).calendar(), 'I dag kl. 12:00', 'today at the same time');
+ assert.equal(moment(a).add({m: 25}).calendar(), 'I dag kl. 12:25', 'Now plus 25 min');
+ assert.equal(moment(a).add({h: 1}).calendar(), 'I dag kl. 13:00', 'Now plus 1 hour');
+ assert.equal(moment(a).add({d: 1}).calendar(), 'I morgen kl. 12:00', 'tomorrow at the same time');
+ assert.equal(moment(a).subtract({h: 1}).calendar(), 'I dag kl. 11:00', 'Now minus 1 hour');
+ assert.equal(moment(a).subtract({d: 1}).calendar(), 'I går kl. 12:00', 'yesterday at the same time');
+});
+
+test('calendar next week', function (assert) {
+ var i, m;
+
+ for (i = 2; i < 7; i++) {
+ m = moment().add({d: i});
+ assert.equal(m.calendar(), m.format('dddd [kl.] LT'), 'Today + ' + i + ' days current time');
+ m.hours(0).minutes(0).seconds(0).milliseconds(0);
+ assert.equal(m.calendar(), m.format('dddd [kl.] LT'), 'Today + ' + i + ' days beginning of day');
+ m.hours(23).minutes(59).seconds(59).milliseconds(999);
+ assert.equal(m.calendar(), m.format('dddd [kl.] LT'), 'Today + ' + i + ' days end of day');
+ }
+});
+
+test('calendar last week', function (assert) {
+ var i, m;
+
+ for (i = 2; i < 7; i++) {
+ m = moment().subtract({d: i});
+ assert.equal(m.calendar(), m.format('[sidste] dddd [kl] LT'), 'Today - ' + i + ' days current time');
+ m.hours(0).minutes(0).seconds(0).milliseconds(0);
+ assert.equal(m.calendar(), m.format('[sidste] dddd [kl] LT'), 'Today - ' + i + ' days beginning of day');
+ m.hours(23).minutes(59).seconds(59).milliseconds(999);
+ assert.equal(m.calendar(), m.format('[sidste] dddd [kl] LT'), 'Today - ' + i + ' days end of day');
+ }
+});
+
+test('calendar all else', function (assert) {
+ var weeksAgo = moment().subtract({w: 1}),
+ weeksFromNow = moment().add({w: 1});
+
+ assert.equal(weeksAgo.calendar(), weeksAgo.format('L'), '1 week ago');
+ assert.equal(weeksFromNow.calendar(), weeksFromNow.format('L'), 'in 1 week');
+
+ weeksAgo = moment().subtract({w: 2});
+ weeksFromNow = moment().add({w: 2});
+
+ assert.equal(weeksAgo.calendar(), weeksAgo.format('L'), '2 weeks ago');
+ assert.equal(weeksFromNow.calendar(), weeksFromNow.format('L'), 'in 2 weeks');
});
test('weeks year starting sunday formatted', function (assert) {
@@ -219,38 +210,3 @@
assert.equal(moment([2012, 0, 15]).format('w ww wo'), '2 02 2.', 'Jan 15 2012 should be week 2');
});
-test('lenient ordinal parsing', function (assert) {
- var i, ordinalStr, testMoment;
- for (i = 1; i <= 31; ++i) {
- ordinalStr = moment([2014, 0, i]).format('YYYY MM Do');
- testMoment = moment(ordinalStr, 'YYYY MM Do');
- assert.equal(testMoment.year(), 2014,
- 'lenient ordinal parsing ' + i + ' year check');
- assert.equal(testMoment.month(), 0,
- 'lenient ordinal parsing ' + i + ' month check');
- assert.equal(testMoment.date(), i,
- 'lenient ordinal parsing ' + i + ' date check');
- }
-});
-
-test('lenient ordinal parsing of number', function (assert) {
- var i, testMoment;
- for (i = 1; i <= 31; ++i) {
- testMoment = moment('2014 01 ' + i, 'YYYY MM Do');
- assert.equal(testMoment.year(), 2014,
- 'lenient ordinal parsing of number ' + i + ' year check');
- assert.equal(testMoment.month(), 0,
- 'lenient ordinal parsing of number ' + i + ' month check');
- assert.equal(testMoment.date(), i,
- 'lenient ordinal parsing of number ' + i + ' date check');
- }
-});
-
-test('strict ordinal parsing', function (assert) {
- var i, ordinalStr, testMoment;
- for (i = 1; i <= 31; ++i) {
- ordinalStr = moment([2014, 0, i]).format('YYYY MM Do');
- testMoment = moment(ordinalStr, 'YYYY MM Do', true);
- assert.ok(testMoment.isValid(), 'strict ordinal parsing ' + i);
- }
-});
diff --git a/src/test/locale/de-at.js b/src/test/locale/de-at.js
index a4c2e94..86e0051 100644
--- a/src/test/locale/de-at.js
+++ b/src/test/locale/de-at.js
@@ -148,14 +148,14 @@
});
test('calendar day', function (assert) {
- var a = moment().hours(2).minutes(0).seconds(0);
-
- assert.equal(moment(a).calendar(), 'heute um 02:00 Uhr', 'today at the same time');
- assert.equal(moment(a).add({m: 25}).calendar(), 'heute um 02:25 Uhr', 'Now plus 25 min');
- assert.equal(moment(a).add({h: 1}).calendar(), 'heute um 03:00 Uhr', 'Now plus 1 hour');
- assert.equal(moment(a).add({d: 1}).calendar(), 'morgen um 02:00 Uhr', 'tomorrow at the same time');
- assert.equal(moment(a).subtract({h: 1}).calendar(), 'heute um 01:00 Uhr', 'Now minus 1 hour');
- assert.equal(moment(a).subtract({d: 1}).calendar(), 'gestern um 02:00 Uhr', 'yesterday at the same time');
+ var a = moment().hours(12).minutes(0).seconds(0);
+
+ assert.equal(moment(a).calendar(), 'heute um 12:00 Uhr', 'today at the same time');
+ assert.equal(moment(a).add({m: 25}).calendar(), 'heute um 12:25 Uhr', 'Now plus 25 min');
+ assert.equal(moment(a).add({h: 1}).calendar(), 'heute um 13:00 Uhr', 'Now plus 1 hour');
+ assert.equal(moment(a).add({d: 1}).calendar(), 'morgen um 12:00 Uhr', 'tomorrow at the same time');
+ assert.equal(moment(a).subtract({h: 1}).calendar(), 'heute um 11:00 Uhr', 'Now minus 1 hour');
+ assert.equal(moment(a).subtract({d: 1}).calendar(), 'gestern um 12:00 Uhr', 'yesterday at the same time');
});
test('calendar next week', function (assert) {
@@ -196,67 +196,6 @@
assert.equal(weeksFromNow.calendar(), weeksFromNow.format('L'), 'in 2 weeks');
});
-test('weeks year starting sunday', function (assert) {
- assert.equal(moment([2012, 0, 1]).week(), 52, 'Jan 1 2012 should be week 52');
- assert.equal(moment([2012, 0, 2]).week(), 1, 'Jan 2 2012 should be week 1');
- assert.equal(moment([2012, 0, 8]).week(), 1, 'Jan 8 2012 should be week 1');
- assert.equal(moment([2012, 0, 9]).week(), 2, 'Jan 9 2012 should be week 2');
- assert.equal(moment([2012, 0, 15]).week(), 2, 'Jan 15 2012 should be week 2');
-});
-
-test('weeks year starting monday', function (assert) {
- assert.equal(moment([2007, 0, 1]).week(), 1, 'Jan 1 2007 should be week 1');
- assert.equal(moment([2007, 0, 7]).week(), 1, 'Jan 7 2007 should be week 1');
- assert.equal(moment([2007, 0, 8]).week(), 2, 'Jan 8 2007 should be week 2');
- assert.equal(moment([2007, 0, 14]).week(), 2, 'Jan 14 2007 should be week 2');
- assert.equal(moment([2007, 0, 15]).week(), 3, 'Jan 15 2007 should be week 3');
-});
-
-test('weeks year starting tuesday', function (assert) {
- assert.equal(moment([2007, 11, 31]).week(), 1, 'Dec 31 2007 should be week 1');
- assert.equal(moment([2008, 0, 1]).week(), 1, 'Jan 1 2008 should be week 1');
- assert.equal(moment([2008, 0, 6]).week(), 1, 'Jan 6 2008 should be week 1');
- assert.equal(moment([2008, 0, 7]).week(), 2, 'Jan 7 2008 should be week 2');
- assert.equal(moment([2008, 0, 13]).week(), 2, 'Jan 13 2008 should be week 2');
- assert.equal(moment([2008, 0, 14]).week(), 3, 'Jan 14 2008 should be week 3');
-});
-
-test('weeks year starting wednesday', function (assert) {
- assert.equal(moment([2002, 11, 30]).week(), 1, 'Dec 30 2002 should be week 1');
- assert.equal(moment([2003, 0, 1]).week(), 1, 'Jan 1 2003 should be week 1');
- assert.equal(moment([2003, 0, 5]).week(), 1, 'Jan 5 2003 should be week 1');
- assert.equal(moment([2003, 0, 6]).week(), 2, 'Jan 6 2003 should be week 2');
- assert.equal(moment([2003, 0, 12]).week(), 2, 'Jan 12 2003 should be week 2');
- assert.equal(moment([2003, 0, 13]).week(), 3, 'Jan 13 2003 should be week 3');
-});
-
-test('weeks year starting thursday', function (assert) {
- assert.equal(moment([2008, 11, 29]).week(), 1, 'Dec 29 2008 should be week 1');
- assert.equal(moment([2009, 0, 1]).week(), 1, 'Jan 1 2009 should be week 1');
- assert.equal(moment([2009, 0, 4]).week(), 1, 'Jan 4 2009 should be week 1');
- assert.equal(moment([2009, 0, 5]).week(), 2, 'Jan 5 2009 should be week 2');
- assert.equal(moment([2009, 0, 11]).week(), 2, 'Jan 11 2009 should be week 2');
- assert.equal(moment([2009, 0, 13]).week(), 3, 'Jan 12 2009 should be week 3');
-});
-
-test('weeks year starting friday', function (assert) {
- assert.equal(moment([2009, 11, 28]).week(), 53, 'Dec 28 2009 should be week 53');
- assert.equal(moment([2010, 0, 1]).week(), 53, 'Jan 1 2010 should be week 53');
- assert.equal(moment([2010, 0, 3]).week(), 53, 'Jan 3 2010 should be week 53');
- assert.equal(moment([2010, 0, 4]).week(), 1, 'Jan 4 2010 should be week 1');
- assert.equal(moment([2010, 0, 10]).week(), 1, 'Jan 10 2010 should be week 1');
- assert.equal(moment([2010, 0, 11]).week(), 2, 'Jan 11 2010 should be week 2');
-});
-
-test('weeks year starting saturday', function (assert) {
- assert.equal(moment([2010, 11, 27]).week(), 52, 'Dec 27 2010 should be week 52');
- assert.equal(moment([2011, 0, 1]).week(), 52, 'Jan 1 2011 should be week 52');
- assert.equal(moment([2011, 0, 2]).week(), 52, 'Jan 2 2011 should be week 52');
- assert.equal(moment([2011, 0, 3]).week(), 1, 'Jan 3 2011 should be week 1');
- assert.equal(moment([2011, 0, 9]).week(), 1, 'Jan 9 2011 should be week 1');
- assert.equal(moment([2011, 0, 10]).week(), 2, 'Jan 10 2011 should be week 2');
-});
-
test('weeks year starting sunday formatted', function (assert) {
assert.equal(moment([2012, 0, 1]).format('w ww wo'), '52 52 52.', 'Jan 1 2012 should be week 52');
assert.equal(moment([2012, 0, 2]).format('w ww wo'), '1 01 1.', 'Jan 2 2012 should be week 1');
@@ -265,38 +204,3 @@
assert.equal(moment([2012, 0, 15]).format('w ww wo'), '2 02 2.', 'Jan 15 2012 should be week 2');
});
-test('lenient ordinal parsing', function (assert) {
- var i, ordinalStr, testMoment;
- for (i = 1; i <= 31; ++i) {
- ordinalStr = moment([2014, 0, i]).format('YYYY MM Do');
- testMoment = moment(ordinalStr, 'YYYY MM Do');
- assert.equal(testMoment.year(), 2014,
- 'lenient ordinal parsing ' + i + ' year check');
- assert.equal(testMoment.month(), 0,
- 'lenient ordinal parsing ' + i + ' month check');
- assert.equal(testMoment.date(), i,
- 'lenient ordinal parsing ' + i + ' date check');
- }
-});
-
-test('lenient ordinal parsing of number', function (assert) {
- var i, testMoment;
- for (i = 1; i <= 31; ++i) {
- testMoment = moment('2014 01 ' + i, 'YYYY MM Do');
- assert.equal(testMoment.year(), 2014,
- 'lenient ordinal parsing of number ' + i + ' year check');
- assert.equal(testMoment.month(), 0,
- 'lenient ordinal parsing of number ' + i + ' month check');
- assert.equal(testMoment.date(), i,
- 'lenient ordinal parsing of number ' + i + ' date check');
- }
-});
-
-test('strict ordinal parsing', function (assert) {
- var i, ordinalStr, testMoment;
- for (i = 1; i <= 31; ++i) {
- ordinalStr = moment([2014, 0, i]).format('YYYY MM Do');
- testMoment = moment(ordinalStr, 'YYYY MM Do', true);
- assert.ok(testMoment.isValid(), 'strict ordinal parsing ' + i);
- }
-});
diff --git a/src/test/locale/de.js b/src/test/locale/de.js
index 10d7292..51ed999 100644
--- a/src/test/locale/de.js
+++ b/src/test/locale/de.js
@@ -147,14 +147,14 @@
});
test('calendar day', function (assert) {
- var a = moment().hours(2).minutes(0).seconds(0);
-
- assert.equal(moment(a).calendar(), 'heute um 02:00 Uhr', 'today at the same time');
- assert.equal(moment(a).add({m: 25}).calendar(), 'heute um 02:25 Uhr', 'Now plus 25 min');
- assert.equal(moment(a).add({h: 1}).calendar(), 'heute um 03:00 Uhr', 'Now plus 1 hour');
- assert.equal(moment(a).add({d: 1}).calendar(), 'morgen um 02:00 Uhr', 'tomorrow at the same time');
- assert.equal(moment(a).subtract({h: 1}).calendar(), 'heute um 01:00 Uhr', 'Now minus 1 hour');
- assert.equal(moment(a).subtract({d: 1}).calendar(), 'gestern um 02:00 Uhr', 'yesterday at the same time');
+ var a = moment().hours(12).minutes(0).seconds(0);
+
+ assert.equal(moment(a).calendar(), 'heute um 12:00 Uhr', 'today at the same time');
+ assert.equal(moment(a).add({m: 25}).calendar(), 'heute um 12:25 Uhr', 'Now plus 25 min');
+ assert.equal(moment(a).add({h: 1}).calendar(), 'heute um 13:00 Uhr', 'Now plus 1 hour');
+ assert.equal(moment(a).add({d: 1}).calendar(), 'morgen um 12:00 Uhr', 'tomorrow at the same time');
+ assert.equal(moment(a).subtract({h: 1}).calendar(), 'heute um 11:00 Uhr', 'Now minus 1 hour');
+ assert.equal(moment(a).subtract({d: 1}).calendar(), 'gestern um 12:00 Uhr', 'yesterday at the same time');
});
test('calendar next week', function (assert) {
@@ -195,67 +195,6 @@
assert.equal(weeksFromNow.calendar(), weeksFromNow.format('L'), 'in 2 weeks');
});
-test('weeks year starting sunday', function (assert) {
- assert.equal(moment([2012, 0, 1]).week(), 52, 'Jan 1 2012 should be week 52');
- assert.equal(moment([2012, 0, 2]).week(), 1, 'Jan 2 2012 should be week 1');
- assert.equal(moment([2012, 0, 8]).week(), 1, 'Jan 8 2012 should be week 1');
- assert.equal(moment([2012, 0, 9]).week(), 2, 'Jan 9 2012 should be week 2');
- assert.equal(moment([2012, 0, 15]).week(), 2, 'Jan 15 2012 should be week 2');
-});
-
-test('weeks year starting monday', function (assert) {
- assert.equal(moment([2007, 0, 1]).week(), 1, 'Jan 1 2007 should be week 1');
- assert.equal(moment([2007, 0, 7]).week(), 1, 'Jan 7 2007 should be week 1');
- assert.equal(moment([2007, 0, 8]).week(), 2, 'Jan 8 2007 should be week 2');
- assert.equal(moment([2007, 0, 14]).week(), 2, 'Jan 14 2007 should be week 2');
- assert.equal(moment([2007, 0, 15]).week(), 3, 'Jan 15 2007 should be week 3');
-});
-
-test('weeks year starting tuesday', function (assert) {
- assert.equal(moment([2007, 11, 31]).week(), 1, 'Dec 31 2007 should be week 1');
- assert.equal(moment([2008, 0, 1]).week(), 1, 'Jan 1 2008 should be week 1');
- assert.equal(moment([2008, 0, 6]).week(), 1, 'Jan 6 2008 should be week 1');
- assert.equal(moment([2008, 0, 7]).week(), 2, 'Jan 7 2008 should be week 2');
- assert.equal(moment([2008, 0, 13]).week(), 2, 'Jan 13 2008 should be week 2');
- assert.equal(moment([2008, 0, 14]).week(), 3, 'Jan 14 2008 should be week 3');
-});
-
-test('weeks year starting wednesday', function (assert) {
- assert.equal(moment([2002, 11, 30]).week(), 1, 'Dec 30 2002 should be week 1');
- assert.equal(moment([2003, 0, 1]).week(), 1, 'Jan 1 2003 should be week 1');
- assert.equal(moment([2003, 0, 5]).week(), 1, 'Jan 5 2003 should be week 1');
- assert.equal(moment([2003, 0, 6]).week(), 2, 'Jan 6 2003 should be week 2');
- assert.equal(moment([2003, 0, 12]).week(), 2, 'Jan 12 2003 should be week 2');
- assert.equal(moment([2003, 0, 13]).week(), 3, 'Jan 13 2003 should be week 3');
-});
-
-test('weeks year starting thursday', function (assert) {
- assert.equal(moment([2008, 11, 29]).week(), 1, 'Dec 29 2008 should be week 1');
- assert.equal(moment([2009, 0, 1]).week(), 1, 'Jan 1 2009 should be week 1');
- assert.equal(moment([2009, 0, 4]).week(), 1, 'Jan 4 2009 should be week 1');
- assert.equal(moment([2009, 0, 5]).week(), 2, 'Jan 5 2009 should be week 2');
- assert.equal(moment([2009, 0, 11]).week(), 2, 'Jan 11 2009 should be week 2');
- assert.equal(moment([2009, 0, 13]).week(), 3, 'Jan 12 2009 should be week 3');
-});
-
-test('weeks year starting friday', function (assert) {
- assert.equal(moment([2009, 11, 28]).week(), 53, 'Dec 28 2009 should be week 53');
- assert.equal(moment([2010, 0, 1]).week(), 53, 'Jan 1 2010 should be week 53');
- assert.equal(moment([2010, 0, 3]).week(), 53, 'Jan 3 2010 should be week 53');
- assert.equal(moment([2010, 0, 4]).week(), 1, 'Jan 4 2010 should be week 1');
- assert.equal(moment([2010, 0, 10]).week(), 1, 'Jan 10 2010 should be week 1');
- assert.equal(moment([2010, 0, 11]).week(), 2, 'Jan 11 2010 should be week 2');
-});
-
-test('weeks year starting saturday', function (assert) {
- assert.equal(moment([2010, 11, 27]).week(), 52, 'Dec 27 2010 should be week 52');
- assert.equal(moment([2011, 0, 1]).week(), 52, 'Jan 1 2011 should be week 52');
- assert.equal(moment([2011, 0, 2]).week(), 52, 'Jan 2 2011 should be week 52');
- assert.equal(moment([2011, 0, 3]).week(), 1, 'Jan 3 2011 should be week 1');
- assert.equal(moment([2011, 0, 9]).week(), 1, 'Jan 9 2011 should be week 1');
- assert.equal(moment([2011, 0, 10]).week(), 2, 'Jan 10 2011 should be week 2');
-});
-
test('weeks year starting sunday formatted', function (assert) {
assert.equal(moment([2012, 0, 1]).format('w ww wo'), '52 52 52.', 'Jan 1 2012 should be week 52');
assert.equal(moment([2012, 0, 2]).format('w ww wo'), '1 01 1.', 'Jan 2 2012 should be week 1');
@@ -264,38 +203,3 @@
assert.equal(moment([2012, 0, 15]).format('w ww wo'), '2 02 2.', 'Jan 15 2012 should be week 2');
});
-test('lenient ordinal parsing', function (assert) {
- var i, ordinalStr, testMoment;
- for (i = 1; i <= 31; ++i) {
- ordinalStr = moment([2014, 0, i]).format('YYYY MM Do');
- testMoment = moment(ordinalStr, 'YYYY MM Do');
- assert.equal(testMoment.year(), 2014,
- 'lenient ordinal parsing ' + i + ' year check');
- assert.equal(testMoment.month(), 0,
- 'lenient ordinal parsing ' + i + ' month check');
- assert.equal(testMoment.date(), i,
- 'lenient ordinal parsing ' + i + ' date check');
- }
-});
-
-test('lenient ordinal parsing of number', function (assert) {
- var i, testMoment;
- for (i = 1; i <= 31; ++i) {
- testMoment = moment('2014 01 ' + i, 'YYYY MM Do');
- assert.equal(testMoment.year(), 2014,
- 'lenient ordinal parsing of number ' + i + ' year check');
- assert.equal(testMoment.month(), 0,
- 'lenient ordinal parsing of number ' + i + ' month check');
- assert.equal(testMoment.date(), i,
- 'lenient ordinal parsing of number ' + i + ' date check');
- }
-});
-
-test('strict ordinal parsing', function (assert) {
- var i, ordinalStr, testMoment;
- for (i = 1; i <= 31; ++i) {
- ordinalStr = moment([2014, 0, i]).format('YYYY MM Do');
- testMoment = moment(ordinalStr, 'YYYY MM Do', true);
- assert.ok(testMoment.isValid(), 'strict ordinal parsing ' + i);
- }
-});
diff --git a/src/test/locale/dv.js b/src/test/locale/dv.js
index bb6020c..071ea39 100644
--- a/src/test/locale/dv.js
+++ b/src/test/locale/dv.js
@@ -102,3 +102,103 @@
assert.equal(moment([2011, 0, 2 + i]).format('dddd'), expected[i]);
}
});
+
+
+test('from', function (assert) {
+ var start = moment([2007, 1, 28]);
+ assert.equal(start.from(moment([2007, 1, 28]).add({s: 44}), true), 'ސިކުންތުކޮޅެއް', '44 seconds = a few seconds');
+ assert.equal(start.from(moment([2007, 1, 28]).add({s: 45}), true), 'މިނިޓެއް', '45 seconds = a minute');
+ assert.equal(start.from(moment([2007, 1, 28]).add({s: 89}), true), 'މިނިޓެއް', '89 seconds = a minute');
+ assert.equal(start.from(moment([2007, 1, 28]).add({s: 90}), true), 'މިނިޓު 2', '90 seconds = 2 minutes');
+ assert.equal(start.from(moment([2007, 1, 28]).add({m: 44}), true), 'މިނިޓު 44', '44 minutes = 44 minutes');
+ assert.equal(start.from(moment([2007, 1, 28]).add({m: 45}), true), 'ގަޑިއިރެއް', '45 minutes = an hour');
+ assert.equal(start.from(moment([2007, 1, 28]).add({m: 89}), true), 'ގަޑިއިރެއް', '89 minutes = an hour');
+ assert.equal(start.from(moment([2007, 1, 28]).add({m: 90}), true), 'ގަޑިއިރު 2', '90 minutes = 2 hours');
+ assert.equal(start.from(moment([2007, 1, 28]).add({h: 5}), true), 'ގަޑިއިރު 5', '5 hours = 5 hours');
+ assert.equal(start.from(moment([2007, 1, 28]).add({h: 21}), true), 'ގަޑިއިރު 21', '21 hours = 21 hours');
+ assert.equal(start.from(moment([2007, 1, 28]).add({h: 22}), true), 'ދުވަހެއް', '22 hours = a day');
+ assert.equal(start.from(moment([2007, 1, 28]).add({h: 35}), true), 'ދުވަހެއް', '35 hours = a day');
+ assert.equal(start.from(moment([2007, 1, 28]).add({h: 36}), true), 'ދުވަސް 2', '36 hours = 2 days');
+ assert.equal(start.from(moment([2007, 1, 28]).add({d: 1}), true), 'ދުވަހެއް', '1 day = a day');
+ assert.equal(start.from(moment([2007, 1, 28]).add({d: 5}), true), 'ދުވަސް 5', '5 days = 5 days');
+ assert.equal(start.from(moment([2007, 1, 28]).add({d: 25}), true), 'ދުވަސް 25', '25 days = 25 days');
+ assert.equal(start.from(moment([2007, 1, 28]).add({d: 26}), true), 'މަހެއް', '26 days = a month');
+ assert.equal(start.from(moment([2007, 1, 28]).add({d: 30}), true), 'މަހެއް', '30 days = a month');
+ assert.equal(start.from(moment([2007, 1, 28]).add({d: 43}), true), 'މަހެއް', '43 days = a month');
+ assert.equal(start.from(moment([2007, 1, 28]).add({d: 46}), true), 'މަސް 2', '46 days = 2 months');
+ assert.equal(start.from(moment([2007, 1, 28]).add({d: 74}), true), 'މަސް 2', '75 days = 2 months');
+ assert.equal(start.from(moment([2007, 1, 28]).add({d: 76}), true), 'މަސް 3', '76 days = 3 months');
+ assert.equal(start.from(moment([2007, 1, 28]).add({M: 1}), true), 'މަހެއް', '1 month = a month');
+ assert.equal(start.from(moment([2007, 1, 28]).add({M: 5}), true), 'މަސް 5', '5 months = 5 months');
+ assert.equal(start.from(moment([2007, 1, 28]).add({d: 345}), true), 'އަހަރެއް', '345 days = a year');
+ assert.equal(start.from(moment([2007, 1, 28]).add({d: 548}), true), 'އަހަރު 2', '548 days = 2 years');
+ assert.equal(start.from(moment([2007, 1, 28]).add({y: 1}), true), 'އަހަރެއް', '1 year = a year');
+ assert.equal(start.from(moment([2007, 1, 28]).add({y: 5}), true), 'އަހަރު 5', '5 years = 5 years');
+});
+
+test('suffix', function (assert) {
+ assert.equal(moment(30000).from(0), 'ތެރޭގައި ސިކުންތުކޮޅެއް', 'prefix');
+ assert.equal(moment(0).from(30000), 'ކުރިން ސިކުންތުކޮޅެއް', 'suffix');
+});
+
+test('fromNow', function (assert) {
+ assert.equal(moment().add({s: 30}).fromNow(), 'ތެރޭގައި ސިކުންތުކޮޅެއް', 'in a few seconds');
+ assert.equal(moment().add({d: 5}).fromNow(), 'ތެރޭގައި ދުވަސް 5', 'in 5 days');
+});
+
+test('calendar day', function (assert) {
+ var a = moment().hours(12).minutes(0).seconds(0);
+
+ assert.equal(moment(a).calendar(), 'މިއަދު 12:00', 'today at the same time');
+ assert.equal(moment(a).add({m: 25}).calendar(), 'މިއަދު 12:25', 'Now plus 25 min');
+ assert.equal(moment(a).add({h: 1}).calendar(), 'މިއަދު 13:00', 'Now plus 1 hour');
+ assert.equal(moment(a).add({d: 1}).calendar(), 'މާދަމާ 12:00', 'tomorrow at the same time');
+ assert.equal(moment(a).subtract({h: 1}).calendar(), 'މިއަދު 11:00', 'Now minus 1 hour');
+ assert.equal(moment(a).subtract({d: 1}).calendar(), 'އިއްޔެ 12:00', 'yesterday at the same time');
+});
+
+test('calendar next week', function (assert) {
+ var i, m;
+ for (i = 2; i < 7; i++) {
+ m = moment().add({d: i});
+ assert.equal(m.calendar(), m.format('dddd LT'), 'Today + ' + i + ' days current time');
+ m.hours(0).minutes(0).seconds(0).milliseconds(0);
+ assert.equal(m.calendar(), m.format('dddd LT'), 'Today + ' + i + ' days beginning of day');
+ m.hours(23).minutes(59).seconds(59).milliseconds(999);
+ assert.equal(m.calendar(), m.format('dddd LT'), 'Today + ' + i + ' days end of day');
+ }
+});
+
+test('calendar last week', function (assert) {
+ var i, m;
+ for (i = 2; i < 7; i++) {
+ m = moment().subtract({d: i});
+ assert.equal(m.calendar(), m.format('[ފާއިތުވި] dddd LT'), 'Today + ' + i + ' days current time');
+ m.hours(0).minutes(0).seconds(0).milliseconds(0);
+ assert.equal(m.calendar(), m.format('[ފާއިތުވި] dddd LT'), 'Today + ' + i + ' days beginning of day');
+ m.hours(23).minutes(59).seconds(59).milliseconds(999);
+ assert.equal(m.calendar(), m.format('[ފާއިތުވި] dddd LT'), 'Today + ' + i + ' days end of day');
+ }
+});
+
+test('calendar all else', function (assert) {
+ var weeksAgo = moment().subtract({w: 1}),
+ weeksFromNow = moment().add({w: 1});
+
+ assert.equal(weeksAgo.calendar(), weeksAgo.format('L'), '1 week ago');
+ assert.equal(weeksFromNow.calendar(), weeksFromNow.format('L'), 'in 1 week');
+
+ weeksAgo = moment().subtract({w: 2});
+ weeksFromNow = moment().add({w: 2});
+
+ assert.equal(weeksAgo.calendar(), weeksAgo.format('L'), '2 weeks ago');
+ assert.equal(weeksFromNow.calendar(), weeksFromNow.format('L'), 'in 2 weeks');
+});
+
+test('weeks year starting sunday formatted', function (assert) {
+ assert.equal(moment([2012, 0, 1]).format('w ww wo'), '1 01 1', 'Jan 1 2012 should be week 1');
+ assert.equal(moment([2012, 0, 2]).format('w ww wo'), '1 01 1', 'Jan 2 2012 should be week 1');
+ assert.equal(moment([2012, 0, 8]).format('w ww wo'), '2 02 2', 'Jan 8 2012 should be week 2');
+ assert.equal(moment([2012, 0, 9]).format('w ww wo'), '2 02 2', 'Jan 9 2012 should be week 2');
+ assert.equal(moment([2012, 0, 15]).format('w ww wo'), '3 03 3', 'Jan 15 2012 should be week 3');
+});
diff --git a/src/test/locale/el.js b/src/test/locale/el.js
index b1f310f..738490d 100644
--- a/src/test/locale/el.js
+++ b/src/test/locale/el.js
@@ -199,14 +199,14 @@
});
test('calendar day', function (assert) {
- var a = moment().hours(2).minutes(0).seconds(0);
-
- assert.equal(moment(a).calendar(), 'Σήμερα στις 2:00 ΠΜ', 'today at the same time');
- assert.equal(moment(a).add({m: 25}).calendar(), 'Σήμερα στις 2:25 ΠΜ', 'Now plus 25 min');
- assert.equal(moment(a).add({h: 1}).calendar(), 'Σήμερα στις 3:00 ΠΜ', 'Now plus 1 hour');
- assert.equal(moment(a).add({d: 1}).calendar(), 'Αύριο στις 2:00 ΠΜ', 'tomorrow at the same time');
- assert.equal(moment(a).subtract({h: 1}).calendar(), 'Σήμερα στη 1:00 ΠΜ', 'Now minus 1 hour');
- assert.equal(moment(a).subtract({d: 1}).calendar(), 'Χθες στις 2:00 ΠΜ', 'yesterday at the same time');
+ var a = moment().hours(12).minutes(0).seconds(0);
+
+ assert.equal(moment(a).calendar(), 'Σήμερα στις 12:00 ΜΜ', 'today at the same time');
+ assert.equal(moment(a).add({m: 25}).calendar(), 'Σήμερα στις 12:25 ΜΜ', 'Now plus 25 min');
+ assert.equal(moment(a).add({h: 1}).calendar(), 'Σήμερα στη 1:00 ΜΜ', 'Now plus 1 hour');
+ assert.equal(moment(a).add({d: 1}).calendar(), 'Αύριο στις 12:00 ΜΜ', 'tomorrow at the same time');
+ assert.equal(moment(a).subtract({h: 1}).calendar(), 'Σήμερα στις 11:00 ΠΜ', 'Now minus 1 hour');
+ assert.equal(moment(a).subtract({d: 1}).calendar(), 'Χθες στις 12:00 ΜΜ', 'yesterday at the same time');
});
test('calendar next week', function (assert) {
@@ -250,69 +250,6 @@
assert.equal(weeksFromNow.calendar(), weeksFromNow.format('L'), 'in 2 weeks');
});
-test('weeks year starting sunday', function (assert) {
- assert.equal(moment([2012, 0, 1]).week(), 52, 'Jan 1 2012 should be week 52');
- assert.equal(moment([2012, 0, 7]).week(), 1, 'Jan 7 2012 should be week 1');
- assert.equal(moment([2012, 0, 8]).week(), 1, 'Jan 8 2012 should be week 1');
- assert.equal(moment([2012, 0, 14]).week(), 2, 'Jan 14 2012 should be week 2');
- assert.equal(moment([2012, 0, 15]).week(), 2, 'Jan 15 2012 should be week 2');
-});
-
-test('weeks year starting monday', function (assert) {
- assert.equal(moment([2006, 11, 31]).week(), 52, 'Dec 31 2006 should be week 52');
- assert.equal(moment([2007, 0, 1]).week(), 1, 'Jan 1 2007 should be week 1');
- assert.equal(moment([2007, 0, 6]).week(), 1, 'Jan 6 2007 should be week 1');
- assert.equal(moment([2007, 0, 7]).week(), 1, 'Jan 7 2007 should be week 1');
- assert.equal(moment([2007, 0, 13]).week(), 2, 'Jan 13 2007 should be week 2');
- assert.equal(moment([2007, 0, 14]).week(), 2, 'Jan 14 2007 should be week 2');
-});
-
-test('weeks year starting tuesday', function (assert) {
- assert.equal(moment([2007, 11, 30]).week(), 52, 'Dec 30 2007 should be week 52');
- assert.equal(moment([2008, 0, 1]).week(), 1, 'Jan 1 2008 should be week 1');
- assert.equal(moment([2008, 0, 5]).week(), 1, 'Jan 5 2008 should be week 1');
- assert.equal(moment([2008, 0, 6]).week(), 1, 'Jan 6 2008 should be week 1');
- assert.equal(moment([2008, 0, 12]).week(), 2, 'Jan 12 2008 should be week 2');
- assert.equal(moment([2008, 0, 13]).week(), 2, 'Jan 13 2008 should be week 2');
-});
-
-test('weeks year starting wednesday', function (assert) {
- assert.equal(moment([2002, 11, 29]).week(), 52, 'Dec 29 2002 should be week 52');
- assert.equal(moment([2003, 0, 1]).week(), 1, 'Jan 1 2003 should be week 1');
- assert.equal(moment([2003, 0, 4]).week(), 1, 'Jan 4 2003 should be week 1');
- assert.equal(moment([2003, 0, 5]).week(), 1, 'Jan 5 2003 should be week 1');
- assert.equal(moment([2003, 0, 11]).week(), 2, 'Jan 11 2003 should be week 2');
- assert.equal(moment([2003, 0, 12]).week(), 2, 'Jan 12 2003 should be week 2');
-});
-
-test('weeks year starting thursday', function (assert) {
- assert.equal(moment([2008, 11, 28]).week(), 52, 'Dec 28 2008 should be week 52');
- assert.equal(moment([2009, 0, 1]).week(), 1, 'Jan 1 2009 should be week 1');
- assert.equal(moment([2009, 0, 3]).week(), 1, 'Jan 3 2009 should be week 1');
- assert.equal(moment([2009, 0, 4]).week(), 1, 'Jan 4 2009 should be week 1');
- assert.equal(moment([2009, 0, 10]).week(), 2, 'Jan 10 2009 should be week 2');
- assert.equal(moment([2009, 0, 11]).week(), 2, 'Jan 11 2009 should be week 2');
-});
-
-test('weeks year starting friday', function (assert) {
- assert.equal(moment([2009, 11, 27]).week(), 52, 'Dec 27 2009 should be week 52');
- assert.equal(moment([2010, 0, 1]).week(), 53, 'Jan 1 2010 should be week 53');
- assert.equal(moment([2010, 0, 2]).week(), 53, 'Jan 2 2010 should be week 53');
- assert.equal(moment([2010, 0, 3]).week(), 53, 'Jan 3 2010 should be week 1');
- assert.equal(moment([2010, 0, 9]).week(), 1, 'Jan 9 2010 should be week 1');
- assert.equal(moment([2010, 0, 10]).week(), 1, 'Jan 10 2010 should be week 1');
- assert.equal(moment([2010, 0, 11]).week(), 2, 'Jan 11 2010 should be week 2');
-});
-
-test('weeks year starting saturday', function (assert) {
- assert.equal(moment([2010, 11, 26]).week(), 51, 'Dec 26 2010 should be week 51');
- assert.equal(moment([2011, 0, 1]).week(), 52, 'Jan 1 2011 should be week 52');
- assert.equal(moment([2011, 0, 2]).week(), 52, 'Jan 2 2011 should be week 52');
- assert.equal(moment([2011, 0, 8]).week(), 1, 'Jan 8 2011 should be week 1');
- assert.equal(moment([2011, 0, 9]).week(), 1, 'Jan 9 2011 should be week 1');
- assert.equal(moment([2011, 0, 10]).week(), 2, 'Jan 10 2011 should be week 2');
-});
-
test('weeks year starting sunday format', function (assert) {
assert.equal(moment([2012, 0, 1]).format('w ww wo'), '52 52 52η', 'Jan 1 2012 should be week 52');
assert.equal(moment([2012, 0, 7]).format('w ww wo'), '1 01 1η', 'Jan 7 2012 should be week 1');
@@ -321,38 +258,3 @@
assert.equal(moment([2012, 0, 15]).format('w ww wo'), '2 02 2η', 'Jan 15 2012 should be week 2');
});
-test('lenient ordinal parsing', function (assert) {
- var i, ordinalStr, testMoment;
- for (i = 1; i <= 31; ++i) {
- ordinalStr = moment([2014, 0, i]).format('YYYY MM Do');
- testMoment = moment(ordinalStr, 'YYYY MM Do');
- assert.equal(testMoment.year(), 2014,
- 'lenient ordinal parsing ' + i + ' year check');
- assert.equal(testMoment.month(), 0,
- 'lenient ordinal parsing ' + i + ' month check');
- assert.equal(testMoment.date(), i,
- 'lenient ordinal parsing ' + i + ' date check');
- }
-});
-
-test('lenient ordinal parsing of number', function (assert) {
- var i, testMoment;
- for (i = 1; i <= 31; ++i) {
- testMoment = moment('2014 01 ' + i, 'YYYY MM Do');
- assert.equal(testMoment.year(), 2014,
- 'lenient ordinal parsing of number ' + i + ' year check');
- assert.equal(testMoment.month(), 0,
- 'lenient ordinal parsing of number ' + i + ' month check');
- assert.equal(testMoment.date(), i,
- 'lenient ordinal parsing of number ' + i + ' date check');
- }
-});
-
-test('strict ordinal parsing', function (assert) {
- var i, ordinalStr, testMoment;
- for (i = 1; i <= 31; ++i) {
- ordinalStr = moment([2014, 0, i]).format('YYYY MM Do');
- testMoment = moment(ordinalStr, 'YYYY MM Do', true);
- assert.ok(testMoment.isValid(), 'strict ordinal parsing ' + i);
- }
-});
diff --git a/src/test/locale/en-au.js b/src/test/locale/en-au.js
index db65cf3..db7aef2 100644
--- a/src/test/locale/en-au.js
+++ b/src/test/locale/en-au.js
@@ -3,7 +3,7 @@
localeModule('en-au');
test('parse', function (assert) {
- var tests = 'January Jan_February Feb_March Mar_April Apr_May May_June Jun_July Jul_August Aug_September Sept_October Oct_November Nov_December Dec'.split('_'), i;
+ var tests = '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('_'), i;
function equalTest(input, mmm, i) {
assert.equal(moment(input, mmm).month(), i, input + ' should be month ' + (i + 1));
}
@@ -91,7 +91,7 @@
});
test('format month', function (assert) {
- var expected = 'January Jan_February Feb_March Mar_April Apr_May May_June Jun_July Jul_August Aug_September Sept_October Oct_November Nov_December Dec'.split('_'), i;
+ 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('_'), i;
for (i = 0; i < expected.length; i++) {
assert.equal(moment([2011, i, 1]).format('MMMM MMM'), expected[i], expected[i]);
}
@@ -151,14 +151,14 @@
});
test('calendar day', function (assert) {
- var a = moment().hours(2).minutes(0).seconds(0);
-
- assert.equal(moment(a).calendar(), 'Today at 2:00 AM', 'today at the same time');
- assert.equal(moment(a).add({m: 25}).calendar(), 'Today at 2:25 AM', 'Now plus 25 min');
- assert.equal(moment(a).add({h: 1}).calendar(), 'Today at 3:00 AM', 'Now plus 1 hour');
- assert.equal(moment(a).add({d: 1}).calendar(), 'Tomorrow at 2:00 AM', 'tomorrow at the same time');
- assert.equal(moment(a).subtract({h: 1}).calendar(), 'Today at 1:00 AM', 'Now minus 1 hour');
- assert.equal(moment(a).subtract({d: 1}).calendar(), 'Yesterday at 2:00 AM', 'yesterday at the same time');
+ var a = moment().hours(12).minutes(0).seconds(0);
+
+ assert.equal(moment(a).calendar(), 'Today at 12:00 PM', 'today at the same time');
+ assert.equal(moment(a).add({m: 25}).calendar(), 'Today at 12:25 PM', 'Now plus 25 min');
+ assert.equal(moment(a).add({h: 1}).calendar(), 'Today at 1:00 PM', 'Now plus 1 hour');
+ assert.equal(moment(a).add({d: 1}).calendar(), 'Tomorrow at 12:00 PM', 'tomorrow at the same time');
+ assert.equal(moment(a).subtract({h: 1}).calendar(), 'Today at 11:00 AM', 'Now minus 1 hour');
+ assert.equal(moment(a).subtract({d: 1}).calendar(), 'Yesterday at 12:00 PM', 'yesterday at the same time');
});
test('calendar next week', function (assert) {
@@ -200,67 +200,6 @@
assert.equal(weeksFromNow.calendar(), weeksFromNow.format('L'), 'in 2 weeks');
});
-test('weeks year starting sunday', function (assert) {
- assert.equal(moment([2012, 0, 1]).week(), 52, 'Jan 1 2012 should be week 52');
- assert.equal(moment([2012, 0, 2]).week(), 1, 'Jan 2 2012 should be week 1');
- assert.equal(moment([2012, 0, 8]).week(), 1, 'Jan 8 2012 should be week 1');
- assert.equal(moment([2012, 0, 9]).week(), 2, 'Jan 9 2012 should be week 2');
- assert.equal(moment([2012, 0, 15]).week(), 2, 'Jan 15 2012 should be week 2');
-});
-
-test('weeks year starting monday', function (assert) {
- assert.equal(moment([2007, 0, 1]).week(), 1, 'Jan 1 2007 should be week 1');
- assert.equal(moment([2007, 0, 7]).week(), 1, 'Jan 7 2007 should be week 1');
- assert.equal(moment([2007, 0, 8]).week(), 2, 'Jan 8 2007 should be week 2');
- assert.equal(moment([2007, 0, 14]).week(), 2, 'Jan 14 2007 should be week 2');
- assert.equal(moment([2007, 0, 15]).week(), 3, 'Jan 15 2007 should be week 3');
-});
-
-test('weeks year starting tuesday', function (assert) {
- assert.equal(moment([2007, 11, 31]).week(), 1, 'Dec 31 2007 should be week 1');
- assert.equal(moment([2008, 0, 1]).week(), 1, 'Jan 1 2008 should be week 1');
- assert.equal(moment([2008, 0, 6]).week(), 1, 'Jan 6 2008 should be week 1');
- assert.equal(moment([2008, 0, 7]).week(), 2, 'Jan 7 2008 should be week 2');
- assert.equal(moment([2008, 0, 13]).week(), 2, 'Jan 13 2008 should be week 2');
- assert.equal(moment([2008, 0, 14]).week(), 3, 'Jan 14 2008 should be week 3');
-});
-
-test('weeks year starting wednesday', function (assert) {
- assert.equal(moment([2002, 11, 30]).week(), 1, 'Dec 30 2002 should be week 1');
- assert.equal(moment([2003, 0, 1]).week(), 1, 'Jan 1 2003 should be week 1');
- assert.equal(moment([2003, 0, 5]).week(), 1, 'Jan 5 2003 should be week 1');
- assert.equal(moment([2003, 0, 6]).week(), 2, 'Jan 6 2003 should be week 2');
- assert.equal(moment([2003, 0, 12]).week(), 2, 'Jan 12 2003 should be week 2');
- assert.equal(moment([2003, 0, 13]).week(), 3, 'Jan 13 2003 should be week 3');
-});
-
-test('weeks year starting thursday', function (assert) {
- assert.equal(moment([2008, 11, 29]).week(), 1, 'Dec 29 2008 should be week 1');
- assert.equal(moment([2009, 0, 1]).week(), 1, 'Jan 1 2009 should be week 1');
- assert.equal(moment([2009, 0, 4]).week(), 1, 'Jan 4 2009 should be week 1');
- assert.equal(moment([2009, 0, 5]).week(), 2, 'Jan 5 2009 should be week 2');
- assert.equal(moment([2009, 0, 11]).week(), 2, 'Jan 11 2009 should be week 2');
- assert.equal(moment([2009, 0, 13]).week(), 3, 'Jan 12 2009 should be week 3');
-});
-
-test('weeks year starting friday', function (assert) {
- assert.equal(moment([2009, 11, 28]).week(), 53, 'Dec 28 2009 should be week 53');
- assert.equal(moment([2010, 0, 1]).week(), 53, 'Jan 1 2010 should be week 53');
- assert.equal(moment([2010, 0, 3]).week(), 53, 'Jan 3 2010 should be week 53');
- assert.equal(moment([2010, 0, 4]).week(), 1, 'Jan 4 2010 should be week 1');
- assert.equal(moment([2010, 0, 10]).week(), 1, 'Jan 10 2010 should be week 1');
- assert.equal(moment([2010, 0, 11]).week(), 2, 'Jan 11 2010 should be week 2');
-});
-
-test('weeks year starting saturday', function (assert) {
- assert.equal(moment([2010, 11, 27]).week(), 52, 'Dec 27 2010 should be week 52');
- assert.equal(moment([2011, 0, 1]).week(), 52, 'Jan 1 2011 should be week 52');
- assert.equal(moment([2011, 0, 2]).week(), 52, 'Jan 2 2011 should be week 52');
- assert.equal(moment([2011, 0, 3]).week(), 1, 'Jan 3 2011 should be week 1');
- assert.equal(moment([2011, 0, 9]).week(), 1, 'Jan 9 2011 should be week 1');
- assert.equal(moment([2011, 0, 10]).week(), 2, 'Jan 10 2011 should be week 2');
-});
-
test('weeks year starting sunday formatted', function (assert) {
assert.equal(moment([2012, 0, 1]).format('w ww wo'), '52 52 52nd', 'Jan 1 2012 should be week 52');
assert.equal(moment([2012, 0, 2]).format('w ww wo'), '1 01 1st', 'Jan 2 2012 should be week 1');
@@ -268,30 +207,3 @@
assert.equal(moment([2012, 0, 9]).format('w ww wo'), '2 02 2nd', 'Jan 9 2012 should be week 2');
assert.equal(moment([2012, 0, 15]).format('w ww wo'), '2 02 2nd', 'Jan 15 2012 should be week 2');
});
-
-test('lenient ordinal parsing', function (assert) {
- var i, ordinalStr, testStr;
- for (i = 1; i <= 31; ++i) {
- ordinalStr = moment([2014, 0, i]).format('YYYY MM Do');
- testStr = moment(ordinalStr, 'YYYY MM Do').format('YYYY MM D');
- assert.equal(testStr, '2014 01 ' + i, 'lenient ordinal parsing ' + i);
- }
-});
-
-test('lenient ordinal parsing of number', function (assert) {
- var i, testStr;
- for (i = 1; i <= 31; ++i) {
- testStr = moment('2014 01 ' + i, 'YYYY MM Do').format('YYYY MM D');
- assert.equal(testStr, '2014 01 ' + i,
- 'lenient ordinal parsing of number ' + i);
- }
-});
-
-test('strict ordinal parsing', function (assert) {
- var i, ordinalStr, testMoment;
- for (i = 1; i <= 31; ++i) {
- ordinalStr = moment([2014, 0, i]).format('YYYY MMM Do');
- testMoment = moment(ordinalStr, 'YYYY MMM Do', true);
- assert.ok(testMoment.isValid(), 'strict ordinal parsing ' + i);
- }
-});
diff --git a/src/test/locale/en-ca.js b/src/test/locale/en-ca.js
index ee822f4..54516e8 100644
--- a/src/test/locale/en-ca.js
+++ b/src/test/locale/en-ca.js
@@ -4,7 +4,7 @@
test('parse', function (assert) {
var i,
- tests = 'January Jan_February Feb_March Mar_April Apr_May May_June Jun_July Jul_August Aug_September Sept_October Oct_November Nov_December Dec'.split('_');
+ tests = '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('_');
function equalTest(input, mmm, i) {
assert.equal(moment(input, mmm).month(), i, input + ' should be month ' + (i + 1));
@@ -41,13 +41,13 @@
['[the] DDDo [day of the year]', 'the 45th day of the year'],
['L', '2010-02-14'],
['LTS', '3:25:50 PM'],
- ['LL', '14 February, 2010'],
- ['LLL', '14 February, 2010 3:25 PM'],
- ['LLLL', 'Sunday, 14 February, 2010 3:25 PM'],
+ ['LL', 'February 14, 2010'],
+ ['LLL', 'February 14, 2010 3:25 PM'],
+ ['LLLL', 'Sunday, February 14, 2010 3:25 PM'],
['l', '2010-2-14'],
- ['ll', '14 Feb, 2010'],
- ['lll', '14 Feb, 2010 3:25 PM'],
- ['llll', 'Sun, 14 Feb, 2010 3:25 PM']
+ ['ll', 'Feb 14, 2010'],
+ ['lll', 'Feb 14, 2010 3:25 PM'],
+ ['llll', 'Sun, Feb 14, 2010 3:25 PM']
],
b = moment(new Date(2010, 1, 14, 15, 25, 50, 125)),
i;
@@ -96,7 +96,7 @@
test('format month', function (assert) {
var i,
- expected = 'January Jan_February Feb_March Mar_April Apr_May May_June Jun_July Jul_August Aug_September Sept_October Oct_November Nov_December Dec'.split('_');
+ 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('_');
for (i = 0; i < expected.length; i++) {
assert.equal(moment([2011, i, 1]).format('MMMM MMM'), expected[i], expected[i]);
@@ -159,14 +159,14 @@
});
test('calendar day', function (assert) {
- var a = moment().hours(2).minutes(0).seconds(0);
-
- assert.equal(moment(a).calendar(), 'Today at 2:00 AM', 'today at the same time');
- assert.equal(moment(a).add({m: 25}).calendar(), 'Today at 2:25 AM', 'Now plus 25 min');
- assert.equal(moment(a).add({h: 1}).calendar(), 'Today at 3:00 AM', 'Now plus 1 hour');
- assert.equal(moment(a).add({d: 1}).calendar(), 'Tomorrow at 2:00 AM', 'tomorrow at the same time');
- assert.equal(moment(a).subtract({h: 1}).calendar(), 'Today at 1:00 AM', 'Now minus 1 hour');
- assert.equal(moment(a).subtract({d: 1}).calendar(), 'Yesterday at 2:00 AM', 'yesterday at the same time');
+ var a = moment().hours(12).minutes(0).seconds(0);
+
+ assert.equal(moment(a).calendar(), 'Today at 12:00 PM', 'today at the same time');
+ assert.equal(moment(a).add({m: 25}).calendar(), 'Today at 12:25 PM', 'Now plus 25 min');
+ assert.equal(moment(a).add({h: 1}).calendar(), 'Today at 1:00 PM', 'Now plus 1 hour');
+ assert.equal(moment(a).add({d: 1}).calendar(), 'Tomorrow at 12:00 PM', 'tomorrow at the same time');
+ assert.equal(moment(a).subtract({h: 1}).calendar(), 'Today at 11:00 AM', 'Now minus 1 hour');
+ assert.equal(moment(a).subtract({d: 1}).calendar(), 'Yesterday at 12:00 PM', 'yesterday at the same time');
});
test('calendar next week', function (assert) {
@@ -209,67 +209,6 @@
assert.equal(weeksFromNow.calendar(), weeksFromNow.format('L'), 'in 2 weeks');
});
-test('weeks year starting sunday', function (assert) {
- assert.equal(moment([2012, 0, 1]).week(), 1, 'Jan 1 2012 should be week 1');
- assert.equal(moment([2012, 0, 7]).week(), 1, 'Jan 7 2012 should be week 1');
- assert.equal(moment([2012, 0, 8]).week(), 2, 'Jan 8 2012 should be week 2');
- assert.equal(moment([2012, 0, 14]).week(), 2, 'Jan 14 2012 should be week 2');
- assert.equal(moment([2012, 0, 15]).week(), 3, 'Jan 15 2012 should be week 3');
-});
-
-test('weeks year starting monday', function (assert) {
- assert.equal(moment([2006, 11, 31]).week(), 1, 'Dec 31 2006 should be week 1');
- assert.equal(moment([2007, 0, 1]).week(), 1, 'Jan 1 2007 should be week 1');
- assert.equal(moment([2007, 0, 6]).week(), 1, 'Jan 6 2007 should be week 1');
- assert.equal(moment([2007, 0, 7]).week(), 2, 'Jan 7 2007 should be week 2');
- assert.equal(moment([2007, 0, 13]).week(), 2, 'Jan 13 2007 should be week 2');
- assert.equal(moment([2007, 0, 14]).week(), 3, 'Jan 14 2007 should be week 3');
-});
-
-test('weeks year starting tuesday', function (assert) {
- assert.equal(moment([2007, 11, 29]).week(), 52, 'Dec 29 2007 should be week 52');
- assert.equal(moment([2008, 0, 1]).week(), 1, 'Jan 1 2008 should be week 1');
- assert.equal(moment([2008, 0, 5]).week(), 1, 'Jan 5 2008 should be week 1');
- assert.equal(moment([2008, 0, 6]).week(), 2, 'Jan 6 2008 should be week 2');
- assert.equal(moment([2008, 0, 12]).week(), 2, 'Jan 12 2008 should be week 2');
- assert.equal(moment([2008, 0, 13]).week(), 3, 'Jan 13 2008 should be week 3');
-});
-
-test('weeks year starting wednesday', function (assert) {
- assert.equal(moment([2002, 11, 29]).week(), 1, 'Dec 29 2002 should be week 1');
- assert.equal(moment([2003, 0, 1]).week(), 1, 'Jan 1 2003 should be week 1');
- assert.equal(moment([2003, 0, 4]).week(), 1, 'Jan 4 2003 should be week 1');
- assert.equal(moment([2003, 0, 5]).week(), 2, 'Jan 5 2003 should be week 2');
- assert.equal(moment([2003, 0, 11]).week(), 2, 'Jan 11 2003 should be week 2');
- assert.equal(moment([2003, 0, 12]).week(), 3, 'Jan 12 2003 should be week 3');
-});
-
-test('weeks year starting thursday', function (assert) {
- assert.equal(moment([2008, 11, 28]).week(), 1, 'Dec 28 2008 should be week 1');
- assert.equal(moment([2009, 0, 1]).week(), 1, 'Jan 1 2009 should be week 1');
- assert.equal(moment([2009, 0, 3]).week(), 1, 'Jan 3 2009 should be week 1');
- assert.equal(moment([2009, 0, 4]).week(), 2, 'Jan 4 2009 should be week 2');
- assert.equal(moment([2009, 0, 10]).week(), 2, 'Jan 10 2009 should be week 2');
- assert.equal(moment([2009, 0, 11]).week(), 3, 'Jan 11 2009 should be week 3');
-});
-
-test('weeks year starting friday', function (assert) {
- assert.equal(moment([2009, 11, 27]).week(), 1, 'Dec 27 2009 should be week 1');
- assert.equal(moment([2010, 0, 1]).week(), 1, 'Jan 1 2010 should be week 1');
- assert.equal(moment([2010, 0, 2]).week(), 1, 'Jan 2 2010 should be week 1');
- assert.equal(moment([2010, 0, 3]).week(), 2, 'Jan 3 2010 should be week 2');
- assert.equal(moment([2010, 0, 9]).week(), 2, 'Jan 9 2010 should be week 2');
- assert.equal(moment([2010, 0, 10]).week(), 3, 'Jan 10 2010 should be week 3');
-});
-
-test('weeks year starting saturday', function (assert) {
- assert.equal(moment([2010, 11, 26]).week(), 1, 'Dec 26 2010 should be week 1');
- assert.equal(moment([2011, 0, 1]).week(), 1, 'Jan 1 2011 should be week 1');
- assert.equal(moment([2011, 0, 2]).week(), 2, 'Jan 2 2011 should be week 2');
- assert.equal(moment([2011, 0, 8]).week(), 2, 'Jan 8 2011 should be week 2');
- assert.equal(moment([2011, 0, 9]).week(), 3, 'Jan 9 2011 should be week 3');
-});
-
test('weeks year starting sunday format', function (assert) {
assert.equal(moment([2012, 0, 1]).format('w ww wo'), '1 01 1st', 'Jan 1 2012 should be week 1');
assert.equal(moment([2012, 0, 7]).format('w ww wo'), '1 01 1st', 'Jan 7 2012 should be week 1');
@@ -278,38 +217,3 @@
assert.equal(moment([2012, 0, 15]).format('w ww wo'), '3 03 3rd', 'Jan 15 2012 should be week 3');
});
-test('lenient ordinal parsing', function (assert) {
- var i, ordinalStr, testMoment;
- for (i = 1; i <= 31; ++i) {
- ordinalStr = moment([2014, 0, i]).format('YYYY MM Do');
- testMoment = moment(ordinalStr, 'YYYY MM Do');
- assert.equal(testMoment.year(), 2014,
- 'lenient ordinal parsing ' + i + ' year check');
- assert.equal(testMoment.month(), 0,
- 'lenient ordinal parsing ' + i + ' month check');
- assert.equal(testMoment.date(), i,
- 'lenient ordinal parsing ' + i + ' date check');
- }
-});
-
-test('lenient ordinal parsing of number', function (assert) {
- var i, testMoment;
- for (i = 1; i <= 31; ++i) {
- testMoment = moment('2014 01 ' + i, 'YYYY MM Do');
- assert.equal(testMoment.year(), 2014,
- 'lenient ordinal parsing of number ' + i + ' year check');
- assert.equal(testMoment.month(), 0,
- 'lenient ordinal parsing of number ' + i + ' month check');
- assert.equal(testMoment.date(), i,
- 'lenient ordinal parsing of number ' + i + ' date check');
- }
-});
-
-test('strict ordinal parsing', function (assert) {
- var i, ordinalStr, testMoment;
- for (i = 1; i <= 31; ++i) {
- ordinalStr = moment([2014, 0, i]).format('YYYY MM Do');
- testMoment = moment(ordinalStr, 'YYYY MM Do', true);
- assert.ok(testMoment.isValid(), 'strict ordinal parsing ' + i);
- }
-});
diff --git a/src/test/locale/en-gb.js b/src/test/locale/en-gb.js
index 5ddc16e..0b98fe4 100644
--- a/src/test/locale/en-gb.js
+++ b/src/test/locale/en-gb.js
@@ -3,7 +3,7 @@
localeModule('en-gb');
test('parse', function (assert) {
- var tests = 'January Jan_February Feb_March Mar_April Apr_May May_June Jun_July Jul_August Aug_September Sept_October Oct_November Nov_December Dec'.split('_'), i;
+ var tests = '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('_'), i;
function equalTest(input, mmm, i) {
assert.equal(moment(input, mmm).month(), i, input + ' should be month ' + (i + 1));
}
@@ -91,7 +91,7 @@
});
test('format month', function (assert) {
- var expected = 'January Jan_February Feb_March Mar_April Apr_May May_June Jun_July Jul_August Aug_September Sept_October Oct_November Nov_December Dec'.split('_'), i;
+ 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('_'), i;
for (i = 0; i < expected.length; i++) {
assert.equal(moment([2011, i, 1]).format('MMMM MMM'), expected[i], expected[i]);
}
@@ -151,14 +151,14 @@
});
test('calendar day', function (assert) {
- var a = moment().hours(2).minutes(0).seconds(0);
-
- assert.equal(moment(a).calendar(), 'Today at 02:00', 'today at the same time');
- assert.equal(moment(a).add({m: 25}).calendar(), 'Today at 02:25', 'Now plus 25 min');
- assert.equal(moment(a).add({h: 1}).calendar(), 'Today at 03:00', 'Now plus 1 hour');
- assert.equal(moment(a).add({d: 1}).calendar(), 'Tomorrow at 02:00', 'tomorrow at the same time');
- assert.equal(moment(a).subtract({h: 1}).calendar(), 'Today at 01:00', 'Now minus 1 hour');
- assert.equal(moment(a).subtract({d: 1}).calendar(), 'Yesterday at 02:00', 'yesterday at the same time');
+ var a = moment().hours(12).minutes(0).seconds(0);
+
+ assert.equal(moment(a).calendar(), 'Today at 12:00', 'today at the same time');
+ assert.equal(moment(a).add({m: 25}).calendar(), 'Today at 12:25', 'Now plus 25 min');
+ assert.equal(moment(a).add({h: 1}).calendar(), 'Today at 13:00', 'Now plus 1 hour');
+ assert.equal(moment(a).add({d: 1}).calendar(), 'Tomorrow at 12:00', 'tomorrow at the same time');
+ assert.equal(moment(a).subtract({h: 1}).calendar(), 'Today at 11:00', 'Now minus 1 hour');
+ assert.equal(moment(a).subtract({d: 1}).calendar(), 'Yesterday at 12:00', 'yesterday at the same time');
});
test('calendar next week', function (assert) {
@@ -200,67 +200,6 @@
assert.equal(weeksFromNow.calendar(), weeksFromNow.format('L'), 'in 2 weeks');
});
-test('weeks year starting sunday', function (assert) {
- assert.equal(moment([2012, 0, 1]).week(), 52, 'Jan 1 2012 should be week 52');
- assert.equal(moment([2012, 0, 2]).week(), 1, 'Jan 2 2012 should be week 1');
- assert.equal(moment([2012, 0, 8]).week(), 1, 'Jan 8 2012 should be week 1');
- assert.equal(moment([2012, 0, 9]).week(), 2, 'Jan 9 2012 should be week 2');
- assert.equal(moment([2012, 0, 15]).week(), 2, 'Jan 15 2012 should be week 2');
-});
-
-test('weeks year starting monday', function (assert) {
- assert.equal(moment([2007, 0, 1]).week(), 1, 'Jan 1 2007 should be week 1');
- assert.equal(moment([2007, 0, 7]).week(), 1, 'Jan 7 2007 should be week 1');
- assert.equal(moment([2007, 0, 8]).week(), 2, 'Jan 8 2007 should be week 2');
- assert.equal(moment([2007, 0, 14]).week(), 2, 'Jan 14 2007 should be week 2');
- assert.equal(moment([2007, 0, 15]).week(), 3, 'Jan 15 2007 should be week 3');
-});
-
-test('weeks year starting tuesday', function (assert) {
- assert.equal(moment([2007, 11, 31]).week(), 1, 'Dec 31 2007 should be week 1');
- assert.equal(moment([2008, 0, 1]).week(), 1, 'Jan 1 2008 should be week 1');
- assert.equal(moment([2008, 0, 6]).week(), 1, 'Jan 6 2008 should be week 1');
- assert.equal(moment([2008, 0, 7]).week(), 2, 'Jan 7 2008 should be week 2');
- assert.equal(moment([2008, 0, 13]).week(), 2, 'Jan 13 2008 should be week 2');
- assert.equal(moment([2008, 0, 14]).week(), 3, 'Jan 14 2008 should be week 3');
-});
-
-test('weeks year starting wednesday', function (assert) {
- assert.equal(moment([2002, 11, 30]).week(), 1, 'Dec 30 2002 should be week 1');
- assert.equal(moment([2003, 0, 1]).week(), 1, 'Jan 1 2003 should be week 1');
- assert.equal(moment([2003, 0, 5]).week(), 1, 'Jan 5 2003 should be week 1');
- assert.equal(moment([2003, 0, 6]).week(), 2, 'Jan 6 2003 should be week 2');
- assert.equal(moment([2003, 0, 12]).week(), 2, 'Jan 12 2003 should be week 2');
- assert.equal(moment([2003, 0, 13]).week(), 3, 'Jan 13 2003 should be week 3');
-});
-
-test('weeks year starting thursday', function (assert) {
- assert.equal(moment([2008, 11, 29]).week(), 1, 'Dec 29 2008 should be week 1');
- assert.equal(moment([2009, 0, 1]).week(), 1, 'Jan 1 2009 should be week 1');
- assert.equal(moment([2009, 0, 4]).week(), 1, 'Jan 4 2009 should be week 1');
- assert.equal(moment([2009, 0, 5]).week(), 2, 'Jan 5 2009 should be week 2');
- assert.equal(moment([2009, 0, 11]).week(), 2, 'Jan 11 2009 should be week 2');
- assert.equal(moment([2009, 0, 13]).week(), 3, 'Jan 12 2009 should be week 3');
-});
-
-test('weeks year starting friday', function (assert) {
- assert.equal(moment([2009, 11, 28]).week(), 53, 'Dec 28 2009 should be week 53');
- assert.equal(moment([2010, 0, 1]).week(), 53, 'Jan 1 2010 should be week 53');
- assert.equal(moment([2010, 0, 3]).week(), 53, 'Jan 3 2010 should be week 53');
- assert.equal(moment([2010, 0, 4]).week(), 1, 'Jan 4 2010 should be week 1');
- assert.equal(moment([2010, 0, 10]).week(), 1, 'Jan 10 2010 should be week 1');
- assert.equal(moment([2010, 0, 11]).week(), 2, 'Jan 11 2010 should be week 2');
-});
-
-test('weeks year starting saturday', function (assert) {
- assert.equal(moment([2010, 11, 27]).week(), 52, 'Dec 27 2010 should be week 52');
- assert.equal(moment([2011, 0, 1]).week(), 52, 'Jan 1 2011 should be week 52');
- assert.equal(moment([2011, 0, 2]).week(), 52, 'Jan 2 2011 should be week 52');
- assert.equal(moment([2011, 0, 3]).week(), 1, 'Jan 3 2011 should be week 1');
- assert.equal(moment([2011, 0, 9]).week(), 1, 'Jan 9 2011 should be week 1');
- assert.equal(moment([2011, 0, 10]).week(), 2, 'Jan 10 2011 should be week 2');
-});
-
test('weeks year starting sunday formatted', function (assert) {
assert.equal(moment([2012, 0, 1]).format('w ww wo'), '52 52 52nd', 'Jan 1 2012 should be week 52');
assert.equal(moment([2012, 0, 2]).format('w ww wo'), '1 01 1st', 'Jan 2 2012 should be week 1');
@@ -269,38 +208,3 @@
assert.equal(moment([2012, 0, 15]).format('w ww wo'), '2 02 2nd', 'Jan 15 2012 should be week 2');
});
-test('lenient ordinal parsing', function (assert) {
- var i, ordinalStr, testMoment;
- for (i = 1; i <= 31; ++i) {
- ordinalStr = moment([2014, 0, i]).format('YYYY MM Do');
- testMoment = moment(ordinalStr, 'YYYY MM Do');
- assert.equal(testMoment.year(), 2014,
- 'lenient ordinal parsing ' + i + ' year check');
- assert.equal(testMoment.month(), 0,
- 'lenient ordinal parsing ' + i + ' month check');
- assert.equal(testMoment.date(), i,
- 'lenient ordinal parsing ' + i + ' date check');
- }
-});
-
-test('lenient ordinal parsing of number', function (assert) {
- var i, testMoment;
- for (i = 1; i <= 31; ++i) {
- testMoment = moment('2014 01 ' + i, 'YYYY MM Do');
- assert.equal(testMoment.year(), 2014,
- 'lenient ordinal parsing of number ' + i + ' year check');
- assert.equal(testMoment.month(), 0,
- 'lenient ordinal parsing of number ' + i + ' month check');
- assert.equal(testMoment.date(), i,
- 'lenient ordinal parsing of number ' + i + ' date check');
- }
-});
-
-test('strict ordinal parsing', function (assert) {
- var i, ordinalStr, testMoment;
- for (i = 1; i <= 31; ++i) {
- ordinalStr = moment([2014, 0, i]).format('YYYY MM Do');
- testMoment = moment(ordinalStr, 'YYYY MM Do', true);
- assert.ok(testMoment.isValid(), 'strict ordinal parsing ' + i);
- }
-});
diff --git a/src/test/locale/en-ie.js b/src/test/locale/en-ie.js
index c7896a7..6f5a781 100644
--- a/src/test/locale/en-ie.js
+++ b/src/test/locale/en-ie.js
@@ -151,14 +151,14 @@
});
test('calendar day', function (assert) {
- var a = moment().hours(2).minutes(0).seconds(0);
-
- assert.equal(moment(a).calendar(), 'Today at 02:00', 'today at the same time');
- assert.equal(moment(a).add({m: 25}).calendar(), 'Today at 02:25', 'Now plus 25 min');
- assert.equal(moment(a).add({h: 1}).calendar(), 'Today at 03:00', 'Now plus 1 hour');
- assert.equal(moment(a).add({d: 1}).calendar(), 'Tomorrow at 02:00', 'tomorrow at the same time');
- assert.equal(moment(a).subtract({h: 1}).calendar(), 'Today at 01:00', 'Now minus 1 hour');
- assert.equal(moment(a).subtract({d: 1}).calendar(), 'Yesterday at 02:00', 'yesterday at the same time');
+ var a = moment().hours(12).minutes(0).seconds(0);
+
+ assert.equal(moment(a).calendar(), 'Today at 12:00', 'today at the same time');
+ assert.equal(moment(a).add({m: 25}).calendar(), 'Today at 12:25', 'Now plus 25 min');
+ assert.equal(moment(a).add({h: 1}).calendar(), 'Today at 13:00', 'Now plus 1 hour');
+ assert.equal(moment(a).add({d: 1}).calendar(), 'Tomorrow at 12:00', 'tomorrow at the same time');
+ assert.equal(moment(a).subtract({h: 1}).calendar(), 'Today at 11:00', 'Now minus 1 hour');
+ assert.equal(moment(a).subtract({d: 1}).calendar(), 'Yesterday at 12:00', 'yesterday at the same time');
});
test('calendar next week', function (assert) {
@@ -200,67 +200,6 @@
assert.equal(weeksFromNow.calendar(), weeksFromNow.format('L'), 'in 2 weeks');
});
-test('weeks year starting sunday', function (assert) {
- assert.equal(moment([2012, 0, 1]).week(), 52, 'Jan 1 2012 should be week 52');
- assert.equal(moment([2012, 0, 2]).week(), 1, 'Jan 2 2012 should be week 1');
- assert.equal(moment([2012, 0, 8]).week(), 1, 'Jan 8 2012 should be week 1');
- assert.equal(moment([2012, 0, 9]).week(), 2, 'Jan 9 2012 should be week 2');
- assert.equal(moment([2012, 0, 15]).week(), 2, 'Jan 15 2012 should be week 2');
-});
-
-test('weeks year starting monday', function (assert) {
- assert.equal(moment([2007, 0, 1]).week(), 1, 'Jan 1 2007 should be week 1');
- assert.equal(moment([2007, 0, 7]).week(), 1, 'Jan 7 2007 should be week 1');
- assert.equal(moment([2007, 0, 8]).week(), 2, 'Jan 8 2007 should be week 2');
- assert.equal(moment([2007, 0, 14]).week(), 2, 'Jan 14 2007 should be week 2');
- assert.equal(moment([2007, 0, 15]).week(), 3, 'Jan 15 2007 should be week 3');
-});
-
-test('weeks year starting tuesday', function (assert) {
- assert.equal(moment([2007, 11, 31]).week(), 1, 'Dec 31 2007 should be week 1');
- assert.equal(moment([2008, 0, 1]).week(), 1, 'Jan 1 2008 should be week 1');
- assert.equal(moment([2008, 0, 6]).week(), 1, 'Jan 6 2008 should be week 1');
- assert.equal(moment([2008, 0, 7]).week(), 2, 'Jan 7 2008 should be week 2');
- assert.equal(moment([2008, 0, 13]).week(), 2, 'Jan 13 2008 should be week 2');
- assert.equal(moment([2008, 0, 14]).week(), 3, 'Jan 14 2008 should be week 3');
-});
-
-test('weeks year starting wednesday', function (assert) {
- assert.equal(moment([2002, 11, 30]).week(), 1, 'Dec 30 2002 should be week 1');
- assert.equal(moment([2003, 0, 1]).week(), 1, 'Jan 1 2003 should be week 1');
- assert.equal(moment([2003, 0, 5]).week(), 1, 'Jan 5 2003 should be week 1');
- assert.equal(moment([2003, 0, 6]).week(), 2, 'Jan 6 2003 should be week 2');
- assert.equal(moment([2003, 0, 12]).week(), 2, 'Jan 12 2003 should be week 2');
- assert.equal(moment([2003, 0, 13]).week(), 3, 'Jan 13 2003 should be week 3');
-});
-
-test('weeks year starting thursday', function (assert) {
- assert.equal(moment([2008, 11, 29]).week(), 1, 'Dec 29 2008 should be week 1');
- assert.equal(moment([2009, 0, 1]).week(), 1, 'Jan 1 2009 should be week 1');
- assert.equal(moment([2009, 0, 4]).week(), 1, 'Jan 4 2009 should be week 1');
- assert.equal(moment([2009, 0, 5]).week(), 2, 'Jan 5 2009 should be week 2');
- assert.equal(moment([2009, 0, 11]).week(), 2, 'Jan 11 2009 should be week 2');
- assert.equal(moment([2009, 0, 13]).week(), 3, 'Jan 12 2009 should be week 3');
-});
-
-test('weeks year starting friday', function (assert) {
- assert.equal(moment([2009, 11, 28]).week(), 53, 'Dec 28 2009 should be week 53');
- assert.equal(moment([2010, 0, 1]).week(), 53, 'Jan 1 2010 should be week 53');
- assert.equal(moment([2010, 0, 3]).week(), 53, 'Jan 3 2010 should be week 53');
- assert.equal(moment([2010, 0, 4]).week(), 1, 'Jan 4 2010 should be week 1');
- assert.equal(moment([2010, 0, 10]).week(), 1, 'Jan 10 2010 should be week 1');
- assert.equal(moment([2010, 0, 11]).week(), 2, 'Jan 11 2010 should be week 2');
-});
-
-test('weeks year starting saturday', function (assert) {
- assert.equal(moment([2010, 11, 27]).week(), 52, 'Dec 27 2010 should be week 52');
- assert.equal(moment([2011, 0, 1]).week(), 52, 'Jan 1 2011 should be week 52');
- assert.equal(moment([2011, 0, 2]).week(), 52, 'Jan 2 2011 should be week 52');
- assert.equal(moment([2011, 0, 3]).week(), 1, 'Jan 3 2011 should be week 1');
- assert.equal(moment([2011, 0, 9]).week(), 1, 'Jan 9 2011 should be week 1');
- assert.equal(moment([2011, 0, 10]).week(), 2, 'Jan 10 2011 should be week 2');
-});
-
test('weeks year starting sunday formatted', function (assert) {
assert.equal(moment([2012, 0, 1]).format('w ww wo'), '52 52 52nd', 'Jan 1 2012 should be week 52');
assert.equal(moment([2012, 0, 2]).format('w ww wo'), '1 01 1st', 'Jan 2 2012 should be week 1');
@@ -269,38 +208,3 @@
assert.equal(moment([2012, 0, 15]).format('w ww wo'), '2 02 2nd', 'Jan 15 2012 should be week 2');
});
-test('lenient ordinal parsing', function (assert) {
- var i, ordinalStr, testMoment;
- for (i = 1; i <= 31; ++i) {
- ordinalStr = moment([2014, 0, i]).format('YYYY MM Do');
- testMoment = moment(ordinalStr, 'YYYY MM Do');
- assert.equal(testMoment.year(), 2014,
- 'lenient ordinal parsing ' + i + ' year check');
- assert.equal(testMoment.month(), 0,
- 'lenient ordinal parsing ' + i + ' month check');
- assert.equal(testMoment.date(), i,
- 'lenient ordinal parsing ' + i + ' date check');
- }
-});
-
-test('lenient ordinal parsing of number', function (assert) {
- var i, testMoment;
- for (i = 1; i <= 31; ++i) {
- testMoment = moment('2014 01 ' + i, 'YYYY MM Do');
- assert.equal(testMoment.year(), 2014,
- 'lenient ordinal parsing of number ' + i + ' year check');
- assert.equal(testMoment.month(), 0,
- 'lenient ordinal parsing of number ' + i + ' month check');
- assert.equal(testMoment.date(), i,
- 'lenient ordinal parsing of number ' + i + ' date check');
- }
-});
-
-test('strict ordinal parsing', function (assert) {
- var i, ordinalStr, testMoment;
- for (i = 1; i <= 31; ++i) {
- ordinalStr = moment([2014, 0, i]).format('YYYY MM Do');
- testMoment = moment(ordinalStr, 'YYYY MM Do', true);
- assert.ok(testMoment.isValid(), 'strict ordinal parsing ' + i);
- }
-});
diff --git a/src/test/locale/en-nz.js b/src/test/locale/en-nz.js
index 5bfa5e5..1f596cf 100644
--- a/src/test/locale/en-nz.js
+++ b/src/test/locale/en-nz.js
@@ -3,7 +3,7 @@
localeModule('en-nz');
test('parse', function (assert) {
- var tests = 'January Jan_February Feb_March Mar_April Apr_May May_June Jun_July Jul_August Aug_September Sept_October Oct_November Nov_December Dec'.split('_'), i;
+ var tests = '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('_'), i;
function equalTest(input, mmm, i) {
assert.equal(moment(input, mmm).month(), i, input + ' should be month ' + (i + 1));
}
@@ -91,7 +91,7 @@
});
test('format month', function (assert) {
- var expected = 'January Jan_February Feb_March Mar_April Apr_May May_June Jun_July Jul_August Aug_September Sept_October Oct_November Nov_December Dec'.split('_'), i;
+ 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('_'), i;
for (i = 0; i < expected.length; i++) {
assert.equal(moment([2011, i, 1]).format('MMMM MMM'), expected[i], expected[i]);
}
@@ -151,14 +151,14 @@
});
test('calendar day', function (assert) {
- var a = moment().hours(2).minutes(0).seconds(0);
-
- assert.equal(moment(a).calendar(), 'Today at 2:00 AM', 'today at the same time');
- assert.equal(moment(a).add({m: 25}).calendar(), 'Today at 2:25 AM', 'Now plus 25 min');
- assert.equal(moment(a).add({h: 1}).calendar(), 'Today at 3:00 AM', 'Now plus 1 hour');
- assert.equal(moment(a).add({d: 1}).calendar(), 'Tomorrow at 2:00 AM', 'tomorrow at the same time');
- assert.equal(moment(a).subtract({h: 1}).calendar(), 'Today at 1:00 AM', 'Now minus 1 hour');
- assert.equal(moment(a).subtract({d: 1}).calendar(), 'Yesterday at 2:00 AM', 'yesterday at the same time');
+ var a = moment().hours(12).minutes(0).seconds(0);
+
+ assert.equal(moment(a).calendar(), 'Today at 12:00 PM', 'today at the same time');
+ assert.equal(moment(a).add({m: 25}).calendar(), 'Today at 12:25 PM', 'Now plus 25 min');
+ assert.equal(moment(a).add({h: 1}).calendar(), 'Today at 1:00 PM', 'Now plus 1 hour');
+ assert.equal(moment(a).add({d: 1}).calendar(), 'Tomorrow at 12:00 PM', 'tomorrow at the same time');
+ assert.equal(moment(a).subtract({h: 1}).calendar(), 'Today at 11:00 AM', 'Now minus 1 hour');
+ assert.equal(moment(a).subtract({d: 1}).calendar(), 'Yesterday at 12:00 PM', 'yesterday at the same time');
});
test('calendar next week', function (assert) {
@@ -200,67 +200,6 @@
assert.equal(weeksFromNow.calendar(), weeksFromNow.format('L'), 'in 2 weeks');
});
-test('weeks year starting sunday', function (assert) {
- assert.equal(moment([2012, 0, 1]).week(), 52, 'Jan 1 2012 should be week 52');
- assert.equal(moment([2012, 0, 2]).week(), 1, 'Jan 2 2012 should be week 1');
- assert.equal(moment([2012, 0, 8]).week(), 1, 'Jan 8 2012 should be week 1');
- assert.equal(moment([2012, 0, 9]).week(), 2, 'Jan 9 2012 should be week 2');
- assert.equal(moment([2012, 0, 15]).week(), 2, 'Jan 15 2012 should be week 2');
-});
-
-test('weeks year starting monday', function (assert) {
- assert.equal(moment([2007, 0, 1]).week(), 1, 'Jan 1 2007 should be week 1');
- assert.equal(moment([2007, 0, 7]).week(), 1, 'Jan 7 2007 should be week 1');
- assert.equal(moment([2007, 0, 8]).week(), 2, 'Jan 8 2007 should be week 2');
- assert.equal(moment([2007, 0, 14]).week(), 2, 'Jan 14 2007 should be week 2');
- assert.equal(moment([2007, 0, 15]).week(), 3, 'Jan 15 2007 should be week 3');
-});
-
-test('weeks year starting tuesday', function (assert) {
- assert.equal(moment([2007, 11, 31]).week(), 1, 'Dec 31 2007 should be week 1');
- assert.equal(moment([2008, 0, 1]).week(), 1, 'Jan 1 2008 should be week 1');
- assert.equal(moment([2008, 0, 6]).week(), 1, 'Jan 6 2008 should be week 1');
- assert.equal(moment([2008, 0, 7]).week(), 2, 'Jan 7 2008 should be week 2');
- assert.equal(moment([2008, 0, 13]).week(), 2, 'Jan 13 2008 should be week 2');
- assert.equal(moment([2008, 0, 14]).week(), 3, 'Jan 14 2008 should be week 3');
-});
-
-test('weeks year starting wednesday', function (assert) {
- assert.equal(moment([2002, 11, 30]).week(), 1, 'Dec 30 2002 should be week 1');
- assert.equal(moment([2003, 0, 1]).week(), 1, 'Jan 1 2003 should be week 1');
- assert.equal(moment([2003, 0, 5]).week(), 1, 'Jan 5 2003 should be week 1');
- assert.equal(moment([2003, 0, 6]).week(), 2, 'Jan 6 2003 should be week 2');
- assert.equal(moment([2003, 0, 12]).week(), 2, 'Jan 12 2003 should be week 2');
- assert.equal(moment([2003, 0, 13]).week(), 3, 'Jan 13 2003 should be week 3');
-});
-
-test('weeks year starting thursday', function (assert) {
- assert.equal(moment([2008, 11, 29]).week(), 1, 'Dec 29 2008 should be week 1');
- assert.equal(moment([2009, 0, 1]).week(), 1, 'Jan 1 2009 should be week 1');
- assert.equal(moment([2009, 0, 4]).week(), 1, 'Jan 4 2009 should be week 1');
- assert.equal(moment([2009, 0, 5]).week(), 2, 'Jan 5 2009 should be week 2');
- assert.equal(moment([2009, 0, 11]).week(), 2, 'Jan 11 2009 should be week 2');
- assert.equal(moment([2009, 0, 13]).week(), 3, 'Jan 12 2009 should be week 3');
-});
-
-test('weeks year starting friday', function (assert) {
- assert.equal(moment([2009, 11, 28]).week(), 53, 'Dec 28 2009 should be week 53');
- assert.equal(moment([2010, 0, 1]).week(), 53, 'Jan 1 2010 should be week 53');
- assert.equal(moment([2010, 0, 3]).week(), 53, 'Jan 3 2010 should be week 53');
- assert.equal(moment([2010, 0, 4]).week(), 1, 'Jan 4 2010 should be week 1');
- assert.equal(moment([2010, 0, 10]).week(), 1, 'Jan 10 2010 should be week 1');
- assert.equal(moment([2010, 0, 11]).week(), 2, 'Jan 11 2010 should be week 2');
-});
-
-test('weeks year starting saturday', function (assert) {
- assert.equal(moment([2010, 11, 27]).week(), 52, 'Dec 27 2010 should be week 52');
- assert.equal(moment([2011, 0, 1]).week(), 52, 'Jan 1 2011 should be week 52');
- assert.equal(moment([2011, 0, 2]).week(), 52, 'Jan 2 2011 should be week 52');
- assert.equal(moment([2011, 0, 3]).week(), 1, 'Jan 3 2011 should be week 1');
- assert.equal(moment([2011, 0, 9]).week(), 1, 'Jan 9 2011 should be week 1');
- assert.equal(moment([2011, 0, 10]).week(), 2, 'Jan 10 2011 should be week 2');
-});
-
test('weeks year starting sunday formatted', function (assert) {
assert.equal(moment([2012, 0, 1]).format('w ww wo'), '52 52 52nd', 'Jan 1 2012 should be week 52');
assert.equal(moment([2012, 0, 2]).format('w ww wo'), '1 01 1st', 'Jan 2 2012 should be week 1');
@@ -268,30 +207,3 @@
assert.equal(moment([2012, 0, 9]).format('w ww wo'), '2 02 2nd', 'Jan 9 2012 should be week 2');
assert.equal(moment([2012, 0, 15]).format('w ww wo'), '2 02 2nd', 'Jan 15 2012 should be week 2');
});
-
-test('lenient ordinal parsing', function (assert) {
- var i, ordinalStr, testStr;
- for (i = 1; i <= 31; ++i) {
- ordinalStr = moment([2014, 0, i]).format('YYYY MM Do');
- testStr = moment(ordinalStr, 'YYYY MM Do').format('YYYY MM D');
- assert.equal(testStr, '2014 01 ' + i, 'lenient ordinal parsing ' + i);
- }
-});
-
-test('lenient ordinal parsing of number', function (assert) {
- var i, testStr;
- for (i = 1; i <= 31; ++i) {
- testStr = moment('2014 01 ' + i, 'YYYY MM Do').format('YYYY MM D');
- assert.equal(testStr, '2014 01 ' + i,
- 'lenient ordinal parsing of number ' + i);
- }
-});
-
-test('strict ordinal parsing', function (assert) {
- var i, ordinalStr, testMoment;
- for (i = 1; i <= 31; ++i) {
- ordinalStr = moment([2014, 0, i]).format('YYYY MMM Do');
- testMoment = moment(ordinalStr, 'YYYY MMM Do', true);
- assert.ok(testMoment.isValid(), 'strict ordinal parsing ' + i);
- }
-});
diff --git a/src/test/locale/en.js b/src/test/locale/en.js
index 2b12f9d..b8a16c5 100644
--- a/src/test/locale/en.js
+++ b/src/test/locale/en.js
@@ -4,7 +4,7 @@
test('parse', function (assert) {
var i,
- tests = 'January Jan_February Feb_March Mar_April Apr_May May_June Jun_July Jul_August Aug_September Sept_October Oct_November Nov_December Dec'.split('_');
+ tests = '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('_');
function equalTest(input, mmm, i) {
assert.equal(moment(input, mmm).month(), i, input + ' should be month ' + (i + 1));
@@ -96,7 +96,7 @@
test('format month', function (assert) {
var i,
- expected = 'January Jan_February Feb_March Mar_April Apr_May May_June Jun_July Jul_August Aug_September Sept_October Oct_November Nov_December Dec'.split('_');
+ 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('_');
for (i = 0; i < expected.length; i++) {
assert.equal(moment([2011, i, 1]).format('MMMM MMM'), expected[i], expected[i]);
@@ -160,14 +160,14 @@
});
test('calendar day', function (assert) {
- var a = moment().hours(2).minutes(0).seconds(0);
-
- assert.equal(moment(a).calendar(), 'Today at 2:00 AM', 'today at the same time');
- assert.equal(moment(a).add({m: 25}).calendar(), 'Today at 2:25 AM', 'Now plus 25 min');
- assert.equal(moment(a).add({h: 1}).calendar(), 'Today at 3:00 AM', 'Now plus 1 hour');
- assert.equal(moment(a).add({d: 1}).calendar(), 'Tomorrow at 2:00 AM', 'tomorrow at the same time');
- assert.equal(moment(a).subtract({h: 1}).calendar(), 'Today at 1:00 AM', 'Now minus 1 hour');
- assert.equal(moment(a).subtract({d: 1}).calendar(), 'Yesterday at 2:00 AM', 'yesterday at the same time');
+ var a = moment().hours(12).minutes(0).seconds(0);
+
+ assert.equal(moment(a).calendar(), 'Today at 12:00 PM', 'today at the same time');
+ assert.equal(moment(a).add({m: 25}).calendar(), 'Today at 12:25 PM', 'Now plus 25 min');
+ assert.equal(moment(a).add({h: 1}).calendar(), 'Today at 1:00 PM', 'Now plus 1 hour');
+ assert.equal(moment(a).add({d: 1}).calendar(), 'Tomorrow at 12:00 PM', 'tomorrow at the same time');
+ assert.equal(moment(a).subtract({h: 1}).calendar(), 'Today at 11:00 AM', 'Now minus 1 hour');
+ assert.equal(moment(a).subtract({d: 1}).calendar(), 'Yesterday at 12:00 PM', 'yesterday at the same time');
});
test('calendar next week', function (assert) {
@@ -210,67 +210,6 @@
assert.equal(weeksFromNow.calendar(), weeksFromNow.format('L'), 'in 2 weeks');
});
-test('weeks year starting sunday', function (assert) {
- assert.equal(moment([2012, 0, 1]).week(), 1, 'Jan 1 2012 should be week 1');
- assert.equal(moment([2012, 0, 7]).week(), 1, 'Jan 7 2012 should be week 1');
- assert.equal(moment([2012, 0, 8]).week(), 2, 'Jan 8 2012 should be week 2');
- assert.equal(moment([2012, 0, 14]).week(), 2, 'Jan 14 2012 should be week 2');
- assert.equal(moment([2012, 0, 15]).week(), 3, 'Jan 15 2012 should be week 3');
-});
-
-test('weeks year starting monday', function (assert) {
- assert.equal(moment([2006, 11, 31]).week(), 1, 'Dec 31 2006 should be week 1');
- assert.equal(moment([2007, 0, 1]).week(), 1, 'Jan 1 2007 should be week 1');
- assert.equal(moment([2007, 0, 6]).week(), 1, 'Jan 6 2007 should be week 1');
- assert.equal(moment([2007, 0, 7]).week(), 2, 'Jan 7 2007 should be week 2');
- assert.equal(moment([2007, 0, 13]).week(), 2, 'Jan 13 2007 should be week 2');
- assert.equal(moment([2007, 0, 14]).week(), 3, 'Jan 14 2007 should be week 3');
-});
-
-test('weeks year starting tuesday', function (assert) {
- assert.equal(moment([2007, 11, 29]).week(), 52, 'Dec 29 2007 should be week 52');
- assert.equal(moment([2008, 0, 1]).week(), 1, 'Jan 1 2008 should be week 1');
- assert.equal(moment([2008, 0, 5]).week(), 1, 'Jan 5 2008 should be week 1');
- assert.equal(moment([2008, 0, 6]).week(), 2, 'Jan 6 2008 should be week 2');
- assert.equal(moment([2008, 0, 12]).week(), 2, 'Jan 12 2008 should be week 2');
- assert.equal(moment([2008, 0, 13]).week(), 3, 'Jan 13 2008 should be week 3');
-});
-
-test('weeks year starting wednesday', function (assert) {
- assert.equal(moment([2002, 11, 29]).week(), 1, 'Dec 29 2002 should be week 1');
- assert.equal(moment([2003, 0, 1]).week(), 1, 'Jan 1 2003 should be week 1');
- assert.equal(moment([2003, 0, 4]).week(), 1, 'Jan 4 2003 should be week 1');
- assert.equal(moment([2003, 0, 5]).week(), 2, 'Jan 5 2003 should be week 2');
- assert.equal(moment([2003, 0, 11]).week(), 2, 'Jan 11 2003 should be week 2');
- assert.equal(moment([2003, 0, 12]).week(), 3, 'Jan 12 2003 should be week 3');
-});
-
-test('weeks year starting thursday', function (assert) {
- assert.equal(moment([2008, 11, 28]).week(), 1, 'Dec 28 2008 should be week 1');
- assert.equal(moment([2009, 0, 1]).week(), 1, 'Jan 1 2009 should be week 1');
- assert.equal(moment([2009, 0, 3]).week(), 1, 'Jan 3 2009 should be week 1');
- assert.equal(moment([2009, 0, 4]).week(), 2, 'Jan 4 2009 should be week 2');
- assert.equal(moment([2009, 0, 10]).week(), 2, 'Jan 10 2009 should be week 2');
- assert.equal(moment([2009, 0, 11]).week(), 3, 'Jan 11 2009 should be week 3');
-});
-
-test('weeks year starting friday', function (assert) {
- assert.equal(moment([2009, 11, 27]).week(), 1, 'Dec 27 2009 should be week 1');
- assert.equal(moment([2010, 0, 1]).week(), 1, 'Jan 1 2010 should be week 1');
- assert.equal(moment([2010, 0, 2]).week(), 1, 'Jan 2 2010 should be week 1');
- assert.equal(moment([2010, 0, 3]).week(), 2, 'Jan 3 2010 should be week 2');
- assert.equal(moment([2010, 0, 9]).week(), 2, 'Jan 9 2010 should be week 2');
- assert.equal(moment([2010, 0, 10]).week(), 3, 'Jan 10 2010 should be week 3');
-});
-
-test('weeks year starting saturday', function (assert) {
- assert.equal(moment([2010, 11, 26]).week(), 1, 'Dec 26 2010 should be week 1');
- assert.equal(moment([2011, 0, 1]).week(), 1, 'Jan 1 2011 should be week 1');
- assert.equal(moment([2011, 0, 2]).week(), 2, 'Jan 2 2011 should be week 2');
- assert.equal(moment([2011, 0, 8]).week(), 2, 'Jan 8 2011 should be week 2');
- assert.equal(moment([2011, 0, 9]).week(), 3, 'Jan 9 2011 should be week 3');
-});
-
test('weeks year starting sunday format', function (assert) {
assert.equal(moment([2012, 0, 1]).format('w ww wo'), '1 01 1st', 'Jan 1 2012 should be week 1');
assert.equal(moment([2012, 0, 7]).format('w ww wo'), '1 01 1st', 'Jan 7 2012 should be week 1');
@@ -279,20 +218,6 @@
assert.equal(moment([2012, 0, 15]).format('w ww wo'), '3 03 3rd', 'Jan 15 2012 should be week 3');
});
-test('lenient ordinal parsing', function (assert) {
- var i, ordinalStr, testMoment;
- for (i = 1; i <= 31; ++i) {
- ordinalStr = moment([2014, 0, i]).format('YYYY MM Do');
- testMoment = moment(ordinalStr, 'YYYY MM Do');
- assert.equal(testMoment.year(), 2014,
- 'lenient ordinal parsing ' + i + ' year check');
- assert.equal(testMoment.month(), 0,
- 'lenient ordinal parsing ' + i + ' month check');
- assert.equal(testMoment.date(), i,
- 'lenient ordinal parsing ' + i + ' date check');
- }
-});
-
test('weekdays strict parsing', function (assert) {
var m = moment('2015-01-01T12', moment.ISO_8601, true),
enLocale = moment.localeData('en');
@@ -308,24 +233,3 @@
}
});
-test('lenient ordinal parsing of number', function (assert) {
- var i, testMoment;
- for (i = 1; i <= 31; ++i) {
- testMoment = moment('2014 01 ' + i, 'YYYY MM Do');
- assert.equal(testMoment.year(), 2014,
- 'lenient ordinal parsing of number ' + i + ' year check');
- assert.equal(testMoment.month(), 0,
- 'lenient ordinal parsing of number ' + i + ' month check');
- assert.equal(testMoment.date(), i,
- 'lenient ordinal parsing of number ' + i + ' date check');
- }
-});
-
-test('strict ordinal parsing', function (assert) {
- var i, ordinalStr, testMoment;
- for (i = 1; i <= 31; ++i) {
- ordinalStr = moment([2014, 0, i]).format('YYYY MM Do');
- testMoment = moment(ordinalStr, 'YYYY MM Do', true);
- assert.ok(testMoment.isValid(), 'strict ordinal parsing ' + i);
- }
-});
diff --git a/src/test/locale/eo.js b/src/test/locale/eo.js
index d5c58b3..b0d7993 100644
--- a/src/test/locale/eo.js
+++ b/src/test/locale/eo.js
@@ -151,14 +151,14 @@
});
test('calendar day', function (assert) {
- var a = moment().hours(2).minutes(0).seconds(0);
-
- assert.equal(moment(a).calendar(), 'Hodiaŭ je 02:00', 'today at the same time');
- assert.equal(moment(a).add({m: 25}).calendar(), 'Hodiaŭ je 02:25', 'Now plus 25 min');
- assert.equal(moment(a).add({h: 1}).calendar(), 'Hodiaŭ je 03:00', 'Now plus 1 hour');
- assert.equal(moment(a).add({d: 1}).calendar(), 'Morgaŭ je 02:00', 'tomorrow at the same time');
- assert.equal(moment(a).subtract({h: 1}).calendar(), 'Hodiaŭ je 01:00', 'Now minus 1 hour');
- assert.equal(moment(a).subtract({d: 1}).calendar(), 'Hieraŭ je 02:00', 'yesterday at the same time');
+ var a = moment().hours(12).minutes(0).seconds(0);
+
+ assert.equal(moment(a).calendar(), 'Hodiaŭ je 12:00', 'today at the same time');
+ assert.equal(moment(a).add({m: 25}).calendar(), 'Hodiaŭ je 12:25', 'Now plus 25 min');
+ assert.equal(moment(a).add({h: 1}).calendar(), 'Hodiaŭ je 13:00', 'Now plus 1 hour');
+ assert.equal(moment(a).add({d: 1}).calendar(), 'Morgaŭ je 12:00', 'tomorrow at the same time');
+ assert.equal(moment(a).subtract({h: 1}).calendar(), 'Hodiaŭ je 11:00', 'Now minus 1 hour');
+ assert.equal(moment(a).subtract({d: 1}).calendar(), 'Hieraŭ je 12:00', 'yesterday at the same time');
});
test('calendar next week', function (assert) {
@@ -201,67 +201,6 @@
assert.equal(weeksFromNow.calendar(), weeksFromNow.format('L'), 'in 2 weeks');
});
-test('weeks year starting sunday', function (assert) {
- assert.equal(moment([2011, 11, 26]).week(), 1, 'Dec 26 2011 should be week 1');
- assert.equal(moment([2012, 0, 1]).week(), 1, 'Jan 1 2012 should be week 1');
- assert.equal(moment([2012, 0, 2]).week(), 2, 'Jan 2 2012 should be week 2');
- assert.equal(moment([2012, 0, 8]).week(), 2, 'Jan 8 2012 should be week 2');
- assert.equal(moment([2012, 0, 9]).week(), 3, 'Jan 9 2012 should be week 3');
-});
-
-test('weeks year starting monday', function (assert) {
- assert.equal(moment([2007, 0, 1]).week(), 1, 'Jan 1 2007 should be week 1');
- assert.equal(moment([2007, 0, 7]).week(), 1, 'Jan 7 2007 should be week 1');
- assert.equal(moment([2007, 0, 8]).week(), 2, 'Jan 8 2007 should be week 2');
- assert.equal(moment([2007, 0, 14]).week(), 2, 'Jan 14 2007 should be week 2');
- assert.equal(moment([2007, 0, 15]).week(), 3, 'Jan 15 2007 should be week 3');
-});
-
-test('weeks year starting tuesday', function (assert) {
- assert.equal(moment([2007, 11, 31]).week(), 1, 'Dec 31 2007 should be week 1');
- assert.equal(moment([2008, 0, 1]).week(), 1, 'Jan 1 2008 should be week 1');
- assert.equal(moment([2008, 0, 6]).week(), 1, 'Jan 6 2008 should be week 1');
- assert.equal(moment([2008, 0, 7]).week(), 2, 'Jan 7 2008 should be week 2');
- assert.equal(moment([2008, 0, 13]).week(), 2, 'Jan 13 2008 should be week 2');
- assert.equal(moment([2008, 0, 14]).week(), 3, 'Jan 14 2008 should be week 3');
-});
-
-test('weeks year starting wednesday', function (assert) {
- assert.equal(moment([2002, 11, 30]).week(), 1, 'Dec 30 2002 should be week 1');
- assert.equal(moment([2003, 0, 1]).week(), 1, 'Jan 1 2003 should be week 1');
- assert.equal(moment([2003, 0, 5]).week(), 1, 'Jan 5 2003 should be week 1');
- assert.equal(moment([2003, 0, 6]).week(), 2, 'Jan 6 2003 should be week 2');
- assert.equal(moment([2003, 0, 12]).week(), 2, 'Jan 12 2003 should be week 2');
- assert.equal(moment([2003, 0, 13]).week(), 3, 'Jan 13 2003 should be week 3');
-});
-
-test('weeks year starting thursday', function (assert) {
- assert.equal(moment([2008, 11, 29]).week(), 1, 'Dec 29 2008 should be week 1');
- assert.equal(moment([2009, 0, 1]).week(), 1, 'Jan 1 2009 should be week 1');
- assert.equal(moment([2009, 0, 4]).week(), 1, 'Jan 4 2009 should be week 1');
- assert.equal(moment([2009, 0, 5]).week(), 2, 'Jan 5 2009 should be week 2');
- assert.equal(moment([2009, 0, 11]).week(), 2, 'Jan 11 2009 should be week 2');
- assert.equal(moment([2009, 0, 12]).week(), 3, 'Jan 12 2009 should be week 3');
-});
-
-test('weeks year starting friday', function (assert) {
- assert.equal(moment([2009, 11, 28]).week(), 1, 'Dec 28 2009 should be week 1');
- assert.equal(moment([2010, 0, 1]).week(), 1, 'Jan 1 2010 should be week 1');
- assert.equal(moment([2010, 0, 3]).week(), 1, 'Jan 3 2010 should be week 1');
- assert.equal(moment([2010, 0, 4]).week(), 2, 'Jan 4 2010 should be week 2');
- assert.equal(moment([2010, 0, 10]).week(), 2, 'Jan 10 2010 should be week 2');
- assert.equal(moment([2010, 0, 11]).week(), 3, 'Jan 11 2010 should be week 3');
-});
-
-test('weeks year starting saturday', function (assert) {
- assert.equal(moment([2010, 11, 27]).week(), 1, 'Dec 27 2010 should be week 1');
- assert.equal(moment([2011, 0, 1]).week(), 1, 'Jan 1 2011 should be week 1');
- assert.equal(moment([2011, 0, 2]).week(), 1, 'Jan 2 2011 should be week 1');
- assert.equal(moment([2011, 0, 3]).week(), 2, 'Jan 3 2011 should be week 2');
- assert.equal(moment([2011, 0, 9]).week(), 2, 'Jan 9 2011 should be week 2');
- assert.equal(moment([2011, 0, 10]).week(), 3, 'Jan 10 2011 should be week 3');
-});
-
test('weeks year starting sunday formatted', function (assert) {
assert.equal(moment([2011, 11, 26]).format('w ww wo'), '1 01 1a', 'Dec 26 2011 should be week 1');
assert.equal(moment([2012, 0, 1]).format('w ww wo'), '1 01 1a', 'Jan 1 2012 should be week 1');
@@ -270,38 +209,3 @@
assert.equal(moment([2012, 0, 9]).format('w ww wo'), '3 03 3a', 'Jan 9 2012 should be week 3');
});
-test('lenient ordinal parsing', function (assert) {
- var i, ordinalStr, testMoment;
- for (i = 1; i <= 31; ++i) {
- ordinalStr = moment([2014, 0, i]).format('YYYY MM Do');
- testMoment = moment(ordinalStr, 'YYYY MM Do');
- assert.equal(testMoment.year(), 2014,
- 'lenient ordinal parsing ' + i + ' year check');
- assert.equal(testMoment.month(), 0,
- 'lenient ordinal parsing ' + i + ' month check');
- assert.equal(testMoment.date(), i,
- 'lenient ordinal parsing ' + i + ' date check');
- }
-});
-
-test('lenient ordinal parsing of number', function (assert) {
- var i, testMoment;
- for (i = 1; i <= 31; ++i) {
- testMoment = moment('2014 01 ' + i, 'YYYY MM Do');
- assert.equal(testMoment.year(), 2014,
- 'lenient ordinal parsing of number ' + i + ' year check');
- assert.equal(testMoment.month(), 0,
- 'lenient ordinal parsing of number ' + i + ' month check');
- assert.equal(testMoment.date(), i,
- 'lenient ordinal parsing of number ' + i + ' date check');
- }
-});
-
-test('strict ordinal parsing', function (assert) {
- var i, ordinalStr, testMoment;
- for (i = 1; i <= 31; ++i) {
- ordinalStr = moment([2014, 0, i]).format('YYYY MM Do');
- testMoment = moment(ordinalStr, 'YYYY MM Do', true);
- assert.ok(testMoment.isValid(), 'strict ordinal parsing ' + i);
- }
-});
diff --git a/src/test/locale/es.js b/src/test/locale/es.js
index 5a10c3e..f9ee15c 100644
--- a/src/test/locale/es.js
+++ b/src/test/locale/es.js
@@ -152,15 +152,15 @@
});
test('calendar day', function (assert) {
- var a = moment().hours(2).minutes(0).seconds(0);
-
- assert.equal(moment(a).calendar(), 'hoy a las 2:00', 'today at the same time');
- assert.equal(moment(a).add({m: 25}).calendar(), 'hoy a las 2:25', 'Now plus 25 min');
- assert.equal(moment(a).add({h: 1}).calendar(), 'hoy a las 3:00', 'Now plus 1 hour');
- assert.equal(moment(a).add({d: 1}).calendar(), 'mañana a las 2:00', 'tomorrow at the same time');
- assert.equal(moment(a).add({d: 1, h : -1}).calendar(), 'mañana a la 1:00', 'tomorrow minus 1 hour');
- assert.equal(moment(a).subtract({h: 1}).calendar(), 'hoy a la 1:00', 'Now minus 1 hour');
- assert.equal(moment(a).subtract({d: 1}).calendar(), 'ayer a las 2:00', 'yesterday at the same time');
+ var a = moment().hours(12).minutes(0).seconds(0);
+
+ assert.equal(moment(a).calendar(), 'hoy a las 12:00', 'today at the same time');
+ assert.equal(moment(a).add({m: 25}).calendar(), 'hoy a las 12:25', 'Now plus 25 min');
+ assert.equal(moment(a).add({h: 1}).calendar(), 'hoy a las 13:00', 'Now plus 1 hour');
+ assert.equal(moment(a).add({d: 1}).calendar(), 'mañana a las 12:00', 'tomorrow at the same time');
+ assert.equal(moment(a).add({d: 1, h : -1}).calendar(), 'mañana a las 11:00', 'tomorrow minus 1 hour');
+ assert.equal(moment(a).subtract({h: 1}).calendar(), 'hoy a las 11:00', 'Now minus 1 hour');
+ assert.equal(moment(a).subtract({d: 1}).calendar(), 'ayer a las 12:00', 'yesterday at the same time');
});
test('calendar next week', function (assert) {
@@ -203,67 +203,6 @@
assert.equal(weeksFromNow.calendar(), weeksFromNow.format('L'), 'in 2 weeks');
});
-test('weeks year starting sunday', function (assert) {
- assert.equal(moment([2012, 0, 1]).week(), 52, 'Jan 1 2012 should be week 52');
- assert.equal(moment([2012, 0, 2]).week(), 1, 'Jan 2 2012 should be week 1');
- assert.equal(moment([2012, 0, 8]).week(), 1, 'Jan 8 2012 should be week 1');
- assert.equal(moment([2012, 0, 9]).week(), 2, 'Jan 9 2012 should be week 2');
- assert.equal(moment([2012, 0, 15]).week(), 2, 'Jan 15 2012 should be week 2');
-});
-
-test('weeks year starting monday', function (assert) {
- assert.equal(moment([2007, 0, 1]).week(), 1, 'Jan 1 2007 should be week 1');
- assert.equal(moment([2007, 0, 7]).week(), 1, 'Jan 7 2007 should be week 1');
- assert.equal(moment([2007, 0, 8]).week(), 2, 'Jan 8 2007 should be week 2');
- assert.equal(moment([2007, 0, 14]).week(), 2, 'Jan 14 2007 should be week 2');
- assert.equal(moment([2007, 0, 15]).week(), 3, 'Jan 15 2007 should be week 3');
-});
-
-test('weeks year starting tuesday', function (assert) {
- assert.equal(moment([2007, 11, 31]).week(), 1, 'Dec 31 2007 should be week 1');
- assert.equal(moment([2008, 0, 1]).week(), 1, 'Jan 1 2008 should be week 1');
- assert.equal(moment([2008, 0, 6]).week(), 1, 'Jan 6 2008 should be week 1');
- assert.equal(moment([2008, 0, 7]).week(), 2, 'Jan 7 2008 should be week 2');
- assert.equal(moment([2008, 0, 13]).week(), 2, 'Jan 13 2008 should be week 2');
- assert.equal(moment([2008, 0, 14]).week(), 3, 'Jan 14 2008 should be week 3');
-});
-
-test('weeks year starting wednesday', function (assert) {
- assert.equal(moment([2002, 11, 30]).week(), 1, 'Dec 30 2002 should be week 1');
- assert.equal(moment([2003, 0, 1]).week(), 1, 'Jan 1 2003 should be week 1');
- assert.equal(moment([2003, 0, 5]).week(), 1, 'Jan 5 2003 should be week 1');
- assert.equal(moment([2003, 0, 6]).week(), 2, 'Jan 6 2003 should be week 2');
- assert.equal(moment([2003, 0, 12]).week(), 2, 'Jan 12 2003 should be week 2');
- assert.equal(moment([2003, 0, 13]).week(), 3, 'Jan 13 2003 should be week 3');
-});
-
-test('weeks year starting thursday', function (assert) {
- assert.equal(moment([2008, 11, 29]).week(), 1, 'Dec 29 2008 should be week 1');
- assert.equal(moment([2009, 0, 1]).week(), 1, 'Jan 1 2009 should be week 1');
- assert.equal(moment([2009, 0, 4]).week(), 1, 'Jan 4 2009 should be week 1');
- assert.equal(moment([2009, 0, 5]).week(), 2, 'Jan 5 2009 should be week 2');
- assert.equal(moment([2009, 0, 11]).week(), 2, 'Jan 11 2009 should be week 2');
- assert.equal(moment([2009, 0, 13]).week(), 3, 'Jan 12 2009 should be week 3');
-});
-
-test('weeks year starting friday', function (assert) {
- assert.equal(moment([2009, 11, 28]).week(), 53, 'Dec 28 2009 should be week 53');
- assert.equal(moment([2010, 0, 1]).week(), 53, 'Jan 1 2010 should be week 53');
- assert.equal(moment([2010, 0, 3]).week(), 53, 'Jan 3 2010 should be week 53');
- assert.equal(moment([2010, 0, 4]).week(), 1, 'Jan 4 2010 should be week 1');
- assert.equal(moment([2010, 0, 10]).week(), 1, 'Jan 10 2010 should be week 1');
- assert.equal(moment([2010, 0, 11]).week(), 2, 'Jan 11 2010 should be week 2');
-});
-
-test('weeks year starting saturday', function (assert) {
- assert.equal(moment([2010, 11, 27]).week(), 52, 'Dec 27 2010 should be week 52');
- assert.equal(moment([2011, 0, 1]).week(), 52, 'Jan 1 2011 should be week 52');
- assert.equal(moment([2011, 0, 2]).week(), 52, 'Jan 2 2011 should be week 52');
- assert.equal(moment([2011, 0, 3]).week(), 1, 'Jan 3 2011 should be week 1');
- assert.equal(moment([2011, 0, 9]).week(), 1, 'Jan 9 2011 should be week 1');
- assert.equal(moment([2011, 0, 10]).week(), 2, 'Jan 10 2011 should be week 2');
-});
-
test('weeks year starting sunday formatted', function (assert) {
assert.equal(moment([2012, 0, 1]).format('w ww wo'), '52 52 52º', 'Jan 1 2012 should be week 52');
assert.equal(moment([2012, 0, 2]).format('w ww wo'), '1 01 1º', 'Jan 2 2012 should be week 1');
@@ -272,38 +211,3 @@
assert.equal(moment([2012, 0, 15]).format('w ww wo'), '2 02 2º', 'Jan 15 2012 should be week 2');
});
-test('lenient ordinal parsing', function (assert) {
- var i, ordinalStr, testMoment;
- for (i = 1; i <= 31; ++i) {
- ordinalStr = moment([2014, 0, i]).format('YYYY MM Do');
- testMoment = moment(ordinalStr, 'YYYY MM Do');
- assert.equal(testMoment.year(), 2014,
- 'lenient ordinal parsing ' + i + ' year check');
- assert.equal(testMoment.month(), 0,
- 'lenient ordinal parsing ' + i + ' month check');
- assert.equal(testMoment.date(), i,
- 'lenient ordinal parsing ' + i + ' date check');
- }
-});
-
-test('lenient ordinal parsing of number', function (assert) {
- var i, testMoment;
- for (i = 1; i <= 31; ++i) {
- testMoment = moment('2014 01 ' + i, 'YYYY MM Do');
- assert.equal(testMoment.year(), 2014,
- 'lenient ordinal parsing of number ' + i + ' year check');
- assert.equal(testMoment.month(), 0,
- 'lenient ordinal parsing of number ' + i + ' month check');
- assert.equal(testMoment.date(), i,
- 'lenient ordinal parsing of number ' + i + ' date check');
- }
-});
-
-test('strict ordinal parsing', function (assert) {
- var i, ordinalStr, testMoment;
- for (i = 1; i <= 31; ++i) {
- ordinalStr = moment([2014, 0, i]).format('YYYY MM Do');
- testMoment = moment(ordinalStr, 'YYYY MM Do', true);
- assert.ok(testMoment.isValid(), 'strict ordinal parsing ' + i);
- }
-});
diff --git a/src/test/locale/et.js b/src/test/locale/et.js
index a01a26a..cdccead 100644
--- a/src/test/locale/et.js
+++ b/src/test/locale/et.js
@@ -175,14 +175,14 @@
});
test('calendar day', function (assert) {
- var a = moment().hours(2).minutes(0).seconds(0);
-
- assert.equal(moment(a).calendar(), 'Täna, 2:00', 'today at the same time');
- assert.equal(moment(a).add({m: 25}).calendar(), 'Täna, 2:25', 'Now plus 25 min');
- assert.equal(moment(a).add({h: 1}).calendar(), 'Täna, 3:00', 'Now plus 1 hour');
- assert.equal(moment(a).add({d: 1}).calendar(), 'Homme, 2:00', 'tomorrow at the same time');
- assert.equal(moment(a).subtract({h: 1}).calendar(), 'Täna, 1:00', 'Now minus 1 hour');
- assert.equal(moment(a).subtract({d: 1}).calendar(), 'Eile, 2:00', 'yesterday at the same time');
+ var a = moment().hours(12).minutes(0).seconds(0);
+
+ assert.equal(moment(a).calendar(), 'Täna, 12:00', 'today at the same time');
+ assert.equal(moment(a).add({m: 25}).calendar(), 'Täna, 12:25', 'Now plus 25 min');
+ assert.equal(moment(a).add({h: 1}).calendar(), 'Täna, 13:00', 'Now plus 1 hour');
+ assert.equal(moment(a).add({d: 1}).calendar(), 'Homme, 12:00', 'tomorrow at the same time');
+ assert.equal(moment(a).subtract({h: 1}).calendar(), 'Täna, 11:00', 'Now minus 1 hour');
+ assert.equal(moment(a).subtract({d: 1}).calendar(), 'Eile, 12:00', 'yesterday at the same time');
});
test('calendar next week', function (assert) {
@@ -223,67 +223,6 @@
assert.equal(weeksFromNow.calendar(), weeksFromNow.format('L'), '2 nädala pärast');
});
-test('weeks year starting sunday', function (assert) {
- assert.equal(moment([2012, 0, 1]).week(), 52, 'Jan 1 2012 should be week 52');
- assert.equal(moment([2012, 0, 2]).week(), 1, 'Jan 2 2012 should be week 1');
- assert.equal(moment([2012, 0, 8]).week(), 1, 'Jan 8 2012 should be week 1');
- assert.equal(moment([2012, 0, 9]).week(), 2, 'Jan 9 2012 should be week 2');
- assert.equal(moment([2012, 0, 15]).week(), 2, 'Jan 15 2012 should be week 2');
-});
-
-test('weeks year starting monday', function (assert) {
- assert.equal(moment([2007, 0, 1]).week(), 1, 'Jan 1 2007 should be week 1');
- assert.equal(moment([2007, 0, 7]).week(), 1, 'Jan 7 2007 should be week 1');
- assert.equal(moment([2007, 0, 8]).week(), 2, 'Jan 8 2007 should be week 2');
- assert.equal(moment([2007, 0, 14]).week(), 2, 'Jan 14 2007 should be week 2');
- assert.equal(moment([2007, 0, 15]).week(), 3, 'Jan 15 2007 should be week 3');
-});
-
-test('weeks year starting tuesday', function (assert) {
- assert.equal(moment([2007, 11, 31]).week(), 1, 'Dec 31 2007 should be week 1');
- assert.equal(moment([2008, 0, 1]).week(), 1, 'Jan 1 2008 should be week 1');
- assert.equal(moment([2008, 0, 6]).week(), 1, 'Jan 6 2008 should be week 1');
- assert.equal(moment([2008, 0, 7]).week(), 2, 'Jan 7 2008 should be week 2');
- assert.equal(moment([2008, 0, 13]).week(), 2, 'Jan 13 2008 should be week 2');
- assert.equal(moment([2008, 0, 14]).week(), 3, 'Jan 14 2008 should be week 3');
-});
-
-test('weeks year starting wednesday', function (assert) {
- assert.equal(moment([2002, 11, 30]).week(), 1, 'Dec 30 2002 should be week 1');
- assert.equal(moment([2003, 0, 1]).week(), 1, 'Jan 1 2003 should be week 1');
- assert.equal(moment([2003, 0, 5]).week(), 1, 'Jan 5 2003 should be week 1');
- assert.equal(moment([2003, 0, 6]).week(), 2, 'Jan 6 2003 should be week 2');
- assert.equal(moment([2003, 0, 12]).week(), 2, 'Jan 12 2003 should be week 2');
- assert.equal(moment([2003, 0, 13]).week(), 3, 'Jan 13 2003 should be week 3');
-});
-
-test('weeks year starting thursday', function (assert) {
- assert.equal(moment([2008, 11, 29]).week(), 1, 'Dec 29 2008 should be week 1');
- assert.equal(moment([2009, 0, 1]).week(), 1, 'Jan 1 2009 should be week 1');
- assert.equal(moment([2009, 0, 4]).week(), 1, 'Jan 4 2009 should be week 1');
- assert.equal(moment([2009, 0, 5]).week(), 2, 'Jan 5 2009 should be week 2');
- assert.equal(moment([2009, 0, 11]).week(), 2, 'Jan 11 2009 should be week 2');
- assert.equal(moment([2009, 0, 13]).week(), 3, 'Jan 12 2009 should be week 3');
-});
-
-test('weeks year starting friday', function (assert) {
- assert.equal(moment([2009, 11, 28]).week(), 53, 'Dec 28 2009 should be week 53');
- assert.equal(moment([2010, 0, 1]).week(), 53, 'Jan 1 2010 should be week 53');
- assert.equal(moment([2010, 0, 3]).week(), 53, 'Jan 3 2010 should be week 53');
- assert.equal(moment([2010, 0, 4]).week(), 1, 'Jan 4 2010 should be week 1');
- assert.equal(moment([2010, 0, 10]).week(), 1, 'Jan 10 2010 should be week 1');
- assert.equal(moment([2010, 0, 11]).week(), 2, 'Jan 11 2010 should be week 2');
-});
-
-test('weeks year starting saturday', function (assert) {
- assert.equal(moment([2010, 11, 27]).week(), 52, 'Dec 27 2010 should be week 52');
- assert.equal(moment([2011, 0, 1]).week(), 52, 'Jan 1 2011 should be week 52');
- assert.equal(moment([2011, 0, 2]).week(), 52, 'Jan 2 2011 should be week 52');
- assert.equal(moment([2011, 0, 3]).week(), 1, 'Jan 3 2011 should be week 1');
- assert.equal(moment([2011, 0, 9]).week(), 1, 'Jan 9 2011 should be week 1');
- assert.equal(moment([2011, 0, 10]).week(), 2, 'Jan 10 2011 should be week 2');
-});
-
test('weeks year starting sunday formatted', function (assert) {
assert.equal(moment([2012, 0, 1]).format('w ww wo'), '52 52 52.', 'Jan 1 2012 should be week 52');
assert.equal(moment([2012, 0, 2]).format('w ww wo'), '1 01 1.', 'Jan 2 2012 should be week 1');
@@ -292,38 +231,3 @@
assert.equal(moment([2012, 0, 15]).format('w ww wo'), '2 02 2.', 'Jan 15 2012 should be week 2');
});
-test('lenient ordinal parsing', function (assert) {
- var i, ordinalStr, testMoment;
- for (i = 1; i <= 31; ++i) {
- ordinalStr = moment([2014, 0, i]).format('YYYY MM Do');
- testMoment = moment(ordinalStr, 'YYYY MM Do');
- assert.equal(testMoment.year(), 2014,
- 'lenient ordinal parsing ' + i + ' year check');
- assert.equal(testMoment.month(), 0,
- 'lenient ordinal parsing ' + i + ' month check');
- assert.equal(testMoment.date(), i,
- 'lenient ordinal parsing ' + i + ' date check');
- }
-});
-
-test('lenient ordinal parsing of number', function (assert) {
- var i, testMoment;
- for (i = 1; i <= 31; ++i) {
- testMoment = moment('2014 01 ' + i, 'YYYY MM Do');
- assert.equal(testMoment.year(), 2014,
- 'lenient ordinal parsing of number ' + i + ' year check');
- assert.equal(testMoment.month(), 0,
- 'lenient ordinal parsing of number ' + i + ' month check');
- assert.equal(testMoment.date(), i,
- 'lenient ordinal parsing of number ' + i + ' date check');
- }
-});
-
-test('strict ordinal parsing', function (assert) {
- var i, ordinalStr, testMoment;
- for (i = 1; i <= 31; ++i) {
- ordinalStr = moment([2014, 0, i]).format('YYYY MM Do');
- testMoment = moment(ordinalStr, 'YYYY MM Do', true);
- assert.ok(testMoment.isValid(), 'strict ordinal parsing ' + i);
- }
-});
diff --git a/src/test/locale/eu.js b/src/test/locale/eu.js
index 171b85e..c848232 100644
--- a/src/test/locale/eu.js
+++ b/src/test/locale/eu.js
@@ -151,14 +151,14 @@
});
test('calendar day', function (assert) {
- var a = moment().hours(2).minutes(0).seconds(0);
-
- assert.equal(moment(a).calendar(), 'gaur 02:00etan', 'today at the same time');
- assert.equal(moment(a).add({m: 25}).calendar(), 'gaur 02:25etan', 'now plus 25 min');
- assert.equal(moment(a).add({h: 1}).calendar(), 'gaur 03:00etan', 'now plus 1 hour');
- assert.equal(moment(a).add({d: 1}).calendar(), 'bihar 02:00etan', 'tomorrow at the same time');
- assert.equal(moment(a).subtract({h: 1}).calendar(), 'gaur 01:00etan', 'now minus 1 hour');
- assert.equal(moment(a).subtract({d: 1}).calendar(), 'atzo 02:00etan', 'yesterday at the same time');
+ var a = moment().hours(12).minutes(0).seconds(0);
+
+ assert.equal(moment(a).calendar(), 'gaur 12:00etan', 'today at the same time');
+ assert.equal(moment(a).add({m: 25}).calendar(), 'gaur 12:25etan', 'now plus 25 min');
+ assert.equal(moment(a).add({h: 1}).calendar(), 'gaur 13:00etan', 'now plus 1 hour');
+ assert.equal(moment(a).add({d: 1}).calendar(), 'bihar 12:00etan', 'tomorrow at the same time');
+ assert.equal(moment(a).subtract({h: 1}).calendar(), 'gaur 11:00etan', 'now minus 1 hour');
+ assert.equal(moment(a).subtract({d: 1}).calendar(), 'atzo 12:00etan', 'yesterday at the same time');
});
test('calendar next week', function (assert) {
@@ -199,67 +199,6 @@
assert.equal(weeksFromNow.calendar(), weeksFromNow.format('L'), 'in 2 weeks');
});
-test('weeks year starting sunday', function (assert) {
- assert.equal(moment([2011, 11, 26]).week(), 1, 'Dec 26 2011 should be week 1');
- assert.equal(moment([2012, 0, 1]).week(), 1, 'Jan 1 2012 should be week 1');
- assert.equal(moment([2012, 0, 2]).week(), 2, 'Jan 2 2012 should be week 2');
- assert.equal(moment([2012, 0, 8]).week(), 2, 'Jan 8 2012 should be week 2');
- assert.equal(moment([2012, 0, 9]).week(), 3, 'Jan 9 2012 should be week 3');
-});
-
-test('weeks year starting monday', function (assert) {
- assert.equal(moment([2007, 0, 1]).week(), 1, 'Jan 1 2007 should be week 1');
- assert.equal(moment([2007, 0, 7]).week(), 1, 'Jan 7 2007 should be week 1');
- assert.equal(moment([2007, 0, 8]).week(), 2, 'Jan 8 2007 should be week 2');
- assert.equal(moment([2007, 0, 14]).week(), 2, 'Jan 14 2007 should be week 2');
- assert.equal(moment([2007, 0, 15]).week(), 3, 'Jan 15 2007 should be week 3');
-});
-
-test('weeks year starting tuesday', function (assert) {
- assert.equal(moment([2007, 11, 31]).week(), 1, 'Dec 31 2007 should be week 1');
- assert.equal(moment([2008, 0, 1]).week(), 1, 'Jan 1 2008 should be week 1');
- assert.equal(moment([2008, 0, 6]).week(), 1, 'Jan 6 2008 should be week 1');
- assert.equal(moment([2008, 0, 7]).week(), 2, 'Jan 7 2008 should be week 2');
- assert.equal(moment([2008, 0, 13]).week(), 2, 'Jan 13 2008 should be week 2');
- assert.equal(moment([2008, 0, 14]).week(), 3, 'Jan 14 2008 should be week 3');
-});
-
-test('weeks year starting wednesday', function (assert) {
- assert.equal(moment([2002, 11, 30]).week(), 1, 'Dec 30 2002 should be week 1');
- assert.equal(moment([2003, 0, 1]).week(), 1, 'Jan 1 2003 should be week 1');
- assert.equal(moment([2003, 0, 5]).week(), 1, 'Jan 5 2003 should be week 1');
- assert.equal(moment([2003, 0, 6]).week(), 2, 'Jan 6 2003 should be week 2');
- assert.equal(moment([2003, 0, 12]).week(), 2, 'Jan 12 2003 should be week 2');
- assert.equal(moment([2003, 0, 13]).week(), 3, 'Jan 13 2003 should be week 3');
-});
-
-test('weeks year starting thursday', function (assert) {
- assert.equal(moment([2008, 11, 29]).week(), 1, 'Dec 29 2008 should be week 1');
- assert.equal(moment([2009, 0, 1]).week(), 1, 'Jan 1 2009 should be week 1');
- assert.equal(moment([2009, 0, 4]).week(), 1, 'Jan 4 2009 should be week 1');
- assert.equal(moment([2009, 0, 5]).week(), 2, 'Jan 5 2009 should be week 2');
- assert.equal(moment([2009, 0, 11]).week(), 2, 'Jan 11 2009 should be week 2');
- assert.equal(moment([2009, 0, 12]).week(), 3, 'Jan 12 2009 should be week 3');
-});
-
-test('weeks year starting friday', function (assert) {
- assert.equal(moment([2009, 11, 28]).week(), 1, 'Dec 28 2009 should be week 1');
- assert.equal(moment([2010, 0, 1]).week(), 1, 'Jan 1 2010 should be week 1');
- assert.equal(moment([2010, 0, 3]).week(), 1, 'Jan 3 2010 should be week 1');
- assert.equal(moment([2010, 0, 4]).week(), 2, 'Jan 4 2010 should be week 2');
- assert.equal(moment([2010, 0, 10]).week(), 2, 'Jan 10 2010 should be week 2');
- assert.equal(moment([2010, 0, 11]).week(), 3, 'Jan 11 2010 should be week 3');
-});
-
-test('weeks year starting saturday', function (assert) {
- assert.equal(moment([2010, 11, 27]).week(), 1, 'Dec 27 2010 should be week 1');
- assert.equal(moment([2011, 0, 1]).week(), 1, 'Jan 1 2011 should be week 1');
- assert.equal(moment([2011, 0, 2]).week(), 1, 'Jan 2 2011 should be week 1');
- assert.equal(moment([2011, 0, 3]).week(), 2, 'Jan 3 2011 should be week 2');
- assert.equal(moment([2011, 0, 9]).week(), 2, 'Jan 9 2011 should be week 2');
- assert.equal(moment([2011, 0, 10]).week(), 3, 'Jan 10 2011 should be week 3');
-});
-
test('weeks year starting sunday formatted', function (assert) {
assert.equal(moment([2011, 11, 26]).format('w ww wo'), '1 01 1.', 'Dec 26 2011 should be week 1');
assert.equal(moment([2012, 0, 1]).format('w ww wo'), '1 01 1.', 'Jan 1 2012 should be week 1');
@@ -268,38 +207,3 @@
assert.equal(moment([2012, 0, 9]).format('w ww wo'), '3 03 3.', 'Jan 9 2012 should be week 3');
});
-test('lenient ordinal parsing', function (assert) {
- var i, ordinalStr, testMoment;
- for (i = 1; i <= 31; ++i) {
- ordinalStr = moment([2014, 0, i]).format('YYYY MM Do');
- testMoment = moment(ordinalStr, 'YYYY MM Do');
- assert.equal(testMoment.year(), 2014,
- 'lenient ordinal parsing ' + i + ' year check');
- assert.equal(testMoment.month(), 0,
- 'lenient ordinal parsing ' + i + ' month check');
- assert.equal(testMoment.date(), i,
- 'lenient ordinal parsing ' + i + ' date check');
- }
-});
-
-test('lenient ordinal parsing of number', function (assert) {
- var i, testMoment;
- for (i = 1; i <= 31; ++i) {
- testMoment = moment('2014 01 ' + i, 'YYYY MM Do');
- assert.equal(testMoment.year(), 2014,
- 'lenient ordinal parsing of number ' + i + ' year check');
- assert.equal(testMoment.month(), 0,
- 'lenient ordinal parsing of number ' + i + ' month check');
- assert.equal(testMoment.date(), i,
- 'lenient ordinal parsing of number ' + i + ' date check');
- }
-});
-
-test('strict ordinal parsing', function (assert) {
- var i, ordinalStr, testMoment;
- for (i = 1; i <= 31; ++i) {
- ordinalStr = moment([2014, 0, i]).format('YYYY MM Do');
- testMoment = moment(ordinalStr, 'YYYY MM Do', true);
- assert.ok(testMoment.isValid(), 'strict ordinal parsing ' + i);
- }
-});
diff --git a/src/test/locale/fa.js b/src/test/locale/fa.js
index cc37fbf..63c99bb 100644
--- a/src/test/locale/fa.js
+++ b/src/test/locale/fa.js
@@ -144,14 +144,14 @@
});
test('calendar day', function (assert) {
- var a = moment().hours(2).minutes(0).seconds(0);
-
- assert.equal(moment(a).calendar(), 'امروز ساعت ۰۲:۰۰', 'today at the same time');
- assert.equal(moment(a).add({m: 25}).calendar(), 'امروز ساعت ۰۲:۲۵', 'Now plus 25 min');
- assert.equal(moment(a).add({h: 1}).calendar(), 'امروز ساعت ۰۳:۰۰', 'Now plus 1 hour');
- assert.equal(moment(a).add({d: 1}).calendar(), 'فردا ساعت ۰۲:۰۰', 'tomorrow at the same time');
- assert.equal(moment(a).subtract({h: 1}).calendar(), 'امروز ساعت ۰۱:۰۰', 'Now minus 1 hour');
- assert.equal(moment(a).subtract({d: 1}).calendar(), 'دیروز ساعت ۰۲:۰۰', 'yesterday at the same time');
+ var a = moment().hours(12).minutes(0).seconds(0);
+
+ assert.equal(moment(a).calendar(), 'امروز ساعت ۱۲:۰۰', 'today at the same time');
+ assert.equal(moment(a).add({m: 25}).calendar(), 'امروز ساعت ۱۲:۲۵', 'Now plus 25 min');
+ assert.equal(moment(a).add({h: 1}).calendar(), 'امروز ساعت ۱۳:۰۰', 'Now plus 1 hour');
+ assert.equal(moment(a).add({d: 1}).calendar(), 'فردا ساعت ۱۲:۰۰', 'tomorrow at the same time');
+ assert.equal(moment(a).subtract({h: 1}).calendar(), 'امروز ساعت ۱۱:۰۰', 'Now minus 1 hour');
+ assert.equal(moment(a).subtract({d: 1}).calendar(), 'دیروز ساعت ۱۲:۰۰', 'yesterday at the same time');
});
test('calendar next week', function (assert) {
@@ -192,65 +192,6 @@
assert.equal(weeksFromNow.calendar(), weeksFromNow.format('L'), 'in 2 weeks');
});
-test('weeks year starting sunday', function (assert) {
- assert.equal(moment([2011, 11, 31]).week(), 1, 'Dec 31 2011 should be week 1');
- assert.equal(moment([2012, 0, 6]).week(), 1, 'Jan 6 2012 should be week 1');
- assert.equal(moment([2012, 0, 7]).week(), 2, 'Jan 7 2012 should be week 2');
- assert.equal(moment([2012, 0, 13]).week(), 2, 'Jan 13 2012 should be week 2');
- assert.equal(moment([2012, 0, 14]).week(), 3, 'Jan 14 2012 should be week 3');
-});
-
-test('weeks year starting monday', function (assert) {
- assert.equal(moment([2006, 11, 30]).week(), 1, 'Dec 30 2006 should be week 1');
- assert.equal(moment([2007, 0, 5]).week(), 1, 'Jan 5 2007 should be week 1');
- assert.equal(moment([2007, 0, 6]).week(), 2, 'Jan 6 2007 should be week 2');
- assert.equal(moment([2007, 0, 12]).week(), 2, 'Jan 12 2007 should be week 2');
- assert.equal(moment([2007, 0, 13]).week(), 3, 'Jan 13 2007 should be week 3');
-});
-
-test('weeks year starting tuesday', function (assert) {
- assert.equal(moment([2007, 11, 29]).week(), 1, 'Dec 29 2007 should be week 1');
- assert.equal(moment([2008, 0, 1]).week(), 1, 'Jan 1 2008 should be week 1');
- assert.equal(moment([2008, 0, 4]).week(), 1, 'Jan 4 2008 should be week 1');
- assert.equal(moment([2008, 0, 5]).week(), 2, 'Jan 5 2008 should be week 2');
- assert.equal(moment([2008, 0, 11]).week(), 2, 'Jan 11 2008 should be week 2');
- assert.equal(moment([2008, 0, 12]).week(), 3, 'Jan 12 2008 should be week 3');
-});
-
-test('weeks year starting wednesday', function (assert) {
- assert.equal(moment([2002, 11, 28]).week(), 1, 'Dec 28 2002 should be week 1');
- assert.equal(moment([2003, 0, 1]).week(), 1, 'Jan 1 2003 should be week 1');
- assert.equal(moment([2003, 0, 3]).week(), 1, 'Jan 3 2003 should be week 1');
- assert.equal(moment([2003, 0, 4]).week(), 2, 'Jan 4 2003 should be week 2');
- assert.equal(moment([2003, 0, 10]).week(), 2, 'Jan 10 2003 should be week 2');
- assert.equal(moment([2003, 0, 11]).week(), 3, 'Jan 11 2003 should be week 3');
-});
-
-test('weeks year starting thursday', function (assert) {
- assert.equal(moment([2008, 11, 27]).week(), 1, 'Dec 27 2008 should be week 1');
- assert.equal(moment([2009, 0, 1]).week(), 1, 'Jan 1 2009 should be week 1');
- assert.equal(moment([2009, 0, 2]).week(), 1, 'Jan 2 2009 should be week 1');
- assert.equal(moment([2009, 0, 3]).week(), 2, 'Jan 3 2009 should be week 2');
- assert.equal(moment([2009, 0, 9]).week(), 2, 'Jan 9 2009 should be week 2');
- assert.equal(moment([2009, 0, 10]).week(), 3, 'Jan 10 2009 should be week 3');
-});
-
-test('weeks year starting friday', function (assert) {
- assert.equal(moment([2009, 11, 26]).week(), 1, 'Dec 26 2009 should be week 1');
- assert.equal(moment([2010, 0, 1]).week(), 1, 'Jan 1 2010 should be week 1');
- assert.equal(moment([2010, 0, 2]).week(), 2, 'Jan 2 2010 should be week 2');
- assert.equal(moment([2010, 0, 8]).week(), 2, 'Jan 8 2010 should be week 2');
- assert.equal(moment([2010, 0, 9]).week(), 3, 'Jan 9 2010 should be week 3');
-});
-
-test('weeks year starting saturday', function (assert) {
- assert.equal(moment([2011, 0, 1]).week(), 1, 'Jan 1 2011 should be week 1');
- assert.equal(moment([2011, 0, 7]).week(), 1, 'Jan 7 2011 should be week 1');
- assert.equal(moment([2011, 0, 8]).week(), 2, 'Jan 8 2011 should be week 2');
- assert.equal(moment([2011, 0, 14]).week(), 2, 'Jan 14 2011 should be week 2');
- assert.equal(moment([2011, 0, 15]).week(), 3, 'Jan 15 2011 should be week 3');
-});
-
test('weeks year starting sunday formatted', function (assert) {
assert.equal(moment([2011, 11, 31]).format('w ww wo'), '۱ ۰۱ ۱م', 'Dec 31 2011 should be week 1');
assert.equal(moment([2012, 0, 6]).format('w ww wo'), '۱ ۰۱ ۱م', 'Jan 6 2012 should be week 1');
@@ -259,38 +200,3 @@
assert.equal(moment([2012, 0, 14]).format('w ww wo'), '۳ ۰۳ ۳م', 'Jan 14 2012 should be week 3');
});
-test('lenient ordinal parsing', function (assert) {
- var i, ordinalStr, testMoment;
- for (i = 1; i <= 31; ++i) {
- ordinalStr = moment([2014, 0, i]).format('YYYY MM Do');
- testMoment = moment(ordinalStr, 'YYYY MM Do');
- assert.equal(testMoment.year(), 2014,
- 'lenient ordinal parsing ' + i + ' year check');
- assert.equal(testMoment.month(), 0,
- 'lenient ordinal parsing ' + i + ' month check');
- assert.equal(testMoment.date(), i,
- 'lenient ordinal parsing ' + i + ' date check');
- }
-});
-
-test('lenient ordinal parsing of number', function (assert) {
- var i, testMoment;
- for (i = 1; i <= 31; ++i) {
- testMoment = moment('2014 01 ' + i, 'YYYY MM Do');
- assert.equal(testMoment.year(), 2014,
- 'lenient ordinal parsing of number ' + i + ' year check');
- assert.equal(testMoment.month(), 0,
- 'lenient ordinal parsing of number ' + i + ' month check');
- assert.equal(testMoment.date(), i,
- 'lenient ordinal parsing of number ' + i + ' date check');
- }
-});
-
-test('strict ordinal parsing', function (assert) {
- var i, ordinalStr, testMoment;
- for (i = 1; i <= 31; ++i) {
- ordinalStr = moment([2014, 0, i]).format('YYYY MM Do');
- testMoment = moment(ordinalStr, 'YYYY MM Do', true);
- assert.ok(testMoment.isValid(), 'strict ordinal parsing ' + i);
- }
-});
diff --git a/src/test/locale/fi.js b/src/test/locale/fi.js
index 86f9b3f..78b67d6 100644
--- a/src/test/locale/fi.js
+++ b/src/test/locale/fi.js
@@ -151,14 +151,14 @@
});
test('calendar day', function (assert) {
- var a = moment().hours(2).minutes(0).seconds(0);
-
- assert.equal(moment(a).calendar(), 'tänään klo 02.00', 'today at the same time');
- assert.equal(moment(a).add({m: 25}).calendar(), 'tänään klo 02.25', 'Now plus 25 min');
- assert.equal(moment(a).add({h: 1}).calendar(), 'tänään klo 03.00', 'Now plus 1 hour');
- assert.equal(moment(a).add({d: 1}).calendar(), 'huomenna klo 02.00', 'tomorrow at the same time');
- assert.equal(moment(a).subtract({h: 1}).calendar(), 'tänään klo 01.00', 'Now minus 1 hour');
- assert.equal(moment(a).subtract({d: 1}).calendar(), 'eilen klo 02.00', 'yesterday at the same time');
+ var a = moment().hours(12).minutes(0).seconds(0);
+
+ assert.equal(moment(a).calendar(), 'tänään klo 12.00', 'today at the same time');
+ assert.equal(moment(a).add({m: 25}).calendar(), 'tänään klo 12.25', 'Now plus 25 min');
+ assert.equal(moment(a).add({h: 1}).calendar(), 'tänään klo 13.00', 'Now plus 1 hour');
+ assert.equal(moment(a).add({d: 1}).calendar(), 'huomenna klo 12.00', 'tomorrow at the same time');
+ assert.equal(moment(a).subtract({h: 1}).calendar(), 'tänään klo 11.00', 'Now minus 1 hour');
+ assert.equal(moment(a).subtract({d: 1}).calendar(), 'eilen klo 12.00', 'yesterday at the same time');
});
test('calendar next week', function (assert) {
@@ -200,67 +200,6 @@
assert.equal(weeksFromNow.calendar(), weeksFromNow.format('L'), 'kaden viikon päästä');
});
-test('weeks year starting sunday', function (assert) {
- assert.equal(moment([2012, 0, 1]).week(), 52, 'Jan 1 2012 should be week 52');
- assert.equal(moment([2012, 0, 2]).week(), 1, 'Jan 2 2012 should be week 1');
- assert.equal(moment([2012, 0, 8]).week(), 1, 'Jan 8 2012 should be week 1');
- assert.equal(moment([2012, 0, 9]).week(), 2, 'Jan 9 2012 should be week 2');
- assert.equal(moment([2012, 0, 15]).week(), 2, 'Jan 15 2012 should be week 2');
-});
-
-test('weeks year starting monday', function (assert) {
- assert.equal(moment([2007, 0, 1]).week(), 1, 'Jan 1 2007 should be week 1');
- assert.equal(moment([2007, 0, 7]).week(), 1, 'Jan 7 2007 should be week 1');
- assert.equal(moment([2007, 0, 8]).week(), 2, 'Jan 8 2007 should be week 2');
- assert.equal(moment([2007, 0, 14]).week(), 2, 'Jan 14 2007 should be week 2');
- assert.equal(moment([2007, 0, 15]).week(), 3, 'Jan 15 2007 should be week 3');
-});
-
-test('weeks year starting tuesday', function (assert) {
- assert.equal(moment([2007, 11, 31]).week(), 1, 'Dec 31 2007 should be week 1');
- assert.equal(moment([2008, 0, 1]).week(), 1, 'Jan 1 2008 should be week 1');
- assert.equal(moment([2008, 0, 6]).week(), 1, 'Jan 6 2008 should be week 1');
- assert.equal(moment([2008, 0, 7]).week(), 2, 'Jan 7 2008 should be week 2');
- assert.equal(moment([2008, 0, 13]).week(), 2, 'Jan 13 2008 should be week 2');
- assert.equal(moment([2008, 0, 14]).week(), 3, 'Jan 14 2008 should be week 3');
-});
-
-test('weeks year starting wednesday', function (assert) {
- assert.equal(moment([2002, 11, 30]).week(), 1, 'Dec 30 2002 should be week 1');
- assert.equal(moment([2003, 0, 1]).week(), 1, 'Jan 1 2003 should be week 1');
- assert.equal(moment([2003, 0, 5]).week(), 1, 'Jan 5 2003 should be week 1');
- assert.equal(moment([2003, 0, 6]).week(), 2, 'Jan 6 2003 should be week 2');
- assert.equal(moment([2003, 0, 12]).week(), 2, 'Jan 12 2003 should be week 2');
- assert.equal(moment([2003, 0, 13]).week(), 3, 'Jan 13 2003 should be week 3');
-});
-
-test('weeks year starting thursday', function (assert) {
- assert.equal(moment([2008, 11, 29]).week(), 1, 'Dec 29 2008 should be week 1');
- assert.equal(moment([2009, 0, 1]).week(), 1, 'Jan 1 2009 should be week 1');
- assert.equal(moment([2009, 0, 4]).week(), 1, 'Jan 4 2009 should be week 1');
- assert.equal(moment([2009, 0, 5]).week(), 2, 'Jan 5 2009 should be week 2');
- assert.equal(moment([2009, 0, 11]).week(), 2, 'Jan 11 2009 should be week 2');
- assert.equal(moment([2009, 0, 13]).week(), 3, 'Jan 12 2009 should be week 3');
-});
-
-test('weeks year starting friday', function (assert) {
- assert.equal(moment([2009, 11, 28]).week(), 53, 'Dec 28 2009 should be week 53');
- assert.equal(moment([2010, 0, 1]).week(), 53, 'Jan 1 2010 should be week 53');
- assert.equal(moment([2010, 0, 3]).week(), 53, 'Jan 3 2010 should be week 53');
- assert.equal(moment([2010, 0, 4]).week(), 1, 'Jan 4 2010 should be week 1');
- assert.equal(moment([2010, 0, 10]).week(), 1, 'Jan 10 2010 should be week 1');
- assert.equal(moment([2010, 0, 11]).week(), 2, 'Jan 11 2010 should be week 2');
-});
-
-test('weeks year starting saturday', function (assert) {
- assert.equal(moment([2010, 11, 27]).week(), 52, 'Dec 27 2010 should be week 52');
- assert.equal(moment([2011, 0, 1]).week(), 52, 'Jan 1 2011 should be week 52');
- assert.equal(moment([2011, 0, 2]).week(), 52, 'Jan 2 2011 should be week 52');
- assert.equal(moment([2011, 0, 3]).week(), 1, 'Jan 3 2011 should be week 1');
- assert.equal(moment([2011, 0, 9]).week(), 1, 'Jan 9 2011 should be week 1');
- assert.equal(moment([2011, 0, 10]).week(), 2, 'Jan 10 2011 should be week 2');
-});
-
test('weeks year starting sunday formatted', function (assert) {
assert.equal(moment([2012, 0, 1]).format('w ww wo'), '52 52 52.', 'Jan 1 2012 should be week 52');
assert.equal(moment([2012, 0, 2]).format('w ww wo'), '1 01 1.', 'Jan 2 2012 should be week 1');
@@ -269,38 +208,3 @@
assert.equal(moment([2012, 0, 15]).format('w ww wo'), '2 02 2.', 'Jan 15 2012 should be week 2');
});
-test('lenient ordinal parsing', function (assert) {
- var i, ordinalStr, testMoment;
- for (i = 1; i <= 31; ++i) {
- ordinalStr = moment([2014, 0, i]).format('YYYY MM Do');
- testMoment = moment(ordinalStr, 'YYYY MM Do');
- assert.equal(testMoment.year(), 2014,
- 'lenient ordinal parsing ' + i + ' year check');
- assert.equal(testMoment.month(), 0,
- 'lenient ordinal parsing ' + i + ' month check');
- assert.equal(testMoment.date(), i,
- 'lenient ordinal parsing ' + i + ' date check');
- }
-});
-
-test('lenient ordinal parsing of number', function (assert) {
- var i, testMoment;
- for (i = 1; i <= 31; ++i) {
- testMoment = moment('2014 01 ' + i, 'YYYY MM Do');
- assert.equal(testMoment.year(), 2014,
- 'lenient ordinal parsing of number ' + i + ' year check');
- assert.equal(testMoment.month(), 0,
- 'lenient ordinal parsing of number ' + i + ' month check');
- assert.equal(testMoment.date(), i,
- 'lenient ordinal parsing of number ' + i + ' date check');
- }
-});
-
-test('strict ordinal parsing', function (assert) {
- var i, ordinalStr, testMoment;
- for (i = 1; i <= 31; ++i) {
- ordinalStr = moment([2014, 0, i]).format('YYYY MM Do');
- testMoment = moment(ordinalStr, 'YYYY MM Do', true);
- assert.ok(testMoment.isValid(), 'strict ordinal parsing ' + i);
- }
-});
diff --git a/src/test/locale/fo.js b/src/test/locale/fo.js
index 08668b6..31cc36d 100644
--- a/src/test/locale/fo.js
+++ b/src/test/locale/fo.js
@@ -150,65 +150,55 @@
assert.equal(moment().add({d: 5}).fromNow(), 'um 5 dagar', 'in 5 days');
});
-test('weeks year starting sunday', function (assert) {
- assert.equal(moment([2012, 0, 1]).week(), 52, 'Jan 1 2012 should be week 52');
- assert.equal(moment([2012, 0, 2]).week(), 1, 'Jan 2 2012 should be week 1');
- assert.equal(moment([2012, 0, 8]).week(), 1, 'Jan 8 2012 should be week 1');
- assert.equal(moment([2012, 0, 9]).week(), 2, 'Jan 9 2012 should be week 2');
- assert.equal(moment([2012, 0, 15]).week(), 2, 'Jan 15 2012 should be week 2');
-});
-
-test('weeks year starting monday', function (assert) {
- assert.equal(moment([2007, 0, 1]).week(), 1, 'Jan 1 2007 should be week 1');
- assert.equal(moment([2007, 0, 7]).week(), 1, 'Jan 7 2007 should be week 1');
- assert.equal(moment([2007, 0, 8]).week(), 2, 'Jan 8 2007 should be week 2');
- assert.equal(moment([2007, 0, 14]).week(), 2, 'Jan 14 2007 should be week 2');
- assert.equal(moment([2007, 0, 15]).week(), 3, 'Jan 15 2007 should be week 3');
-});
-
-test('weeks year starting tuesday', function (assert) {
- assert.equal(moment([2007, 11, 31]).week(), 1, 'Dec 31 2007 should be week 1');
- assert.equal(moment([2008, 0, 1]).week(), 1, 'Jan 1 2008 should be week 1');
- assert.equal(moment([2008, 0, 6]).week(), 1, 'Jan 6 2008 should be week 1');
- assert.equal(moment([2008, 0, 7]).week(), 2, 'Jan 7 2008 should be week 2');
- assert.equal(moment([2008, 0, 13]).week(), 2, 'Jan 13 2008 should be week 2');
- assert.equal(moment([2008, 0, 14]).week(), 3, 'Jan 14 2008 should be week 3');
-});
-
-test('weeks year starting wednesday', function (assert) {
- assert.equal(moment([2002, 11, 30]).week(), 1, 'Dec 30 2002 should be week 1');
- assert.equal(moment([2003, 0, 1]).week(), 1, 'Jan 1 2003 should be week 1');
- assert.equal(moment([2003, 0, 5]).week(), 1, 'Jan 5 2003 should be week 1');
- assert.equal(moment([2003, 0, 6]).week(), 2, 'Jan 6 2003 should be week 2');
- assert.equal(moment([2003, 0, 12]).week(), 2, 'Jan 12 2003 should be week 2');
- assert.equal(moment([2003, 0, 13]).week(), 3, 'Jan 13 2003 should be week 3');
-});
-
-test('weeks year starting thursday', function (assert) {
- assert.equal(moment([2008, 11, 29]).week(), 1, 'Dec 29 2008 should be week 1');
- assert.equal(moment([2009, 0, 1]).week(), 1, 'Jan 1 2009 should be week 1');
- assert.equal(moment([2009, 0, 4]).week(), 1, 'Jan 4 2009 should be week 1');
- assert.equal(moment([2009, 0, 5]).week(), 2, 'Jan 5 2009 should be week 2');
- assert.equal(moment([2009, 0, 11]).week(), 2, 'Jan 11 2009 should be week 2');
- assert.equal(moment([2009, 0, 13]).week(), 3, 'Jan 12 2009 should be week 3');
-});
-
-test('weeks year starting friday', function (assert) {
- assert.equal(moment([2009, 11, 28]).week(), 53, 'Dec 28 2009 should be week 53');
- assert.equal(moment([2010, 0, 1]).week(), 53, 'Jan 1 2010 should be week 53');
- assert.equal(moment([2010, 0, 3]).week(), 53, 'Jan 3 2010 should be week 53');
- assert.equal(moment([2010, 0, 4]).week(), 1, 'Jan 4 2010 should be week 1');
- assert.equal(moment([2010, 0, 10]).week(), 1, 'Jan 10 2010 should be week 1');
- assert.equal(moment([2010, 0, 11]).week(), 2, 'Jan 11 2010 should be week 2');
-});
-
-test('weeks year starting saturday', function (assert) {
- assert.equal(moment([2010, 11, 27]).week(), 52, 'Dec 27 2010 should be week 52');
- assert.equal(moment([2011, 0, 1]).week(), 52, 'Jan 1 2011 should be week 52');
- assert.equal(moment([2011, 0, 2]).week(), 52, 'Jan 2 2011 should be week 52');
- assert.equal(moment([2011, 0, 3]).week(), 1, 'Jan 3 2011 should be week 1');
- assert.equal(moment([2011, 0, 9]).week(), 1, 'Jan 9 2011 should be week 1');
- assert.equal(moment([2011, 0, 10]).week(), 2, 'Jan 10 2011 should be week 2');
+
+test('calendar day', function (assert) {
+ var a = moment().hours(12).minutes(0).seconds(0);
+
+ assert.equal(moment(a).calendar(), 'Í dag kl. 12:00', 'today at the same time');
+ assert.equal(moment(a).add({m: 25}).calendar(), 'Í dag kl. 12:25', 'Now plus 25 min');
+ assert.equal(moment(a).add({h: 1}).calendar(), 'Í dag kl. 13:00', 'Now plus 1 hour');
+ assert.equal(moment(a).add({d: 1}).calendar(), 'Í morgin kl. 12:00', 'tomorrow at the same time');
+ assert.equal(moment(a).subtract({h: 1}).calendar(), 'Í dag kl. 11:00', 'Now minus 1 hour');
+ assert.equal(moment(a).subtract({d: 1}).calendar(), 'Í gjár kl. 12:00', 'yesterday at the same time');
+});
+
+test('calendar next week', function (assert) {
+ var i, m;
+
+ for (i = 2; i < 7; i++) {
+ m = moment().add({d: i});
+ assert.equal(m.calendar(), m.format('dddd [kl.] LT'), 'today + ' + i + ' days current time');
+ m.hours(0).minutes(0).seconds(0).milliseconds(0);
+ assert.equal(m.calendar(), m.format('dddd [kl.] LT'), 'today + ' + i + ' days beginning of day');
+ m.hours(23).minutes(59).seconds(59).milliseconds(999);
+ assert.equal(m.calendar(), m.format('dddd [kl.] LT'), 'today + ' + i + ' days end of day');
+ }
+});
+
+test('calendar last week', function (assert) {
+ var i, m;
+ for (i = 2; i < 7; i++) {
+ m = moment().subtract({d: i});
+ assert.equal(m.calendar(), m.format('[síðstu] dddd [kl] LT'), 'today - ' + i + ' days current time');
+ m.hours(0).minutes(0).seconds(0).milliseconds(0);
+ assert.equal(m.calendar(), m.format('[síðstu] dddd [kl] LT'), 'today - ' + i + ' days beginning of day');
+ m.hours(23).minutes(59).seconds(59).milliseconds(999);
+ assert.equal(m.calendar(), m.format('[síðstu] dddd [kl] LT'), 'today - ' + i + ' days end of day');
+ }
+});
+
+test('calendar all else', function (assert) {
+ var weeksAgo = moment().subtract({w: 1}),
+ weeksFromNow = moment().add({w: 1});
+
+ assert.equal(weeksAgo.calendar(), weeksAgo.format('L'), 'yksi viikko sitten');
+ assert.equal(weeksFromNow.calendar(), weeksFromNow.format('L'), 'yhden viikon päästä');
+
+ weeksAgo = moment().subtract({w: 2});
+ weeksFromNow = moment().add({w: 2});
+
+ assert.equal(weeksAgo.calendar(), weeksAgo.format('L'), 'kaksi viikkoa sitten');
+ assert.equal(weeksFromNow.calendar(), weeksFromNow.format('L'), 'kaden viikon päästä');
});
test('weeks year starting sunday formatted', function (assert) {
@@ -219,38 +209,3 @@
assert.equal(moment([2012, 0, 15]).format('w ww wo'), '2 02 2.', 'Jan 15 2012 should be week 2');
});
-test('lenient ordinal parsing', function (assert) {
- var i, ordinalStr, testMoment;
- for (i = 1; i <= 31; ++i) {
- ordinalStr = moment([2014, 0, i]).format('YYYY MM Do');
- testMoment = moment(ordinalStr, 'YYYY MM Do');
- assert.equal(testMoment.year(), 2014,
- 'lenient ordinal parsing ' + i + ' year check');
- assert.equal(testMoment.month(), 0,
- 'lenient ordinal parsing ' + i + ' month check');
- assert.equal(testMoment.date(), i,
- 'lenient ordinal parsing ' + i + ' date check');
- }
-});
-
-test('lenient ordinal parsing of number', function (assert) {
- var i, testMoment;
- for (i = 1; i <= 31; ++i) {
- testMoment = moment('2014 01 ' + i, 'YYYY MM Do');
- assert.equal(testMoment.year(), 2014,
- 'lenient ordinal parsing of number ' + i + ' year check');
- assert.equal(testMoment.month(), 0,
- 'lenient ordinal parsing of number ' + i + ' month check');
- assert.equal(testMoment.date(), i,
- 'lenient ordinal parsing of number ' + i + ' date check');
- }
-});
-
-test('strict ordinal parsing', function (assert) {
- var i, ordinalStr, testMoment;
- for (i = 1; i <= 31; ++i) {
- ordinalStr = moment([2014, 0, i]).format('YYYY MM Do');
- testMoment = moment(ordinalStr, 'YYYY MM Do', true);
- assert.ok(testMoment.isValid(), 'strict ordinal parsing ' + i);
- }
-});
diff --git a/src/test/locale/fr-ca.js b/src/test/locale/fr-ca.js
index 27f9c22..e914460 100644
--- a/src/test/locale/fr-ca.js
+++ b/src/test/locale/fr-ca.js
@@ -156,14 +156,14 @@
});
test('same day', function (assert) {
- var a = moment().hours(2).minutes(0).seconds(0);
-
- assert.equal(moment(a).calendar(), 'Aujourd\'hui à 02:00', 'today at the same time');
- assert.equal(moment(a).add({m: 25}).calendar(), 'Aujourd\'hui à 02:25', 'Now plus 25 min');
- assert.equal(moment(a).add({h: 1}).calendar(), 'Aujourd\'hui à 03:00', 'Now plus 1 hour');
- assert.equal(moment(a).add({d: 1}).calendar(), 'Demain à 02:00', 'tomorrow at the same time');
- assert.equal(moment(a).subtract({h: 1}).calendar(), 'Aujourd\'hui à 01:00', 'Now minus 1 hour');
- assert.equal(moment(a).subtract({d: 1}).calendar(), 'Hier à 02:00', 'yesterday at the same time');
+ var a = moment().hours(12).minutes(0).seconds(0);
+
+ assert.equal(moment(a).calendar(), 'Aujourd\'hui à 12:00', 'today at the same time');
+ assert.equal(moment(a).add({m: 25}).calendar(), 'Aujourd\'hui à 12:25', 'Now plus 25 min');
+ assert.equal(moment(a).add({h: 1}).calendar(), 'Aujourd\'hui à 13:00', 'Now plus 1 hour');
+ assert.equal(moment(a).add({d: 1}).calendar(), 'Demain à 12:00', 'tomorrow at the same time');
+ assert.equal(moment(a).subtract({h: 1}).calendar(), 'Aujourd\'hui à 11:00', 'Now minus 1 hour');
+ assert.equal(moment(a).subtract({d: 1}).calendar(), 'Hier à 12:00', 'yesterday at the same time');
});
test('same next week', function (assert) {
@@ -206,67 +206,6 @@
assert.equal(weeksFromNow.calendar(), weeksFromNow.format('L'), 'in 2 weeks');
});
-test('weeks year starting sunday', function (assert) {
- assert.equal(moment([2012, 0, 1]).week(), 1, 'Jan 1 2012 should be week 1');
- assert.equal(moment([2012, 0, 7]).week(), 1, 'Jan 7 2012 should be week 1');
- assert.equal(moment([2012, 0, 8]).week(), 2, 'Jan 8 2012 should be week 2');
- assert.equal(moment([2012, 0, 14]).week(), 2, 'Jan 14 2012 should be week 2');
- assert.equal(moment([2012, 0, 15]).week(), 3, 'Jan 15 2012 should be week 3');
-});
-
-test('weeks year starting monday', function (assert) {
- assert.equal(moment([2006, 11, 31]).week(), 1, 'Dec 31 2006 should be week 1');
- assert.equal(moment([2007, 0, 1]).week(), 1, 'Jan 1 2007 should be week 1');
- assert.equal(moment([2007, 0, 6]).week(), 1, 'Jan 6 2007 should be week 1');
- assert.equal(moment([2007, 0, 7]).week(), 2, 'Jan 7 2007 should be week 2');
- assert.equal(moment([2007, 0, 13]).week(), 2, 'Jan 13 2007 should be week 2');
- assert.equal(moment([2007, 0, 14]).week(), 3, 'Jan 14 2007 should be week 3');
-});
-
-test('weeks year starting tuesday', function (assert) {
- assert.equal(moment([2007, 11, 29]).week(), 52, 'Dec 29 2007 should be week 52');
- assert.equal(moment([2008, 0, 1]).week(), 1, 'Jan 1 2008 should be week 1');
- assert.equal(moment([2008, 0, 5]).week(), 1, 'Jan 5 2008 should be week 1');
- assert.equal(moment([2008, 0, 6]).week(), 2, 'Jan 6 2008 should be week 2');
- assert.equal(moment([2008, 0, 12]).week(), 2, 'Jan 12 2008 should be week 2');
- assert.equal(moment([2008, 0, 13]).week(), 3, 'Jan 13 2008 should be week 3');
-});
-
-test('weeks year starting wednesday', function (assert) {
- assert.equal(moment([2002, 11, 29]).week(), 1, 'Dec 29 2002 should be week 1');
- assert.equal(moment([2003, 0, 1]).week(), 1, 'Jan 1 2003 should be week 1');
- assert.equal(moment([2003, 0, 4]).week(), 1, 'Jan 4 2003 should be week 1');
- assert.equal(moment([2003, 0, 5]).week(), 2, 'Jan 5 2003 should be week 2');
- assert.equal(moment([2003, 0, 11]).week(), 2, 'Jan 11 2003 should be week 2');
- assert.equal(moment([2003, 0, 12]).week(), 3, 'Jan 12 2003 should be week 3');
-});
-
-test('weeks year starting thursday', function (assert) {
- assert.equal(moment([2008, 11, 28]).week(), 1, 'Dec 28 2008 should be week 1');
- assert.equal(moment([2009, 0, 1]).week(), 1, 'Jan 1 2009 should be week 1');
- assert.equal(moment([2009, 0, 3]).week(), 1, 'Jan 3 2009 should be week 1');
- assert.equal(moment([2009, 0, 4]).week(), 2, 'Jan 4 2009 should be week 2');
- assert.equal(moment([2009, 0, 10]).week(), 2, 'Jan 10 2009 should be week 2');
- assert.equal(moment([2009, 0, 11]).week(), 3, 'Jan 11 2009 should be week 3');
-});
-
-test('weeks year starting friday', function (assert) {
- assert.equal(moment([2009, 11, 27]).week(), 1, 'Dec 27 2009 should be week 1');
- assert.equal(moment([2010, 0, 1]).week(), 1, 'Jan 1 2010 should be week 1');
- assert.equal(moment([2010, 0, 2]).week(), 1, 'Jan 2 2010 should be week 1');
- assert.equal(moment([2010, 0, 3]).week(), 2, 'Jan 3 2010 should be week 2');
- assert.equal(moment([2010, 0, 9]).week(), 2, 'Jan 9 2010 should be week 2');
- assert.equal(moment([2010, 0, 10]).week(), 3, 'Jan 10 2010 should be week 3');
-});
-
-test('weeks year starting saturday', function (assert) {
- assert.equal(moment([2010, 11, 26]).week(), 1, 'Dec 26 2010 should be week 1');
- assert.equal(moment([2011, 0, 1]).week(), 1, 'Jan 1 2011 should be week 1');
- assert.equal(moment([2011, 0, 2]).week(), 2, 'Jan 2 2011 should be week 2');
- assert.equal(moment([2011, 0, 8]).week(), 2, 'Jan 8 2011 should be week 2');
- assert.equal(moment([2011, 0, 9]).week(), 3, 'Jan 9 2011 should be week 3');
-});
-
test('weeks year starting sunday format', function (assert) {
assert.equal(moment([2012, 0, 1]).format('w ww wo'), '1 01 1er', 'Jan 1 2012 should be week 1');
assert.equal(moment([2012, 0, 7]).format('w ww wo'), '1 01 1er', 'Jan 7 2012 should be week 1');
@@ -275,38 +214,3 @@
assert.equal(moment([2012, 0, 15]).format('w ww wo'), '3 03 3e', 'Jan 15 2012 should be week 3');
});
-test('lenient ordinal parsing', function (assert) {
- var i, ordinalStr, testMoment;
- for (i = 1; i <= 31; ++i) {
- ordinalStr = moment([2014, 0, i]).format('YYYY MM Do');
- testMoment = moment(ordinalStr, 'YYYY MM Do');
- assert.equal(testMoment.year(), 2014,
- 'lenient ordinal parsing ' + i + ' year check');
- assert.equal(testMoment.month(), 0,
- 'lenient ordinal parsing ' + i + ' month check');
- assert.equal(testMoment.date(), i,
- 'lenient ordinal parsing ' + i + ' date check');
- }
-});
-
-test('lenient ordinal parsing of number', function (assert) {
- var i, testMoment;
- for (i = 1; i <= 31; ++i) {
- testMoment = moment('2014 01 ' + i, 'YYYY MM Do');
- assert.equal(testMoment.year(), 2014,
- 'lenient ordinal parsing of number ' + i + ' year check');
- assert.equal(testMoment.month(), 0,
- 'lenient ordinal parsing of number ' + i + ' month check');
- assert.equal(testMoment.date(), i,
- 'lenient ordinal parsing of number ' + i + ' date check');
- }
-});
-
-test('strict ordinal parsing', function (assert) {
- var i, ordinalStr, testMoment;
- for (i = 1; i <= 31; ++i) {
- ordinalStr = moment([2014, 0, i]).format('YYYY MM Do');
- testMoment = moment(ordinalStr, 'YYYY MM Do', true);
- assert.ok(testMoment.isValid(), 'strict ordinal parsing ' + i);
- }
-});
diff --git a/src/test/locale/fr-ch.js b/src/test/locale/fr-ch.js
index df990ac..6a3aa8f 100644
--- a/src/test/locale/fr-ch.js
+++ b/src/test/locale/fr-ch.js
@@ -156,14 +156,14 @@
});
test('same day', function (assert) {
- var a = moment().hours(2).minutes(0).seconds(0);
-
- assert.equal(moment(a).calendar(), 'Aujourd\'hui à 02:00', 'today at the same time');
- assert.equal(moment(a).add({m: 25}).calendar(), 'Aujourd\'hui à 02:25', 'Now plus 25 min');
- assert.equal(moment(a).add({h: 1}).calendar(), 'Aujourd\'hui à 03:00', 'Now plus 1 hour');
- assert.equal(moment(a).add({d: 1}).calendar(), 'Demain à 02:00', 'tomorrow at the same time');
- assert.equal(moment(a).subtract({h: 1}).calendar(), 'Aujourd\'hui à 01:00', 'Now minus 1 hour');
- assert.equal(moment(a).subtract({d: 1}).calendar(), 'Hier à 02:00', 'yesterday at the same time');
+ var a = moment().hours(12).minutes(0).seconds(0);
+
+ assert.equal(moment(a).calendar(), 'Aujourd\'hui à 12:00', 'today at the same time');
+ assert.equal(moment(a).add({m: 25}).calendar(), 'Aujourd\'hui à 12:25', 'Now plus 25 min');
+ assert.equal(moment(a).add({h: 1}).calendar(), 'Aujourd\'hui à 13:00', 'Now plus 1 hour');
+ assert.equal(moment(a).add({d: 1}).calendar(), 'Demain à 12:00', 'tomorrow at the same time');
+ assert.equal(moment(a).subtract({h: 1}).calendar(), 'Aujourd\'hui à 11:00', 'Now minus 1 hour');
+ assert.equal(moment(a).subtract({d: 1}).calendar(), 'Hier à 12:00', 'yesterday at the same time');
});
test('same next week', function (assert) {
@@ -206,67 +206,6 @@
assert.equal(weeksFromNow.calendar(), weeksFromNow.format('L'), 'in 2 weeks');
});
-test('weeks year starting sunday', function (assert) {
- assert.equal(moment([2012, 0, 1]).week(), 52, 'Jan 1 2012 should be week 52');
- assert.equal(moment([2012, 0, 2]).week(), 1, 'Jan 2 2012 should be week 1');
- assert.equal(moment([2012, 0, 8]).week(), 1, 'Jan 8 2012 should be week 1');
- assert.equal(moment([2012, 0, 9]).week(), 2, 'Jan 9 2012 should be week 2');
- assert.equal(moment([2012, 0, 15]).week(), 2, 'Jan 15 2012 should be week 2');
-});
-
-test('weeks year starting monday', function (assert) {
- assert.equal(moment([2007, 0, 1]).week(), 1, 'Jan 1 2007 should be week 1');
- assert.equal(moment([2007, 0, 7]).week(), 1, 'Jan 7 2007 should be week 1');
- assert.equal(moment([2007, 0, 8]).week(), 2, 'Jan 8 2007 should be week 2');
- assert.equal(moment([2007, 0, 14]).week(), 2, 'Jan 14 2007 should be week 2');
- assert.equal(moment([2007, 0, 15]).week(), 3, 'Jan 15 2007 should be week 3');
-});
-
-test('weeks year starting tuesday', function (assert) {
- assert.equal(moment([2007, 11, 31]).week(), 1, 'Dec 31 2007 should be week 1');
- assert.equal(moment([2008, 0, 1]).week(), 1, 'Jan 1 2008 should be week 1');
- assert.equal(moment([2008, 0, 6]).week(), 1, 'Jan 6 2008 should be week 1');
- assert.equal(moment([2008, 0, 7]).week(), 2, 'Jan 7 2008 should be week 2');
- assert.equal(moment([2008, 0, 13]).week(), 2, 'Jan 13 2008 should be week 2');
- assert.equal(moment([2008, 0, 14]).week(), 3, 'Jan 14 2008 should be week 3');
-});
-
-test('weeks year starting wednesday', function (assert) {
- assert.equal(moment([2002, 11, 30]).week(), 1, 'Dec 30 2002 should be week 1');
- assert.equal(moment([2003, 0, 1]).week(), 1, 'Jan 1 2003 should be week 1');
- assert.equal(moment([2003, 0, 5]).week(), 1, 'Jan 5 2003 should be week 1');
- assert.equal(moment([2003, 0, 6]).week(), 2, 'Jan 6 2003 should be week 2');
- assert.equal(moment([2003, 0, 12]).week(), 2, 'Jan 12 2003 should be week 2');
- assert.equal(moment([2003, 0, 13]).week(), 3, 'Jan 13 2003 should be week 3');
-});
-
-test('weeks year starting thursday', function (assert) {
- assert.equal(moment([2008, 11, 29]).week(), 1, 'Dec 29 2008 should be week 1');
- assert.equal(moment([2009, 0, 1]).week(), 1, 'Jan 1 2009 should be week 1');
- assert.equal(moment([2009, 0, 4]).week(), 1, 'Jan 4 2009 should be week 1');
- assert.equal(moment([2009, 0, 5]).week(), 2, 'Jan 5 2009 should be week 2');
- assert.equal(moment([2009, 0, 11]).week(), 2, 'Jan 11 2009 should be week 2');
- assert.equal(moment([2009, 0, 13]).week(), 3, 'Jan 12 2009 should be week 3');
-});
-
-test('weeks year starting friday', function (assert) {
- assert.equal(moment([2009, 11, 28]).week(), 53, 'Dec 28 2009 should be week 53');
- assert.equal(moment([2010, 0, 1]).week(), 53, 'Jan 1 2010 should be week 53');
- assert.equal(moment([2010, 0, 3]).week(), 53, 'Jan 3 2010 should be week 53');
- assert.equal(moment([2010, 0, 4]).week(), 1, 'Jan 4 2010 should be week 1');
- assert.equal(moment([2010, 0, 10]).week(), 1, 'Jan 10 2010 should be week 1');
- assert.equal(moment([2010, 0, 11]).week(), 2, 'Jan 11 2010 should be week 2');
-});
-
-test('weeks year starting saturday', function (assert) {
- assert.equal(moment([2010, 11, 27]).week(), 52, 'Dec 27 2010 should be week 52');
- assert.equal(moment([2011, 0, 1]).week(), 52, 'Jan 1 2011 should be week 52');
- assert.equal(moment([2011, 0, 2]).week(), 52, 'Jan 2 2011 should be week 52');
- assert.equal(moment([2011, 0, 3]).week(), 1, 'Jan 3 2011 should be week 1');
- assert.equal(moment([2011, 0, 9]).week(), 1, 'Jan 9 2011 should be week 1');
- assert.equal(moment([2011, 0, 10]).week(), 2, 'Jan 10 2011 should be week 2');
-});
-
test('weeks year starting sunday formatted', function (assert) {
assert.equal(moment([2012, 0, 1]).format('w ww wo'), '52 52 52e', 'Jan 1 2012 should be week 52');
assert.equal(moment([2012, 0, 2]).format('w ww wo'), '1 01 1er', 'Jan 2 2012 should be week 1');
@@ -275,38 +214,3 @@
assert.equal(moment([2012, 0, 15]).format('w ww wo'), '2 02 2e', 'Jan 15 2012 should be week 2');
});
-test('lenient ordinal parsing', function (assert) {
- var i, ordinalStr, testMoment;
- for (i = 1; i <= 31; ++i) {
- ordinalStr = moment([2014, 0, i]).format('YYYY MM Do');
- testMoment = moment(ordinalStr, 'YYYY MM Do');
- assert.equal(testMoment.year(), 2014,
- 'lenient ordinal parsing ' + i + ' year check');
- assert.equal(testMoment.month(), 0,
- 'lenient ordinal parsing ' + i + ' month check');
- assert.equal(testMoment.date(), i,
- 'lenient ordinal parsing ' + i + ' date check');
- }
-});
-
-test('lenient ordinal parsing of number', function (assert) {
- var i, testMoment;
- for (i = 1; i <= 31; ++i) {
- testMoment = moment('2014 01 ' + i, 'YYYY MM Do');
- assert.equal(testMoment.year(), 2014,
- 'lenient ordinal parsing of number ' + i + ' year check');
- assert.equal(testMoment.month(), 0,
- 'lenient ordinal parsing of number ' + i + ' month check');
- assert.equal(testMoment.date(), i,
- 'lenient ordinal parsing of number ' + i + ' date check');
- }
-});
-
-test('strict ordinal parsing', function (assert) {
- var i, ordinalStr, testMoment;
- for (i = 1; i <= 31; ++i) {
- ordinalStr = moment([2014, 0, i]).format('YYYY MM Do');
- testMoment = moment(ordinalStr, 'YYYY MM Do', true);
- assert.ok(testMoment.isValid(), 'strict ordinal parsing ' + i);
- }
-});
diff --git a/src/test/locale/fr.js b/src/test/locale/fr.js
index 55afbde..83297df 100644
--- a/src/test/locale/fr.js
+++ b/src/test/locale/fr.js
@@ -148,14 +148,14 @@
});
test('same day', function (assert) {
- var a = moment().hours(2).minutes(0).seconds(0);
-
- assert.equal(moment(a).calendar(), 'Aujourd\'hui à 02:00', 'today at the same time');
- assert.equal(moment(a).add({m: 25}).calendar(), 'Aujourd\'hui à 02:25', 'Now plus 25 min');
- assert.equal(moment(a).add({h: 1}).calendar(), 'Aujourd\'hui à 03:00', 'Now plus 1 hour');
- assert.equal(moment(a).add({d: 1}).calendar(), 'Demain à 02:00', 'tomorrow at the same time');
- assert.equal(moment(a).subtract({h: 1}).calendar(), 'Aujourd\'hui à 01:00', 'Now minus 1 hour');
- assert.equal(moment(a).subtract({d: 1}).calendar(), 'Hier à 02:00', 'yesterday at the same time');
+ var a = moment().hours(12).minutes(0).seconds(0);
+
+ assert.equal(moment(a).calendar(), 'Aujourd\'hui à 12:00', 'today at the same time');
+ assert.equal(moment(a).add({m: 25}).calendar(), 'Aujourd\'hui à 12:25', 'Now plus 25 min');
+ assert.equal(moment(a).add({h: 1}).calendar(), 'Aujourd\'hui à 13:00', 'Now plus 1 hour');
+ assert.equal(moment(a).add({d: 1}).calendar(), 'Demain à 12:00', 'tomorrow at the same time');
+ assert.equal(moment(a).subtract({h: 1}).calendar(), 'Aujourd\'hui à 11:00', 'Now minus 1 hour');
+ assert.equal(moment(a).subtract({d: 1}).calendar(), 'Hier à 12:00', 'yesterday at the same time');
});
test('same next week', function (assert) {
@@ -198,67 +198,6 @@
assert.equal(weeksFromNow.calendar(), weeksFromNow.format('L'), 'in 2 weeks');
});
-test('weeks year starting sunday', function (assert) {
- assert.equal(moment([2012, 0, 1]).week(), 52, 'Jan 1 2012 should be week 52');
- assert.equal(moment([2012, 0, 2]).week(), 1, 'Jan 2 2012 should be week 1');
- assert.equal(moment([2012, 0, 8]).week(), 1, 'Jan 8 2012 should be week 1');
- assert.equal(moment([2012, 0, 9]).week(), 2, 'Jan 9 2012 should be week 2');
- assert.equal(moment([2012, 0, 15]).week(), 2, 'Jan 15 2012 should be week 2');
-});
-
-test('weeks year starting monday', function (assert) {
- assert.equal(moment([2007, 0, 1]).week(), 1, 'Jan 1 2007 should be week 1');
- assert.equal(moment([2007, 0, 7]).week(), 1, 'Jan 7 2007 should be week 1');
- assert.equal(moment([2007, 0, 8]).week(), 2, 'Jan 8 2007 should be week 2');
- assert.equal(moment([2007, 0, 14]).week(), 2, 'Jan 14 2007 should be week 2');
- assert.equal(moment([2007, 0, 15]).week(), 3, 'Jan 15 2007 should be week 3');
-});
-
-test('weeks year starting tuesday', function (assert) {
- assert.equal(moment([2007, 11, 31]).week(), 1, 'Dec 31 2007 should be week 1');
- assert.equal(moment([2008, 0, 1]).week(), 1, 'Jan 1 2008 should be week 1');
- assert.equal(moment([2008, 0, 6]).week(), 1, 'Jan 6 2008 should be week 1');
- assert.equal(moment([2008, 0, 7]).week(), 2, 'Jan 7 2008 should be week 2');
- assert.equal(moment([2008, 0, 13]).week(), 2, 'Jan 13 2008 should be week 2');
- assert.equal(moment([2008, 0, 14]).week(), 3, 'Jan 14 2008 should be week 3');
-});
-
-test('weeks year starting wednesday', function (assert) {
- assert.equal(moment([2002, 11, 30]).week(), 1, 'Dec 30 2002 should be week 1');
- assert.equal(moment([2003, 0, 1]).week(), 1, 'Jan 1 2003 should be week 1');
- assert.equal(moment([2003, 0, 5]).week(), 1, 'Jan 5 2003 should be week 1');
- assert.equal(moment([2003, 0, 6]).week(), 2, 'Jan 6 2003 should be week 2');
- assert.equal(moment([2003, 0, 12]).week(), 2, 'Jan 12 2003 should be week 2');
- assert.equal(moment([2003, 0, 13]).week(), 3, 'Jan 13 2003 should be week 3');
-});
-
-test('weeks year starting thursday', function (assert) {
- assert.equal(moment([2008, 11, 29]).week(), 1, 'Dec 29 2008 should be week 1');
- assert.equal(moment([2009, 0, 1]).week(), 1, 'Jan 1 2009 should be week 1');
- assert.equal(moment([2009, 0, 4]).week(), 1, 'Jan 4 2009 should be week 1');
- assert.equal(moment([2009, 0, 5]).week(), 2, 'Jan 5 2009 should be week 2');
- assert.equal(moment([2009, 0, 11]).week(), 2, 'Jan 11 2009 should be week 2');
- assert.equal(moment([2009, 0, 13]).week(), 3, 'Jan 12 2009 should be week 3');
-});
-
-test('weeks year starting friday', function (assert) {
- assert.equal(moment([2009, 11, 28]).week(), 53, 'Dec 28 2009 should be week 53');
- assert.equal(moment([2010, 0, 1]).week(), 53, 'Jan 1 2010 should be week 53');
- assert.equal(moment([2010, 0, 3]).week(), 53, 'Jan 3 2010 should be week 53');
- assert.equal(moment([2010, 0, 4]).week(), 1, 'Jan 4 2010 should be week 1');
- assert.equal(moment([2010, 0, 10]).week(), 1, 'Jan 10 2010 should be week 1');
- assert.equal(moment([2010, 0, 11]).week(), 2, 'Jan 11 2010 should be week 2');
-});
-
-test('weeks year starting saturday', function (assert) {
- assert.equal(moment([2010, 11, 27]).week(), 52, 'Dec 27 2010 should be week 52');
- assert.equal(moment([2011, 0, 1]).week(), 52, 'Jan 1 2011 should be week 52');
- assert.equal(moment([2011, 0, 2]).week(), 52, 'Jan 2 2011 should be week 52');
- assert.equal(moment([2011, 0, 3]).week(), 1, 'Jan 3 2011 should be week 1');
- assert.equal(moment([2011, 0, 9]).week(), 1, 'Jan 9 2011 should be week 1');
- assert.equal(moment([2011, 0, 10]).week(), 2, 'Jan 10 2011 should be week 2');
-});
-
test('weeks year starting sunday formatted', function (assert) {
assert.equal(moment([2012, 0, 1]).format('w ww wo'), '52 52 52', 'Jan 1 2012 should be week 52');
assert.equal(moment([2012, 0, 2]).format('w ww wo'), '1 01 1er', 'Jan 2 2012 should be week 1');
@@ -267,38 +206,3 @@
assert.equal(moment([2012, 0, 15]).format('w ww wo'), '2 02 2', 'Jan 15 2012 should be week 2');
});
-test('lenient ordinal parsing', function (assert) {
- var i, ordinalStr, testMoment;
- for (i = 1; i <= 31; ++i) {
- ordinalStr = moment([2014, 0, i]).format('YYYY MM Do');
- testMoment = moment(ordinalStr, 'YYYY MM Do');
- assert.equal(testMoment.year(), 2014,
- 'lenient ordinal parsing ' + i + ' year check');
- assert.equal(testMoment.month(), 0,
- 'lenient ordinal parsing ' + i + ' month check');
- assert.equal(testMoment.date(), i,
- 'lenient ordinal parsing ' + i + ' date check');
- }
-});
-
-test('lenient ordinal parsing of number', function (assert) {
- var i, testMoment;
- for (i = 1; i <= 31; ++i) {
- testMoment = moment('2014 01 ' + i, 'YYYY MM Do');
- assert.equal(testMoment.year(), 2014,
- 'lenient ordinal parsing of number ' + i + ' year check');
- assert.equal(testMoment.month(), 0,
- 'lenient ordinal parsing of number ' + i + ' month check');
- assert.equal(testMoment.date(), i,
- 'lenient ordinal parsing of number ' + i + ' date check');
- }
-});
-
-test('strict ordinal parsing', function (assert) {
- var i, ordinalStr, testMoment;
- for (i = 1; i <= 31; ++i) {
- ordinalStr = moment([2014, 0, i]).format('YYYY MM Do');
- testMoment = moment(ordinalStr, 'YYYY MM Do', true);
- assert.ok(testMoment.isValid(), 'strict ordinal parsing ' + i);
- }
-});
diff --git a/src/test/locale/fy.js b/src/test/locale/fy.js
index b3d8897..50f0259 100644
--- a/src/test/locale/fy.js
+++ b/src/test/locale/fy.js
@@ -151,14 +151,14 @@
});
test('calendar day', function (assert) {
- var a = moment().hours(2).minutes(0).seconds(0);
-
- assert.equal(moment(a).calendar(), 'hjoed om 02:00', 'today at the same time');
- assert.equal(moment(a).add({m: 25}).calendar(), 'hjoed om 02:25', 'Now plus 25 min');
- assert.equal(moment(a).add({h: 1}).calendar(), 'hjoed om 03:00', 'Now plus 1 hour');
- assert.equal(moment(a).add({d: 1}).calendar(), 'moarn om 02:00', 'tomorrow at the same time');
- assert.equal(moment(a).subtract({h: 1}).calendar(), 'hjoed om 01:00', 'Now minus 1 hour');
- assert.equal(moment(a).subtract({d: 1}).calendar(), 'juster om 02:00', 'yesterday at the same time');
+ var a = moment().hours(12).minutes(0).seconds(0);
+
+ assert.equal(moment(a).calendar(), 'hjoed om 12:00', 'today at the same time');
+ assert.equal(moment(a).add({m: 25}).calendar(), 'hjoed om 12:25', 'Now plus 25 min');
+ assert.equal(moment(a).add({h: 1}).calendar(), 'hjoed om 13:00', 'Now plus 1 hour');
+ assert.equal(moment(a).add({d: 1}).calendar(), 'moarn om 12:00', 'tomorrow at the same time');
+ assert.equal(moment(a).subtract({h: 1}).calendar(), 'hjoed om 11:00', 'Now minus 1 hour');
+ assert.equal(moment(a).subtract({d: 1}).calendar(), 'juster om 12:00', 'yesterday at the same time');
});
test('calendar next week', function (assert) {
@@ -204,67 +204,6 @@
assert.equal(moment([2012, 5, 23]).format('D MMM YYYY'), '23 jun. 2012', 'format month abbreviation not surrounded by dashes should include a dot');
});
-test('weeks year starting sunday', function (assert) {
- assert.equal(moment([2012, 0, 1]).week(), 52, 'Jan 1 2012 should be week 52');
- assert.equal(moment([2012, 0, 2]).week(), 1, 'Jan 2 2012 should be week 1');
- assert.equal(moment([2012, 0, 8]).week(), 1, 'Jan 8 2012 should be week 1');
- assert.equal(moment([2012, 0, 9]).week(), 2, 'Jan 9 2012 should be week 2');
- assert.equal(moment([2012, 0, 15]).week(), 2, 'Jan 15 2012 should be week 2');
-});
-
-test('weeks year starting monday', function (assert) {
- assert.equal(moment([2007, 0, 1]).week(), 1, 'Jan 1 2007 should be week 1');
- assert.equal(moment([2007, 0, 7]).week(), 1, 'Jan 7 2007 should be week 1');
- assert.equal(moment([2007, 0, 8]).week(), 2, 'Jan 8 2007 should be week 2');
- assert.equal(moment([2007, 0, 14]).week(), 2, 'Jan 14 2007 should be week 2');
- assert.equal(moment([2007, 0, 15]).week(), 3, 'Jan 15 2007 should be week 3');
-});
-
-test('weeks year starting tuesday', function (assert) {
- assert.equal(moment([2007, 11, 31]).week(), 1, 'Dec 31 2007 should be week 1');
- assert.equal(moment([2008, 0, 1]).week(), 1, 'Jan 1 2008 should be week 1');
- assert.equal(moment([2008, 0, 6]).week(), 1, 'Jan 6 2008 should be week 1');
- assert.equal(moment([2008, 0, 7]).week(), 2, 'Jan 7 2008 should be week 2');
- assert.equal(moment([2008, 0, 13]).week(), 2, 'Jan 13 2008 should be week 2');
- assert.equal(moment([2008, 0, 14]).week(), 3, 'Jan 14 2008 should be week 3');
-});
-
-test('weeks year starting wednesday', function (assert) {
- assert.equal(moment([2002, 11, 30]).week(), 1, 'Dec 30 2002 should be week 1');
- assert.equal(moment([2003, 0, 1]).week(), 1, 'Jan 1 2003 should be week 1');
- assert.equal(moment([2003, 0, 5]).week(), 1, 'Jan 5 2003 should be week 1');
- assert.equal(moment([2003, 0, 6]).week(), 2, 'Jan 6 2003 should be week 2');
- assert.equal(moment([2003, 0, 12]).week(), 2, 'Jan 12 2003 should be week 2');
- assert.equal(moment([2003, 0, 13]).week(), 3, 'Jan 13 2003 should be week 3');
-});
-
-test('weeks year starting thursday', function (assert) {
- assert.equal(moment([2008, 11, 29]).week(), 1, 'Dec 29 2008 should be week 1');
- assert.equal(moment([2009, 0, 1]).week(), 1, 'Jan 1 2009 should be week 1');
- assert.equal(moment([2009, 0, 4]).week(), 1, 'Jan 4 2009 should be week 1');
- assert.equal(moment([2009, 0, 5]).week(), 2, 'Jan 5 2009 should be week 2');
- assert.equal(moment([2009, 0, 11]).week(), 2, 'Jan 11 2009 should be week 2');
- assert.equal(moment([2009, 0, 13]).week(), 3, 'Jan 12 2009 should be week 3');
-});
-
-test('weeks year starting friday', function (assert) {
- assert.equal(moment([2009, 11, 28]).week(), 53, 'Dec 28 2009 should be week 53');
- assert.equal(moment([2010, 0, 1]).week(), 53, 'Jan 1 2010 should be week 53');
- assert.equal(moment([2010, 0, 3]).week(), 53, 'Jan 3 2010 should be week 53');
- assert.equal(moment([2010, 0, 4]).week(), 1, 'Jan 4 2010 should be week 1');
- assert.equal(moment([2010, 0, 10]).week(), 1, 'Jan 10 2010 should be week 1');
- assert.equal(moment([2010, 0, 11]).week(), 2, 'Jan 11 2010 should be week 2');
-});
-
-test('weeks year starting saturday', function (assert) {
- assert.equal(moment([2010, 11, 27]).week(), 52, 'Dec 27 2010 should be week 52');
- assert.equal(moment([2011, 0, 1]).week(), 52, 'Jan 1 2011 should be week 52');
- assert.equal(moment([2011, 0, 2]).week(), 52, 'Jan 2 2011 should be week 52');
- assert.equal(moment([2011, 0, 3]).week(), 1, 'Jan 3 2011 should be week 1');
- assert.equal(moment([2011, 0, 9]).week(), 1, 'Jan 9 2011 should be week 1');
- assert.equal(moment([2011, 0, 10]).week(), 2, 'Jan 10 2011 should be week 2');
-});
-
test('weeks year starting sunday formatted', function (assert) {
assert.equal(moment([2012, 0, 1]).format('w ww wo'), '52 52 52ste', 'Jan 1 2012 should be week 52');
assert.equal(moment([2012, 0, 2]).format('w ww wo'), '1 01 1ste', 'Jan 2 2012 should be week 1');
@@ -273,38 +212,3 @@
assert.equal(moment([2012, 0, 15]).format('w ww wo'), '2 02 2de', 'Jan 15 2012 should be week 2');
});
-test('lenient ordinal parsing', function (assert) {
- var i, ordinalStr, testMoment;
- for (i = 1; i <= 31; ++i) {
- ordinalStr = moment([2014, 0, i]).format('YYYY MM Do');
- testMoment = moment(ordinalStr, 'YYYY MM Do');
- assert.equal(testMoment.year(), 2014,
- 'lenient ordinal parsing ' + i + ' year check');
- assert.equal(testMoment.month(), 0,
- 'lenient ordinal parsing ' + i + ' month check');
- assert.equal(testMoment.date(), i,
- 'lenient ordinal parsing ' + i + ' date check');
- }
-});
-
-test('lenient ordinal parsing of number', function (assert) {
- var i, testMoment;
- for (i = 1; i <= 31; ++i) {
- testMoment = moment('2014 01 ' + i, 'YYYY MM Do');
- assert.equal(testMoment.year(), 2014,
- 'lenient ordinal parsing of number ' + i + ' year check');
- assert.equal(testMoment.month(), 0,
- 'lenient ordinal parsing of number ' + i + ' month check');
- assert.equal(testMoment.date(), i,
- 'lenient ordinal parsing of number ' + i + ' date check');
- }
-});
-
-test('strict ordinal parsing', function (assert) {
- var i, ordinalStr, testMoment;
- for (i = 1; i <= 31; ++i) {
- ordinalStr = moment([2014, 0, i]).format('YYYY MM Do');
- testMoment = moment(ordinalStr, 'YYYY MM Do', true);
- assert.ok(testMoment.isValid(), 'strict ordinal parsing ' + i);
- }
-});
diff --git a/src/test/locale/gd.js b/src/test/locale/gd.js
index 583d574..30718a8 100644
--- a/src/test/locale/gd.js
+++ b/src/test/locale/gd.js
@@ -19,7 +19,7 @@
test('parse', function (assert) {
function equalTest(monthName, monthFormat, monthNum) {
- assert.equal(moment(monthName, monthFormat).month(), monthNum, monthName + ' should be month ' + monthNum + 1);
+ assert.equal(moment(monthName, monthFormat).month(), monthNum, monthName + ' should be month ' + (monthNum + 1));
}
for (var i = 0; i < 12; i++) {
@@ -163,14 +163,14 @@
});
test('calendar day', function (assert) {
- var a = moment().hours(2).minutes(0).seconds(0);
-
- assert.equal(moment(a).calendar(), 'An-diugh aig 02:00', 'today at the same time');
- assert.equal(moment(a).add({m: 25}).calendar(), 'An-diugh aig 02:25', 'Now plus 25 min');
- assert.equal(moment(a).add({h: 1}).calendar(), 'An-diugh aig 03:00', 'Now plus 1 hour');
- assert.equal(moment(a).add({d: 1}).calendar(), 'A-màireach aig 02:00', 'tomorrow at the same time');
- assert.equal(moment(a).subtract({h: 1}).calendar(), 'An-diugh aig 01:00', 'Now minus 1 hour');
- assert.equal(moment(a).subtract({d: 1}).calendar(), 'An-dè aig 02:00', 'yesterday at the same time');
+ var a = moment().hours(12).minutes(0).seconds(0);
+
+ assert.equal(moment(a).calendar(), 'An-diugh aig 12:00', 'today at the same time');
+ assert.equal(moment(a).add({m: 25}).calendar(), 'An-diugh aig 12:25', 'Now plus 25 min');
+ assert.equal(moment(a).add({h: 1}).calendar(), 'An-diugh aig 13:00', 'Now plus 1 hour');
+ assert.equal(moment(a).add({d: 1}).calendar(), 'A-màireach aig 12:00', 'tomorrow at the same time');
+ assert.equal(moment(a).subtract({h: 1}).calendar(), 'An-diugh aig 11:00', 'Now minus 1 hour');
+ assert.equal(moment(a).subtract({d: 1}).calendar(), 'An-dè aig 12:00', 'yesterday at the same time');
});
test('calendar next week', function (assert) {
@@ -212,67 +212,6 @@
assert.equal(weeksFromNow.calendar(), weeksFromNow.format('L'), 'in 2 weeks');
});
-test('weeks year starting sunday', function (assert) {
- assert.equal(moment([2012, 0, 1]).week(), 52, 'Faoi 1 2012 should be week 52');
- assert.equal(moment([2012, 0, 2]).week(), 1, 'Faoi 2 2012 should be week 1');
- assert.equal(moment([2012, 0, 8]).week(), 1, 'Faoi 8 2012 should be week 1');
- assert.equal(moment([2012, 0, 9]).week(), 2, 'Faoi 9 2012 should be week 2');
- assert.equal(moment([2012, 0, 15]).week(), 2, 'Faoi 15 2012 should be week 2');
-});
-
-test('weeks year starting monday', function (assert) {
- assert.equal(moment([2007, 0, 1]).week(), 1, 'Faoi 1 2007 should be week 1');
- assert.equal(moment([2007, 0, 7]).week(), 1, 'Faoi 7 2007 should be week 1');
- assert.equal(moment([2007, 0, 8]).week(), 2, 'Faoi 8 2007 should be week 2');
- assert.equal(moment([2007, 0, 14]).week(), 2, 'Faoi 14 2007 should be week 2');
- assert.equal(moment([2007, 0, 15]).week(), 3, 'Faoi 15 2007 should be week 3');
-});
-
-test('weeks year starting tuesday', function (assert) {
- assert.equal(moment([2007, 11, 31]).week(), 1, 'Dùbh 31 2007 should be week 1');
- assert.equal(moment([2008, 0, 1]).week(), 1, 'Faoi 1 2008 should be week 1');
- assert.equal(moment([2008, 0, 6]).week(), 1, 'Faoi 6 2008 should be week 1');
- assert.equal(moment([2008, 0, 7]).week(), 2, 'Faoi 7 2008 should be week 2');
- assert.equal(moment([2008, 0, 13]).week(), 2, 'Faoi 13 2008 should be week 2');
- assert.equal(moment([2008, 0, 14]).week(), 3, 'Faoi 14 2008 should be week 3');
-});
-
-test('weeks year starting wednesday', function (assert) {
- assert.equal(moment([2002, 11, 30]).week(), 1, 'Dùbh 30 2002 should be week 1');
- assert.equal(moment([2003, 0, 1]).week(), 1, 'Faoi 1 2003 should be week 1');
- assert.equal(moment([2003, 0, 5]).week(), 1, 'Faoi 5 2003 should be week 1');
- assert.equal(moment([2003, 0, 6]).week(), 2, 'Faoi 6 2003 should be week 2');
- assert.equal(moment([2003, 0, 12]).week(), 2, 'Faoi 12 2003 should be week 2');
- assert.equal(moment([2003, 0, 13]).week(), 3, 'Faoi 13 2003 should be week 3');
-});
-
-test('weeks year starting thursday', function (assert) {
- assert.equal(moment([2008, 11, 29]).week(), 1, 'Dùbh 29 2008 should be week 1');
- assert.equal(moment([2009, 0, 1]).week(), 1, 'Faoi 1 2009 should be week 1');
- assert.equal(moment([2009, 0, 4]).week(), 1, 'Faoi 4 2009 should be week 1');
- assert.equal(moment([2009, 0, 5]).week(), 2, 'Faoi 5 2009 should be week 2');
- assert.equal(moment([2009, 0, 11]).week(), 2, 'Faoi 11 2009 should be week 2');
- assert.equal(moment([2009, 0, 13]).week(), 3, 'Faoi 12 2009 should be week 3');
-});
-
-test('weeks year starting friday', function (assert) {
- assert.equal(moment([2009, 11, 28]).week(), 53, 'Dùbh 28 2009 should be week 53');
- assert.equal(moment([2010, 0, 1]).week(), 53, 'Faoi 1 2010 should be week 53');
- assert.equal(moment([2010, 0, 3]).week(), 53, 'Faoi 3 2010 should be week 53');
- assert.equal(moment([2010, 0, 4]).week(), 1, 'Faoi 4 2010 should be week 1');
- assert.equal(moment([2010, 0, 10]).week(), 1, 'Faoi 10 2010 should be week 1');
- assert.equal(moment([2010, 0, 11]).week(), 2, 'Faoi 11 2010 should be week 2');
-});
-
-test('weeks year starting saturday', function (assert) {
- assert.equal(moment([2010, 11, 27]).week(), 52, 'Dùbh 27 2010 should be week 52');
- assert.equal(moment([2011, 0, 1]).week(), 52, 'Faoi 1 2011 should be week 52');
- assert.equal(moment([2011, 0, 2]).week(), 52, 'Faoi 2 2011 should be week 52');
- assert.equal(moment([2011, 0, 3]).week(), 1, 'Faoi 3 2011 should be week 1');
- assert.equal(moment([2011, 0, 9]).week(), 1, 'Faoi 9 2011 should be week 1');
- assert.equal(moment([2011, 0, 10]).week(), 2, 'Faoi 10 2011 should be week 2');
-});
-
test('weeks year starting sunday formatted', function (assert) {
assert.equal(moment([2012, 0, 1]).format('w ww wo'), '52 52 52na', 'Faoi 1 2012 should be week 52');
assert.equal(moment([2012, 0, 2]).format('w ww wo'), '1 01 1d', 'Faoi 2 2012 should be week 1');
@@ -281,39 +220,3 @@
assert.equal(moment([2012, 0, 15]).format('w ww wo'), '2 02 2na', 'Faoi 15 2012 should be week 2');
});
-test('lenient ordinal parsing', function (assert) {
- var i, ordinalStr, testMoment;
- for (i = 1; i <= 31; ++i) {
- ordinalStr = moment([2014, 0, i]).format('YYYY MM Do');
- testMoment = moment(ordinalStr, 'YYYY MM Do');
- assert.equal(testMoment.year(), 2014,
- 'lenient ordinal parsing ' + i + ' year check');
- assert.equal(testMoment.month(), 0,
- 'lenient ordinal parsing ' + i + ' month check');
- assert.equal(testMoment.date(), i,
- 'lenient ordinal parsing ' + i + ' date check');
- }
-});
-
-test('lenient ordinal parsing of number', function (assert) {
- var i, testMoment;
- for (i = 1; i <= 31; ++i) {
- testMoment = moment('2014 01 ' + i, 'YYYY MM Do');
- assert.equal(testMoment.year(), 2014,
- 'lenient ordinal parsing of number ' + i + ' year check');
- assert.equal(testMoment.month(), 0,
- 'lenient ordinal parsing of number ' + i + ' month check');
- assert.equal(testMoment.date(), i,
- 'lenient ordinal parsing of number ' + i + ' date check');
- }
-});
-
-test('strict ordinal parsing', function (assert) {
- var i, ordinalStr, testMoment;
- for (i = 1; i <= 31; ++i) {
- ordinalStr = moment([2014, 0, i]).format('YYYY MM Do');
- testMoment = moment(ordinalStr, 'YYYY MM Do', true);
- assert.ok(testMoment.isValid(), 'strict ordinal parsing ' + i);
- }
-});
-
diff --git a/src/test/locale/gl.js b/src/test/locale/gl.js
index 01bd220..420fa36 100644
--- a/src/test/locale/gl.js
+++ b/src/test/locale/gl.js
@@ -153,15 +153,15 @@
});
test('calendar day', function (assert) {
- var a = moment().hours(2).minutes(0).seconds(0);
-
- assert.equal(moment(a).calendar(), 'hoxe ás 2:00', 'today at the same time');
- assert.equal(moment(a).add({m: 25}).calendar(), 'hoxe ás 2:25', 'Now plus 25 min');
- assert.equal(moment(a).add({h: 1}).calendar(), 'hoxe ás 3:00', 'Now plus 1 hour');
- assert.equal(moment(a).add({d: 1}).calendar(), 'mañá ás 2:00', 'tomorrow at the same time');
- assert.equal(moment(a).add({d: 1, h : -1}).calendar(), 'mañá á 1:00', 'tomorrow minus 1 hour');
- assert.equal(moment(a).subtract({h: 1}).calendar(), 'hoxe á 1:00', 'Now minus 1 hour');
- assert.equal(moment(a).subtract({d: 1}).calendar(), 'onte á 2:00', 'yesterday at the same time');
+ var a = moment().hours(12).minutes(0).seconds(0);
+
+ assert.equal(moment(a).calendar(), 'hoxe ás 12:00', 'today at the same time');
+ assert.equal(moment(a).add({m: 25}).calendar(), 'hoxe ás 12:25', 'Now plus 25 min');
+ assert.equal(moment(a).add({h: 1}).calendar(), 'hoxe ás 13:00', 'Now plus 1 hour');
+ assert.equal(moment(a).add({d: 1}).calendar(), 'mañá ás 12:00', 'tomorrow at the same time');
+ assert.equal(moment(a).add({d: 1, h : -1}).calendar(), 'mañá ás 11:00', 'tomorrow minus 1 hour');
+ assert.equal(moment(a).subtract({h: 1}).calendar(), 'hoxe ás 11:00', 'Now minus 1 hour');
+ assert.equal(moment(a).subtract({d: 1}).calendar(), 'onte á 12:00', 'yesterday at the same time');
});
test('calendar next week', function (assert) {
@@ -208,67 +208,6 @@
assert.equal(lastWeek.calendar(), lastWeek.format('[o] dddd [pasado a] LT'), '1 o\'clock bug');
});
-test('weeks year starting sunday', function (assert) {
- assert.equal(moment([2011, 11, 26]).week(), 1, 'Dec 26 2011 should be week 1');
- assert.equal(moment([2012, 0, 1]).week(), 1, 'Jan 1 2012 should be week 1');
- assert.equal(moment([2012, 0, 2]).week(), 2, 'Jan 2 2012 should be week 2');
- assert.equal(moment([2012, 0, 8]).week(), 2, 'Jan 8 2012 should be week 2');
- assert.equal(moment([2012, 0, 9]).week(), 3, 'Jan 9 2012 should be week 3');
-});
-
-test('weeks year starting monday', function (assert) {
- assert.equal(moment([2007, 0, 1]).week(), 1, 'Jan 1 2007 should be week 1');
- assert.equal(moment([2007, 0, 7]).week(), 1, 'Jan 7 2007 should be week 1');
- assert.equal(moment([2007, 0, 8]).week(), 2, 'Jan 8 2007 should be week 2');
- assert.equal(moment([2007, 0, 14]).week(), 2, 'Jan 14 2007 should be week 2');
- assert.equal(moment([2007, 0, 15]).week(), 3, 'Jan 15 2007 should be week 3');
-});
-
-test('weeks year starting tuesday', function (assert) {
- assert.equal(moment([2007, 11, 31]).week(), 1, 'Dec 31 2007 should be week 1');
- assert.equal(moment([2008, 0, 1]).week(), 1, 'Jan 1 2008 should be week 1');
- assert.equal(moment([2008, 0, 6]).week(), 1, 'Jan 6 2008 should be week 1');
- assert.equal(moment([2008, 0, 7]).week(), 2, 'Jan 7 2008 should be week 2');
- assert.equal(moment([2008, 0, 13]).week(), 2, 'Jan 13 2008 should be week 2');
- assert.equal(moment([2008, 0, 14]).week(), 3, 'Jan 14 2008 should be week 3');
-});
-
-test('weeks year starting wednesday', function (assert) {
- assert.equal(moment([2002, 11, 30]).week(), 1, 'Dec 30 2002 should be week 1');
- assert.equal(moment([2003, 0, 1]).week(), 1, 'Jan 1 2003 should be week 1');
- assert.equal(moment([2003, 0, 5]).week(), 1, 'Jan 5 2003 should be week 1');
- assert.equal(moment([2003, 0, 6]).week(), 2, 'Jan 6 2003 should be week 2');
- assert.equal(moment([2003, 0, 12]).week(), 2, 'Jan 12 2003 should be week 2');
- assert.equal(moment([2003, 0, 13]).week(), 3, 'Jan 13 2003 should be week 3');
-});
-
-test('weeks year starting thursday', function (assert) {
- assert.equal(moment([2008, 11, 29]).week(), 1, 'Dec 29 2008 should be week 1');
- assert.equal(moment([2009, 0, 1]).week(), 1, 'Jan 1 2009 should be week 1');
- assert.equal(moment([2009, 0, 4]).week(), 1, 'Jan 4 2009 should be week 1');
- assert.equal(moment([2009, 0, 5]).week(), 2, 'Jan 5 2009 should be week 2');
- assert.equal(moment([2009, 0, 11]).week(), 2, 'Jan 11 2009 should be week 2');
- assert.equal(moment([2009, 0, 12]).week(), 3, 'Jan 12 2009 should be week 3');
-});
-
-test('weeks year starting friday', function (assert) {
- assert.equal(moment([2009, 11, 28]).week(), 1, 'Dec 28 2009 should be week 1');
- assert.equal(moment([2010, 0, 1]).week(), 1, 'Jan 1 2010 should be week 1');
- assert.equal(moment([2010, 0, 3]).week(), 1, 'Jan 3 2010 should be week 1');
- assert.equal(moment([2010, 0, 4]).week(), 2, 'Jan 4 2010 should be week 2');
- assert.equal(moment([2010, 0, 10]).week(), 2, 'Jan 10 2010 should be week 2');
- assert.equal(moment([2010, 0, 11]).week(), 3, 'Jan 11 2010 should be week 3');
-});
-
-test('weeks year starting saturday', function (assert) {
- assert.equal(moment([2010, 11, 27]).week(), 1, 'Dec 27 2010 should be week 1');
- assert.equal(moment([2011, 0, 1]).week(), 1, 'Jan 1 2011 should be week 1');
- assert.equal(moment([2011, 0, 2]).week(), 1, 'Jan 2 2011 should be week 1');
- assert.equal(moment([2011, 0, 3]).week(), 2, 'Jan 3 2011 should be week 2');
- assert.equal(moment([2011, 0, 9]).week(), 2, 'Jan 9 2011 should be week 2');
- assert.equal(moment([2011, 0, 10]).week(), 3, 'Jan 10 2011 should be week 3');
-});
-
test('weeks year starting sunday formatted', function (assert) {
assert.equal(moment([2011, 11, 26]).format('w ww wo'), '1 01 1º', 'Dec 26 2011 should be week 1');
assert.equal(moment([2012, 0, 1]).format('w ww wo'), '1 01 1º', 'Jan 1 2012 should be week 1');
@@ -277,38 +216,3 @@
assert.equal(moment([2012, 0, 9]).format('w ww wo'), '3 03 3º', 'Jan 9 2012 should be week 3');
});
-test('lenient ordinal parsing', function (assert) {
- var i, ordinalStr, testMoment;
- for (i = 1; i <= 31; ++i) {
- ordinalStr = moment([2014, 0, i]).format('YYYY MM Do');
- testMoment = moment(ordinalStr, 'YYYY MM Do');
- assert.equal(testMoment.year(), 2014,
- 'lenient ordinal parsing ' + i + ' year check');
- assert.equal(testMoment.month(), 0,
- 'lenient ordinal parsing ' + i + ' month check');
- assert.equal(testMoment.date(), i,
- 'lenient ordinal parsing ' + i + ' date check');
- }
-});
-
-test('lenient ordinal parsing of number', function (assert) {
- var i, testMoment;
- for (i = 1; i <= 31; ++i) {
- testMoment = moment('2014 01 ' + i, 'YYYY MM Do');
- assert.equal(testMoment.year(), 2014,
- 'lenient ordinal parsing of number ' + i + ' year check');
- assert.equal(testMoment.month(), 0,
- 'lenient ordinal parsing of number ' + i + ' month check');
- assert.equal(testMoment.date(), i,
- 'lenient ordinal parsing of number ' + i + ' date check');
- }
-});
-
-test('strict ordinal parsing', function (assert) {
- var i, ordinalStr, testMoment;
- for (i = 1; i <= 31; ++i) {
- ordinalStr = moment([2014, 0, i]).format('YYYY MM Do');
- testMoment = moment(ordinalStr, 'YYYY MM Do', true);
- assert.ok(testMoment.isValid(), 'strict ordinal parsing ' + i);
- }
-});
diff --git a/src/test/locale/he.js b/src/test/locale/he.js
index ddd0422..b6aefbe 100644
--- a/src/test/locale/he.js
+++ b/src/test/locale/he.js
@@ -22,8 +22,8 @@
test('format', function (assert) {
var a = [
- ['dddd, MMMM Do YYYY, h:mm:ss a', 'ראשון, פברואר 14 2010, 3:25:50 pm'],
- ['ddd, hA', 'א׳, 3PM'],
+ ['dddd, MMMM Do YYYY, h:mm:ss a', 'ראשון, פברואר 14 2010, 3:25:50 אחה"צ'],
+ ['ddd, h A', 'א׳, 3 אחרי הצהריים'],
['M Mo MM MMMM MMM', '2 2 02 פברואר פבר׳'],
['YYYY YY', '2010 10'],
['D Do DD', '14 14 14'],
@@ -34,7 +34,7 @@
['H HH', '15 15'],
['m mm', '25 25'],
['s ss', '50 50'],
- ['a A', 'pm PM'],
+ ['a A', 'אחה"צ אחרי הצהריים'],
['[the] DDDo [day of the year]', 'the 45 day of the year'],
['LTS', '15:25:50'],
['L', '14/02/2010'],
@@ -116,14 +116,14 @@
});
test('calendar day', function (assert) {
- var a = moment().hours(2).minutes(0).seconds(0);
+ var a = moment().hours(12).minutes(0).seconds(0);
- assert.equal(moment(a).calendar(), 'היום ב־02:00', 'today at the same time');
- assert.equal(moment(a).add({m: 25}).calendar(), 'היום ב־02:25', 'Now plus 25 min');
- assert.equal(moment(a).add({h: 1}).calendar(), 'היום ב־03:00', 'Now plus 1 hour');
- assert.equal(moment(a).add({d: 1}).calendar(), 'מחר ב־02:00', 'tomorrow at the same time');
- assert.equal(moment(a).subtract({h: 1}).calendar(), 'היום ב־01:00', 'Now minus 1 hour');
- assert.equal(moment(a).subtract({d: 1}).calendar(), 'אתמול ב־02:00', 'yesterday at the same time');
+ assert.equal(moment(a).calendar(), 'היום ב־12:00', 'today at the same time');
+ assert.equal(moment(a).add({m: 25}).calendar(), 'היום ב־12:25', 'Now plus 25 min');
+ assert.equal(moment(a).add({h: 1}).calendar(), 'היום ב־13:00', 'Now plus 1 hour');
+ assert.equal(moment(a).add({d: 1}).calendar(), 'מחר ב־12:00', 'tomorrow at the same time');
+ assert.equal(moment(a).subtract({h: 1}).calendar(), 'היום ב־11:00', 'Now minus 1 hour');
+ assert.equal(moment(a).subtract({d: 1}).calendar(), 'אתמול ב־12:00', 'yesterday at the same time');
});
test('calendar next week', function (assert) {
@@ -164,67 +164,6 @@
assert.equal(weeksFromNow.calendar(), weeksFromNow.format('L'), 'in 2 weeks');
});
-test('weeks year starting sunday', function (assert) {
- assert.equal(moment([2012, 0, 1]).week(), 1, 'Jan 1 2012 should be week 1');
- assert.equal(moment([2012, 0, 7]).week(), 1, 'Jan 7 2012 should be week 1');
- assert.equal(moment([2012, 0, 8]).week(), 2, 'Jan 8 2012 should be week 2');
- assert.equal(moment([2012, 0, 14]).week(), 2, 'Jan 14 2012 should be week 2');
- assert.equal(moment([2012, 0, 15]).week(), 3, 'Jan 15 2012 should be week 3');
-});
-
-test('weeks year starting monday', function (assert) {
- assert.equal(moment([2006, 11, 31]).week(), 1, 'Dec 31 2006 should be week 1');
- assert.equal(moment([2007, 0, 1]).week(), 1, 'Jan 1 2007 should be week 1');
- assert.equal(moment([2007, 0, 6]).week(), 1, 'Jan 6 2007 should be week 1');
- assert.equal(moment([2007, 0, 7]).week(), 2, 'Jan 7 2007 should be week 2');
- assert.equal(moment([2007, 0, 13]).week(), 2, 'Jan 13 2007 should be week 2');
- assert.equal(moment([2007, 0, 14]).week(), 3, 'Jan 14 2007 should be week 3');
-});
-
-test('weeks year starting tuesday', function (assert) {
- assert.equal(moment([2007, 11, 29]).week(), 52, 'Dec 29 2007 should be week 52');
- assert.equal(moment([2008, 0, 1]).week(), 1, 'Jan 1 2008 should be week 1');
- assert.equal(moment([2008, 0, 5]).week(), 1, 'Jan 5 2008 should be week 1');
- assert.equal(moment([2008, 0, 6]).week(), 2, 'Jan 6 2008 should be week 2');
- assert.equal(moment([2008, 0, 12]).week(), 2, 'Jan 12 2008 should be week 2');
- assert.equal(moment([2008, 0, 13]).week(), 3, 'Jan 13 2008 should be week 3');
-});
-
-test('weeks year starting wednesday', function (assert) {
- assert.equal(moment([2002, 11, 29]).week(), 1, 'Dec 29 2002 should be week 1');
- assert.equal(moment([2003, 0, 1]).week(), 1, 'Jan 1 2003 should be week 1');
- assert.equal(moment([2003, 0, 4]).week(), 1, 'Jan 4 2003 should be week 1');
- assert.equal(moment([2003, 0, 5]).week(), 2, 'Jan 5 2003 should be week 2');
- assert.equal(moment([2003, 0, 11]).week(), 2, 'Jan 11 2003 should be week 2');
- assert.equal(moment([2003, 0, 12]).week(), 3, 'Jan 12 2003 should be week 3');
-});
-
-test('weeks year starting thursday', function (assert) {
- assert.equal(moment([2008, 11, 28]).week(), 1, 'Dec 28 2008 should be week 1');
- assert.equal(moment([2009, 0, 1]).week(), 1, 'Jan 1 2009 should be week 1');
- assert.equal(moment([2009, 0, 3]).week(), 1, 'Jan 3 2009 should be week 1');
- assert.equal(moment([2009, 0, 4]).week(), 2, 'Jan 4 2009 should be week 2');
- assert.equal(moment([2009, 0, 10]).week(), 2, 'Jan 10 2009 should be week 2');
- assert.equal(moment([2009, 0, 11]).week(), 3, 'Jan 11 2009 should be week 3');
-});
-
-test('weeks year starting friday', function (assert) {
- assert.equal(moment([2009, 11, 27]).week(), 1, 'Dec 27 2009 should be week 1');
- assert.equal(moment([2010, 0, 1]).week(), 1, 'Jan 1 2010 should be week 1');
- assert.equal(moment([2010, 0, 2]).week(), 1, 'Jan 2 2010 should be week 1');
- assert.equal(moment([2010, 0, 3]).week(), 2, 'Jan 3 2010 should be week 2');
- assert.equal(moment([2010, 0, 9]).week(), 2, 'Jan 9 2010 should be week 2');
- assert.equal(moment([2010, 0, 10]).week(), 3, 'Jan 10 2010 should be week 3');
-});
-
-test('weeks year starting saturday', function (assert) {
- assert.equal(moment([2010, 11, 26]).week(), 1, 'Dec 26 2010 should be week 1');
- assert.equal(moment([2011, 0, 1]).week(), 1, 'Jan 1 2011 should be week 1');
- assert.equal(moment([2011, 0, 2]).week(), 2, 'Jan 2 2011 should be week 2');
- assert.equal(moment([2011, 0, 8]).week(), 2, 'Jan 8 2011 should be week 2');
- assert.equal(moment([2011, 0, 9]).week(), 3, 'Jan 9 2011 should be week 3');
-});
-
test('weeks year starting sunday format', function (assert) {
assert.equal(moment([2012, 0, 1]).format('w ww wo'), '1 01 1', 'Jan 1 2012 should be week 1');
assert.equal(moment([2012, 0, 7]).format('w ww wo'), '1 01 1', 'Jan 7 2012 should be week 1');
@@ -233,38 +172,3 @@
assert.equal(moment([2012, 0, 15]).format('w ww wo'), '3 03 3', 'Jan 15 2012 should be week 3');
});
-test('lenient ordinal parsing', function (assert) {
- var i, ordinalStr, testMoment;
- for (i = 1; i <= 31; ++i) {
- ordinalStr = moment([2014, 0, i]).format('YYYY MM Do');
- testMoment = moment(ordinalStr, 'YYYY MM Do');
- assert.equal(testMoment.year(), 2014,
- 'lenient ordinal parsing ' + i + ' year check');
- assert.equal(testMoment.month(), 0,
- 'lenient ordinal parsing ' + i + ' month check');
- assert.equal(testMoment.date(), i,
- 'lenient ordinal parsing ' + i + ' date check');
- }
-});
-
-test('lenient ordinal parsing of number', function (assert) {
- var i, testMoment;
- for (i = 1; i <= 31; ++i) {
- testMoment = moment('2014 01 ' + i, 'YYYY MM Do');
- assert.equal(testMoment.year(), 2014,
- 'lenient ordinal parsing of number ' + i + ' year check');
- assert.equal(testMoment.month(), 0,
- 'lenient ordinal parsing of number ' + i + ' month check');
- assert.equal(testMoment.date(), i,
- 'lenient ordinal parsing of number ' + i + ' date check');
- }
-});
-
-test('strict ordinal parsing', function (assert) {
- var i, ordinalStr, testMoment;
- for (i = 1; i <= 31; ++i) {
- ordinalStr = moment([2014, 0, i]).format('YYYY MM Do');
- testMoment = moment(ordinalStr, 'YYYY MM Do', true);
- assert.ok(testMoment.isValid(), 'strict ordinal parsing ' + i);
- }
-});
diff --git a/src/test/locale/hi.js b/src/test/locale/hi.js
index 341ab37..d1ff58a 100644
--- a/src/test/locale/hi.js
+++ b/src/test/locale/hi.js
@@ -150,14 +150,14 @@
});
test('calendar day', function (assert) {
- var a = moment().hours(2).minutes(0).seconds(0);
-
- assert.equal(moment(a).calendar(), 'आज रात २:०० बजे', 'today at the same time');
- assert.equal(moment(a).add({m: 25}).calendar(), 'आज रात २:२५ बजे', 'Now plus 25 min');
- assert.equal(moment(a).add({h: 3}).calendar(), 'आज सुबह ५:०० बजे', 'Now plus 3 hour');
- assert.equal(moment(a).add({d: 1}).calendar(), 'कल रात २:०० बजे', 'tomorrow at the same time');
- assert.equal(moment(a).subtract({h: 1}).calendar(), 'आज रात १:०० बजे', 'Now minus 1 hour');
- assert.equal(moment(a).subtract({d: 1}).calendar(), 'कल रात २:०० बजे', 'yesterday at the same time');
+ var a = moment().hours(12).minutes(0).seconds(0);
+
+ assert.equal(moment(a).calendar(), 'आज दोपहर १२:०० बजे', 'today at the same time');
+ assert.equal(moment(a).add({m: 25}).calendar(), 'आज दोपहर १२:२५ बजे', 'Now plus 25 min');
+ assert.equal(moment(a).add({h: 3}).calendar(), 'आज दोपहर ३:०० बजे', 'Now plus 3 hours');
+ assert.equal(moment(a).add({d: 1}).calendar(), 'कल दोपहर १२:०० बजे', 'tomorrow at the same time');
+ assert.equal(moment(a).subtract({h: 1}).calendar(), 'आज दोपहर ११:०० बजे', 'Now minus 1 hour');
+ assert.equal(moment(a).subtract({d: 1}).calendar(), 'कल दोपहर १२:०० बजे', 'yesterday at the same time');
});
test('calendar next week', function (assert) {
@@ -199,7 +199,7 @@
assert.equal(weeksFromNow.calendar(), weeksFromNow.format('L'), 'in 2 weeks');
});
-test('meridiem invariant', function (assert) {
+test('meridiem', function (assert) {
assert.equal(moment([2011, 2, 23, 2, 30]).format('a'), 'रात', 'before dawn');
assert.equal(moment([2011, 2, 23, 9, 30]).format('a'), 'सुबह', 'morning');
assert.equal(moment([2011, 2, 23, 14, 30]).format('a'), 'दोपहर', 'during day');
@@ -215,67 +215,6 @@
assert.equal(moment([2011, 2, 23, 21, 20]).format('A'), 'रात', 'night');
});
-test('weeks year starting sunday', function (assert) {
- assert.equal(moment([2012, 0, 1]).week(), 1, 'Jan 1 2012 should be week 1');
- assert.equal(moment([2012, 0, 7]).week(), 1, 'Jan 7 2012 should be week 1');
- assert.equal(moment([2012, 0, 8]).week(), 2, 'Jan 8 2012 should be week 2');
- assert.equal(moment([2012, 0, 14]).week(), 2, 'Jan 14 2012 should be week 2');
- assert.equal(moment([2012, 0, 15]).week(), 3, 'Jan 15 2012 should be week 3');
-});
-
-test('weeks year starting monday', function (assert) {
- assert.equal(moment([2006, 11, 31]).week(), 1, 'Dec 31 2006 should be week 1');
- assert.equal(moment([2007, 0, 1]).week(), 1, 'Jan 1 2007 should be week 1');
- assert.equal(moment([2007, 0, 6]).week(), 1, 'Jan 6 2007 should be week 1');
- assert.equal(moment([2007, 0, 7]).week(), 2, 'Jan 7 2007 should be week 2');
- assert.equal(moment([2007, 0, 13]).week(), 2, 'Jan 13 2007 should be week 2');
- assert.equal(moment([2007, 0, 14]).week(), 3, 'Jan 14 2007 should be week 3');
-});
-
-test('weeks year starting tuesday', function (assert) {
- assert.equal(moment([2007, 11, 29]).week(), 52, 'Dec 29 2007 should be week 52');
- assert.equal(moment([2008, 0, 1]).week(), 1, 'Jan 1 2008 should be week 1');
- assert.equal(moment([2008, 0, 5]).week(), 1, 'Jan 5 2008 should be week 1');
- assert.equal(moment([2008, 0, 6]).week(), 2, 'Jan 6 2008 should be week 2');
- assert.equal(moment([2008, 0, 12]).week(), 2, 'Jan 12 2008 should be week 2');
- assert.equal(moment([2008, 0, 13]).week(), 3, 'Jan 13 2008 should be week 3');
-});
-
-test('weeks year starting wednesday', function (assert) {
- assert.equal(moment([2002, 11, 29]).week(), 1, 'Dec 29 2002 should be week 1');
- assert.equal(moment([2003, 0, 1]).week(), 1, 'Jan 1 2003 should be week 1');
- assert.equal(moment([2003, 0, 4]).week(), 1, 'Jan 4 2003 should be week 1');
- assert.equal(moment([2003, 0, 5]).week(), 2, 'Jan 5 2003 should be week 2');
- assert.equal(moment([2003, 0, 11]).week(), 2, 'Jan 11 2003 should be week 2');
- assert.equal(moment([2003, 0, 12]).week(), 3, 'Jan 12 2003 should be week 3');
-});
-
-test('weeks year starting thursday', function (assert) {
- assert.equal(moment([2008, 11, 28]).week(), 1, 'Dec 28 2008 should be week 1');
- assert.equal(moment([2009, 0, 1]).week(), 1, 'Jan 1 2009 should be week 1');
- assert.equal(moment([2009, 0, 3]).week(), 1, 'Jan 3 2009 should be week 1');
- assert.equal(moment([2009, 0, 4]).week(), 2, 'Jan 4 2009 should be week 2');
- assert.equal(moment([2009, 0, 10]).week(), 2, 'Jan 10 2009 should be week 2');
- assert.equal(moment([2009, 0, 11]).week(), 3, 'Jan 11 2009 should be week 3');
-});
-
-test('weeks year starting friday', function (assert) {
- assert.equal(moment([2009, 11, 27]).week(), 1, 'Dec 27 2009 should be week 1');
- assert.equal(moment([2010, 0, 1]).week(), 1, 'Jan 1 2010 should be week 1');
- assert.equal(moment([2010, 0, 2]).week(), 1, 'Jan 2 2010 should be week 1');
- assert.equal(moment([2010, 0, 3]).week(), 2, 'Jan 3 2010 should be week 2');
- assert.equal(moment([2010, 0, 9]).week(), 2, 'Jan 9 2010 should be week 2');
- assert.equal(moment([2010, 0, 10]).week(), 3, 'Jan 10 2010 should be week 3');
-});
-
-test('weeks year starting saturday', function (assert) {
- assert.equal(moment([2010, 11, 26]).week(), 1, 'Dec 26 2010 should be week 1');
- assert.equal(moment([2011, 0, 1]).week(), 1, 'Jan 1 2011 should be week 1');
- assert.equal(moment([2011, 0, 2]).week(), 2, 'Jan 2 2011 should be week 2');
- assert.equal(moment([2011, 0, 8]).week(), 2, 'Jan 8 2011 should be week 2');
- assert.equal(moment([2011, 0, 9]).week(), 3, 'Jan 9 2011 should be week 3');
-});
-
test('weeks year starting sunday formatted', function (assert) {
assert.equal(moment([2012, 0, 1]).format('w ww wo'), '१ ०१ १', 'Jan 1 2012 should be week 1');
assert.equal(moment([2012, 0, 7]).format('w ww wo'), '१ ०१ १', 'Jan 7 2012 should be week 1');
@@ -284,50 +223,3 @@
assert.equal(moment([2012, 0, 15]).format('w ww wo'), '३ ०३ ३', 'Jan 15 2012 should be week 3');
});
-test('lenient ordinal parsing', function (assert) {
- var i, ordinalStr, testMoment;
- for (i = 1; i <= 31; ++i) {
- ordinalStr = moment([2014, 0, i]).format('YYYY MM Do');
- testMoment = moment(ordinalStr, 'YYYY MM Do');
- assert.equal(testMoment.year(), 2014,
- 'lenient ordinal parsing ' + i + ' year check');
- assert.equal(testMoment.month(), 0,
- 'lenient ordinal parsing ' + i + ' month check');
- assert.equal(testMoment.date(), i,
- 'lenient ordinal parsing ' + i + ' date check');
- }
-});
-
-test('lenient ordinal parsing of number', function (assert) {
- var i, testMoment;
- for (i = 1; i <= 31; ++i) {
- testMoment = moment('2014 01 ' + i, 'YYYY MM Do');
- assert.equal(testMoment.year(), 2014,
- 'lenient ordinal parsing of number ' + i + ' year check');
- assert.equal(testMoment.month(), 0,
- 'lenient ordinal parsing of number ' + i + ' month check');
- assert.equal(testMoment.date(), i,
- 'lenient ordinal parsing of number ' + i + ' date check');
- }
-});
-
-test('meridiem', function (assert) {
- var h, m, t1, t2;
- for (h = 0; h < 24; ++h) {
- for (m = 0; m < 60; m += 15) {
- t1 = moment.utc([2000, 0, 1, h, m]);
- t2 = moment(t1.format('A h:mm'), 'A h:mm');
- assert.equal(t2.format('HH:mm'), t1.format('HH:mm'),
- 'meridiem at ' + t1.format('HH:mm'));
- }
- }
-});
-
-test('strict ordinal parsing', function (assert) {
- var i, ordinalStr, testMoment;
- for (i = 1; i <= 31; ++i) {
- ordinalStr = moment([2014, 0, i]).format('YYYY MM Do');
- testMoment = moment(ordinalStr, 'YYYY MM Do', true);
- assert.ok(testMoment.isValid(), 'strict ordinal parsing ' + i);
- }
-});
diff --git a/src/test/locale/hr.js b/src/test/locale/hr.js
index cbc91f4..8bfa4b9 100644
--- a/src/test/locale/hr.js
+++ b/src/test/locale/hr.js
@@ -151,14 +151,14 @@
});
test('calendar day', function (assert) {
- var a = moment().hours(2).minutes(0).seconds(0);
-
- assert.equal(moment(a).calendar(), 'danas u 2:00', 'today at the same time');
- assert.equal(moment(a).add({m: 25}).calendar(), 'danas u 2:25', 'Now plus 25 min');
- assert.equal(moment(a).add({h: 1}).calendar(), 'danas u 3:00', 'Now plus 1 hour');
- assert.equal(moment(a).add({d: 1}).calendar(), 'sutra u 2:00', 'tomorrow at the same time');
- assert.equal(moment(a).subtract({h: 1}).calendar(), 'danas u 1:00', 'Now minus 1 hour');
- assert.equal(moment(a).subtract({d: 1}).calendar(), 'jučer u 2:00', 'yesterday at the same time');
+ var a = moment().hours(12).minutes(0).seconds(0);
+
+ assert.equal(moment(a).calendar(), 'danas u 12:00', 'today at the same time');
+ assert.equal(moment(a).add({m: 25}).calendar(), 'danas u 12:25', 'Now plus 25 min');
+ assert.equal(moment(a).add({h: 1}).calendar(), 'danas u 13:00', 'Now plus 1 hour');
+ assert.equal(moment(a).add({d: 1}).calendar(), 'sutra u 12:00', 'tomorrow at the same time');
+ assert.equal(moment(a).subtract({h: 1}).calendar(), 'danas u 11:00', 'Now minus 1 hour');
+ assert.equal(moment(a).subtract({d: 1}).calendar(), 'jučer u 12:00', 'yesterday at the same time');
});
test('calendar next week', function (assert) {
@@ -232,67 +232,6 @@
assert.equal(weeksFromNow.calendar(), weeksFromNow.format('L'), 'in 2 weeks');
});
-test('weeks year starting sunday', function (assert) {
- assert.equal(moment([2011, 11, 26]).week(), 1, 'Dec 26 2011 should be week 1');
- assert.equal(moment([2012, 0, 1]).week(), 1, 'Jan 1 2012 should be week 1');
- assert.equal(moment([2012, 0, 2]).week(), 2, 'Jan 2 2012 should be week 2');
- assert.equal(moment([2012, 0, 8]).week(), 2, 'Jan 8 2012 should be week 2');
- assert.equal(moment([2012, 0, 9]).week(), 3, 'Jan 9 2012 should be week 3');
-});
-
-test('weeks year starting monday', function (assert) {
- assert.equal(moment([2007, 0, 1]).week(), 1, 'Jan 1 2007 should be week 1');
- assert.equal(moment([2007, 0, 7]).week(), 1, 'Jan 7 2007 should be week 1');
- assert.equal(moment([2007, 0, 8]).week(), 2, 'Jan 8 2007 should be week 2');
- assert.equal(moment([2007, 0, 14]).week(), 2, 'Jan 14 2007 should be week 2');
- assert.equal(moment([2007, 0, 15]).week(), 3, 'Jan 15 2007 should be week 3');
-});
-
-test('weeks year starting tuesday', function (assert) {
- assert.equal(moment([2007, 11, 31]).week(), 1, 'Dec 31 2007 should be week 1');
- assert.equal(moment([2008, 0, 1]).week(), 1, 'Jan 1 2008 should be week 1');
- assert.equal(moment([2008, 0, 6]).week(), 1, 'Jan 6 2008 should be week 1');
- assert.equal(moment([2008, 0, 7]).week(), 2, 'Jan 7 2008 should be week 2');
- assert.equal(moment([2008, 0, 13]).week(), 2, 'Jan 13 2008 should be week 2');
- assert.equal(moment([2008, 0, 14]).week(), 3, 'Jan 14 2008 should be week 3');
-});
-
-test('weeks year starting wednesday', function (assert) {
- assert.equal(moment([2002, 11, 30]).week(), 1, 'Dec 30 2002 should be week 1');
- assert.equal(moment([2003, 0, 1]).week(), 1, 'Jan 1 2003 should be week 1');
- assert.equal(moment([2003, 0, 5]).week(), 1, 'Jan 5 2003 should be week 1');
- assert.equal(moment([2003, 0, 6]).week(), 2, 'Jan 6 2003 should be week 2');
- assert.equal(moment([2003, 0, 12]).week(), 2, 'Jan 12 2003 should be week 2');
- assert.equal(moment([2003, 0, 13]).week(), 3, 'Jan 13 2003 should be week 3');
-});
-
-test('weeks year starting thursday', function (assert) {
- assert.equal(moment([2008, 11, 29]).week(), 1, 'Dec 29 2008 should be week 1');
- assert.equal(moment([2009, 0, 1]).week(), 1, 'Jan 1 2009 should be week 1');
- assert.equal(moment([2009, 0, 4]).week(), 1, 'Jan 4 2009 should be week 1');
- assert.equal(moment([2009, 0, 5]).week(), 2, 'Jan 5 2009 should be week 2');
- assert.equal(moment([2009, 0, 11]).week(), 2, 'Jan 11 2009 should be week 2');
- assert.equal(moment([2009, 0, 12]).week(), 3, 'Jan 12 2009 should be week 3');
-});
-
-test('weeks year starting friday', function (assert) {
- assert.equal(moment([2009, 11, 28]).week(), 1, 'Dec 28 2009 should be week 1');
- assert.equal(moment([2010, 0, 1]).week(), 1, 'Jan 1 2010 should be week 1');
- assert.equal(moment([2010, 0, 3]).week(), 1, 'Jan 3 2010 should be week 1');
- assert.equal(moment([2010, 0, 4]).week(), 2, 'Jan 4 2010 should be week 2');
- assert.equal(moment([2010, 0, 10]).week(), 2, 'Jan 10 2010 should be week 2');
- assert.equal(moment([2010, 0, 11]).week(), 3, 'Jan 11 2010 should be week 3');
-});
-
-test('weeks year starting saturday', function (assert) {
- assert.equal(moment([2010, 11, 27]).week(), 1, 'Dec 27 2010 should be week 1');
- assert.equal(moment([2011, 0, 1]).week(), 1, 'Jan 1 2011 should be week 1');
- assert.equal(moment([2011, 0, 2]).week(), 1, 'Jan 2 2011 should be week 1');
- assert.equal(moment([2011, 0, 3]).week(), 2, 'Jan 3 2011 should be week 2');
- assert.equal(moment([2011, 0, 9]).week(), 2, 'Jan 9 2011 should be week 2');
- assert.equal(moment([2011, 0, 10]).week(), 3, 'Jan 10 2011 should be week 3');
-});
-
test('weeks year starting sunday formatted', function (assert) {
assert.equal(moment([2011, 11, 26]).format('w ww wo'), '1 01 1.', 'Dec 26 2011 should be week 1');
assert.equal(moment([2012, 0, 1]).format('w ww wo'), '1 01 1.', 'Jan 1 2012 should be week 1');
@@ -301,38 +240,3 @@
assert.equal(moment([2012, 0, 9]).format('w ww wo'), '3 03 3.', 'Jan 9 2012 should be week 3');
});
-test('lenient ordinal parsing', function (assert) {
- var i, ordinalStr, testMoment;
- for (i = 1; i <= 31; ++i) {
- ordinalStr = moment([2014, 0, i]).format('YYYY MM Do');
- testMoment = moment(ordinalStr, 'YYYY MM Do');
- assert.equal(testMoment.year(), 2014,
- 'lenient ordinal parsing ' + i + ' year check');
- assert.equal(testMoment.month(), 0,
- 'lenient ordinal parsing ' + i + ' month check');
- assert.equal(testMoment.date(), i,
- 'lenient ordinal parsing ' + i + ' date check');
- }
-});
-
-test('lenient ordinal parsing of number', function (assert) {
- var i, testMoment;
- for (i = 1; i <= 31; ++i) {
- testMoment = moment('2014 01 ' + i, 'YYYY MM Do');
- assert.equal(testMoment.year(), 2014,
- 'lenient ordinal parsing of number ' + i + ' year check');
- assert.equal(testMoment.month(), 0,
- 'lenient ordinal parsing of number ' + i + ' month check');
- assert.equal(testMoment.date(), i,
- 'lenient ordinal parsing of number ' + i + ' date check');
- }
-});
-
-test('strict ordinal parsing', function (assert) {
- var i, ordinalStr, testMoment;
- for (i = 1; i <= 31; ++i) {
- ordinalStr = moment([2014, 0, i]).format('YYYY MM Do');
- testMoment = moment(ordinalStr, 'YYYY MM Do', true);
- assert.ok(testMoment.isValid(), 'strict ordinal parsing ' + i);
- }
-});
diff --git a/src/test/locale/hu.js b/src/test/locale/hu.js
index 676f426..ff0270b 100644
--- a/src/test/locale/hu.js
+++ b/src/test/locale/hu.js
@@ -164,14 +164,14 @@
});
test('calendar day', function (assert) {
- var a = moment().hours(2).minutes(0).seconds(0);
-
- assert.equal(moment(a).calendar(), 'ma 2:00-kor', 'today at the same time');
- assert.equal(moment(a).add({m: 25}).calendar(), 'ma 2:25-kor', 'Now plus 25 min');
- assert.equal(moment(a).add({h: 1}).calendar(), 'ma 3:00-kor', 'Now plus 1 hour');
- assert.equal(moment(a).add({d: 1}).calendar(), 'holnap 2:00-kor', 'tomorrow at the same time');
- assert.equal(moment(a).subtract({h: 1}).calendar(), 'ma 1:00-kor', 'Now minus 1 hour');
- assert.equal(moment(a).subtract({d: 1}).calendar(), 'tegnap 2:00-kor', 'yesterday at the same time');
+ var a = moment().hours(12).minutes(0).seconds(0);
+
+ assert.equal(moment(a).calendar(), 'ma 12:00-kor', 'today at the same time');
+ assert.equal(moment(a).add({m: 25}).calendar(), 'ma 12:25-kor', 'Now plus 25 min');
+ assert.equal(moment(a).add({h: 1}).calendar(), 'ma 13:00-kor', 'Now plus 1 hour');
+ assert.equal(moment(a).add({d: 1}).calendar(), 'holnap 12:00-kor', 'tomorrow at the same time');
+ assert.equal(moment(a).subtract({h: 1}).calendar(), 'ma 11:00-kor', 'Now minus 1 hour');
+ assert.equal(moment(a).subtract({d: 1}).calendar(), 'tegnap 12:00-kor', 'yesterday at the same time');
});
test('calendar next week', function (assert) {
@@ -213,67 +213,6 @@
assert.equal(weeksFromNow.calendar(), weeksFromNow.format('L'), '2 hét múlva');
});
-test('weeks year starting sunday', function (assert) {
- assert.equal(moment([2011, 11, 26]).week(), 1, 'Dec 26 2011 should be week 1');
- assert.equal(moment([2012, 0, 1]).week(), 1, 'Jan 1 2012 should be week 1');
- assert.equal(moment([2012, 0, 2]).week(), 2, 'Jan 2 2012 should be week 2');
- assert.equal(moment([2012, 0, 8]).week(), 2, 'Jan 8 2012 should be week 2');
- assert.equal(moment([2012, 0, 9]).week(), 3, 'Jan 9 2012 should be week 3');
-});
-
-test('weeks year starting monday', function (assert) {
- assert.equal(moment([2007, 0, 1]).week(), 1, 'Jan 1 2007 should be week 1');
- assert.equal(moment([2007, 0, 7]).week(), 1, 'Jan 7 2007 should be week 1');
- assert.equal(moment([2007, 0, 8]).week(), 2, 'Jan 8 2007 should be week 2');
- assert.equal(moment([2007, 0, 14]).week(), 2, 'Jan 14 2007 should be week 2');
- assert.equal(moment([2007, 0, 15]).week(), 3, 'Jan 15 2007 should be week 3');
-});
-
-test('weeks year starting tuesday', function (assert) {
- assert.equal(moment([2007, 11, 31]).week(), 1, 'Dec 31 2007 should be week 1');
- assert.equal(moment([2008, 0, 1]).week(), 1, 'Jan 1 2008 should be week 1');
- assert.equal(moment([2008, 0, 6]).week(), 1, 'Jan 6 2008 should be week 1');
- assert.equal(moment([2008, 0, 7]).week(), 2, 'Jan 7 2008 should be week 2');
- assert.equal(moment([2008, 0, 13]).week(), 2, 'Jan 13 2008 should be week 2');
- assert.equal(moment([2008, 0, 14]).week(), 3, 'Jan 14 2008 should be week 3');
-});
-
-test('weeks year starting wednesday', function (assert) {
- assert.equal(moment([2002, 11, 30]).week(), 1, 'Dec 30 2002 should be week 1');
- assert.equal(moment([2003, 0, 1]).week(), 1, 'Jan 1 2003 should be week 1');
- assert.equal(moment([2003, 0, 5]).week(), 1, 'Jan 5 2003 should be week 1');
- assert.equal(moment([2003, 0, 6]).week(), 2, 'Jan 6 2003 should be week 2');
- assert.equal(moment([2003, 0, 12]).week(), 2, 'Jan 12 2003 should be week 2');
- assert.equal(moment([2003, 0, 13]).week(), 3, 'Jan 13 2003 should be week 3');
-});
-
-test('weeks year starting thursday', function (assert) {
- assert.equal(moment([2008, 11, 29]).week(), 1, 'Dec 29 2008 should be week 1');
- assert.equal(moment([2009, 0, 1]).week(), 1, 'Jan 1 2009 should be week 1');
- assert.equal(moment([2009, 0, 4]).week(), 1, 'Jan 4 2009 should be week 1');
- assert.equal(moment([2009, 0, 5]).week(), 2, 'Jan 5 2009 should be week 2');
- assert.equal(moment([2009, 0, 11]).week(), 2, 'Jan 11 2009 should be week 2');
- assert.equal(moment([2009, 0, 12]).week(), 3, 'Jan 12 2009 should be week 3');
-});
-
-test('weeks year starting friday', function (assert) {
- assert.equal(moment([2009, 11, 28]).week(), 1, 'Dec 28 2009 should be week 1');
- assert.equal(moment([2010, 0, 1]).week(), 1, 'Jan 1 2010 should be week 1');
- assert.equal(moment([2010, 0, 3]).week(), 1, 'Jan 3 2010 should be week 1');
- assert.equal(moment([2010, 0, 4]).week(), 2, 'Jan 4 2010 should be week 2');
- assert.equal(moment([2010, 0, 10]).week(), 2, 'Jan 10 2010 should be week 2');
- assert.equal(moment([2010, 0, 11]).week(), 3, 'Jan 11 2010 should be week 3');
-});
-
-test('weeks year starting saturday', function (assert) {
- assert.equal(moment([2010, 11, 27]).week(), 1, 'Dec 27 2010 should be week 1');
- assert.equal(moment([2011, 0, 1]).week(), 1, 'Jan 1 2011 should be week 1');
- assert.equal(moment([2011, 0, 2]).week(), 1, 'Jan 2 2011 should be week 1');
- assert.equal(moment([2011, 0, 3]).week(), 2, 'Jan 3 2011 should be week 2');
- assert.equal(moment([2011, 0, 9]).week(), 2, 'Jan 9 2011 should be week 2');
- assert.equal(moment([2011, 0, 10]).week(), 3, 'Jan 10 2011 should be week 3');
-});
-
test('weeks year starting sunday formatted', function (assert) {
assert.equal(moment([2011, 11, 26]).format('w ww wo'), '1 01 1.', 'Dec 26 2011 should be week 1');
assert.equal(moment([2012, 0, 1]).format('w ww wo'), '1 01 1.', 'Jan 1 2012 should be week 1');
@@ -282,38 +221,3 @@
assert.equal(moment([2012, 0, 9]).format('w ww wo'), '3 03 3.', 'Jan 9 2012 should be week 3');
});
-test('lenient ordinal parsing', function (assert) {
- var i, ordinalStr, testMoment;
- for (i = 1; i <= 31; ++i) {
- ordinalStr = moment([2014, 0, i]).format('YYYY MM Do');
- testMoment = moment(ordinalStr, 'YYYY MM Do');
- assert.equal(testMoment.year(), 2014,
- 'lenient ordinal parsing ' + i + ' year check');
- assert.equal(testMoment.month(), 0,
- 'lenient ordinal parsing ' + i + ' month check');
- assert.equal(testMoment.date(), i,
- 'lenient ordinal parsing ' + i + ' date check');
- }
-});
-
-test('lenient ordinal parsing of number', function (assert) {
- var i, testMoment;
- for (i = 1; i <= 31; ++i) {
- testMoment = moment('2014 01 ' + i, 'YYYY MM Do');
- assert.equal(testMoment.year(), 2014,
- 'lenient ordinal parsing of number ' + i + ' year check');
- assert.equal(testMoment.month(), 0,
- 'lenient ordinal parsing of number ' + i + ' month check');
- assert.equal(testMoment.date(), i,
- 'lenient ordinal parsing of number ' + i + ' date check');
- }
-});
-
-test('strict ordinal parsing', function (assert) {
- var i, ordinalStr, testMoment;
- for (i = 1; i <= 31; ++i) {
- ordinalStr = moment([2014, 0, i]).format('YYYY MM Do');
- testMoment = moment(ordinalStr, 'YYYY MM Do', true);
- assert.ok(testMoment.isValid(), 'strict ordinal parsing ' + i);
- }
-});
diff --git a/src/test/locale/hy-am.js b/src/test/locale/hy-am.js
index 39dfcc5..6964c40 100644
--- a/src/test/locale/hy-am.js
+++ b/src/test/locale/hy-am.js
@@ -212,14 +212,14 @@
});
test('calendar day', function (assert) {
- var a = moment().hours(2).minutes(0).seconds(0);
-
- assert.equal(moment(a).calendar(), 'այսօր 02:00', 'today at the same time');
- assert.equal(moment(a).add({m: 25}).calendar(), 'այսօր 02:25', 'Now plus 25 min');
- assert.equal(moment(a).add({h: 1}).calendar(), 'այսօր 03:00', 'Now plus 1 hour');
- assert.equal(moment(a).add({d: 1}).calendar(), 'վաղը 02:00', 'tomorrow at the same time');
- assert.equal(moment(a).subtract({h: 1}).calendar(), 'այսօր 01:00', 'Now minus 1 hour');
- assert.equal(moment(a).subtract({d: 1}).calendar(), 'երեկ 02:00', 'yesterday at the same time');
+ var a = moment().hours(12).minutes(0).seconds(0);
+
+ assert.equal(moment(a).calendar(), 'այսօր 12:00', 'today at the same time');
+ assert.equal(moment(a).add({m: 25}).calendar(), 'այսօր 12:25', 'Now plus 25 min');
+ assert.equal(moment(a).add({h: 1}).calendar(), 'այսօր 13:00', 'Now plus 1 hour');
+ assert.equal(moment(a).add({d: 1}).calendar(), 'վաղը 12:00', 'tomorrow at the same time');
+ assert.equal(moment(a).subtract({h: 1}).calendar(), 'այսօր 11:00', 'Now minus 1 hour');
+ assert.equal(moment(a).subtract({d: 1}).calendar(), 'երեկ 12:00', 'yesterday at the same time');
});
test('calendar next week', function (assert) {
@@ -269,67 +269,6 @@
assert.equal(weeksFromNow.calendar(), weeksFromNow.format('L'), 'in 2 weeks');
});
-test('weeks year starting sunday', function (assert) {
- assert.equal(moment([2011, 11, 26]).week(), 1, 'Dec 26 2011 should be week 1');
- assert.equal(moment([2012, 0, 1]).week(), 1, 'Jan 1 2012 should be week 1');
- assert.equal(moment([2012, 0, 2]).week(), 2, 'Jan 2 2012 should be week 2');
- assert.equal(moment([2012, 0, 8]).week(), 2, 'Jan 8 2012 should be week 2');
- assert.equal(moment([2012, 0, 9]).week(), 3, 'Jan 9 2012 should be week 3');
-});
-
-test('weeks year starting monday', function (assert) {
- assert.equal(moment([2007, 0, 1]).week(), 1, 'Jan 1 2007 should be week 1');
- assert.equal(moment([2007, 0, 7]).week(), 1, 'Jan 7 2007 should be week 1');
- assert.equal(moment([2007, 0, 8]).week(), 2, 'Jan 8 2007 should be week 2');
- assert.equal(moment([2007, 0, 14]).week(), 2, 'Jan 14 2007 should be week 2');
- assert.equal(moment([2007, 0, 15]).week(), 3, 'Jan 15 2007 should be week 3');
-});
-
-test('weeks year starting tuesday', function (assert) {
- assert.equal(moment([2007, 11, 31]).week(), 1, 'Dec 31 2007 should be week 1');
- assert.equal(moment([2008, 0, 1]).week(), 1, 'Jan 1 2008 should be week 1');
- assert.equal(moment([2008, 0, 6]).week(), 1, 'Jan 6 2008 should be week 1');
- assert.equal(moment([2008, 0, 7]).week(), 2, 'Jan 7 2008 should be week 2');
- assert.equal(moment([2008, 0, 13]).week(), 2, 'Jan 13 2008 should be week 2');
- assert.equal(moment([2008, 0, 14]).week(), 3, 'Jan 14 2008 should be week 3');
-});
-
-test('weeks year starting wednesday', function (assert) {
- assert.equal(moment([2002, 11, 30]).week(), 1, 'Dec 30 2002 should be week 1');
- assert.equal(moment([2003, 0, 1]).week(), 1, 'Jan 1 2003 should be week 1');
- assert.equal(moment([2003, 0, 5]).week(), 1, 'Jan 5 2003 should be week 1');
- assert.equal(moment([2003, 0, 6]).week(), 2, 'Jan 6 2003 should be week 2');
- assert.equal(moment([2003, 0, 12]).week(), 2, 'Jan 12 2003 should be week 2');
- assert.equal(moment([2003, 0, 13]).week(), 3, 'Jan 13 2003 should be week 3');
-});
-
-test('weeks year starting thursday', function (assert) {
- assert.equal(moment([2008, 11, 29]).week(), 1, 'Dec 29 2008 should be week 1');
- assert.equal(moment([2009, 0, 1]).week(), 1, 'Jan 1 2009 should be week 1');
- assert.equal(moment([2009, 0, 4]).week(), 1, 'Jan 4 2009 should be week 1');
- assert.equal(moment([2009, 0, 5]).week(), 2, 'Jan 5 2009 should be week 2');
- assert.equal(moment([2009, 0, 11]).week(), 2, 'Jan 11 2009 should be week 2');
- assert.equal(moment([2009, 0, 12]).week(), 3, 'Jan 12 2009 should be week 3');
-});
-
-test('weeks year starting friday', function (assert) {
- assert.equal(moment([2009, 11, 28]).week(), 1, 'Dec 28 2009 should be week 1');
- assert.equal(moment([2010, 0, 1]).week(), 1, 'Jan 1 2010 should be week 1');
- assert.equal(moment([2010, 0, 3]).week(), 1, 'Jan 3 2010 should be week 1');
- assert.equal(moment([2010, 0, 4]).week(), 2, 'Jan 4 2010 should be week 2');
- assert.equal(moment([2010, 0, 10]).week(), 2, 'Jan 10 2010 should be week 2');
- assert.equal(moment([2010, 0, 11]).week(), 3, 'Jan 11 2010 should be week 3');
-});
-
-test('weeks year starting saturday', function (assert) {
- assert.equal(moment([2010, 11, 27]).week(), 1, 'Dec 27 2010 should be week 1');
- assert.equal(moment([2011, 0, 1]).week(), 1, 'Jan 1 2011 should be week 1');
- assert.equal(moment([2011, 0, 2]).week(), 1, 'Jan 2 2011 should be week 1');
- assert.equal(moment([2011, 0, 3]).week(), 2, 'Jan 3 2011 should be week 2');
- assert.equal(moment([2011, 0, 9]).week(), 2, 'Jan 9 2011 should be week 2');
- assert.equal(moment([2011, 0, 10]).week(), 3, 'Jan 10 2011 should be week 3');
-});
-
test('weeks year starting sunday formatted', function (assert) {
assert.equal(moment([2011, 11, 26]).format('w ww wo'), '1 01 1-ին', 'Dec 26 2011 should be week 1');
assert.equal(moment([2012, 0, 1]).format('w ww wo'), '1 01 1-ին', 'Jan 1 2012 should be week 1');
@@ -338,38 +277,3 @@
assert.equal(moment([2012, 0, 9]).format('w ww wo'), '3 03 3-րդ', 'Jan 9 2012 should be week 3');
});
-test('lenient ordinal parsing', function (assert) {
- var i, ordinalStr, testMoment;
- for (i = 1; i <= 31; ++i) {
- ordinalStr = moment([2014, 0, i]).format('YYYY MM Do');
- testMoment = moment(ordinalStr, 'YYYY MM Do');
- assert.equal(testMoment.year(), 2014,
- 'lenient ordinal parsing ' + i + ' year check');
- assert.equal(testMoment.month(), 0,
- 'lenient ordinal parsing ' + i + ' month check');
- assert.equal(testMoment.date(), i,
- 'lenient ordinal parsing ' + i + ' date check');
- }
-});
-
-test('lenient ordinal parsing of number', function (assert) {
- var i, testMoment;
- for (i = 1; i <= 31; ++i) {
- testMoment = moment('2014 01 ' + i, 'YYYY MM Do');
- assert.equal(testMoment.year(), 2014,
- 'lenient ordinal parsing of number ' + i + ' year check');
- assert.equal(testMoment.month(), 0,
- 'lenient ordinal parsing of number ' + i + ' month check');
- assert.equal(testMoment.date(), i,
- 'lenient ordinal parsing of number ' + i + ' date check');
- }
-});
-
-test('strict ordinal parsing', function (assert) {
- var i, ordinalStr, testMoment;
- for (i = 1; i <= 31; ++i) {
- ordinalStr = moment([2014, 0, i]).format('YYYY MM Do');
- testMoment = moment(ordinalStr, 'YYYY MM Do', true);
- assert.ok(testMoment.isValid(), 'strict ordinal parsing ' + i);
- }
-});
diff --git a/src/test/locale/id.js b/src/test/locale/id.js
index 869897e..017739a 100644
--- a/src/test/locale/id.js
+++ b/src/test/locale/id.js
@@ -114,14 +114,14 @@
});
test('calendar day', function (assert) {
- var a = moment().hours(2).minutes(0).seconds(0);
+ var a = moment().hours(12).minutes(0).seconds(0);
- assert.equal(moment(a).calendar(), 'Hari ini pukul 02.00', 'today at the same time');
- assert.equal(moment(a).add({m: 25}).calendar(), 'Hari ini pukul 02.25', 'Now plus 25 min');
- assert.equal(moment(a).add({h: 1}).calendar(), 'Hari ini pukul 03.00', 'Now plus 1 hour');
- assert.equal(moment(a).add({d: 1}).calendar(), 'Besok pukul 02.00', 'tomorrow at the same time');
- assert.equal(moment(a).subtract({h: 1}).calendar(), 'Hari ini pukul 01.00', 'Now minus 1 hour');
- assert.equal(moment(a).subtract({d: 1}).calendar(), 'Kemarin pukul 02.00', 'yesterday at the same time');
+ assert.equal(moment(a).calendar(), 'Hari ini pukul 12.00', 'today at the same time');
+ assert.equal(moment(a).add({m: 25}).calendar(), 'Hari ini pukul 12.25', 'Now plus 25 min');
+ assert.equal(moment(a).add({h: 1}).calendar(), 'Hari ini pukul 13.00', 'Now plus 1 hour');
+ assert.equal(moment(a).add({d: 1}).calendar(), 'Besok pukul 12.00', 'tomorrow at the same time');
+ assert.equal(moment(a).subtract({h: 1}).calendar(), 'Hari ini pukul 11.00', 'Now minus 1 hour');
+ assert.equal(moment(a).subtract({d: 1}).calendar(), 'Kemarin pukul 12.00', 'yesterday at the same time');
});
test('calendar next week', function (assert) {
@@ -162,67 +162,6 @@
assert.equal(weeksFromNow.calendar(), weeksFromNow.format('L'), 'in 2 weeks');
});
-test('weeks year starting sunday', function (assert) {
- assert.equal(moment([2011, 11, 26]).week(), 1, 'Dec 26 2011 should be week 1');
- assert.equal(moment([2012, 0, 1]).week(), 1, 'Jan 1 2012 should be week 1');
- assert.equal(moment([2012, 0, 2]).week(), 2, 'Jan 2 2012 should be week 2');
- assert.equal(moment([2012, 0, 8]).week(), 2, 'Jan 8 2012 should be week 2');
- assert.equal(moment([2012, 0, 9]).week(), 3, 'Jan 9 2012 should be week 3');
-});
-
-test('weeks year starting monday', function (assert) {
- assert.equal(moment([2007, 0, 1]).week(), 1, 'Jan 1 2007 should be week 1');
- assert.equal(moment([2007, 0, 7]).week(), 1, 'Jan 7 2007 should be week 1');
- assert.equal(moment([2007, 0, 8]).week(), 2, 'Jan 8 2007 should be week 2');
- assert.equal(moment([2007, 0, 14]).week(), 2, 'Jan 14 2007 should be week 2');
- assert.equal(moment([2007, 0, 15]).week(), 3, 'Jan 15 2007 should be week 3');
-});
-
-test('weeks year starting tuesday', function (assert) {
- assert.equal(moment([2007, 11, 31]).week(), 1, 'Dec 31 2007 should be week 1');
- assert.equal(moment([2008, 0, 1]).week(), 1, 'Jan 1 2008 should be week 1');
- assert.equal(moment([2008, 0, 6]).week(), 1, 'Jan 6 2008 should be week 1');
- assert.equal(moment([2008, 0, 7]).week(), 2, 'Jan 7 2008 should be week 2');
- assert.equal(moment([2008, 0, 13]).week(), 2, 'Jan 13 2008 should be week 2');
- assert.equal(moment([2008, 0, 14]).week(), 3, 'Jan 14 2008 should be week 3');
-});
-
-test('weeks year starting wednesday', function (assert) {
- assert.equal(moment([2002, 11, 30]).week(), 1, 'Dec 30 2002 should be week 1');
- assert.equal(moment([2003, 0, 1]).week(), 1, 'Jan 1 2003 should be week 1');
- assert.equal(moment([2003, 0, 5]).week(), 1, 'Jan 5 2003 should be week 1');
- assert.equal(moment([2003, 0, 6]).week(), 2, 'Jan 6 2003 should be week 2');
- assert.equal(moment([2003, 0, 12]).week(), 2, 'Jan 12 2003 should be week 2');
- assert.equal(moment([2003, 0, 13]).week(), 3, 'Jan 13 2003 should be week 3');
-});
-
-test('weeks year starting thursday', function (assert) {
- assert.equal(moment([2008, 11, 29]).week(), 1, 'Dec 29 2008 should be week 1');
- assert.equal(moment([2009, 0, 1]).week(), 1, 'Jan 1 2009 should be week 1');
- assert.equal(moment([2009, 0, 4]).week(), 1, 'Jan 4 2009 should be week 1');
- assert.equal(moment([2009, 0, 5]).week(), 2, 'Jan 5 2009 should be week 2');
- assert.equal(moment([2009, 0, 11]).week(), 2, 'Jan 11 2009 should be week 2');
- assert.equal(moment([2009, 0, 12]).week(), 3, 'Jan 12 2009 should be week 3');
-});
-
-test('weeks year starting friday', function (assert) {
- assert.equal(moment([2009, 11, 28]).week(), 1, 'Dec 28 2009 should be week 1');
- assert.equal(moment([2010, 0, 1]).week(), 1, 'Jan 1 2010 should be week 1');
- assert.equal(moment([2010, 0, 3]).week(), 1, 'Jan 3 2010 should be week 1');
- assert.equal(moment([2010, 0, 4]).week(), 2, 'Jan 4 2010 should be week 2');
- assert.equal(moment([2010, 0, 10]).week(), 2, 'Jan 10 2010 should be week 2');
- assert.equal(moment([2010, 0, 11]).week(), 3, 'Jan 11 2010 should be week 3');
-});
-
-test('weeks year starting saturday', function (assert) {
- assert.equal(moment([2010, 11, 27]).week(), 1, 'Dec 27 2010 should be week 1');
- assert.equal(moment([2011, 0, 1]).week(), 1, 'Jan 1 2011 should be week 1');
- assert.equal(moment([2011, 0, 2]).week(), 1, 'Jan 2 2011 should be week 1');
- assert.equal(moment([2011, 0, 3]).week(), 2, 'Jan 3 2011 should be week 2');
- assert.equal(moment([2011, 0, 9]).week(), 2, 'Jan 9 2011 should be week 2');
- assert.equal(moment([2011, 0, 10]).week(), 3, 'Jan 10 2011 should be week 3');
-});
-
test('weeks year starting sunday formatted', function (assert) {
assert.equal(moment([2011, 11, 26]).format('w ww wo'), '1 01 1', 'Dec 26 2011 should be week 1');
assert.equal(moment([2012, 0, 1]).format('w ww wo'), '1 01 1', 'Jan 1 2012 should be week 1');
@@ -231,50 +170,4 @@
assert.equal(moment([2012, 0, 9]).format('w ww wo'), '3 03 3', 'Jan 9 2012 should be week 3');
});
-test('lenient ordinal parsing', function (assert) {
- var i, ordinalStr, testMoment;
- for (i = 1; i <= 31; ++i) {
- ordinalStr = moment([2014, 0, i]).format('YYYY MM Do');
- testMoment = moment(ordinalStr, 'YYYY MM Do');
- assert.equal(testMoment.year(), 2014,
- 'lenient ordinal parsing ' + i + ' year check');
- assert.equal(testMoment.month(), 0,
- 'lenient ordinal parsing ' + i + ' month check');
- assert.equal(testMoment.date(), i,
- 'lenient ordinal parsing ' + i + ' date check');
- }
-});
-test('lenient ordinal parsing of number', function (assert) {
- var i, testMoment;
- for (i = 1; i <= 31; ++i) {
- testMoment = moment('2014 01 ' + i, 'YYYY MM Do');
- assert.equal(testMoment.year(), 2014,
- 'lenient ordinal parsing of number ' + i + ' year check');
- assert.equal(testMoment.month(), 0,
- 'lenient ordinal parsing of number ' + i + ' month check');
- assert.equal(testMoment.date(), i,
- 'lenient ordinal parsing of number ' + i + ' date check');
- }
-});
-
-test('meridiem invariant', function (assert) {
- var h, m, t1, t2;
- for (h = 0; h < 24; ++h) {
- for (m = 0; m < 60; m += 15) {
- t1 = moment.utc([2000, 0, 1, h, m]);
- t2 = moment(t1.format('A h:mm'), 'A h:mm');
- assert.equal(t2.format('HH:mm'), t1.format('HH:mm'),
- 'meridiem at ' + t1.format('HH:mm'));
- }
- }
-});
-
-test('strict ordinal parsing', function (assert) {
- var i, ordinalStr, testMoment;
- for (i = 1; i <= 31; ++i) {
- ordinalStr = moment([2014, 0, i]).format('YYYY MM Do');
- testMoment = moment(ordinalStr, 'YYYY MM Do', true);
- assert.ok(testMoment.isValid(), 'strict ordinal parsing ' + i);
- }
-});
diff --git a/src/test/locale/is.js b/src/test/locale/is.js
index 068eb6c..31758af 100644
--- a/src/test/locale/is.js
+++ b/src/test/locale/is.js
@@ -37,11 +37,11 @@
['a A', 'pm PM'],
['[the] DDDo [day of the year]', 'the 45. day of the year'],
['LTS', '15:25:50'],
- ['L', '14/02/2010'],
+ ['L', '14.02.2010'],
['LL', '14. febrúar 2010'],
['LLL', '14. febrúar 2010 kl. 15:25'],
['LLLL', 'sunnudagur, 14. febrúar 2010 kl. 15:25'],
- ['l', '14/2/2010'],
+ ['l', '14.2.2010'],
['ll', '14. feb 2010'],
['lll', '14. feb 2010 kl. 15:25'],
['llll', 'sun, 14. feb 2010 kl. 15:25']
@@ -157,14 +157,14 @@
});
test('calendar day', function (assert) {
- var a = moment().hours(2).minutes(0).seconds(0);
-
- assert.equal(moment(a).calendar(), 'í dag kl. 2:00', 'today at the same time');
- assert.equal(moment(a).add({m: 25}).calendar(), 'í dag kl. 2:25', 'Now plus 25 min');
- assert.equal(moment(a).add({h: 1}).calendar(), 'í dag kl. 3:00', 'Now plus 1 hour');
- assert.equal(moment(a).add({d: 1}).calendar(), 'á morgun kl. 2:00', 'tomorrow at the same time');
- assert.equal(moment(a).subtract({h: 1}).calendar(), 'í dag kl. 1:00', 'Now minus 1 hour');
- assert.equal(moment(a).subtract({d: 1}).calendar(), 'í gær kl. 2:00', 'yesterday at the same time');
+ var a = moment().hours(12).minutes(0).seconds(0);
+
+ assert.equal(moment(a).calendar(), 'í dag kl. 12:00', 'today at the same time');
+ assert.equal(moment(a).add({m: 25}).calendar(), 'í dag kl. 12:25', 'Now plus 25 min');
+ assert.equal(moment(a).add({h: 1}).calendar(), 'í dag kl. 13:00', 'Now plus 1 hour');
+ assert.equal(moment(a).add({d: 1}).calendar(), 'á morgun kl. 12:00', 'tomorrow at the same time');
+ assert.equal(moment(a).subtract({h: 1}).calendar(), 'í dag kl. 11:00', 'Now minus 1 hour');
+ assert.equal(moment(a).subtract({d: 1}).calendar(), 'í gær kl. 12:00', 'yesterday at the same time');
});
test('calendar next week', function (assert) {
@@ -206,67 +206,6 @@
assert.equal(weeksFromNow.calendar(), weeksFromNow.format('L'), 'in 2 weeks');
});
-test('weeks year starting sunday', function (assert) {
- assert.equal(moment([2012, 0, 1]).week(), 52, 'Jan 1 2012 should be week 52');
- assert.equal(moment([2012, 0, 2]).week(), 1, 'Jan 2 2012 should be week 1');
- assert.equal(moment([2012, 0, 8]).week(), 1, 'Jan 8 2012 should be week 1');
- assert.equal(moment([2012, 0, 9]).week(), 2, 'Jan 9 2012 should be week 2');
- assert.equal(moment([2012, 0, 15]).week(), 2, 'Jan 15 2012 should be week 2');
-});
-
-test('weeks year starting monday', function (assert) {
- assert.equal(moment([2007, 0, 1]).week(), 1, 'Jan 1 2007 should be week 1');
- assert.equal(moment([2007, 0, 7]).week(), 1, 'Jan 7 2007 should be week 1');
- assert.equal(moment([2007, 0, 8]).week(), 2, 'Jan 8 2007 should be week 2');
- assert.equal(moment([2007, 0, 14]).week(), 2, 'Jan 14 2007 should be week 2');
- assert.equal(moment([2007, 0, 15]).week(), 3, 'Jan 15 2007 should be week 3');
-});
-
-test('weeks year starting tuesday', function (assert) {
- assert.equal(moment([2007, 11, 31]).week(), 1, 'Dec 31 2007 should be week 1');
- assert.equal(moment([2008, 0, 1]).week(), 1, 'Jan 1 2008 should be week 1');
- assert.equal(moment([2008, 0, 6]).week(), 1, 'Jan 6 2008 should be week 1');
- assert.equal(moment([2008, 0, 7]).week(), 2, 'Jan 7 2008 should be week 2');
- assert.equal(moment([2008, 0, 13]).week(), 2, 'Jan 13 2008 should be week 2');
- assert.equal(moment([2008, 0, 14]).week(), 3, 'Jan 14 2008 should be week 3');
-});
-
-test('weeks year starting wednesday', function (assert) {
- assert.equal(moment([2002, 11, 30]).week(), 1, 'Dec 30 2002 should be week 1');
- assert.equal(moment([2003, 0, 1]).week(), 1, 'Jan 1 2003 should be week 1');
- assert.equal(moment([2003, 0, 5]).week(), 1, 'Jan 5 2003 should be week 1');
- assert.equal(moment([2003, 0, 6]).week(), 2, 'Jan 6 2003 should be week 2');
- assert.equal(moment([2003, 0, 12]).week(), 2, 'Jan 12 2003 should be week 2');
- assert.equal(moment([2003, 0, 13]).week(), 3, 'Jan 13 2003 should be week 3');
-});
-
-test('weeks year starting thursday', function (assert) {
- assert.equal(moment([2008, 11, 29]).week(), 1, 'Dec 29 2008 should be week 1');
- assert.equal(moment([2009, 0, 1]).week(), 1, 'Jan 1 2009 should be week 1');
- assert.equal(moment([2009, 0, 4]).week(), 1, 'Jan 4 2009 should be week 1');
- assert.equal(moment([2009, 0, 5]).week(), 2, 'Jan 5 2009 should be week 2');
- assert.equal(moment([2009, 0, 11]).week(), 2, 'Jan 11 2009 should be week 2');
- assert.equal(moment([2009, 0, 13]).week(), 3, 'Jan 12 2009 should be week 3');
-});
-
-test('weeks year starting friday', function (assert) {
- assert.equal(moment([2009, 11, 28]).week(), 53, 'Dec 28 2009 should be week 53');
- assert.equal(moment([2010, 0, 1]).week(), 53, 'Jan 1 2010 should be week 53');
- assert.equal(moment([2010, 0, 3]).week(), 53, 'Jan 3 2010 should be week 53');
- assert.equal(moment([2010, 0, 4]).week(), 1, 'Jan 4 2010 should be week 1');
- assert.equal(moment([2010, 0, 10]).week(), 1, 'Jan 10 2010 should be week 1');
- assert.equal(moment([2010, 0, 11]).week(), 2, 'Jan 11 2010 should be week 2');
-});
-
-test('weeks year starting saturday', function (assert) {
- assert.equal(moment([2010, 11, 27]).week(), 52, 'Dec 27 2010 should be week 52');
- assert.equal(moment([2011, 0, 1]).week(), 52, 'Jan 1 2011 should be week 52');
- assert.equal(moment([2011, 0, 2]).week(), 52, 'Jan 2 2011 should be week 52');
- assert.equal(moment([2011, 0, 3]).week(), 1, 'Jan 3 2011 should be week 1');
- assert.equal(moment([2011, 0, 9]).week(), 1, 'Jan 9 2011 should be week 1');
- assert.equal(moment([2011, 0, 10]).week(), 2, 'Jan 10 2011 should be week 2');
-});
-
test('weeks year starting sunday formatted', function (assert) {
assert.equal(moment([2012, 0, 1]).format('w ww wo'), '52 52 52.', 'Jan 1 2012 should be week 52');
assert.equal(moment([2012, 0, 2]).format('w ww wo'), '1 01 1.', 'Jan 2 2012 should be week 1');
@@ -275,38 +214,3 @@
assert.equal(moment([2012, 0, 15]).format('w ww wo'), '2 02 2.', 'Jan 15 2012 should be week 2');
});
-test('lenient ordinal parsing', function (assert) {
- var i, ordinalStr, testMoment;
- for (i = 1; i <= 31; ++i) {
- ordinalStr = moment([2014, 0, i]).format('YYYY MM Do');
- testMoment = moment(ordinalStr, 'YYYY MM Do');
- assert.equal(testMoment.year(), 2014,
- 'lenient ordinal parsing ' + i + ' year check');
- assert.equal(testMoment.month(), 0,
- 'lenient ordinal parsing ' + i + ' month check');
- assert.equal(testMoment.date(), i,
- 'lenient ordinal parsing ' + i + ' date check');
- }
-});
-
-test('lenient ordinal parsing of number', function (assert) {
- var i, testMoment;
- for (i = 1; i <= 31; ++i) {
- testMoment = moment('2014 01 ' + i, 'YYYY MM Do');
- assert.equal(testMoment.year(), 2014,
- 'lenient ordinal parsing of number ' + i + ' year check');
- assert.equal(testMoment.month(), 0,
- 'lenient ordinal parsing of number ' + i + ' month check');
- assert.equal(testMoment.date(), i,
- 'lenient ordinal parsing of number ' + i + ' date check');
- }
-});
-
-test('strict ordinal parsing', function (assert) {
- var i, ordinalStr, testMoment;
- for (i = 1; i <= 31; ++i) {
- ordinalStr = moment([2014, 0, i]).format('YYYY MM Do');
- testMoment = moment(ordinalStr, 'YYYY MM Do', true);
- assert.ok(testMoment.isValid(), 'strict ordinal parsing ' + i);
- }
-});
diff --git a/src/test/locale/it.js b/src/test/locale/it.js
index 9b46fa0..db5b626 100644
--- a/src/test/locale/it.js
+++ b/src/test/locale/it.js
@@ -147,14 +147,14 @@
});
test('calendar day', function (assert) {
- var a = moment().hours(2).minutes(0).seconds(0);
-
- assert.equal(moment(a).calendar(), 'Oggi alle 02:00', 'today at the same time');
- assert.equal(moment(a).add({m: 25}).calendar(), 'Oggi alle 02:25', 'Now plus 25 min');
- assert.equal(moment(a).add({h: 1}).calendar(), 'Oggi alle 03:00', 'Now plus 1 hour');
- assert.equal(moment(a).add({d: 1}).calendar(), 'Domani alle 02:00', 'tomorrow at the same time');
- assert.equal(moment(a).subtract({h: 1}).calendar(), 'Oggi alle 01:00', 'Now minus 1 hour');
- assert.equal(moment(a).subtract({d: 1}).calendar(), 'Ieri alle 02:00', 'yesterday at the same time');
+ var a = moment().hours(12).minutes(0).seconds(0);
+
+ assert.equal(moment(a).calendar(), 'Oggi alle 12:00', 'today at the same time');
+ assert.equal(moment(a).add({m: 25}).calendar(), 'Oggi alle 12:25', 'Now plus 25 min');
+ assert.equal(moment(a).add({h: 1}).calendar(), 'Oggi alle 13:00', 'Now plus 1 hour');
+ assert.equal(moment(a).add({d: 1}).calendar(), 'Domani alle 12:00', 'tomorrow at the same time');
+ assert.equal(moment(a).subtract({h: 1}).calendar(), 'Oggi alle 11:00', 'Now minus 1 hour');
+ assert.equal(moment(a).subtract({d: 1}).calendar(), 'Ieri alle 12:00', 'yesterday at the same time');
});
test('calendar next week', function (assert) {
@@ -198,67 +198,6 @@
assert.equal(weeksFromNow.calendar(), weeksFromNow.format('L'), 'in 2 weeks');
});
-test('weeks year starting sunday', function (assert) {
- assert.equal(moment([2012, 0, 1]).week(), 52, 'Jan 1 2012 should be week 52');
- assert.equal(moment([2012, 0, 2]).week(), 1, 'Jan 2 2012 should be week 1');
- assert.equal(moment([2012, 0, 8]).week(), 1, 'Jan 8 2012 should be week 1');
- assert.equal(moment([2012, 0, 9]).week(), 2, 'Jan 9 2012 should be week 2');
- assert.equal(moment([2012, 0, 15]).week(), 2, 'Jan 15 2012 should be week 2');
-});
-
-test('weeks year starting monday', function (assert) {
- assert.equal(moment([2007, 0, 1]).week(), 1, 'Jan 1 2007 should be week 1');
- assert.equal(moment([2007, 0, 7]).week(), 1, 'Jan 7 2007 should be week 1');
- assert.equal(moment([2007, 0, 8]).week(), 2, 'Jan 8 2007 should be week 2');
- assert.equal(moment([2007, 0, 14]).week(), 2, 'Jan 14 2007 should be week 2');
- assert.equal(moment([2007, 0, 15]).week(), 3, 'Jan 15 2007 should be week 3');
-});
-
-test('weeks year starting tuesday', function (assert) {
- assert.equal(moment([2007, 11, 31]).week(), 1, 'Dec 31 2007 should be week 1');
- assert.equal(moment([2008, 0, 1]).week(), 1, 'Jan 1 2008 should be week 1');
- assert.equal(moment([2008, 0, 6]).week(), 1, 'Jan 6 2008 should be week 1');
- assert.equal(moment([2008, 0, 7]).week(), 2, 'Jan 7 2008 should be week 2');
- assert.equal(moment([2008, 0, 13]).week(), 2, 'Jan 13 2008 should be week 2');
- assert.equal(moment([2008, 0, 14]).week(), 3, 'Jan 14 2008 should be week 3');
-});
-
-test('weeks year starting wednesday', function (assert) {
- assert.equal(moment([2002, 11, 30]).week(), 1, 'Dec 30 2002 should be week 1');
- assert.equal(moment([2003, 0, 1]).week(), 1, 'Jan 1 2003 should be week 1');
- assert.equal(moment([2003, 0, 5]).week(), 1, 'Jan 5 2003 should be week 1');
- assert.equal(moment([2003, 0, 6]).week(), 2, 'Jan 6 2003 should be week 2');
- assert.equal(moment([2003, 0, 12]).week(), 2, 'Jan 12 2003 should be week 2');
- assert.equal(moment([2003, 0, 13]).week(), 3, 'Jan 13 2003 should be week 3');
-});
-
-test('weeks year starting thursday', function (assert) {
- assert.equal(moment([2008, 11, 29]).week(), 1, 'Dec 29 2008 should be week 1');
- assert.equal(moment([2009, 0, 1]).week(), 1, 'Jan 1 2009 should be week 1');
- assert.equal(moment([2009, 0, 4]).week(), 1, 'Jan 4 2009 should be week 1');
- assert.equal(moment([2009, 0, 5]).week(), 2, 'Jan 5 2009 should be week 2');
- assert.equal(moment([2009, 0, 11]).week(), 2, 'Jan 11 2009 should be week 2');
- assert.equal(moment([2009, 0, 13]).week(), 3, 'Jan 12 2009 should be week 3');
-});
-
-test('weeks year starting friday', function (assert) {
- assert.equal(moment([2009, 11, 28]).week(), 53, 'Dec 28 2009 should be week 53');
- assert.equal(moment([2010, 0, 1]).week(), 53, 'Jan 1 2010 should be week 53');
- assert.equal(moment([2010, 0, 3]).week(), 53, 'Jan 3 2010 should be week 53');
- assert.equal(moment([2010, 0, 4]).week(), 1, 'Jan 4 2010 should be week 1');
- assert.equal(moment([2010, 0, 10]).week(), 1, 'Jan 10 2010 should be week 1');
- assert.equal(moment([2010, 0, 11]).week(), 2, 'Jan 11 2010 should be week 2');
-});
-
-test('weeks year starting saturday', function (assert) {
- assert.equal(moment([2010, 11, 27]).week(), 52, 'Dec 27 2010 should be week 52');
- assert.equal(moment([2011, 0, 1]).week(), 52, 'Jan 1 2011 should be week 52');
- assert.equal(moment([2011, 0, 2]).week(), 52, 'Jan 2 2011 should be week 52');
- assert.equal(moment([2011, 0, 3]).week(), 1, 'Jan 3 2011 should be week 1');
- assert.equal(moment([2011, 0, 9]).week(), 1, 'Jan 9 2011 should be week 1');
- assert.equal(moment([2011, 0, 10]).week(), 2, 'Jan 10 2011 should be week 2');
-});
-
test('weeks year starting sunday formatted', function (assert) {
assert.equal(moment([2012, 0, 1]).format('w ww wo'), '52 52 52º', 'Jan 1 2012 should be week 52');
assert.equal(moment([2012, 0, 2]).format('w ww wo'), '1 01 1º', 'Jan 2 2012 should be week 1');
@@ -267,38 +206,3 @@
assert.equal(moment([2012, 0, 15]).format('w ww wo'), '2 02 2º', 'Jan 15 2012 should be week 2');
});
-test('lenient ordinal parsing', function (assert) {
- var i, ordinalStr, testMoment;
- for (i = 1; i <= 31; ++i) {
- ordinalStr = moment([2014, 0, i]).format('YYYY MM Do');
- testMoment = moment(ordinalStr, 'YYYY MM Do');
- assert.equal(testMoment.year(), 2014,
- 'lenient ordinal parsing ' + i + ' year check');
- assert.equal(testMoment.month(), 0,
- 'lenient ordinal parsing ' + i + ' month check');
- assert.equal(testMoment.date(), i,
- 'lenient ordinal parsing ' + i + ' date check');
- }
-});
-
-test('lenient ordinal parsing of number', function (assert) {
- var i, testMoment;
- for (i = 1; i <= 31; ++i) {
- testMoment = moment('2014 01 ' + i, 'YYYY MM Do');
- assert.equal(testMoment.year(), 2014,
- 'lenient ordinal parsing of number ' + i + ' year check');
- assert.equal(testMoment.month(), 0,
- 'lenient ordinal parsing of number ' + i + ' month check');
- assert.equal(testMoment.date(), i,
- 'lenient ordinal parsing of number ' + i + ' date check');
- }
-});
-
-test('strict ordinal parsing', function (assert) {
- var i, ordinalStr, testMoment;
- for (i = 1; i <= 31; ++i) {
- ordinalStr = moment([2014, 0, i]).format('YYYY MM Do');
- testMoment = moment(ordinalStr, 'YYYY MM Do', true);
- assert.ok(testMoment.isValid(), 'strict ordinal parsing ' + i);
- }
-});
diff --git a/src/test/locale/ja.js b/src/test/locale/ja.js
index 29aebaa..76f1b68 100644
--- a/src/test/locale/ja.js
+++ b/src/test/locale/ja.js
@@ -22,20 +22,20 @@
test('format', function (assert) {
var a = [
- ['dddd, MMMM Do YYYY, a h:mm:ss', '日曜日, 2月 14 2010, 午後 3:25:50'],
+ ['dddd, MMMM Do YYYY, a h:mm:ss', '日曜日, 2月 14日 2010, 午後 3:25:50'],
['ddd, Ah', '日, 午後3'],
['M Mo MM MMMM MMM', '2 2 02 2月 2月'],
['YYYY YY', '2010 10'],
- ['D Do DD', '14 14 14'],
- ['d do dddd ddd dd', '0 0 日曜日 日 日'],
- ['DDD DDDo DDDD', '45 45 045'],
+ ['D Do DD', '14 14日 14'],
+ ['d do dddd ddd dd', '0 0日 日曜日 日 日'],
+ ['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', '午後 午後'],
- ['[the] DDDo [day of the year]', 'the 45 day of the year'],
+ ['[the] DDDo [day of the year]', 'the 45日 day of the year'],
['LTS', '午後3時25分50秒'],
['L', '2010/02/14'],
['LL', '2010年2月14日'],
@@ -114,14 +114,14 @@
});
test('calendar day', function (assert) {
- var a = moment().hours(2).minutes(0).seconds(0);
+ var a = moment().hours(12).minutes(0).seconds(0);
- assert.equal(moment(a).calendar(), '今日 午前2時0分', 'today at the same time');
- assert.equal(moment(a).add({m: 25}).calendar(), '今日 午前2時25分', 'Now plus 25 min');
- assert.equal(moment(a).add({h: 1}).calendar(), '今日 午前3時0分', 'Now plus 1 hour');
- assert.equal(moment(a).add({d: 1}).calendar(), '明日 午前2時0分', 'tomorrow at the same time');
- assert.equal(moment(a).subtract({h: 1}).calendar(), '今日 午前1時0分', 'Now minus 1 hour');
- assert.equal(moment(a).subtract({d: 1}).calendar(), '昨日 午前2時0分', 'yesterday at the same time');
+ assert.equal(moment(a).calendar(), '今日 午後12時0分', 'today at the same time');
+ assert.equal(moment(a).add({m: 25}).calendar(), '今日 午後12時25分', 'Now plus 25 min');
+ assert.equal(moment(a).add({h: 1}).calendar(), '今日 午後1時0分', 'Now plus 1 hour');
+ assert.equal(moment(a).add({d: 1}).calendar(), '明日 午後12時0分', 'tomorrow at the same time');
+ assert.equal(moment(a).subtract({h: 1}).calendar(), '今日 午前11時0分', 'Now minus 1 hour');
+ assert.equal(moment(a).subtract({d: 1}).calendar(), '昨日 午後12時0分', 'yesterday at the same time');
});
test('calendar next week', function (assert) {
@@ -162,67 +162,6 @@
assert.equal(weeksFromNow.calendar(), weeksFromNow.format('L'), 'in 2 weeks');
});
-test('weeks year starting sunday', function (assert) {
- assert.equal(moment([2012, 0, 1]).week(), 1, 'Jan 1 2012 should be week 1');
- assert.equal(moment([2012, 0, 7]).week(), 1, 'Jan 7 2012 should be week 1');
- assert.equal(moment([2012, 0, 8]).week(), 2, 'Jan 8 2012 should be week 2');
- assert.equal(moment([2012, 0, 14]).week(), 2, 'Jan 14 2012 should be week 2');
- assert.equal(moment([2012, 0, 15]).week(), 3, 'Jan 15 2012 should be week 3');
-});
-
-test('weeks year starting monday', function (assert) {
- assert.equal(moment([2006, 11, 31]).week(), 1, 'Dec 31 2006 should be week 1');
- assert.equal(moment([2007, 0, 1]).week(), 1, 'Jan 1 2007 should be week 1');
- assert.equal(moment([2007, 0, 6]).week(), 1, 'Jan 6 2007 should be week 1');
- assert.equal(moment([2007, 0, 7]).week(), 2, 'Jan 7 2007 should be week 2');
- assert.equal(moment([2007, 0, 13]).week(), 2, 'Jan 13 2007 should be week 2');
- assert.equal(moment([2007, 0, 14]).week(), 3, 'Jan 14 2007 should be week 3');
-});
-
-test('weeks year starting tuesday', function (assert) {
- assert.equal(moment([2007, 11, 29]).week(), 52, 'Dec 29 2007 should be week 52');
- assert.equal(moment([2008, 0, 1]).week(), 1, 'Jan 1 2008 should be week 1');
- assert.equal(moment([2008, 0, 5]).week(), 1, 'Jan 5 2008 should be week 1');
- assert.equal(moment([2008, 0, 6]).week(), 2, 'Jan 6 2008 should be week 2');
- assert.equal(moment([2008, 0, 12]).week(), 2, 'Jan 12 2008 should be week 2');
- assert.equal(moment([2008, 0, 13]).week(), 3, 'Jan 13 2008 should be week 3');
-});
-
-test('weeks year starting wednesday', function (assert) {
- assert.equal(moment([2002, 11, 29]).week(), 1, 'Dec 29 2002 should be week 1');
- assert.equal(moment([2003, 0, 1]).week(), 1, 'Jan 1 2003 should be week 1');
- assert.equal(moment([2003, 0, 4]).week(), 1, 'Jan 4 2003 should be week 1');
- assert.equal(moment([2003, 0, 5]).week(), 2, 'Jan 5 2003 should be week 2');
- assert.equal(moment([2003, 0, 11]).week(), 2, 'Jan 11 2003 should be week 2');
- assert.equal(moment([2003, 0, 12]).week(), 3, 'Jan 12 2003 should be week 3');
-});
-
-test('weeks year starting thursday', function (assert) {
- assert.equal(moment([2008, 11, 28]).week(), 1, 'Dec 28 2008 should be week 1');
- assert.equal(moment([2009, 0, 1]).week(), 1, 'Jan 1 2009 should be week 1');
- assert.equal(moment([2009, 0, 3]).week(), 1, 'Jan 3 2009 should be week 1');
- assert.equal(moment([2009, 0, 4]).week(), 2, 'Jan 4 2009 should be week 2');
- assert.equal(moment([2009, 0, 10]).week(), 2, 'Jan 10 2009 should be week 2');
- assert.equal(moment([2009, 0, 11]).week(), 3, 'Jan 11 2009 should be week 3');
-});
-
-test('weeks year starting friday', function (assert) {
- assert.equal(moment([2009, 11, 27]).week(), 1, 'Dec 27 2009 should be week 1');
- assert.equal(moment([2010, 0, 1]).week(), 1, 'Jan 1 2010 should be week 1');
- assert.equal(moment([2010, 0, 2]).week(), 1, 'Jan 2 2010 should be week 1');
- assert.equal(moment([2010, 0, 3]).week(), 2, 'Jan 3 2010 should be week 2');
- assert.equal(moment([2010, 0, 9]).week(), 2, 'Jan 9 2010 should be week 2');
- assert.equal(moment([2010, 0, 10]).week(), 3, 'Jan 10 2010 should be week 3');
-});
-
-test('weeks year starting saturday', function (assert) {
- assert.equal(moment([2010, 11, 26]).week(), 1, 'Dec 26 2010 should be week 1');
- assert.equal(moment([2011, 0, 1]).week(), 1, 'Jan 1 2011 should be week 1');
- assert.equal(moment([2011, 0, 2]).week(), 2, 'Jan 2 2011 should be week 2');
- assert.equal(moment([2011, 0, 8]).week(), 2, 'Jan 8 2011 should be week 2');
- assert.equal(moment([2011, 0, 9]).week(), 3, 'Jan 9 2011 should be week 3');
-});
-
test('weeks year starting sunday format', function (assert) {
assert.equal(moment([2012, 0, 1]).format('w ww wo'), '1 01 1', 'Jan 1 2012 should be week 1');
assert.equal(moment([2012, 0, 7]).format('w ww wo'), '1 01 1', 'Jan 7 2012 should be week 1');
@@ -231,38 +170,3 @@
assert.equal(moment([2012, 0, 15]).format('w ww wo'), '3 03 3', 'Jan 15 2012 should be week 3');
});
-test('lenient ordinal parsing', function (assert) {
- var i, ordinalStr, testMoment;
- for (i = 1; i <= 31; ++i) {
- ordinalStr = moment([2014, 0, i]).format('YYYY MM Do');
- testMoment = moment(ordinalStr, 'YYYY MM Do');
- assert.equal(testMoment.year(), 2014,
- 'lenient ordinal parsing ' + i + ' year check');
- assert.equal(testMoment.month(), 0,
- 'lenient ordinal parsing ' + i + ' month check');
- assert.equal(testMoment.date(), i,
- 'lenient ordinal parsing ' + i + ' date check');
- }
-});
-
-test('lenient ordinal parsing of number', function (assert) {
- var i, testMoment;
- for (i = 1; i <= 31; ++i) {
- testMoment = moment('2014 01 ' + i, 'YYYY MM Do');
- assert.equal(testMoment.year(), 2014,
- 'lenient ordinal parsing of number ' + i + ' year check');
- assert.equal(testMoment.month(), 0,
- 'lenient ordinal parsing of number ' + i + ' month check');
- assert.equal(testMoment.date(), i,
- 'lenient ordinal parsing of number ' + i + ' date check');
- }
-});
-
-test('strict ordinal parsing', function (assert) {
- var i, ordinalStr, testMoment;
- for (i = 1; i <= 31; ++i) {
- ordinalStr = moment([2014, 0, i]).format('YYYY MM Do');
- testMoment = moment(ordinalStr, 'YYYY MM Do', true);
- assert.ok(testMoment.isValid(), 'strict ordinal parsing ' + i);
- }
-});
diff --git a/src/test/locale/jv.js b/src/test/locale/jv.js
index fd60b17..0b46076 100644
--- a/src/test/locale/jv.js
+++ b/src/test/locale/jv.js
@@ -1,7 +1,6 @@
import {localeModule, test} from '../qunit';
import moment from '../../moment';
localeModule('jv');
-
test('parse', function (assert) {
var tests = 'Januari Jan_Februari Feb_Maret Mar_April Apr_Mei Mei_Juni Jun_Juli Jul_Agustus Ags_September Sep_Oktober Okt_Nopember Nop_Desember Des'.split('_'), i;
@@ -115,14 +114,14 @@
});
test('calendar day', function (assert) {
- var a = moment().hours(2).minutes(0).seconds(0);
+ var a = moment().hours(12).minutes(0).seconds(0);
- assert.equal(moment(a).calendar(), 'Dinten puniko pukul 02.00', 'today at the same time');
- assert.equal(moment(a).add({m: 25}).calendar(), 'Dinten puniko pukul 02.25', 'Now plus 25 min');
- assert.equal(moment(a).add({h: 1}).calendar(), 'Dinten puniko pukul 03.00', 'Now plus 1 hour');
- assert.equal(moment(a).add({d: 1}).calendar(), 'Mbenjang pukul 02.00', 'tomorrow at the same time');
- assert.equal(moment(a).subtract({h: 1}).calendar(), 'Dinten puniko pukul 01.00', 'Now minus 1 hour');
- assert.equal(moment(a).subtract({d: 1}).calendar(), 'Kala wingi pukul 02.00', 'yesterday at the same time');
+ assert.equal(moment(a).calendar(), 'Dinten puniko pukul 12.00', 'today at the same time');
+ assert.equal(moment(a).add({m: 25}).calendar(), 'Dinten puniko pukul 12.25', 'Now plus 25 min');
+ assert.equal(moment(a).add({h: 1}).calendar(), 'Dinten puniko pukul 13.00', 'Now plus 1 hour');
+ assert.equal(moment(a).add({d: 1}).calendar(), 'Mbenjang pukul 12.00', 'tomorrow at the same time');
+ assert.equal(moment(a).subtract({h: 1}).calendar(), 'Dinten puniko pukul 11.00', 'Now minus 1 hour');
+ assert.equal(moment(a).subtract({d: 1}).calendar(), 'Kala wingi pukul 12.00', 'yesterday at the same time');
});
test('calendar next week', function (assert) {
@@ -166,67 +165,6 @@
// Monday is the first day of the week.
// The week that contains Jan 1st is the first week of the year.
-test('weeks year starting sunday', function (assert) {
- assert.equal(moment([2011, 11, 26]).week(), 1, 'Dec 26 2011 should be week 1');
- assert.equal(moment([2012, 0, 1]).week(), 1, 'Jan 1 2012 should be week 1');
- assert.equal(moment([2012, 0, 2]).week(), 2, 'Jan 2 2012 should be week 2');
- assert.equal(moment([2012, 0, 8]).week(), 2, 'Jan 8 2012 should be week 2');
- assert.equal(moment([2012, 0, 9]).week(), 3, 'Jan 9 2012 should be week 3');
-});
-
-test('weeks year starting monday', function (assert) {
- assert.equal(moment([2007, 0, 1]).week(), 1, 'Jan 1 2007 should be week 1');
- assert.equal(moment([2007, 0, 7]).week(), 1, 'Jan 7 2007 should be week 1');
- assert.equal(moment([2007, 0, 8]).week(), 2, 'Jan 8 2007 should be week 2');
- assert.equal(moment([2007, 0, 14]).week(), 2, 'Jan 14 2007 should be week 2');
- assert.equal(moment([2007, 0, 15]).week(), 3, 'Jan 15 2007 should be week 3');
-});
-
-test('weeks year starting tuesday', function (assert) {
- assert.equal(moment([2007, 11, 31]).week(), 1, 'Dec 31 2007 should be week 1');
- assert.equal(moment([2008, 0, 1]).week(), 1, 'Jan 1 2008 should be week 1');
- assert.equal(moment([2008, 0, 6]).week(), 1, 'Jan 6 2008 should be week 1');
- assert.equal(moment([2008, 0, 7]).week(), 2, 'Jan 7 2008 should be week 2');
- assert.equal(moment([2008, 0, 13]).week(), 2, 'Jan 13 2008 should be week 2');
- assert.equal(moment([2008, 0, 14]).week(), 3, 'Jan 14 2008 should be week 3');
-});
-
-test('weeks year starting wednesday', function (assert) {
- assert.equal(moment([2002, 11, 30]).week(), 1, 'Dec 30 2002 should be week 1');
- assert.equal(moment([2003, 0, 1]).week(), 1, 'Jan 1 2003 should be week 1');
- assert.equal(moment([2003, 0, 5]).week(), 1, 'Jan 5 2003 should be week 1');
- assert.equal(moment([2003, 0, 6]).week(), 2, 'Jan 6 2003 should be week 2');
- assert.equal(moment([2003, 0, 12]).week(), 2, 'Jan 12 2003 should be week 2');
- assert.equal(moment([2003, 0, 13]).week(), 3, 'Jan 13 2003 should be week 3');
-});
-
-test('weeks year starting thursday', function (assert) {
- assert.equal(moment([2008, 11, 29]).week(), 1, 'Dec 29 2008 should be week 1');
- assert.equal(moment([2009, 0, 1]).week(), 1, 'Jan 1 2009 should be week 1');
- assert.equal(moment([2009, 0, 4]).week(), 1, 'Jan 4 2009 should be week 1');
- assert.equal(moment([2009, 0, 5]).week(), 2, 'Jan 5 2009 should be week 2');
- assert.equal(moment([2009, 0, 11]).week(), 2, 'Jan 11 2009 should be week 2');
- assert.equal(moment([2009, 0, 12]).week(), 3, 'Jan 12 2009 should be week 3');
-});
-
-test('weeks year starting friday', function (assert) {
- assert.equal(moment([2009, 11, 28]).week(), 1, 'Dec 28 2009 should be week 1');
- assert.equal(moment([2010, 0, 1]).week(), 1, 'Jan 1 2010 should be week 1');
- assert.equal(moment([2010, 0, 3]).week(), 1, 'Jan 3 2010 should be week 1');
- assert.equal(moment([2010, 0, 4]).week(), 2, 'Jan 4 2010 should be week 2');
- assert.equal(moment([2010, 0, 10]).week(), 2, 'Jan 10 2010 should be week 2');
- assert.equal(moment([2010, 0, 11]).week(), 3, 'Jan 11 2010 should be week 3');
-});
-
-test('weeks year starting saturday', function (assert) {
- assert.equal(moment([2010, 11, 27]).week(), 1, 'Dec 27 2010 should be week 1');
- assert.equal(moment([2011, 0, 1]).week(), 1, 'Jan 1 2011 should be week 1');
- assert.equal(moment([2011, 0, 2]).week(), 1, 'Jan 2 2011 should be week 1');
- assert.equal(moment([2011, 0, 3]).week(), 2, 'Jan 3 2011 should be week 2');
- assert.equal(moment([2011, 0, 9]).week(), 2, 'Jan 9 2011 should be week 2');
- assert.equal(moment([2011, 0, 10]).week(), 3, 'Jan 10 2011 should be week 3');
-});
-
test('weeks year starting sunday formatted', function (assert) {
assert.equal(moment([2011, 11, 26]).format('w ww wo'), '1 01 1', 'Dec 26 2011 should be week 1');
assert.equal(moment([2012, 0, 1]).format('w ww wo'), '1 01 1', 'Jan 1 2012 should be week 1');
@@ -235,50 +173,4 @@
assert.equal(moment([2012, 0, 9]).format('w ww wo'), '3 03 3', 'Jan 9 2012 should be week 3');
});
-test('lenient ordinal parsing', function (assert) {
- var i, ordinalStr, testMoment;
- for (i = 1; i <= 31; ++i) {
- ordinalStr = moment([2014, 0, i]).format('YYYY MM Do');
- testMoment = moment(ordinalStr, 'YYYY MM Do');
- assert.equal(testMoment.year(), 2014,
- 'lenient ordinal parsing ' + i + ' year check');
- assert.equal(testMoment.month(), 0,
- 'lenient ordinal parsing ' + i + ' month check');
- assert.equal(testMoment.date(), i,
- 'lenient ordinal parsing ' + i + ' date check');
- }
-});
-test('lenient ordinal parsing of number', function (assert) {
- var i, testMoment;
- for (i = 1; i <= 31; ++i) {
- testMoment = moment('2014 01 ' + i, 'YYYY MM Do');
- assert.equal(testMoment.year(), 2014,
- 'lenient ordinal parsing of number ' + i + ' year check');
- assert.equal(testMoment.month(), 0,
- 'lenient ordinal parsing of number ' + i + ' month check');
- assert.equal(testMoment.date(), i,
- 'lenient ordinal parsing of number ' + i + ' date check');
- }
-});
-
-test('meridiem invariant', function (assert) {
- var h, m, t1, t2;
- for (h = 0; h < 24; ++h) {
- for (m = 0; m < 60; m += 15) {
- t1 = moment.utc([2000, 0, 1, h, m]);
- t2 = moment(t1.format('A h:mm'), 'A h:mm');
- assert.equal(t2.format('HH:mm'), t1.format('HH:mm'),
- 'meridiem at ' + t1.format('HH:mm'));
- }
- }
-});
-
-test('strict ordinal parsing', function (assert) {
- var i, ordinalStr, testMoment;
- for (i = 1; i <= 31; ++i) {
- ordinalStr = moment([2014, 0, i]).format('YYYY MM Do');
- testMoment = moment(ordinalStr, 'YYYY MM Do', true);
- assert.ok(testMoment.isValid(), 'strict ordinal parsing ' + i);
- }
-});
diff --git a/src/test/locale/ka.js b/src/test/locale/ka.js
index 8786021..c216a71 100644
--- a/src/test/locale/ka.js
+++ b/src/test/locale/ka.js
@@ -164,14 +164,14 @@
});
test('calendar day', function (assert) {
- var a = moment().hours(2).minutes(0).seconds(0);
-
- assert.equal(moment(a).calendar(), 'დღეს 2:00 AM-ზე', 'დღეს ამავე დროს');
- assert.equal(moment(a).add({m: 25}).calendar(), 'დღეს 2:25 AM-ზე', 'ახლანდელ დროს დამატებული 25 წუთი');
- assert.equal(moment(a).add({h: 1}).calendar(), 'დღეს 3:00 AM-ზე', 'ახლანდელ დროს დამატებული 1 საათი');
- assert.equal(moment(a).add({d: 1}).calendar(), 'ხვალ 2:00 AM-ზე', 'ხვალ ამავე დროს');
- assert.equal(moment(a).subtract({h: 1}).calendar(), 'დღეს 1:00 AM-ზე', 'ახლანდელ დროს გამოკლებული 1 საათი');
- assert.equal(moment(a).subtract({d: 1}).calendar(), 'გუშინ 2:00 AM-ზე', 'გუშინ ამავე დროს');
+ var a = moment().hours(12).minutes(0).seconds(0);
+
+ assert.equal(moment(a).calendar(), 'დღეს 12:00 PM-ზე', 'დღეს ამავე დროს');
+ assert.equal(moment(a).add({m: 25}).calendar(), 'დღეს 12:25 PM-ზე', 'ახლანდელ დროს დამატებული 25 წუთი');
+ assert.equal(moment(a).add({h: 1}).calendar(), 'დღეს 1:00 PM-ზე', 'ახლანდელ დროს დამატებული 1 საათი');
+ assert.equal(moment(a).add({d: 1}).calendar(), 'ხვალ 12:00 PM-ზე', 'ხვალ ამავე დროს');
+ assert.equal(moment(a).subtract({h: 1}).calendar(), 'დღეს 11:00 AM-ზე', 'ახლანდელ დროს გამოკლებული 1 საათი');
+ assert.equal(moment(a).subtract({d: 1}).calendar(), 'გუშინ 12:00 PM-ზე', 'გუშინ ამავე დროს');
});
test('calendar next week', function (assert) {
@@ -212,67 +212,6 @@
assert.equal(weeksFromNow.calendar(), weeksFromNow.format('L'), '2 კვირაში');
});
-test('weeks year starting sunday', function (assert) {
- assert.equal(moment([2011, 11, 26]).week(), 1, 'დეკ 26 2011 უნდა იყოს კვირა 1');
- assert.equal(moment([2012, 0, 1]).week(), 1, 'იან 1 2012 უნდა იყოს კვირა 1');
- assert.equal(moment([2012, 0, 2]).week(), 2, 'იან 2 2012 უნდა იყოს კვირა 2');
- assert.equal(moment([2012, 0, 8]).week(), 2, 'იან 8 2012 უნდა იყოს კვირა 2');
- assert.equal(moment([2012, 0, 9]).week(), 3, 'იან 9 2012 უნდა იყოს კვირა 3');
-});
-
-test('weeks year starting monday', function (assert) {
- assert.equal(moment([2007, 0, 1]).week(), 1, 'იან 1 2007 უნდა იყოს კვირა 1');
- assert.equal(moment([2007, 0, 7]).week(), 1, 'იან 7 2007 უნდა იყოს კვირა 1');
- assert.equal(moment([2007, 0, 8]).week(), 2, 'იან 8 2007 უნდა იყოს კვირა 2');
- assert.equal(moment([2007, 0, 14]).week(), 2, 'იან 14 2007 უნდა იყოს კვირა 2');
- assert.equal(moment([2007, 0, 15]).week(), 3, 'იან 15 2007 უნდა იყოს კვირა 3');
-});
-
-test('weeks year starting tuesday', function (assert) {
- assert.equal(moment([2007, 11, 31]).week(), 1, 'დეკ 31 2007 უნდა იყოს კვირა 1');
- assert.equal(moment([2008, 0, 1]).week(), 1, 'იან 1 2008 უნდა იყოს კვირა 1');
- assert.equal(moment([2008, 0, 6]).week(), 1, 'იან 6 2008 უნდა იყოს კვირა 1');
- assert.equal(moment([2008, 0, 7]).week(), 2, 'იან 7 2008 უნდა იყოს კვირა 2');
- assert.equal(moment([2008, 0, 13]).week(), 2, 'იან 13 2008 უნდა იყოს კვირა 2');
- assert.equal(moment([2008, 0, 14]).week(), 3, 'იან 14 2008 უნდა იყოს კვირა 3');
-});
-
-test('weeks year starting wednesday', function (assert) {
- assert.equal(moment([2002, 11, 30]).week(), 1, 'დეკ 30 2002 უნდა იყოს კვირა 1');
- assert.equal(moment([2003, 0, 1]).week(), 1, 'იან 1 2003 უნდა იყოს კვირა 1');
- assert.equal(moment([2003, 0, 5]).week(), 1, 'იან 5 2003 უნდა იყოს კვირა 1');
- assert.equal(moment([2003, 0, 6]).week(), 2, 'იან 6 2003 უნდა იყოს კვირა 2');
- assert.equal(moment([2003, 0, 12]).week(), 2, 'იან 12 2003 უნდა იყოს კვირა 2');
- assert.equal(moment([2003, 0, 13]).week(), 3, 'იან 13 2003 უნდა იყოს კვირა 3');
-});
-
-test('weeks year starting thursday', function (assert) {
- assert.equal(moment([2008, 11, 29]).week(), 1, 'დეკ 29 2008 უნდა იყოს კვირა 1');
- assert.equal(moment([2009, 0, 1]).week(), 1, 'იან 1 2009 უნდა იყოს კვირა 1');
- assert.equal(moment([2009, 0, 4]).week(), 1, 'იან 4 2009 უნდა იყოს კვირა 1');
- assert.equal(moment([2009, 0, 5]).week(), 2, 'იან 5 2009 უნდა იყოს კვირა 2');
- assert.equal(moment([2009, 0, 11]).week(), 2, 'იან 11 2009 უნდა იყოს კვირა 2');
- assert.equal(moment([2009, 0, 12]).week(), 3, 'იან 12 2009 უნდა იყოს კვირა 3');
-});
-
-test('weeks year starting friday', function (assert) {
- assert.equal(moment([2009, 11, 28]).week(), 1, 'დეკ 28 2009 უნდა იყოს კვირა 1');
- assert.equal(moment([2010, 0, 1]).week(), 1, 'იან 1 2010 უნდა იყოს კვირა 1');
- assert.equal(moment([2010, 0, 3]).week(), 1, 'იან 3 2010 უნდა იყოს კვირა 1');
- assert.equal(moment([2010, 0, 4]).week(), 2, 'იან 4 2010 უნდა იყოს კვირა 2');
- assert.equal(moment([2010, 0, 10]).week(), 2, 'იან 10 2010 უნდა იყოს კვირა 2');
- assert.equal(moment([2010, 0, 11]).week(), 3, 'იან 11 2010 უნდა იყოს კვირა 3');
-});
-
-test('weeks year starting saturday', function (assert) {
- assert.equal(moment([2010, 11, 27]).week(), 1, 'დეკ 27 2010 უნდა იყოს კვირა 1');
- assert.equal(moment([2011, 0, 1]).week(), 1, 'იან 1 2011 უნდა იყოს კვირა 1');
- assert.equal(moment([2011, 0, 2]).week(), 1, 'იან 2 2011 უნდა იყოს კვირა 1');
- assert.equal(moment([2011, 0, 3]).week(), 2, 'იან 3 2011 უნდა იყოს კვირა 2');
- assert.equal(moment([2011, 0, 9]).week(), 2, 'იან 9 2011 უნდა იყოს კვირა 2');
- assert.equal(moment([2011, 0, 10]).week(), 3, 'იან 10 2011 უნდა იყოს კვირა 3');
-});
-
test('weeks year starting sunday formatted', function (assert) {
assert.equal(moment([2011, 11, 26]).format('w ww wo'), '1 01 1-ლი', 'დეკ 26 2011 უნდა იყოს კვირა 1');
assert.equal(moment([2012, 0, 1]).format('w ww wo'), '1 01 1-ლი', 'იან 1 2012 უნდა იყოს კვირა 1');
@@ -281,38 +220,3 @@
assert.equal(moment([2012, 0, 9]).format('w ww wo'), '3 03 მე-3', 'იან 9 2012 უნდა იყოს კვირა 3');
});
-test('lenient ordinal parsing', function (assert) {
- var i, ordinalStr, testMoment;
- for (i = 1; i <= 31; ++i) {
- ordinalStr = moment([2014, 0, i]).format('YYYY MM Do');
- testMoment = moment(ordinalStr, 'YYYY MM Do');
- assert.equal(testMoment.year(), 2014,
- 'lenient ordinal parsing ' + i + ' year check');
- assert.equal(testMoment.month(), 0,
- 'lenient ordinal parsing ' + i + ' month check');
- assert.equal(testMoment.date(), i,
- 'lenient ordinal parsing ' + i + ' date check');
- }
-});
-
-test('lenient ordinal parsing of number', function (assert) {
- var i, testMoment;
- for (i = 1; i <= 31; ++i) {
- testMoment = moment('2014 01 ' + i, 'YYYY MM Do');
- assert.equal(testMoment.year(), 2014,
- 'lenient ordinal parsing of number ' + i + ' year check');
- assert.equal(testMoment.month(), 0,
- 'lenient ordinal parsing of number ' + i + ' month check');
- assert.equal(testMoment.date(), i,
- 'lenient ordinal parsing of number ' + i + ' date check');
- }
-});
-
-test('strict ordinal parsing', function (assert) {
- var i, ordinalStr, testMoment;
- for (i = 1; i <= 31; ++i) {
- ordinalStr = moment([2014, 0, i]).format('YYYY MM Do');
- testMoment = moment(ordinalStr, 'YYYY MM Do', true);
- assert.ok(testMoment.isValid(), 'strict ordinal parsing ' + i);
- }
-});
diff --git a/src/test/locale/kk.js b/src/test/locale/kk.js
index c5c52fc..b048060 100644
--- a/src/test/locale/kk.js
+++ b/src/test/locale/kk.js
@@ -3,7 +3,7 @@
localeModule('kk');
test('parse', function (assert) {
- var tests = 'Қаңтар Қаң_Ақпан Ақп_Наурыз Нау_Сәуір Сәу_Мамыр Мам_Маусым Мау_Шілде Шіл_Тамыз Там_Қыркүйек Қыр_Қазан Қаз_Қараша Қар_Желтоқсан Жел'.split('_'), i;
+ var tests = 'қаңтар қаң_ақпан ақп_наурыз нау_сәуір сәу_мамыр мам_маусым мау_шілде шіл_тамыз там_қыркүйек қыр_қазан қаз_қараша қар_желтоқсан жел'.split('_'), i;
function equalTest(input, mmm, i) {
assert.equal(moment(input, mmm).month(), i, input + ' should be month ' + (i + 1));
}
@@ -22,12 +22,12 @@
test('format', function (assert) {
var a = [
- ['dddd, Do MMMM YYYY, HH:mm:ss', 'Жексенбі, 14-ші Ақпан 2010, 15:25:50'],
- ['ddd, hA', 'Жек, 3PM'],
- ['M Mo MM MMMM MMM', '2 2-ші 02 Ақпан Ақп'],
+ ['dddd, Do MMMM YYYY, HH:mm:ss', 'жексенбі, 14-ші ақпан 2010, 15:25:50'],
+ ['ddd, hA', 'жек, 3PM'],
+ ['M Mo MM MMMM MMM', '2 2-ші 02 ақпан ақп'],
['YYYY YY', '2010 10'],
['D Do DD', '14 14-ші 14'],
- ['d do dddd ddd dd', '0 0-ші Жексенбі Жек Жк'],
+ ['d do dddd ddd dd', '0 0-ші жексенбі жек жк'],
['DDD DDDo DDDD', '45 45-ші 045'],
['w wo ww', '7 7-ші 07'],
['h hh', '3 03'],
@@ -38,13 +38,13 @@
['[жылдың] DDDo [күні]', 'жылдың 45-ші күні'],
['LTS', '15:25:50'],
['L', '14.02.2010'],
- ['LL', '14 Ақпан 2010'],
- ['LLL', '14 Ақпан 2010 15:25'],
- ['LLLL', 'Жексенбі, 14 Ақпан 2010 15:25'],
+ ['LL', '14 ақпан 2010'],
+ ['LLL', '14 ақпан 2010 15:25'],
+ ['LLLL', 'жексенбі, 14 ақпан 2010 15:25'],
['l', '14.2.2010'],
- ['ll', '14 Ақп 2010'],
- ['lll', '14 Ақп 2010 15:25'],
- ['llll', 'Жек, 14 Ақп 2010 15:25']
+ ['ll', '14 ақп 2010'],
+ ['lll', '14 ақп 2010 15:25'],
+ ['llll', 'жек, 14 ақп 2010 15:25']
],
b = moment(new Date(2010, 1, 14, 15, 25, 50, 125)),
i;
@@ -91,14 +91,14 @@
});
test('format month', function (assert) {
- var expected = 'Қаңтар Қаң_Ақпан Ақп_Наурыз Нау_Сәуір Сәу_Мамыр Мам_Маусым Мау_Шілде Шіл_Тамыз Там_Қыркүйек Қыр_Қазан Қаз_Қараша Қар_Желтоқсан Жел'.split('_'), i;
+ var expected = 'қаңтар қаң_ақпан ақп_наурыз нау_сәуір сәу_мамыр мам_маусым мау_шілде шіл_тамыз там_қыркүйек қыр_қазан қаз_қараша қар_желтоқсан жел'.split('_'), i;
for (i = 0; i < expected.length; i++) {
assert.equal(moment([2011, i, 1]).format('MMMM MMM'), expected[i], expected[i]);
}
});
test('format week', function (assert) {
- var expected = 'Жексенбі Жек Жк_Дүйсенбі Дүй Дй_Сейсенбі Сей Сй_Сәрсенбі Сәр Ср_Бейсенбі Бей Бй_Жұма Жұм Жм_Сенбі Сен Сн'.split('_'), i;
+ var expected = 'жексенбі жек жк_дүйсенбі дүй дй_сейсенбі сей сй_сәрсенбі сәр ср_бейсенбі бей бй_жұма жұм жм_сенбі сен сн'.split('_'), i;
for (i = 0; i < expected.length; i++) {
assert.equal(moment([2011, 0, 2 + i]).format('dddd ddd dd'), expected[i], expected[i]);
}
@@ -151,14 +151,14 @@
});
test('calendar day', function (assert) {
- var a = moment().hours(2).minutes(0).seconds(0);
-
- assert.equal(moment(a).calendar(), 'Бүгін сағат 02:00', 'today at the same time');
- assert.equal(moment(a).add({m: 25}).calendar(), 'Бүгін сағат 02:25', 'Now plus 25 min');
- assert.equal(moment(a).add({h: 1}).calendar(), 'Бүгін сағат 03:00', 'Now plus 1 hour');
- assert.equal(moment(a).add({d: 1}).calendar(), 'Ертең сағат 02:00', 'tomorrow at the same time');
- assert.equal(moment(a).subtract({h: 1}).calendar(), 'Бүгін сағат 01:00', 'Now minus 1 hour');
- assert.equal(moment(a).subtract({d: 1}).calendar(), 'Кеше сағат 02:00', 'yesterday at the same time');
+ var a = moment().hours(12).minutes(0).seconds(0);
+
+ assert.equal(moment(a).calendar(), 'Бүгін сағат 12:00', 'today at the same time');
+ assert.equal(moment(a).add({m: 25}).calendar(), 'Бүгін сағат 12:25', 'Now plus 25 min');
+ assert.equal(moment(a).add({h: 1}).calendar(), 'Бүгін сағат 13:00', 'Now plus 1 hour');
+ assert.equal(moment(a).add({d: 1}).calendar(), 'Ертең сағат 12:00', 'tomorrow at the same time');
+ assert.equal(moment(a).subtract({h: 1}).calendar(), 'Бүгін сағат 11:00', 'Now minus 1 hour');
+ assert.equal(moment(a).subtract({d: 1}).calendar(), 'Кеше сағат 12:00', 'yesterday at the same time');
});
test('calendar next week', function (assert) {
@@ -200,67 +200,6 @@
assert.equal(weeksFromNow.calendar(), weeksFromNow.format('L'), 'in 2 weeks');
});
-test('weeks year starting sunday', function (assert) {
- assert.equal(moment([2011, 11, 25]).week(), 52, 'Dec 25 2011 should be week 52');
- assert.equal(moment([2012, 0, 2]).week(), 2, 'Jan 2 2012 should be week 2');
- assert.equal(moment([2012, 0, 8]).week(), 2, 'Jan 8 2012 should be week 2');
- assert.equal(moment([2012, 0, 9]).week(), 3, 'Jan 9 2012 should be week 3');
- assert.equal(moment([2012, 0, 15]).week(), 3, 'Jan 15 2012 should be week 3');
-});
-
-test('weeks year starting monday', function (assert) {
- assert.equal(moment([2007, 0, 1]).week(), 1, 'Jan 1 2007 should be week 1');
- assert.equal(moment([2007, 0, 7]).week(), 1, 'Jan 7 2007 should be week 1');
- assert.equal(moment([2007, 0, 8]).week(), 2, 'Jan 8 2007 should be week 2');
- assert.equal(moment([2007, 0, 14]).week(), 2, 'Jan 14 2007 should be week 2');
- assert.equal(moment([2007, 0, 15]).week(), 3, 'Jan 15 2007 should be week 3');
-});
-
-test('weeks year starting tuesday', function (assert) {
- assert.equal(moment([2007, 11, 31]).week(), 1, 'Dec 31 2007 should be week 1');
- assert.equal(moment([2008, 0, 1]).week(), 1, 'Jan 1 2008 should be week 1');
- assert.equal(moment([2008, 0, 6]).week(), 1, 'Jan 6 2008 should be week 1');
- assert.equal(moment([2008, 0, 7]).week(), 2, 'Jan 7 2008 should be week 2');
- assert.equal(moment([2008, 0, 13]).week(), 2, 'Jan 13 2008 should be week 2');
- assert.equal(moment([2008, 0, 14]).week(), 3, 'Jan 14 2008 should be week 3');
-});
-
-test('weeks year starting wednesday', function (assert) {
- assert.equal(moment([2002, 11, 30]).week(), 1, 'Dec 30 2002 should be week 1');
- assert.equal(moment([2003, 0, 1]).week(), 1, 'Jan 1 2003 should be week 1');
- assert.equal(moment([2003, 0, 5]).week(), 1, 'Jan 5 2003 should be week 1');
- assert.equal(moment([2003, 0, 6]).week(), 2, 'Jan 6 2003 should be week 2');
- assert.equal(moment([2003, 0, 12]).week(), 2, 'Jan 12 2003 should be week 2');
- assert.equal(moment([2003, 0, 13]).week(), 3, 'Jan 13 2003 should be week 3');
-});
-
-test('weeks year starting thursday', function (assert) {
- assert.equal(moment([2008, 11, 29]).week(), 1, 'Dec 29 2008 should be week 1');
- assert.equal(moment([2009, 0, 1]).week(), 1, 'Jan 1 2009 should be week 1');
- assert.equal(moment([2009, 0, 4]).week(), 1, 'Jan 4 2009 should be week 1');
- assert.equal(moment([2009, 0, 5]).week(), 2, 'Jan 5 2009 should be week 2');
- assert.equal(moment([2009, 0, 11]).week(), 2, 'Jan 11 2009 should be week 2');
- assert.equal(moment([2009, 0, 13]).week(), 3, 'Jan 12 2009 should be week 3');
-});
-
-test('weeks year starting friday', function (assert) {
- assert.equal(moment([2009, 11, 28]).week(), 1, 'Dec 28 2009 should be week 1');
- assert.equal(moment([2010, 0, 1]).week(), 1, 'Jan 1 2010 should be week 1');
- assert.equal(moment([2010, 0, 3]).week(), 1, 'Jan 3 2010 should be week 1');
- assert.equal(moment([2010, 0, 4]).week(), 2, 'Jan 4 2010 should be week 2');
- assert.equal(moment([2010, 0, 10]).week(), 2, 'Jan 10 2010 should be week 2');
- assert.equal(moment([2010, 0, 11]).week(), 3, 'Jan 11 2010 should be week 3');
-});
-
-test('weeks year starting saturday', function (assert) {
- assert.equal(moment([2010, 11, 27]).week(), 1, 'Dec 27 2010 should be week 1');
- assert.equal(moment([2011, 0, 1]).week(), 1, 'Jan 1 2011 should be week 1');
- assert.equal(moment([2011, 0, 2]).week(), 1, 'Jan 2 2011 should be week 1');
- assert.equal(moment([2011, 0, 3]).week(), 2, 'Jan 3 2011 should be week 2');
- assert.equal(moment([2011, 0, 9]).week(), 2, 'Jan 9 2011 should be week 2');
- assert.equal(moment([2011, 0, 10]).week(), 3, 'Jan 10 2011 should be week 3');
-});
-
test('weeks year starting sunday formatted', function (assert) {
assert.equal(moment([2012, 0, 1]).format('w ww wo'), '1 01 1-ші', 'Jan 1 2012 should be week 1');
assert.equal(moment([2012, 0, 2]).format('w ww wo'), '2 02 2-ші', 'Jan 2 2012 should be week 2');
@@ -269,38 +208,3 @@
assert.equal(moment([2012, 0, 15]).format('w ww wo'), '3 03 3-ші', 'Jan 15 2012 should be week 3');
});
-test('lenient ordinal parsing', function (assert) {
- var i, ordinalStr, testMoment;
- for (i = 1; i <= 31; ++i) {
- ordinalStr = moment([2014, 0, i]).format('YYYY MM Do');
- testMoment = moment(ordinalStr, 'YYYY MM Do');
- assert.equal(testMoment.year(), 2014,
- 'lenient ordinal parsing ' + i + ' year check');
- assert.equal(testMoment.month(), 0,
- 'lenient ordinal parsing ' + i + ' month check');
- assert.equal(testMoment.date(), i,
- 'lenient ordinal parsing ' + i + ' date check');
- }
-});
-
-test('lenient ordinal parsing of number', function (assert) {
- var i, testMoment;
- for (i = 1; i <= 31; ++i) {
- testMoment = moment('2014 01 ' + i, 'YYYY MM Do');
- assert.equal(testMoment.year(), 2014,
- 'lenient ordinal parsing of number ' + i + ' year check');
- assert.equal(testMoment.month(), 0,
- 'lenient ordinal parsing of number ' + i + ' month check');
- assert.equal(testMoment.date(), i,
- 'lenient ordinal parsing of number ' + i + ' date check');
- }
-});
-
-test('strict ordinal parsing', function (assert) {
- var i, ordinalStr, testMoment;
- for (i = 1; i <= 31; ++i) {
- ordinalStr = moment([2014, 0, i]).format('YYYY MM Do');
- testMoment = moment(ordinalStr, 'YYYY MM Do', true);
- assert.ok(testMoment.isValid(), 'strict ordinal parsing ' + i);
- }
-});
diff --git a/src/test/locale/km.js b/src/test/locale/km.js
index 0d662b6..556c68c 100644
--- a/src/test/locale/km.js
+++ b/src/test/locale/km.js
@@ -3,7 +3,7 @@
localeModule('km');
test('parse', function (assert) {
- var tests = 'មករា មករា_កុម្ភៈ កុម្ភៈ_មិនា មិនា_មេសា មេសា_ឧសភា ឧសភា_មិថុនា មិថុនា_កក្កដា កក្កដា_សីហា សីហា_កញ្ញា កញ្ញា_តុលា តុលា_វិច្ឆិកា វិច្ឆិកា_ធ្នូ ធ្នូ'.split('_'),
+ var tests = 'មករា មករា_កុម្ភៈ កុម្ភៈ_មីនា មីនា_មេសា មេសា_ឧសភា ឧសភា_មិថុនា មិថុនា_កក្កដា កក្កដា_សីហា សីហា_កញ្ញា កញ្ញា_តុលា តុលា_វិច្ឆិកា វិច្ឆិកា_ធ្នូ ធ្នូ'.split('_'),
i;
function equalTest(input, mmm, i) {
@@ -93,7 +93,7 @@
});
test('format month', function (assert) {
- var expected = 'មករា មករា_កុម្ភៈ កុម្ភៈ_មិនា មិនា_មេសា មេសា_ឧសភា ឧសភា_មិថុនា មិថុនា_កក្កដា កក្កដា_សីហា សីហា_កញ្ញា កញ្ញា_តុលា តុលា_វិច្ឆិកា វិច្ឆិកា_ធ្នូ ធ្នូ'.split('_'),
+ var expected = 'មករា មករា_កុម្ភៈ កុម្ភៈ_មីនា មីនា_មេសា មេសា_ឧសភា ឧសភា_មិថុនា មិថុនា_កក្កដា កក្កដា_សីហា សីហា_កញ្ញា កញ្ញា_តុលា តុលា_វិច្ឆិកា វិច្ឆិកា_ធ្នូ ធ្នូ'.split('_'),
i;
for (i = 0; i < expected.length; i++) {
assert.equal(moment([2011, i, 1]).format('MMMM MMM'), expected[i], expected[i]);
@@ -159,24 +159,14 @@
});
test('calendar day', function (assert) {
- var a = moment().hours(2).minutes(0).seconds(0);
-
- assert.equal(moment(a).calendar(), 'ថ្ងៃនេះ ម៉ោង 02:00', 'today at the same time');
- assert.equal(moment(a).add({
- m: 25
- }).calendar(), 'ថ្ងៃនេះ ម៉ោង 02:25', 'Now plus 25 min');
- assert.equal(moment(a).add({
- h: 1
- }).calendar(), 'ថ្ងៃនេះ ម៉ោង 03:00', 'Now plus 1 hour');
- assert.equal(moment(a).add({
- d: 1
- }).calendar(), 'ស្អែក ម៉ោង 02:00', 'tomorrow at the same time');
- assert.equal(moment(a).subtract({
- h: 1
- }).calendar(), 'ថ្ងៃនេះ ម៉ោង 01:00', 'Now minus 1 hour');
- assert.equal(moment(a).subtract({
- d: 1
- }).calendar(), 'ម្សិលមិញ ម៉ោង 02:00', 'yesterday at the same time');
+ var a = moment().hours(12).minutes(0).seconds(0);
+
+ assert.equal(moment(a).calendar(), 'ថ្ងៃនេះ ម៉ោង 12:00', 'today at the same time');
+ assert.equal(moment(a).add({m: 25}).calendar(), 'ថ្ងៃនេះ ម៉ោង 12:25', 'Now plus 25 min');
+ assert.equal(moment(a).add({h: 1}).calendar(), 'ថ្ងៃនេះ ម៉ោង 13:00', 'Now plus 1 hour');
+ assert.equal(moment(a).add({d: 1}).calendar(), 'ស្អែក ម៉ោង 12:00', 'tomorrow at the same time');
+ assert.equal(moment(a).subtract({h: 1}).calendar(), 'ថ្ងៃនេះ ម៉ោង 11:00', 'Now minus 1 hour');
+ assert.equal(moment(a).subtract({d: 1}).calendar(), 'ម្សិលមិញ ម៉ោង 12:00', 'yesterday at the same time');
});
test('calendar next week', function (assert) {
@@ -230,67 +220,6 @@
assert.equal(weeksFromNow.calendar(), weeksFromNow.format('L'), 'in 2 weeks');
});
-test('weeks year starting sunday', function (assert) {
- assert.equal(moment([2012, 0, 1]).week(), 52, 'Jan 1 2012 should be week 52');
- assert.equal(moment([2012, 0, 2]).week(), 1, 'Jan 2 2012 should be week 1');
- assert.equal(moment([2012, 0, 8]).week(), 1, 'Jan 8 2012 should be week 1');
- assert.equal(moment([2012, 0, 9]).week(), 2, 'Jan 9 2012 should be week 2');
- assert.equal(moment([2012, 0, 15]).week(), 2, 'Jan 15 2012 should be week 2');
-});
-
-test('weeks year starting monday', function (assert) {
- assert.equal(moment([2007, 0, 1]).week(), 1, 'Jan 1 2007 should be week 1');
- assert.equal(moment([2007, 0, 7]).week(), 1, 'Jan 7 2007 should be week 1');
- assert.equal(moment([2007, 0, 8]).week(), 2, 'Jan 8 2007 should be week 2');
- assert.equal(moment([2007, 0, 14]).week(), 2, 'Jan 14 2007 should be week 2');
- assert.equal(moment([2007, 0, 15]).week(), 3, 'Jan 15 2007 should be week 3');
-});
-
-test('weeks year starting tuesday', function (assert) {
- assert.equal(moment([2007, 11, 31]).week(), 1, 'Dec 31 2007 should be week 1');
- assert.equal(moment([2008, 0, 1]).week(), 1, 'Jan 1 2008 should be week 1');
- assert.equal(moment([2008, 0, 6]).week(), 1, 'Jan 6 2008 should be week 1');
- assert.equal(moment([2008, 0, 7]).week(), 2, 'Jan 7 2008 should be week 2');
- assert.equal(moment([2008, 0, 13]).week(), 2, 'Jan 13 2008 should be week 2');
- assert.equal(moment([2008, 0, 14]).week(), 3, 'Jan 14 2008 should be week 3');
-});
-
-test('weeks year starting wednesday', function (assert) {
- assert.equal(moment([2002, 11, 30]).week(), 1, 'Dec 30 2002 should be week 1');
- assert.equal(moment([2003, 0, 1]).week(), 1, 'Jan 1 2003 should be week 1');
- assert.equal(moment([2003, 0, 5]).week(), 1, 'Jan 5 2003 should be week 1');
- assert.equal(moment([2003, 0, 6]).week(), 2, 'Jan 6 2003 should be week 2');
- assert.equal(moment([2003, 0, 12]).week(), 2, 'Jan 12 2003 should be week 2');
- assert.equal(moment([2003, 0, 13]).week(), 3, 'Jan 13 2003 should be week 3');
-});
-
-test('weeks year starting thursday', function (assert) {
- assert.equal(moment([2008, 11, 29]).week(), 1, 'Dec 29 2008 should be week 1');
- assert.equal(moment([2009, 0, 1]).week(), 1, 'Jan 1 2009 should be week 1');
- assert.equal(moment([2009, 0, 4]).week(), 1, 'Jan 4 2009 should be week 1');
- assert.equal(moment([2009, 0, 5]).week(), 2, 'Jan 5 2009 should be week 2');
- assert.equal(moment([2009, 0, 11]).week(), 2, 'Jan 11 2009 should be week 2');
- assert.equal(moment([2009, 0, 13]).week(), 3, 'Jan 12 2009 should be week 3');
-});
-
-test('weeks year starting friday', function (assert) {
- assert.equal(moment([2009, 11, 28]).week(), 53, 'Dec 28 2009 should be week 53');
- assert.equal(moment([2010, 0, 1]).week(), 53, 'Jan 1 2010 should be week 53');
- assert.equal(moment([2010, 0, 3]).week(), 53, 'Jan 3 2010 should be week 53');
- assert.equal(moment([2010, 0, 4]).week(), 1, 'Jan 4 2010 should be week 1');
- assert.equal(moment([2010, 0, 10]).week(), 1, 'Jan 10 2010 should be week 1');
- assert.equal(moment([2010, 0, 11]).week(), 2, 'Jan 11 2010 should be week 2');
-});
-
-test('weeks year starting saturday', function (assert) {
- assert.equal(moment([2010, 11, 27]).week(), 52, 'Dec 27 2010 should be week 52');
- assert.equal(moment([2011, 0, 1]).week(), 52, 'Jan 1 2011 should be week 52');
- assert.equal(moment([2011, 0, 2]).week(), 52, 'Jan 2 2011 should be week 52');
- assert.equal(moment([2011, 0, 3]).week(), 1, 'Jan 3 2011 should be week 1');
- assert.equal(moment([2011, 0, 9]).week(), 1, 'Jan 9 2011 should be week 1');
- assert.equal(moment([2011, 0, 10]).week(), 2, 'Jan 10 2011 should be week 2');
-});
-
test('weeks year starting sunday formatted', function (assert) {
assert.equal(moment([2012, 0, 1]).format('w ww wo'), '52 52 52', 'Jan 1 2012 should be week 52');
assert.equal(moment([2012, 0, 2]).format('w ww wo'), '1 01 1', 'Jan 2 2012 should be week 1');
@@ -299,38 +228,3 @@
assert.equal(moment([2012, 0, 15]).format('w ww wo'), '2 02 2', 'Jan 15 2012 should be week 2');
});
-test('lenient ordinal parsing', function (assert) {
- var i, ordinalStr, testMoment;
- for (i = 1; i <= 31; ++i) {
- ordinalStr = moment([2014, 0, i]).format('YYYY MM Do');
- testMoment = moment(ordinalStr, 'YYYY MM Do');
- assert.equal(testMoment.year(), 2014,
- 'lenient ordinal parsing ' + i + ' year check');
- assert.equal(testMoment.month(), 0,
- 'lenient ordinal parsing ' + i + ' month check');
- assert.equal(testMoment.date(), i,
- 'lenient ordinal parsing ' + i + ' date check');
- }
-});
-
-test('lenient ordinal parsing of number', function (assert) {
- var i, testMoment;
- for (i = 1; i <= 31; ++i) {
- testMoment = moment('2014 01 ' + i, 'YYYY MM Do');
- assert.equal(testMoment.year(), 2014,
- 'lenient ordinal parsing of number ' + i + ' year check');
- assert.equal(testMoment.month(), 0,
- 'lenient ordinal parsing of number ' + i + ' month check');
- assert.equal(testMoment.date(), i,
- 'lenient ordinal parsing of number ' + i + ' date check');
- }
-});
-
-test('strict ordinal parsing', function (assert) {
- var i, ordinalStr, testMoment;
- for (i = 1; i <= 31; ++i) {
- ordinalStr = moment([2014, 0, i]).format('YYYY MM Do');
- testMoment = moment(ordinalStr, 'YYYY MM Do', true);
- assert.ok(testMoment.isValid(), 'strict ordinal parsing ' + i);
- }
-});
diff --git a/src/test/locale/ko.js b/src/test/locale/ko.js
index 6e317c7..8e46378 100644
--- a/src/test/locale/ko.js
+++ b/src/test/locale/ko.js
@@ -42,7 +42,6 @@
outputFormat : 'H',
expected : '16'
}], i, l, it, actual;
-
for (i = 0, l = elements.length; i < l; ++i) {
it = elements[i];
@@ -142,13 +141,13 @@
test('from', function (assert) {
var start = moment([2007, 1, 28]);
- assert.equal(start.from(moment([2007, 1, 28]).add({s: 44}), true), '몇초', '44초 = 몇초');
+ assert.equal(start.from(moment([2007, 1, 28]).add({s: 44}), true), '몇 초', '44초 = 몇 초');
assert.equal(start.from(moment([2007, 1, 28]).add({s: 45}), true), '일분', '45초 = 일분');
assert.equal(start.from(moment([2007, 1, 28]).add({s: 89}), true), '일분', '89초 = 일분');
assert.equal(start.from(moment([2007, 1, 28]).add({s: 90}), true), '2분', '90초 = 2분');
assert.equal(start.from(moment([2007, 1, 28]).add({m: 44}), true), '44분', '44분 = 44분');
- assert.equal(start.from(moment([2007, 1, 28]).add({m: 45}), true), '한시간', '45분 = 한시간');
- assert.equal(start.from(moment([2007, 1, 28]).add({m: 89}), true), '한시간', '89분 = 한시간');
+ assert.equal(start.from(moment([2007, 1, 28]).add({m: 45}), true), '한 시간', '45분 = 한 시간');
+ assert.equal(start.from(moment([2007, 1, 28]).add({m: 89}), true), '한 시간', '89분 = 한 시간');
assert.equal(start.from(moment([2007, 1, 28]).add({m: 90}), true), '2시간', '90분 = 2시간');
assert.equal(start.from(moment([2007, 1, 28]).add({h: 5}), true), '5시간', '5시간 = 5시간');
assert.equal(start.from(moment([2007, 1, 28]).add({h: 21}), true), '21시간', '21시간 = 21시간');
@@ -158,43 +157,43 @@
assert.equal(start.from(moment([2007, 1, 28]).add({d: 1}), true), '하루', '하루 = 하루');
assert.equal(start.from(moment([2007, 1, 28]).add({d: 5}), true), '5일', '5일 = 5일');
assert.equal(start.from(moment([2007, 1, 28]).add({d: 25}), true), '25일', '25일 = 25일');
- assert.equal(start.from(moment([2007, 1, 28]).add({d: 26}), true), '한달', '26일 = 한달');
- assert.equal(start.from(moment([2007, 1, 28]).add({d: 30}), true), '한달', '30일 = 한달');
- assert.equal(start.from(moment([2007, 1, 28]).add({d: 43}), true), '한달', '45일 = 한달');
+ assert.equal(start.from(moment([2007, 1, 28]).add({d: 26}), true), '한 달', '26일 = 한 달');
+ assert.equal(start.from(moment([2007, 1, 28]).add({d: 30}), true), '한 달', '30일 = 한 달');
+ assert.equal(start.from(moment([2007, 1, 28]).add({d: 43}), true), '한 달', '45일 = 한 달');
assert.equal(start.from(moment([2007, 1, 28]).add({d: 46}), true), '2달', '46일 = 2달');
assert.equal(start.from(moment([2007, 1, 28]).add({d: 74}), true), '2달', '75일 = 2달');
assert.equal(start.from(moment([2007, 1, 28]).add({d: 76}), true), '3달', '76일 = 3달');
- assert.equal(start.from(moment([2007, 1, 28]).add({M: 1}), true), '한달', '1달 = 한달');
+ assert.equal(start.from(moment([2007, 1, 28]).add({M: 1}), true), '한 달', '1달 = 한 달');
assert.equal(start.from(moment([2007, 1, 28]).add({M: 5}), true), '5달', '5달 = 5달');
- assert.equal(start.from(moment([2007, 1, 28]).add({d: 345}), true), '일년', '345일 = 일년');
+ assert.equal(start.from(moment([2007, 1, 28]).add({d: 345}), true), '일 년', '345일 = 일 년');
assert.equal(start.from(moment([2007, 1, 28]).add({d: 548}), true), '2년', '548일 = 2년');
- assert.equal(start.from(moment([2007, 1, 28]).add({y: 1}), true), '일년', '일년 = 일년');
+ assert.equal(start.from(moment([2007, 1, 28]).add({y: 1}), true), '일 년', '일 년 = 일 년');
assert.equal(start.from(moment([2007, 1, 28]).add({y: 5}), true), '5년', '5년 = 5년');
});
test('suffix', function (assert) {
- assert.equal(moment(30000).from(0), '몇초 후', 'prefix');
- assert.equal(moment(0).from(30000), '몇초 전', 'suffix');
+ assert.equal(moment(30000).from(0), '몇 초 후', 'prefix');
+ assert.equal(moment(0).from(30000), '몇 초 전', 'suffix');
});
test('now from now', function (assert) {
- assert.equal(moment().fromNow(), '몇초 전', 'now from now should display as in the past');
+ assert.equal(moment().fromNow(), '몇 초 전', 'now from now should display as in the past');
});
test('fromNow', function (assert) {
- assert.equal(moment().add({s: 30}).fromNow(), '몇초 후', 'in a few seconds');
+ assert.equal(moment().add({s: 30}).fromNow(), '몇 초 후', 'in a few seconds');
assert.equal(moment().add({d: 5}).fromNow(), '5일 후', 'in 5 days');
});
test('calendar day', function (assert) {
- var a = moment().hours(2).minutes(0).seconds(0);
-
- assert.equal(moment(a).calendar(), '오늘 오전 2시 0분', 'today at the same time');
- assert.equal(moment(a).add({m: 25}).calendar(), '오늘 오전 2시 25분', 'Now plus 25 min');
- assert.equal(moment(a).add({h: 1}).calendar(), '오늘 오전 3시 0분', 'Now plus 1 hour');
- assert.equal(moment(a).add({d: 1}).calendar(), '내일 오전 2시 0분', 'tomorrow at the same time');
- assert.equal(moment(a).subtract({h: 1}).calendar(), '오늘 오전 1시 0분', 'Now minus 1 hour');
- assert.equal(moment(a).subtract({d: 1}).calendar(), '어제 오전 2시 0분', 'yesterday at the same time');
+ var a = moment().hours(12).minutes(0).seconds(0);
+
+ assert.equal(moment(a).calendar(), '오늘 오후 12시 0분', 'today at the same time');
+ assert.equal(moment(a).add({m: 25}).calendar(), '오늘 오후 12시 25분', 'Now plus 25 min');
+ assert.equal(moment(a).add({h: 1}).calendar(), '오늘 오후 1시 0분', 'Now plus 1 hour');
+ assert.equal(moment(a).add({d: 1}).calendar(), '내일 오후 12시 0분', 'tomorrow at the same time');
+ assert.equal(moment(a).subtract({h: 1}).calendar(), '오늘 오전 11시 0분', 'Now minus 1 hour');
+ assert.equal(moment(a).subtract({d: 1}).calendar(), '어제 오후 12시 0분', 'yesterday at the same time');
});
test('calendar next week', function (assert) {
@@ -235,67 +234,6 @@
assert.equal(weeksFromNow.calendar(), weeksFromNow.format('L'), 'in 2 weeks');
});
-test('weeks year starting sunday', function (assert) {
- assert.equal(moment([2012, 0, 1]).week(), 1, 'Jan 1 2012 should be week 1');
- assert.equal(moment([2012, 0, 7]).week(), 1, 'Jan 7 2012 should be week 1');
- assert.equal(moment([2012, 0, 8]).week(), 2, 'Jan 8 2012 should be week 2');
- assert.equal(moment([2012, 0, 14]).week(), 2, 'Jan 14 2012 should be week 2');
- assert.equal(moment([2012, 0, 15]).week(), 3, 'Jan 15 2012 should be week 3');
-});
-
-test('weeks year starting monday', function (assert) {
- assert.equal(moment([2006, 11, 31]).week(), 1, 'Dec 31 2006 should be week 1');
- assert.equal(moment([2007, 0, 1]).week(), 1, 'Jan 1 2007 should be week 1');
- assert.equal(moment([2007, 0, 6]).week(), 1, 'Jan 6 2007 should be week 1');
- assert.equal(moment([2007, 0, 7]).week(), 2, 'Jan 7 2007 should be week 2');
- assert.equal(moment([2007, 0, 13]).week(), 2, 'Jan 13 2007 should be week 2');
- assert.equal(moment([2007, 0, 14]).week(), 3, 'Jan 14 2007 should be week 3');
-});
-
-test('weeks year starting tuesday', function (assert) {
- assert.equal(moment([2007, 11, 29]).week(), 52, 'Dec 29 2007 should be week 52');
- assert.equal(moment([2008, 0, 1]).week(), 1, 'Jan 1 2008 should be week 1');
- assert.equal(moment([2008, 0, 5]).week(), 1, 'Jan 5 2008 should be week 1');
- assert.equal(moment([2008, 0, 6]).week(), 2, 'Jan 6 2008 should be week 2');
- assert.equal(moment([2008, 0, 12]).week(), 2, 'Jan 12 2008 should be week 2');
- assert.equal(moment([2008, 0, 13]).week(), 3, 'Jan 13 2008 should be week 3');
-});
-
-test('weeks year starting wednesday', function (assert) {
- assert.equal(moment([2002, 11, 29]).week(), 1, 'Dec 29 2002 should be week 1');
- assert.equal(moment([2003, 0, 1]).week(), 1, 'Jan 1 2003 should be week 1');
- assert.equal(moment([2003, 0, 4]).week(), 1, 'Jan 4 2003 should be week 1');
- assert.equal(moment([2003, 0, 5]).week(), 2, 'Jan 5 2003 should be week 2');
- assert.equal(moment([2003, 0, 11]).week(), 2, 'Jan 11 2003 should be week 2');
- assert.equal(moment([2003, 0, 12]).week(), 3, 'Jan 12 2003 should be week 3');
-});
-
-test('weeks year starting thursday', function (assert) {
- assert.equal(moment([2008, 11, 28]).week(), 1, 'Dec 28 2008 should be week 1');
- assert.equal(moment([2009, 0, 1]).week(), 1, 'Jan 1 2009 should be week 1');
- assert.equal(moment([2009, 0, 3]).week(), 1, 'Jan 3 2009 should be week 1');
- assert.equal(moment([2009, 0, 4]).week(), 2, 'Jan 4 2009 should be week 2');
- assert.equal(moment([2009, 0, 10]).week(), 2, 'Jan 10 2009 should be week 2');
- assert.equal(moment([2009, 0, 11]).week(), 3, 'Jan 11 2009 should be week 3');
-});
-
-test('weeks year starting friday', function (assert) {
- assert.equal(moment([2009, 11, 27]).week(), 1, 'Dec 27 2009 should be week 1');
- assert.equal(moment([2010, 0, 1]).week(), 1, 'Jan 1 2010 should be week 1');
- assert.equal(moment([2010, 0, 2]).week(), 1, 'Jan 2 2010 should be week 1');
- assert.equal(moment([2010, 0, 3]).week(), 2, 'Jan 3 2010 should be week 2');
- assert.equal(moment([2010, 0, 9]).week(), 2, 'Jan 9 2010 should be week 2');
- assert.equal(moment([2010, 0, 10]).week(), 3, 'Jan 10 2010 should be week 3');
-});
-
-test('weeks year starting saturday', function (assert) {
- assert.equal(moment([2010, 11, 26]).week(), 1, 'Dec 26 2010 should be week 1');
- assert.equal(moment([2011, 0, 1]).week(), 1, 'Jan 1 2011 should be week 1');
- assert.equal(moment([2011, 0, 2]).week(), 2, 'Jan 2 2011 should be week 2');
- assert.equal(moment([2011, 0, 8]).week(), 2, 'Jan 8 2011 should be week 2');
- assert.equal(moment([2011, 0, 9]).week(), 3, 'Jan 9 2011 should be week 3');
-});
-
test('weeks year starting sunday format', function (assert) {
assert.equal(moment([2012, 0, 1]).format('w ww wo'), '1 01 1일', 'Jan 1 2012 should be week 1');
assert.equal(moment([2012, 0, 7]).format('w ww wo'), '1 01 1일', 'Jan 7 2012 should be week 1');
@@ -304,38 +242,3 @@
assert.equal(moment([2012, 0, 15]).format('w ww wo'), '3 03 3일', 'Jan 15 2012 should be week 3');
});
-test('lenient ordinal parsing', function (assert) {
- var i, ordinalStr, testMoment;
- for (i = 1; i <= 31; ++i) {
- ordinalStr = moment([2014, 0, i]).format('YYYY MM Do');
- testMoment = moment(ordinalStr, 'YYYY MM Do');
- assert.equal(testMoment.year(), 2014,
- 'lenient ordinal parsing ' + i + ' year check');
- assert.equal(testMoment.month(), 0,
- 'lenient ordinal parsing ' + i + ' month check');
- assert.equal(testMoment.date(), i,
- 'lenient ordinal parsing ' + i + ' date check');
- }
-});
-
-test('lenient ordinal parsing of number', function (assert) {
- var i, testMoment;
- for (i = 1; i <= 31; ++i) {
- testMoment = moment('2014 01 ' + i, 'YYYY MM Do');
- assert.equal(testMoment.year(), 2014,
- 'lenient ordinal parsing of number ' + i + ' year check');
- assert.equal(testMoment.month(), 0,
- 'lenient ordinal parsing of number ' + i + ' month check');
- assert.equal(testMoment.date(), i,
- 'lenient ordinal parsing of number ' + i + ' date check');
- }
-});
-
-test('strict ordinal parsing', function (assert) {
- var i, ordinalStr, testMoment;
- for (i = 1; i <= 31; ++i) {
- ordinalStr = moment([2014, 0, i]).format('YYYY MM Do');
- testMoment = moment(ordinalStr, 'YYYY MM Do', true);
- assert.ok(testMoment.isValid(), 'strict ordinal parsing ' + i);
- }
-});
diff --git a/src/test/locale/ky.js b/src/test/locale/ky.js
new file mode 100644
index 0000000..12385ad
--- /dev/null
+++ b/src/test/locale/ky.js
@@ -0,0 +1,209 @@
+import {localeModule, test} from '../qunit';
+import moment from '../../moment';
+localeModule('ky');
+
+test('parse', function (assert) {
+ var tests = 'январь янв_февраль фев_март март_апрель апр_май май_июнь июнь_июль июль_август авг_сентябрь сен_октябрь окт_ноябрь ноя_декабрь дек'.split('_'), i;
+ function equalTest(input, mmm, i) {
+ assert.equal(moment(input, mmm).month(), i, input + ' should be month ' + (i + 1));
+ }
+ for (i = 0; i < 12; i++) {
+ tests[i] = tests[i].split(' ');
+ equalTest(tests[i][0], 'MMM', i);
+ equalTest(tests[i][1], 'MMM', i);
+ equalTest(tests[i][0], 'MMMM', i);
+ equalTest(tests[i][1], 'MMMM', i);
+ equalTest(tests[i][0].toLocaleLowerCase(), 'MMMM', i);
+ equalTest(tests[i][1].toLocaleLowerCase(), 'MMMM', i);
+ equalTest(tests[i][0].toLocaleUpperCase(), 'MMMM', i);
+ equalTest(tests[i][1].toLocaleUpperCase(), 'MMMM', i);
+ }
+});
+
+test('format', function (assert) {
+ var a = [
+ ['dddd, Do MMMM YYYY, HH:mm:ss', 'Жекшемби, 14-чү февраль 2010, 15:25:50'],
+ ['ddd, hA', 'Жек, 3PM'],
+ ['M Mo MM MMMM MMM', '2 2-чи 02 февраль фев'],
+ ['YYYY YY', '2010 10'],
+ ['D Do DD', '14 14-чү 14'],
+ ['d do dddd ddd dd', '0 0-чү Жекшемби Жек Жк'],
+ ['DDD DDDo DDDD', '45 45-чи 045'],
+ ['w wo ww', '7 7-чи 07'],
+ ['h hh', '3 03'],
+ ['H HH', '15 15'],
+ ['m mm', '25 25'],
+ ['s ss', '50 50'],
+ ['a A', 'pm PM'],
+ ['[жылдын] DDDo [күнү]', 'жылдын 45-чи күнү'],
+ ['LTS', '15:25:50'],
+ ['L', '14.02.2010'],
+ ['LL', '14 февраль 2010'],
+ ['LLL', '14 февраль 2010 15:25'],
+ ['LLLL', 'Жекшемби, 14 февраль 2010 15:25'],
+ ['l', '14.2.2010'],
+ ['ll', '14 фев 2010'],
+ ['lll', '14 фев 2010 15:25'],
+ ['llll', 'Жек, 14 фев 2010 15:25']
+ ],
+ b = moment(new Date(2010, 1, 14, 15, 25, 50, 125)),
+ i;
+ for (i = 0; i < a.length; i++) {
+ assert.equal(b.format(a[i][0]), a[i][1], a[i][0] + ' ---> ' + a[i][1]);
+ }
+});
+
+test('format ordinal', function (assert) {
+ assert.equal(moment([2011, 0, 1]).format('DDDo'), '1-чи', '1st');
+ assert.equal(moment([2011, 0, 2]).format('DDDo'), '2-чи', '2nd');
+ assert.equal(moment([2011, 0, 3]).format('DDDo'), '3-чү', '3rd');
+ assert.equal(moment([2011, 0, 4]).format('DDDo'), '4-чү', '4th');
+ assert.equal(moment([2011, 0, 5]).format('DDDo'), '5-чи', '5th');
+ assert.equal(moment([2011, 0, 6]).format('DDDo'), '6-чы', '6th');
+ assert.equal(moment([2011, 0, 7]).format('DDDo'), '7-чи', '7th');
+ assert.equal(moment([2011, 0, 8]).format('DDDo'), '8-чи', '8th');
+ assert.equal(moment([2011, 0, 9]).format('DDDo'), '9-чу', '9th');
+ assert.equal(moment([2011, 0, 10]).format('DDDo'), '10-чу', '10th');
+
+ assert.equal(moment([2011, 0, 11]).format('DDDo'), '11-чи', '11th');
+ assert.equal(moment([2011, 0, 12]).format('DDDo'), '12-чи', '12th');
+ assert.equal(moment([2011, 0, 13]).format('DDDo'), '13-чү', '13th');
+ assert.equal(moment([2011, 0, 14]).format('DDDo'), '14-чү', '14th');
+ assert.equal(moment([2011, 0, 15]).format('DDDo'), '15-чи', '15th');
+ assert.equal(moment([2011, 0, 16]).format('DDDo'), '16-чы', '16th');
+ assert.equal(moment([2011, 0, 17]).format('DDDo'), '17-чи', '17th');
+ assert.equal(moment([2011, 0, 18]).format('DDDo'), '18-чи', '18th');
+ assert.equal(moment([2011, 0, 19]).format('DDDo'), '19-чу', '19th');
+ assert.equal(moment([2011, 0, 20]).format('DDDo'), '20-чы', '20th');
+
+ assert.equal(moment([2011, 0, 21]).format('DDDo'), '21-чи', '21st');
+ assert.equal(moment([2011, 0, 22]).format('DDDo'), '22-чи', '22nd');
+ assert.equal(moment([2011, 0, 23]).format('DDDo'), '23-чү', '23rd');
+ assert.equal(moment([2011, 0, 24]).format('DDDo'), '24-чү', '24th');
+ assert.equal(moment([2011, 0, 25]).format('DDDo'), '25-чи', '25th');
+ assert.equal(moment([2011, 0, 26]).format('DDDo'), '26-чы', '26th');
+ assert.equal(moment([2011, 0, 27]).format('DDDo'), '27-чи', '27th');
+ assert.equal(moment([2011, 0, 28]).format('DDDo'), '28-чи', '28th');
+ assert.equal(moment([2011, 0, 29]).format('DDDo'), '29-чу', '29th');
+ assert.equal(moment([2011, 0, 30]).format('DDDo'), '30-чу', '30th');
+
+ assert.equal(moment([2011, 0, 31]).format('DDDo'), '31-чи', '31st');
+});
+
+test('format month', function (assert) {
+ var expected = 'январь янв_февраль фев_март март_апрель апр_май май_июнь июнь_июль июль_август авг_сентябрь сен_октябрь окт_ноябрь ноя_декабрь дек'.split('_'), i;
+ for (i = 0; i < expected.length; i++) {
+ assert.equal(moment([2011, i, 1]).format('MMMM MMM'), expected[i], expected[i]);
+ }
+});
+
+test('format week', function (assert) {
+ var expected = 'Жекшемби Жек Жк_Дүйшөмбү Дүй Дй_Шейшемби Шей Шй_Шаршемби Шар Шр_Бейшемби Бей Бй_Жума Жум Жм_Ишемби Ише Иш'.split('_'), i;
+ for (i = 0; i < expected.length; i++) {
+ assert.equal(moment([2011, 0, 2 + i]).format('dddd ddd dd'), expected[i], expected[i]);
+ }
+});
+
+test('from', function (assert) {
+ var start = moment([2007, 1, 28]);
+ assert.equal(start.from(moment([2007, 1, 28]).add({s: 44}), true), 'бирнече секунд', '44 seconds = a few seconds');
+ assert.equal(start.from(moment([2007, 1, 28]).add({s: 45}), true), 'бир мүнөт', '45 seconds = a minute');
+ assert.equal(start.from(moment([2007, 1, 28]).add({s: 89}), true), 'бир мүнөт', '89 seconds = a minute');
+ assert.equal(start.from(moment([2007, 1, 28]).add({s: 90}), true), '2 мүнөт', '90 seconds = 2 minutes');
+ assert.equal(start.from(moment([2007, 1, 28]).add({m: 44}), true), '44 мүнөт', '44 minutes = 44 minutes');
+ assert.equal(start.from(moment([2007, 1, 28]).add({m: 45}), true), 'бир саат', '45 minutes = an hour');
+ assert.equal(start.from(moment([2007, 1, 28]).add({m: 89}), true), 'бир саат', '89 minutes = an hour');
+ assert.equal(start.from(moment([2007, 1, 28]).add({m: 90}), true), '2 саат', '90 minutes = 2 hours');
+ assert.equal(start.from(moment([2007, 1, 28]).add({h: 5}), true), '5 саат', '5 hours = 5 hours');
+ assert.equal(start.from(moment([2007, 1, 28]).add({h: 21}), true), '21 саат', '21 hours = 21 hours');
+ assert.equal(start.from(moment([2007, 1, 28]).add({h: 22}), true), 'бир күн', '22 hours = a day');
+ assert.equal(start.from(moment([2007, 1, 28]).add({h: 35}), true), 'бир күн', '35 hours = a day');
+ assert.equal(start.from(moment([2007, 1, 28]).add({h: 36}), true), '2 күн', '36 hours = 2 days');
+ assert.equal(start.from(moment([2007, 1, 28]).add({d: 1}), true), 'бир күн', '1 day = a day');
+ assert.equal(start.from(moment([2007, 1, 28]).add({d: 5}), true), '5 күн', '5 days = 5 days');
+ assert.equal(start.from(moment([2007, 1, 28]).add({d: 25}), true), '25 күн', '25 days = 25 days');
+ assert.equal(start.from(moment([2007, 1, 28]).add({d: 26}), true), 'бир ай', '26 days = a month');
+ assert.equal(start.from(moment([2007, 1, 28]).add({d: 30}), true), 'бир ай', '30 days = a month');
+ assert.equal(start.from(moment([2007, 1, 28]).add({d: 43}), true), 'бир ай', '43 days = a month');
+ assert.equal(start.from(moment([2007, 1, 28]).add({d: 46}), true), '2 ай', '46 days = 2 months');
+ assert.equal(start.from(moment([2007, 1, 28]).add({d: 74}), true), '2 ай', '75 days = 2 months');
+ assert.equal(start.from(moment([2007, 1, 28]).add({d: 76}), true), '3 ай', '76 days = 3 months');
+ assert.equal(start.from(moment([2007, 1, 28]).add({M: 1}), true), 'бир ай', '1 month = a month');
+ assert.equal(start.from(moment([2007, 1, 28]).add({M: 5}), true), '5 ай', '5 months = 5 months');
+ assert.equal(start.from(moment([2007, 1, 28]).add({d: 345}), true), 'бир жыл', '345 days = a year');
+ assert.equal(start.from(moment([2007, 1, 28]).add({d: 548}), true), '2 жыл', '548 days = 2 years');
+ assert.equal(start.from(moment([2007, 1, 28]).add({y: 1}), true), 'бир жыл', '1 year = a year');
+ assert.equal(start.from(moment([2007, 1, 28]).add({y: 5}), true), '5 жыл', '5 years = 5 years');
+});
+
+test('suffix', function (assert) {
+ assert.equal(moment(30000).from(0), 'бирнече секунд ичинде', 'prefix');
+ assert.equal(moment(0).from(30000), 'бирнече секунд мурун', 'suffix');
+});
+
+test('now from now', function (assert) {
+ assert.equal(moment().fromNow(), 'бирнече секунд мурун', 'now from now should display as in the past');
+});
+
+test('fromNow', function (assert) {
+ assert.equal(moment().add({s: 30}).fromNow(), 'бирнече секунд ичинде', 'in a few seconds');
+ assert.equal(moment().add({d: 5}).fromNow(), '5 күн ичинде', 'in 5 days');
+});
+
+test('calendar day', function (assert) {
+ var a = moment().hours(12).minutes(0).seconds(0);
+
+ assert.equal(moment(a).calendar(), 'Бүгүн саат 12:00', 'today at the same time');
+ assert.equal(moment(a).add({m: 25}).calendar(), 'Бүгүн саат 12:25', 'Now plus 25 min');
+ assert.equal(moment(a).add({h: 1}).calendar(), 'Бүгүн саат 13:00', 'Now plus 1 hour');
+ assert.equal(moment(a).add({d: 1}).calendar(), 'Эртең саат 12:00', 'tomorrow at the same time');
+ assert.equal(moment(a).subtract({h: 1}).calendar(), 'Бүгүн саат 11:00', 'Now minus 1 hour');
+ assert.equal(moment(a).subtract({d: 1}).calendar(), 'Кече саат 12:00', 'yesterday at the same time');
+});
+
+test('calendar next week', function (assert) {
+ var i, m;
+ for (i = 2; i < 7; i++) {
+ m = moment().add({d: i});
+ assert.equal(m.calendar(), m.format('dddd [саат] LT'), 'Today + ' + i + ' days current time');
+ m.hours(0).minutes(0).seconds(0).milliseconds(0);
+ assert.equal(m.calendar(), m.format('dddd [саат] LT'), 'Today + ' + i + ' days beginning of day');
+ m.hours(23).minutes(59).seconds(59).milliseconds(999);
+ assert.equal(m.calendar(), m.format('dddd [саат] LT'), 'Today + ' + i + ' days end of day');
+ }
+});
+
+test('calendar last week', function (assert) {
+ var i, m;
+
+ for (i = 2; i < 7; i++) {
+ m = moment().subtract({d: i});
+ assert.equal(m.calendar(), m.format('[Өткен аптанын] dddd [күнү] [саат] LT'), 'Today - ' + i + ' days current time');
+ m.hours(0).minutes(0).seconds(0).milliseconds(0);
+ assert.equal(m.calendar(), m.format('[Өткен аптанын] dddd [күнү] [саат] LT'), 'Today - ' + i + ' days beginning of day');
+ m.hours(23).minutes(59).seconds(59).milliseconds(999);
+ assert.equal(m.calendar(), m.format('[Өткен аптанын] dddd [күнү] [саат] LT'), 'Today - ' + i + ' days end of day');
+ }
+});
+
+test('calendar all else', function (assert) {
+ var weeksAgo = moment().subtract({w: 1}),
+ weeksFromNow = moment().add({w: 1});
+
+ assert.equal(weeksAgo.calendar(), weeksAgo.format('L'), '1 week ago');
+ assert.equal(weeksFromNow.calendar(), weeksFromNow.format('L'), 'in 1 week');
+
+ weeksAgo = moment().subtract({w: 2});
+ weeksFromNow = moment().add({w: 2});
+
+ assert.equal(weeksAgo.calendar(), weeksAgo.format('L'), '2 weeks ago');
+ assert.equal(weeksFromNow.calendar(), weeksFromNow.format('L'), 'in 2 weeks');
+});
+
+test('weeks year starting sunday formatted', function (assert) {
+ assert.equal(moment([2012, 0, 1]).format('w ww wo'), '1 01 1-чи', 'Jan 1 2012 should be week 1');
+ assert.equal(moment([2012, 0, 2]).format('w ww wo'), '2 02 2-чи', 'Jan 2 2012 should be week 2');
+ assert.equal(moment([2012, 0, 8]).format('w ww wo'), '2 02 2-чи', 'Jan 8 2012 should be week 2');
+ assert.equal(moment([2012, 0, 9]).format('w ww wo'), '3 03 3-чү', 'Jan 9 2012 should be week 3');
+ assert.equal(moment([2012, 0, 15]).format('w ww wo'), '3 03 3-чү', 'Jan 15 2012 should be week 3');
+});
diff --git a/src/test/locale/lb.js b/src/test/locale/lb.js
index 908aa1d..d54cc4f 100644
--- a/src/test/locale/lb.js
+++ b/src/test/locale/lb.js
@@ -122,6 +122,30 @@
assert.equal(moment().add({y: 400}).fromNow(), 'a 400 Joer', 'in 400 years');
});
+test('calendar day', function (assert) {
+ var a = moment().hours(12).minutes(0).seconds(0);
+
+ assert.equal(moment(a).calendar(), 'Haut um 12:00 Auer', 'today at the same time');
+ assert.equal(moment(a).add({m: 25}).calendar(), 'Haut um 12:25 Auer', 'Now plus 25 min');
+ assert.equal(moment(a).add({h: 1}).calendar(), 'Haut um 13:00 Auer', 'Now plus 1 hour');
+ assert.equal(moment(a).add({d: 1}).calendar(), 'Muer um 12:00 Auer', 'tomorrow at the same time');
+ assert.equal(moment(a).subtract({h: 1}).calendar(), 'Haut um 11:00 Auer', 'Now minus 1 hour');
+ assert.equal(moment(a).subtract({d: 1}).calendar(), 'Gëschter um 12:00 Auer', 'yesterday at the same time');
+});
+
+test('calendar next week', function (assert) {
+ var i, m;
+
+ for (i = 2; i < 7; i++) {
+ m = moment().add({d: i});
+ assert.equal(m.calendar(), m.format('dddd [um] LT'), 'Today + ' + i + ' days current time');
+ m.hours(0).minutes(0).seconds(0).milliseconds(0);
+ assert.equal(m.calendar(), m.format('dddd [um] LT'), 'Today + ' + i + ' days beginning of day');
+ m.hours(23).minutes(59).seconds(59).milliseconds(999);
+ assert.equal(m.calendar(), m.format('dddd [um] LT'), 'Today + ' + i + ' days end of day');
+ }
+});
+
test('calendar last week', function (assert) {
var i, m, weekday, datestring;
for (i = 2; i < 7; i++) {
@@ -139,38 +163,24 @@
}
});
-test('lenient ordinal parsing', function (assert) {
- var i, ordinalStr, testMoment;
- for (i = 1; i <= 31; ++i) {
- ordinalStr = moment([2014, 0, i]).format('YYYY MM Do');
- testMoment = moment(ordinalStr, 'YYYY MM Do');
- assert.equal(testMoment.year(), 2014,
- 'lenient ordinal parsing ' + i + ' year check');
- assert.equal(testMoment.month(), 0,
- 'lenient ordinal parsing ' + i + ' month check');
- assert.equal(testMoment.date(), i,
- 'lenient ordinal parsing ' + i + ' date check');
- }
+test('calendar all else', function (assert) {
+ var weeksAgo = moment().subtract({w: 1}),
+ weeksFromNow = moment().add({w: 1});
+
+ assert.equal(weeksAgo.calendar(), weeksAgo.format('L'), '1 week ago');
+ assert.equal(weeksFromNow.calendar(), weeksFromNow.format('L'), 'in 1 week');
+
+ weeksAgo = moment().subtract({w: 2});
+ weeksFromNow = moment().add({w: 2});
+
+ assert.equal(weeksAgo.calendar(), weeksAgo.format('L'), '2 weeks ago');
+ assert.equal(weeksFromNow.calendar(), weeksFromNow.format('L'), 'in 2 weeks');
});
-test('lenient ordinal parsing of number', function (assert) {
- var i, testMoment;
- for (i = 1; i <= 31; ++i) {
- testMoment = moment('2014 01 ' + i, 'YYYY MM Do');
- assert.equal(testMoment.year(), 2014,
- 'lenient ordinal parsing of number ' + i + ' year check');
- assert.equal(testMoment.month(), 0,
- 'lenient ordinal parsing of number ' + i + ' month check');
- assert.equal(testMoment.date(), i,
- 'lenient ordinal parsing of number ' + i + ' date check');
- }
+test('weeks year starting sunday format', function (assert) {
+ assert.equal(moment([2012, 0, 1]).format('w ww wo'), '52 52 52.', 'Jan 1 2012 should be week 52');
+ assert.equal(moment([2012, 0, 7]).format('w ww wo'), '1 01 1.', 'Jan 7 2012 should be week 1');
+ assert.equal(moment([2012, 0, 8]).format('w ww wo'), '1 01 1.', 'Jan 8 2012 should be week 1');
+ assert.equal(moment([2012, 0, 14]).format('w ww wo'), '2 02 2.', 'Jan 14 2012 should be week 2');
+ assert.equal(moment([2012, 0, 15]).format('w ww wo'), '2 02 2.', 'Jan 15 2012 should be week 2');
});
-
-test('strict ordinal parsing', function (assert) {
- var i, ordinalStr, testMoment;
- for (i = 1; i <= 31; ++i) {
- ordinalStr = moment([2014, 0, i]).format('YYYY MM Do');
- testMoment = moment(ordinalStr, 'YYYY MM Do', true);
- assert.ok(testMoment.isValid(), 'strict ordinal parsing ' + i);
- }
-});
diff --git a/src/test/locale/lo.js b/src/test/locale/lo.js
index a9f4167..9e5f57d 100644
--- a/src/test/locale/lo.js
+++ b/src/test/locale/lo.js
@@ -151,14 +151,14 @@
});
test('calendar day', function (assert) {
- var a = moment().hours(2).minutes(0).seconds(0);
-
- assert.equal(moment(a).calendar(), 'ມື້ນີ້ເວລາ 02:00', 'today at the same time');
- assert.equal(moment(a).add({m: 25}).calendar(), 'ມື້ນີ້ເວລາ 02:25', 'Now plus 25 min');
- assert.equal(moment(a).add({h: 1}).calendar(), 'ມື້ນີ້ເວລາ 03:00', 'Now plus 1 hour');
- assert.equal(moment(a).add({d: 1}).calendar(), 'ມື້ອື່ນເວລາ 02:00', 'tomorrow at the same time');
- assert.equal(moment(a).subtract({h: 1}).calendar(), 'ມື້ນີ້ເວລາ 01:00', 'Now minus 1 hour');
- assert.equal(moment(a).subtract({d: 1}).calendar(), 'ມື້ວານນີ້ເວລາ 02:00', 'yesterday at the same time');
+ var a = moment().hours(12).minutes(0).seconds(0);
+
+ assert.equal(moment(a).calendar(), 'ມື້ນີ້ເວລາ 12:00', 'today at the same time');
+ assert.equal(moment(a).add({m: 25}).calendar(), 'ມື້ນີ້ເວລາ 12:25', 'Now plus 25 min');
+ assert.equal(moment(a).add({h: 1}).calendar(), 'ມື້ນີ້ເວລາ 13:00', 'Now plus 1 hour');
+ assert.equal(moment(a).add({d: 1}).calendar(), 'ມື້ອື່ນເວລາ 12:00', 'tomorrow at the same time');
+ assert.equal(moment(a).subtract({h: 1}).calendar(), 'ມື້ນີ້ເວລາ 11:00', 'Now minus 1 hour');
+ assert.equal(moment(a).subtract({d: 1}).calendar(), 'ມື້ວານນີ້ເວລາ 12:00', 'yesterday at the same time');
});
test('calendar next week', function (assert) {
@@ -200,67 +200,6 @@
assert.equal(weeksFromNow.calendar(), weeksFromNow.format('L'), 'in 2 weeks');
});
-test('weeks year starting sunday', function (assert) {
- assert.equal(moment([2012, 0, 1]).week(), 1, 'Jan 1 2012 should be week 1');
- assert.equal(moment([2012, 0, 7]).week(), 1, 'Jan 7 2012 should be week 1');
- assert.equal(moment([2012, 0, 8]).week(), 2, 'Jan 8 2012 should be week 2');
- assert.equal(moment([2012, 0, 14]).week(), 2, 'Jan 14 2012 should be week 2');
- assert.equal(moment([2012, 0, 15]).week(), 3, 'Jan 15 2012 should be week 3');
-});
-
-test('weeks year starting monday', function (assert) {
- assert.equal(moment([2006, 11, 31]).week(), 1, 'Dec 31 2006 should be week 1');
- assert.equal(moment([2007, 0, 1]).week(), 1, 'Jan 1 2007 should be week 1');
- assert.equal(moment([2007, 0, 6]).week(), 1, 'Jan 6 2007 should be week 1');
- assert.equal(moment([2007, 0, 7]).week(), 2, 'Jan 7 2007 should be week 2');
- assert.equal(moment([2007, 0, 13]).week(), 2, 'Jan 13 2007 should be week 2');
- assert.equal(moment([2007, 0, 14]).week(), 3, 'Jan 14 2007 should be week 3');
-});
-
-test('weeks year starting tuesday', function (assert) {
- assert.equal(moment([2007, 11, 29]).week(), 52, 'Dec 29 2007 should be week 52');
- assert.equal(moment([2008, 0, 1]).week(), 1, 'Jan 1 2008 should be week 1');
- assert.equal(moment([2008, 0, 5]).week(), 1, 'Jan 5 2008 should be week 1');
- assert.equal(moment([2008, 0, 6]).week(), 2, 'Jan 6 2008 should be week 2');
- assert.equal(moment([2008, 0, 12]).week(), 2, 'Jan 12 2008 should be week 2');
- assert.equal(moment([2008, 0, 13]).week(), 3, 'Jan 13 2008 should be week 3');
-});
-
-test('weeks year starting wednesday', function (assert) {
- assert.equal(moment([2002, 11, 29]).week(), 1, 'Dec 29 2002 should be week 1');
- assert.equal(moment([2003, 0, 1]).week(), 1, 'Jan 1 2003 should be week 1');
- assert.equal(moment([2003, 0, 4]).week(), 1, 'Jan 4 2003 should be week 1');
- assert.equal(moment([2003, 0, 5]).week(), 2, 'Jan 5 2003 should be week 2');
- assert.equal(moment([2003, 0, 11]).week(), 2, 'Jan 11 2003 should be week 2');
- assert.equal(moment([2003, 0, 12]).week(), 3, 'Jan 12 2003 should be week 3');
-});
-
-test('weeks year starting thursday', function (assert) {
- assert.equal(moment([2008, 11, 28]).week(), 1, 'Dec 28 2008 should be week 1');
- assert.equal(moment([2009, 0, 1]).week(), 1, 'Jan 1 2009 should be week 1');
- assert.equal(moment([2009, 0, 3]).week(), 1, 'Jan 3 2009 should be week 1');
- assert.equal(moment([2009, 0, 4]).week(), 2, 'Jan 4 2009 should be week 2');
- assert.equal(moment([2009, 0, 10]).week(), 2, 'Jan 10 2009 should be week 2');
- assert.equal(moment([2009, 0, 11]).week(), 3, 'Jan 11 2009 should be week 3');
-});
-
-test('weeks year starting friday', function (assert) {
- assert.equal(moment([2009, 11, 27]).week(), 1, 'Dec 27 2009 should be week 1');
- assert.equal(moment([2010, 0, 1]).week(), 1, 'Jan 1 2010 should be week 1');
- assert.equal(moment([2010, 0, 2]).week(), 1, 'Jan 2 2010 should be week 1');
- assert.equal(moment([2010, 0, 3]).week(), 2, 'Jan 3 2010 should be week 2');
- assert.equal(moment([2010, 0, 9]).week(), 2, 'Jan 9 2010 should be week 2');
- assert.equal(moment([2010, 0, 10]).week(), 3, 'Jan 10 2010 should be week 3');
-});
-
-test('weeks year starting saturday', function (assert) {
- assert.equal(moment([2010, 11, 26]).week(), 1, 'Dec 26 2010 should be week 1');
- assert.equal(moment([2011, 0, 1]).week(), 1, 'Jan 1 2011 should be week 1');
- assert.equal(moment([2011, 0, 2]).week(), 2, 'Jan 2 2011 should be week 2');
- assert.equal(moment([2011, 0, 8]).week(), 2, 'Jan 8 2011 should be week 2');
- assert.equal(moment([2011, 0, 9]).week(), 3, 'Jan 9 2011 should be week 3');
-});
-
test('weeks year starting sunday format', function (assert) {
assert.equal(moment([2012, 0, 1]).format('w ww wo'), '1 01 ທີ່1', 'Jan 1 2012 should be week 1');
assert.equal(moment([2012, 0, 7]).format('w ww wo'), '1 01 ທີ່1', 'Jan 7 2012 should be week 1');
@@ -269,38 +208,3 @@
assert.equal(moment([2012, 0, 15]).format('w ww wo'), '3 03 ທີ່3', 'Jan 15 2012 should be week 3');
});
-test('lenient ordinal parsing', function (assert) {
- var i, ordinalStr, testMoment;
- for (i = 1; i <= 31; ++i) {
- ordinalStr = moment([2014, 0, i]).format('YYYY MM Do');
- testMoment = moment(ordinalStr, 'YYYY MM Do');
- assert.equal(testMoment.year(), 2014,
- 'lenient ordinal parsing ' + i + ' year check');
- assert.equal(testMoment.month(), 0,
- 'lenient ordinal parsing ' + i + ' month check');
- assert.equal(testMoment.date(), i,
- 'lenient ordinal parsing ' + i + ' date check');
- }
-});
-
-test('lenient ordinal parsing of number', function (assert) {
- var i, testMoment;
- for (i = 1; i <= 31; ++i) {
- testMoment = moment('2014 01 ' + i, 'YYYY MM Do');
- assert.equal(testMoment.year(), 2014,
- 'lenient ordinal parsing of number ' + i + ' year check');
- assert.equal(testMoment.month(), 0,
- 'lenient ordinal parsing of number ' + i + ' month check');
- assert.equal(testMoment.date(), i,
- 'lenient ordinal parsing of number ' + i + ' date check');
- }
-});
-
-test('strict ordinal parsing', function (assert) {
- var i, ordinalStr, testMoment;
- for (i = 1; i <= 31; ++i) {
- ordinalStr = moment([2014, 0, i]).format('YYYY MM Do');
- testMoment = moment(ordinalStr, 'YYYY MM Do', true);
- assert.ok(testMoment.isValid(), 'strict ordinal parsing ' + i);
- }
-});
diff --git a/src/test/locale/lt.js b/src/test/locale/lt.js
index d17bbc1..45bf2e5 100644
--- a/src/test/locale/lt.js
+++ b/src/test/locale/lt.js
@@ -106,12 +106,12 @@
test('format week on US calendar', function (assert) {
// Tests, whether the weekday names are correct, even if the week does not start on Monday
- moment.locale('lt', {week: {dow: 0, doy: 6}});
+ moment.updateLocale('lt', {week: {dow: 0, doy: 6}});
var expected = 'sekmadienis Sek S_pirmadienis Pir P_antradienis Ant A_trečiadienis Tre T_ketvirtadienis Ket K_penktadienis Pen Pn_šeštadienis Šeš Š'.split('_'), i;
for (i = 0; i < expected.length; i++) {
assert.equal(moment([2011, 0, 2 + i]).format('dddd ddd dd'), expected[i], expected[i]);
}
- moment.locale('lt', {week: {dow: 1, doy: 4}});
+ moment.updateLocale('lt', null);
});
test('from', function (assert) {
@@ -168,14 +168,14 @@
});
test('calendar day', function (assert) {
- var a = moment().hours(2).minutes(0).seconds(0);
-
- assert.equal(moment(a).calendar(), 'Šiandien 02:00', 'today at the same time');
- assert.equal(moment(a).add({m: 25}).calendar(), 'Šiandien 02:25', 'Now plus 25 min');
- assert.equal(moment(a).add({h: 1}).calendar(), 'Šiandien 03:00', 'Now plus 1 hour');
- assert.equal(moment(a).add({d: 1}).calendar(), 'Rytoj 02:00', 'tomorrow at the same time');
- assert.equal(moment(a).subtract({h: 1}).calendar(), 'Šiandien 01:00', 'Now minus 1 hour');
- assert.equal(moment(a).subtract({d: 1}).calendar(), 'Vakar 02:00', 'yesterday at the same time');
+ var a = moment().hours(12).minutes(0).seconds(0);
+
+ assert.equal(moment(a).calendar(), 'Šiandien 12:00', 'today at the same time');
+ assert.equal(moment(a).add({m: 25}).calendar(), 'Šiandien 12:25', 'Now plus 25 min');
+ assert.equal(moment(a).add({h: 1}).calendar(), 'Šiandien 13:00', 'Now plus 1 hour');
+ assert.equal(moment(a).add({d: 1}).calendar(), 'Rytoj 12:00', 'tomorrow at the same time');
+ assert.equal(moment(a).subtract({h: 1}).calendar(), 'Šiandien 11:00', 'Now minus 1 hour');
+ assert.equal(moment(a).subtract({d: 1}).calendar(), 'Vakar 12:00', 'yesterday at the same time');
});
test('calendar next week', function (assert) {
@@ -216,67 +216,6 @@
assert.equal(weeksFromNow.calendar(), weeksFromNow.format('L'), 'in 2 weeks');
});
-test('weeks year starting sunday', function (assert) {
- assert.equal(moment([2012, 0, 1]).week(), 52, 'Jan 1 2012 should be week 52');
- assert.equal(moment([2012, 0, 2]).week(), 1, 'Jan 2 2012 should be week 1');
- assert.equal(moment([2012, 0, 8]).week(), 1, 'Jan 8 2012 should be week 1');
- assert.equal(moment([2012, 0, 9]).week(), 2, 'Jan 9 2012 should be week 2');
- assert.equal(moment([2012, 0, 15]).week(), 2, 'Jan 15 2012 should be week 2');
-});
-
-test('weeks year starting monday', function (assert) {
- assert.equal(moment([2007, 0, 1]).week(), 1, 'Jan 1 2007 should be week 1');
- assert.equal(moment([2007, 0, 7]).week(), 1, 'Jan 7 2007 should be week 1');
- assert.equal(moment([2007, 0, 8]).week(), 2, 'Jan 8 2007 should be week 2');
- assert.equal(moment([2007, 0, 14]).week(), 2, 'Jan 14 2007 should be week 2');
- assert.equal(moment([2007, 0, 15]).week(), 3, 'Jan 15 2007 should be week 3');
-});
-
-test('weeks year starting tuesday', function (assert) {
- assert.equal(moment([2007, 11, 31]).week(), 1, 'Dec 31 2007 should be week 1');
- assert.equal(moment([2008, 0, 1]).week(), 1, 'Jan 1 2008 should be week 1');
- assert.equal(moment([2008, 0, 6]).week(), 1, 'Jan 6 2008 should be week 1');
- assert.equal(moment([2008, 0, 7]).week(), 2, 'Jan 7 2008 should be week 2');
- assert.equal(moment([2008, 0, 13]).week(), 2, 'Jan 13 2008 should be week 2');
- assert.equal(moment([2008, 0, 14]).week(), 3, 'Jan 14 2008 should be week 3');
-});
-
-test('weeks year starting wednesday', function (assert) {
- assert.equal(moment([2002, 11, 30]).week(), 1, 'Dec 30 2002 should be week 1');
- assert.equal(moment([2003, 0, 1]).week(), 1, 'Jan 1 2003 should be week 1');
- assert.equal(moment([2003, 0, 5]).week(), 1, 'Jan 5 2003 should be week 1');
- assert.equal(moment([2003, 0, 6]).week(), 2, 'Jan 6 2003 should be week 2');
- assert.equal(moment([2003, 0, 12]).week(), 2, 'Jan 12 2003 should be week 2');
- assert.equal(moment([2003, 0, 13]).week(), 3, 'Jan 13 2003 should be week 3');
-});
-
-test('weeks year starting thursday', function (assert) {
- assert.equal(moment([2008, 11, 29]).week(), 1, 'Dec 29 2008 should be week 1');
- assert.equal(moment([2009, 0, 1]).week(), 1, 'Jan 1 2009 should be week 1');
- assert.equal(moment([2009, 0, 4]).week(), 1, 'Jan 4 2009 should be week 1');
- assert.equal(moment([2009, 0, 5]).week(), 2, 'Jan 5 2009 should be week 2');
- assert.equal(moment([2009, 0, 11]).week(), 2, 'Jan 11 2009 should be week 2');
- assert.equal(moment([2009, 0, 13]).week(), 3, 'Jan 12 2009 should be week 3');
-});
-
-test('weeks year starting friday', function (assert) {
- assert.equal(moment([2009, 11, 28]).week(), 53, 'Dec 28 2009 should be week 53');
- assert.equal(moment([2010, 0, 1]).week(), 53, 'Jan 1 2010 should be week 53');
- assert.equal(moment([2010, 0, 3]).week(), 53, 'Jan 3 2010 should be week 53');
- assert.equal(moment([2010, 0, 4]).week(), 1, 'Jan 4 2010 should be week 1');
- assert.equal(moment([2010, 0, 10]).week(), 1, 'Jan 10 2010 should be week 1');
- assert.equal(moment([2010, 0, 11]).week(), 2, 'Jan 11 2010 should be week 2');
-});
-
-test('weeks year starting saturday', function (assert) {
- assert.equal(moment([2010, 11, 27]).week(), 52, 'Dec 27 2010 should be week 52');
- assert.equal(moment([2011, 0, 1]).week(), 52, 'Jan 1 2011 should be week 52');
- assert.equal(moment([2011, 0, 2]).week(), 52, 'Jan 2 2011 should be week 52');
- assert.equal(moment([2011, 0, 3]).week(), 1, 'Jan 3 2011 should be week 1');
- assert.equal(moment([2011, 0, 9]).week(), 1, 'Jan 9 2011 should be week 1');
- assert.equal(moment([2011, 0, 10]).week(), 2, 'Jan 10 2011 should be week 2');
-});
-
test('weeks year starting sunday formatted', function (assert) {
assert.equal(moment([2012, 0, 1]).format('w ww wo'), '52 52 52-oji', 'Jan 1 2012 should be week 52');
assert.equal(moment([2012, 0, 2]).format('w ww wo'), '1 01 1-oji', 'Jan 2 2012 should be week 1');
@@ -285,38 +224,3 @@
assert.equal(moment([2012, 0, 15]).format('w ww wo'), '2 02 2-oji', 'Jan 15 2012 should be week 2');
});
-test('lenient ordinal parsing', function (assert) {
- var i, ordinalStr, testMoment;
- for (i = 1; i <= 31; ++i) {
- ordinalStr = moment([2014, 0, i]).format('YYYY MM Do');
- testMoment = moment(ordinalStr, 'YYYY MM Do');
- assert.equal(testMoment.year(), 2014,
- 'lenient ordinal parsing ' + i + ' year check');
- assert.equal(testMoment.month(), 0,
- 'lenient ordinal parsing ' + i + ' month check');
- assert.equal(testMoment.date(), i,
- 'lenient ordinal parsing ' + i + ' date check');
- }
-});
-
-test('lenient ordinal parsing of number', function (assert) {
- var i, testMoment;
- for (i = 1; i <= 31; ++i) {
- testMoment = moment('2014 01 ' + i, 'YYYY MM Do');
- assert.equal(testMoment.year(), 2014,
- 'lenient ordinal parsing of number ' + i + ' year check');
- assert.equal(testMoment.month(), 0,
- 'lenient ordinal parsing of number ' + i + ' month check');
- assert.equal(testMoment.date(), i,
- 'lenient ordinal parsing of number ' + i + ' date check');
- }
-});
-
-test('strict ordinal parsing', function (assert) {
- var i, ordinalStr, testMoment;
- for (i = 1; i <= 31; ++i) {
- ordinalStr = moment([2014, 0, i]).format('YYYY MM Do');
- testMoment = moment(ordinalStr, 'YYYY MM Do', true);
- assert.ok(testMoment.isValid(), 'strict ordinal parsing ' + i);
- }
-});
diff --git a/src/test/locale/lv.js b/src/test/locale/lv.js
index f9ec127..a3ecabd 100644
--- a/src/test/locale/lv.js
+++ b/src/test/locale/lv.js
@@ -172,14 +172,14 @@
});
test('calendar day', function (assert) {
- var a = moment().hours(2).minutes(0).seconds(0);
-
- assert.equal(moment(a).calendar(), 'Šodien pulksten 02:00', 'today at the same time');
- assert.equal(moment(a).add({m: 25}).calendar(), 'Šodien pulksten 02:25', 'Now plus 25 min');
- assert.equal(moment(a).add({h: 1}).calendar(), 'Šodien pulksten 03:00', 'Now plus 1 hour');
- assert.equal(moment(a).add({d: 1}).calendar(), 'Rīt pulksten 02:00', 'tomorrow at the same time');
- assert.equal(moment(a).subtract({h: 1}).calendar(), 'Šodien pulksten 01:00', 'Now minus 1 hour');
- assert.equal(moment(a).subtract({d: 1}).calendar(), 'Vakar pulksten 02:00', 'yesterday at the same time');
+ var a = moment().hours(12).minutes(0).seconds(0);
+
+ assert.equal(moment(a).calendar(), 'Šodien pulksten 12:00', 'today at the same time');
+ assert.equal(moment(a).add({m: 25}).calendar(), 'Šodien pulksten 12:25', 'Now plus 25 min');
+ assert.equal(moment(a).add({h: 1}).calendar(), 'Šodien pulksten 13:00', 'Now plus 1 hour');
+ assert.equal(moment(a).add({d: 1}).calendar(), 'Rīt pulksten 12:00', 'tomorrow at the same time');
+ assert.equal(moment(a).subtract({h: 1}).calendar(), 'Šodien pulksten 11:00', 'Now minus 1 hour');
+ assert.equal(moment(a).subtract({d: 1}).calendar(), 'Vakar pulksten 12:00', 'yesterday at the same time');
});
test('calendar next week', function (assert) {
@@ -220,67 +220,6 @@
assert.equal(weeksFromNow.calendar(), weeksFromNow.format('L'), 'in 2 weeks');
});
-test('weeks year starting sunday', function (assert) {
- assert.equal(moment([2012, 0, 1]).week(), 52, 'Jan 1 2012 should be week 52');
- assert.equal(moment([2012, 0, 2]).week(), 1, 'Jan 2 2012 should be week 1');
- assert.equal(moment([2012, 0, 8]).week(), 1, 'Jan 8 2012 should be week 1');
- assert.equal(moment([2012, 0, 9]).week(), 2, 'Jan 9 2012 should be week 2');
- assert.equal(moment([2012, 0, 15]).week(), 2, 'Jan 15 2012 should be week 2');
-});
-
-test('weeks year starting monday', function (assert) {
- assert.equal(moment([2007, 0, 1]).week(), 1, 'Jan 1 2007 should be week 1');
- assert.equal(moment([2007, 0, 7]).week(), 1, 'Jan 7 2007 should be week 1');
- assert.equal(moment([2007, 0, 8]).week(), 2, 'Jan 8 2007 should be week 2');
- assert.equal(moment([2007, 0, 14]).week(), 2, 'Jan 14 2007 should be week 2');
- assert.equal(moment([2007, 0, 15]).week(), 3, 'Jan 15 2007 should be week 3');
-});
-
-test('weeks year starting tuesday', function (assert) {
- assert.equal(moment([2007, 11, 31]).week(), 1, 'Dec 31 2007 should be week 1');
- assert.equal(moment([2008, 0, 1]).week(), 1, 'Jan 1 2008 should be week 1');
- assert.equal(moment([2008, 0, 6]).week(), 1, 'Jan 6 2008 should be week 1');
- assert.equal(moment([2008, 0, 7]).week(), 2, 'Jan 7 2008 should be week 2');
- assert.equal(moment([2008, 0, 13]).week(), 2, 'Jan 13 2008 should be week 2');
- assert.equal(moment([2008, 0, 14]).week(), 3, 'Jan 14 2008 should be week 3');
-});
-
-test('weeks year starting wednesday', function (assert) {
- assert.equal(moment([2002, 11, 30]).week(), 1, 'Dec 30 2002 should be week 1');
- assert.equal(moment([2003, 0, 1]).week(), 1, 'Jan 1 2003 should be week 1');
- assert.equal(moment([2003, 0, 5]).week(), 1, 'Jan 5 2003 should be week 1');
- assert.equal(moment([2003, 0, 6]).week(), 2, 'Jan 6 2003 should be week 2');
- assert.equal(moment([2003, 0, 12]).week(), 2, 'Jan 12 2003 should be week 2');
- assert.equal(moment([2003, 0, 13]).week(), 3, 'Jan 13 2003 should be week 3');
-});
-
-test('weeks year starting thursday', function (assert) {
- assert.equal(moment([2008, 11, 29]).week(), 1, 'Dec 29 2008 should be week 1');
- assert.equal(moment([2009, 0, 1]).week(), 1, 'Jan 1 2009 should be week 1');
- assert.equal(moment([2009, 0, 4]).week(), 1, 'Jan 4 2009 should be week 1');
- assert.equal(moment([2009, 0, 5]).week(), 2, 'Jan 5 2009 should be week 2');
- assert.equal(moment([2009, 0, 11]).week(), 2, 'Jan 11 2009 should be week 2');
- assert.equal(moment([2009, 0, 13]).week(), 3, 'Jan 12 2009 should be week 3');
-});
-
-test('weeks year starting friday', function (assert) {
- assert.equal(moment([2009, 11, 28]).week(), 53, 'Dec 28 2009 should be week 53');
- assert.equal(moment([2010, 0, 1]).week(), 53, 'Jan 1 2010 should be week 53');
- assert.equal(moment([2010, 0, 3]).week(), 53, 'Jan 3 2010 should be week 53');
- assert.equal(moment([2010, 0, 4]).week(), 1, 'Jan 4 2010 should be week 1');
- assert.equal(moment([2010, 0, 10]).week(), 1, 'Jan 10 2010 should be week 1');
- assert.equal(moment([2010, 0, 11]).week(), 2, 'Jan 11 2010 should be week 2');
-});
-
-test('weeks year starting saturday', function (assert) {
- assert.equal(moment([2010, 11, 27]).week(), 52, 'Dec 27 2010 should be week 52');
- assert.equal(moment([2011, 0, 1]).week(), 52, 'Jan 1 2011 should be week 52');
- assert.equal(moment([2011, 0, 2]).week(), 52, 'Jan 2 2011 should be week 52');
- assert.equal(moment([2011, 0, 3]).week(), 1, 'Jan 3 2011 should be week 1');
- assert.equal(moment([2011, 0, 9]).week(), 1, 'Jan 9 2011 should be week 1');
- assert.equal(moment([2011, 0, 10]).week(), 2, 'Jan 10 2011 should be week 2');
-});
-
test('weeks year starting sunday formatted', function (assert) {
assert.equal(moment([2012, 0, 1]).format('w ww wo'), '52 52 52.', 'Jan 1 2012 should be week 52');
assert.equal(moment([2012, 0, 2]).format('w ww wo'), '1 01 1.', 'Jan 2 2012 should be week 1');
@@ -289,38 +228,3 @@
assert.equal(moment([2012, 0, 15]).format('w ww wo'), '2 02 2.', 'Jan 15 2012 should be week 2');
});
-test('lenient ordinal parsing', function (assert) {
- var i, ordinalStr, testMoment;
- for (i = 1; i <= 31; ++i) {
- ordinalStr = moment([2014, 0, i]).format('YYYY MM Do');
- testMoment = moment(ordinalStr, 'YYYY MM Do');
- assert.equal(testMoment.year(), 2014,
- 'lenient ordinal parsing ' + i + ' year check');
- assert.equal(testMoment.month(), 0,
- 'lenient ordinal parsing ' + i + ' month check');
- assert.equal(testMoment.date(), i,
- 'lenient ordinal parsing ' + i + ' date check');
- }
-});
-
-test('lenient ordinal parsing of number', function (assert) {
- var i, testMoment;
- for (i = 1; i <= 31; ++i) {
- testMoment = moment('2014 01 ' + i, 'YYYY MM Do');
- assert.equal(testMoment.year(), 2014,
- 'lenient ordinal parsing of number ' + i + ' year check');
- assert.equal(testMoment.month(), 0,
- 'lenient ordinal parsing of number ' + i + ' month check');
- assert.equal(testMoment.date(), i,
- 'lenient ordinal parsing of number ' + i + ' date check');
- }
-});
-
-test('strict ordinal parsing', function (assert) {
- var i, ordinalStr, testMoment;
- for (i = 1; i <= 31; ++i) {
- ordinalStr = moment([2014, 0, i]).format('YYYY MM Do');
- testMoment = moment(ordinalStr, 'YYYY MM Do', true);
- assert.ok(testMoment.isValid(), 'strict ordinal parsing ' + i);
- }
-});
diff --git a/src/test/locale/me.js b/src/test/locale/me.js
index b046b16..813d68d 100644
--- a/src/test/locale/me.js
+++ b/src/test/locale/me.js
@@ -154,14 +154,14 @@
});
test('calendar day', function (assert) {
- var a = moment().hours(2).minutes(0).seconds(0);
-
- assert.equal(moment(a).calendar(), 'danas u 2:00', 'today at the same time');
- assert.equal(moment(a).add({m: 25}).calendar(), 'danas u 2:25', 'Now plus 25 min');
- assert.equal(moment(a).add({h: 1}).calendar(), 'danas u 3:00', 'Now plus 1 hour');
- assert.equal(moment(a).add({d: 1}).calendar(), 'sjutra u 2:00', 'tomorrow at the same time');
- assert.equal(moment(a).subtract({h: 1}).calendar(), 'danas u 1:00', 'Now minus 1 hour');
- assert.equal(moment(a).subtract({d: 1}).calendar(), 'juče u 2:00', 'yesterday at the same time');
+ var a = moment().hours(12).minutes(0).seconds(0);
+
+ assert.equal(moment(a).calendar(), 'danas u 12:00', 'today at the same time');
+ assert.equal(moment(a).add({m: 25}).calendar(), 'danas u 12:25', 'Now plus 25 min');
+ assert.equal(moment(a).add({h: 1}).calendar(), 'danas u 13:00', 'Now plus 1 hour');
+ assert.equal(moment(a).add({d: 1}).calendar(), 'sjutra u 12:00', 'tomorrow at the same time');
+ assert.equal(moment(a).subtract({h: 1}).calendar(), 'danas u 11:00', 'Now minus 1 hour');
+ assert.equal(moment(a).subtract({d: 1}).calendar(), 'juče u 12:00', 'yesterday at the same time');
});
test('calendar next week', function (assert) {
@@ -237,67 +237,6 @@
// Monday is the first day of the week.
// The week that contains Jan 1st is the first week of the year.
-test('weeks year starting sunday', function (assert) {
- assert.equal(moment([2011, 11, 26]).week(), 1, 'Dec 26 2011 should be week 1');
- assert.equal(moment([2012, 0, 1]).week(), 1, 'Jan 1 2012 should be week 1');
- assert.equal(moment([2012, 0, 2]).week(), 2, 'Jan 2 2012 should be week 2');
- assert.equal(moment([2012, 0, 8]).week(), 2, 'Jan 8 2012 should be week 2');
- assert.equal(moment([2012, 0, 9]).week(), 3, 'Jan 9 2012 should be week 3');
-});
-
-test('weeks year starting monday', function (assert) {
- assert.equal(moment([2007, 0, 1]).week(), 1, 'Jan 1 2007 should be week 1');
- assert.equal(moment([2007, 0, 7]).week(), 1, 'Jan 7 2007 should be week 1');
- assert.equal(moment([2007, 0, 8]).week(), 2, 'Jan 8 2007 should be week 2');
- assert.equal(moment([2007, 0, 14]).week(), 2, 'Jan 14 2007 should be week 2');
- assert.equal(moment([2007, 0, 15]).week(), 3, 'Jan 15 2007 should be week 3');
-});
-
-test('weeks year starting tuesday', function (assert) {
- assert.equal(moment([2007, 11, 31]).week(), 1, 'Dec 31 2007 should be week 1');
- assert.equal(moment([2008, 0, 1]).week(), 1, 'Jan 1 2008 should be week 1');
- assert.equal(moment([2008, 0, 6]).week(), 1, 'Jan 6 2008 should be week 1');
- assert.equal(moment([2008, 0, 7]).week(), 2, 'Jan 7 2008 should be week 2');
- assert.equal(moment([2008, 0, 13]).week(), 2, 'Jan 13 2008 should be week 2');
- assert.equal(moment([2008, 0, 14]).week(), 3, 'Jan 14 2008 should be week 3');
-});
-
-test('weeks year starting wednesday', function (assert) {
- assert.equal(moment([2002, 11, 30]).week(), 1, 'Dec 30 2002 should be week 1');
- assert.equal(moment([2003, 0, 1]).week(), 1, 'Jan 1 2003 should be week 1');
- assert.equal(moment([2003, 0, 5]).week(), 1, 'Jan 5 2003 should be week 1');
- assert.equal(moment([2003, 0, 6]).week(), 2, 'Jan 6 2003 should be week 2');
- assert.equal(moment([2003, 0, 12]).week(), 2, 'Jan 12 2003 should be week 2');
- assert.equal(moment([2003, 0, 13]).week(), 3, 'Jan 13 2003 should be week 3');
-});
-
-test('weeks year starting thursday', function (assert) {
- assert.equal(moment([2008, 11, 29]).week(), 1, 'Dec 29 2008 should be week 1');
- assert.equal(moment([2009, 0, 1]).week(), 1, 'Jan 1 2009 should be week 1');
- assert.equal(moment([2009, 0, 4]).week(), 1, 'Jan 4 2009 should be week 1');
- assert.equal(moment([2009, 0, 5]).week(), 2, 'Jan 5 2009 should be week 2');
- assert.equal(moment([2009, 0, 11]).week(), 2, 'Jan 11 2009 should be week 2');
- assert.equal(moment([2009, 0, 12]).week(), 3, 'Jan 12 2009 should be week 3');
-});
-
-test('weeks year starting friday', function (assert) {
- assert.equal(moment([2009, 11, 28]).week(), 1, 'Dec 28 2009 should be week 1');
- assert.equal(moment([2010, 0, 1]).week(), 1, 'Jan 1 2010 should be week 1');
- assert.equal(moment([2010, 0, 3]).week(), 1, 'Jan 3 2010 should be week 1');
- assert.equal(moment([2010, 0, 4]).week(), 2, 'Jan 4 2010 should be week 2');
- assert.equal(moment([2010, 0, 10]).week(), 2, 'Jan 10 2010 should be week 2');
- assert.equal(moment([2010, 0, 11]).week(), 3, 'Jan 11 2010 should be week 3');
-});
-
-test('weeks year starting saturday', function (assert) {
- assert.equal(moment([2010, 11, 27]).week(), 1, 'Dec 27 2010 should be week 1');
- assert.equal(moment([2011, 0, 1]).week(), 1, 'Jan 1 2011 should be week 1');
- assert.equal(moment([2011, 0, 2]).week(), 1, 'Jan 2 2011 should be week 1');
- assert.equal(moment([2011, 0, 3]).week(), 2, 'Jan 3 2011 should be week 2');
- assert.equal(moment([2011, 0, 9]).week(), 2, 'Jan 9 2011 should be week 2');
- assert.equal(moment([2011, 0, 10]).week(), 3, 'Jan 10 2011 should be week 3');
-});
-
test('weeks year starting sunday formatted', function (assert) {
assert.equal(moment([2011, 11, 26]).format('w ww wo'), '1 01 1.', 'Dec 26 2011 should be week 1');
assert.equal(moment([2012, 0, 1]).format('w ww wo'), '1 01 1.', 'Jan 1 2012 should be week 1');
@@ -306,38 +245,3 @@
assert.equal(moment([2012, 0, 9]).format('w ww wo'), '3 03 3.', 'Jan 9 2012 should be week 3');
});
-test('lenient ordinal parsing', function (assert) {
- var i, ordinalStr, testMoment;
- for (i = 1; i <= 31; ++i) {
- ordinalStr = moment([2014, 0, i]).format('YYYY MM Do');
- testMoment = moment(ordinalStr, 'YYYY MM Do');
- assert.equal(testMoment.year(), 2014,
- 'lenient ordinal parsing ' + i + ' year check');
- assert.equal(testMoment.month(), 0,
- 'lenient ordinal parsing ' + i + ' month check');
- assert.equal(testMoment.date(), i,
- 'lenient ordinal parsing ' + i + ' date check');
- }
-});
-
-test('lenient ordinal parsing of number', function (assert) {
- var i, testMoment;
- for (i = 1; i <= 31; ++i) {
- testMoment = moment('2014 01 ' + i, 'YYYY MM Do');
- assert.equal(testMoment.year(), 2014,
- 'lenient ordinal parsing of number ' + i + ' year check');
- assert.equal(testMoment.month(), 0,
- 'lenient ordinal parsing of number ' + i + ' month check');
- assert.equal(testMoment.date(), i,
- 'lenient ordinal parsing of number ' + i + ' date check');
- }
-});
-
-test('strict ordinal parsing', function (assert) {
- var i, ordinalStr, testMoment;
- for (i = 1; i <= 31; ++i) {
- ordinalStr = moment([2014, 0, i]).format('YYYY MM Do');
- testMoment = moment(ordinalStr, 'YYYY MM Do', true);
- assert.ok(testMoment.isValid(), 'strict ordinal parsing ' + i);
- }
-});
diff --git a/src/test/locale/mk.js b/src/test/locale/mk.js
index 145f8d4..93357bf 100644
--- a/src/test/locale/mk.js
+++ b/src/test/locale/mk.js
@@ -151,14 +151,14 @@
});
test('calendar day', function (assert) {
- var a = moment().hours(2).minutes(0).seconds(0);
-
- assert.equal(moment(a).calendar(), 'Денес во 2:00', 'today at the same time');
- assert.equal(moment(a).add({m: 25}).calendar(), 'Денес во 2:25', 'Now plus 25 min');
- assert.equal(moment(a).add({h: 1}).calendar(), 'Денес во 3:00', 'Now plus 1 hour');
- assert.equal(moment(a).add({d: 1}).calendar(), 'Утре во 2:00', 'tomorrow at the same time');
- assert.equal(moment(a).subtract({h: 1}).calendar(), 'Денес во 1:00', 'Now minus 1 hour');
- assert.equal(moment(a).subtract({d: 1}).calendar(), 'Вчера во 2:00', 'yesterday at the same time');
+ var a = moment().hours(12).minutes(0).seconds(0);
+
+ assert.equal(moment(a).calendar(), 'Денес во 12:00', 'today at the same time');
+ assert.equal(moment(a).add({m: 25}).calendar(), 'Денес во 12:25', 'Now plus 25 min');
+ assert.equal(moment(a).add({h: 1}).calendar(), 'Денес во 13:00', 'Now plus 1 hour');
+ assert.equal(moment(a).add({d: 1}).calendar(), 'Утре во 12:00', 'tomorrow at the same time');
+ assert.equal(moment(a).subtract({h: 1}).calendar(), 'Денес во 11:00', 'Now minus 1 hour');
+ assert.equal(moment(a).subtract({d: 1}).calendar(), 'Вчера во 12:00', 'yesterday at the same time');
});
test('calendar next week', function (assert) {
@@ -214,67 +214,6 @@
assert.equal(weeksFromNow.calendar(), weeksFromNow.format('L'), 'in 2 weeks');
});
-test('weeks year starting sunday', function (assert) {
- assert.equal(moment([2011, 11, 26]).week(), 1, 'Dec 26 2011 should be week 1');
- assert.equal(moment([2012, 0, 1]).week(), 1, 'Jan 1 2012 should be week 1');
- assert.equal(moment([2012, 0, 2]).week(), 2, 'Jan 2 2012 should be week 2');
- assert.equal(moment([2012, 0, 8]).week(), 2, 'Jan 8 2012 should be week 2');
- assert.equal(moment([2012, 0, 9]).week(), 3, 'Jan 9 2012 should be week 3');
-});
-
-test('weeks year starting monday', function (assert) {
- assert.equal(moment([2007, 0, 1]).week(), 1, 'Jan 1 2007 should be week 1');
- assert.equal(moment([2007, 0, 7]).week(), 1, 'Jan 7 2007 should be week 1');
- assert.equal(moment([2007, 0, 8]).week(), 2, 'Jan 8 2007 should be week 2');
- assert.equal(moment([2007, 0, 14]).week(), 2, 'Jan 14 2007 should be week 2');
- assert.equal(moment([2007, 0, 15]).week(), 3, 'Jan 15 2007 should be week 3');
-});
-
-test('weeks year starting tuesday', function (assert) {
- assert.equal(moment([2007, 11, 31]).week(), 1, 'Dec 31 2007 should be week 1');
- assert.equal(moment([2008, 0, 1]).week(), 1, 'Jan 1 2008 should be week 1');
- assert.equal(moment([2008, 0, 6]).week(), 1, 'Jan 6 2008 should be week 1');
- assert.equal(moment([2008, 0, 7]).week(), 2, 'Jan 7 2008 should be week 2');
- assert.equal(moment([2008, 0, 13]).week(), 2, 'Jan 13 2008 should be week 2');
- assert.equal(moment([2008, 0, 14]).week(), 3, 'Jan 14 2008 should be week 3');
-});
-
-test('weeks year starting wednesday', function (assert) {
- assert.equal(moment([2002, 11, 30]).week(), 1, 'Dec 30 2002 should be week 1');
- assert.equal(moment([2003, 0, 1]).week(), 1, 'Jan 1 2003 should be week 1');
- assert.equal(moment([2003, 0, 5]).week(), 1, 'Jan 5 2003 should be week 1');
- assert.equal(moment([2003, 0, 6]).week(), 2, 'Jan 6 2003 should be week 2');
- assert.equal(moment([2003, 0, 12]).week(), 2, 'Jan 12 2003 should be week 2');
- assert.equal(moment([2003, 0, 13]).week(), 3, 'Jan 13 2003 should be week 3');
-});
-
-test('weeks year starting thursday', function (assert) {
- assert.equal(moment([2008, 11, 29]).week(), 1, 'Dec 29 2008 should be week 1');
- assert.equal(moment([2009, 0, 1]).week(), 1, 'Jan 1 2009 should be week 1');
- assert.equal(moment([2009, 0, 4]).week(), 1, 'Jan 4 2009 should be week 1');
- assert.equal(moment([2009, 0, 5]).week(), 2, 'Jan 5 2009 should be week 2');
- assert.equal(moment([2009, 0, 11]).week(), 2, 'Jan 11 2009 should be week 2');
- assert.equal(moment([2009, 0, 12]).week(), 3, 'Jan 12 2009 should be week 3');
-});
-
-test('weeks year starting friday', function (assert) {
- assert.equal(moment([2009, 11, 28]).week(), 1, 'Dec 28 2009 should be week 1');
- assert.equal(moment([2010, 0, 1]).week(), 1, 'Jan 1 2010 should be week 1');
- assert.equal(moment([2010, 0, 3]).week(), 1, 'Jan 3 2010 should be week 1');
- assert.equal(moment([2010, 0, 4]).week(), 2, 'Jan 4 2010 should be week 2');
- assert.equal(moment([2010, 0, 10]).week(), 2, 'Jan 10 2010 should be week 2');
- assert.equal(moment([2010, 0, 11]).week(), 3, 'Jan 11 2010 should be week 3');
-});
-
-test('weeks year starting saturday', function (assert) {
- assert.equal(moment([2010, 11, 27]).week(), 1, 'Dec 27 2010 should be week 1');
- assert.equal(moment([2011, 0, 1]).week(), 1, 'Jan 1 2011 should be week 1');
- assert.equal(moment([2011, 0, 2]).week(), 1, 'Jan 2 2011 should be week 1');
- assert.equal(moment([2011, 0, 3]).week(), 2, 'Jan 3 2011 should be week 2');
- assert.equal(moment([2011, 0, 9]).week(), 2, 'Jan 9 2011 should be week 2');
- assert.equal(moment([2011, 0, 10]).week(), 3, 'Jan 10 2011 should be week 3');
-});
-
test('weeks year starting sunday formatted', function (assert) {
assert.equal(moment([2011, 11, 26]).format('w ww wo'), '1 01 1-ви', 'Dec 26 2011 should be week 1');
assert.equal(moment([2012, 0, 1]).format('w ww wo'), '1 01 1-ви', 'Jan 1 2012 should be week 1');
@@ -283,38 +222,3 @@
assert.equal(moment([2012, 0, 9]).format('w ww wo'), '3 03 3-ти', 'Jan 9 2012 should be week 3');
});
-test('lenient ordinal parsing', function (assert) {
- var i, ordinalStr, testMoment;
- for (i = 1; i <= 31; ++i) {
- ordinalStr = moment([2014, 0, i]).format('YYYY MM Do');
- testMoment = moment(ordinalStr, 'YYYY MM Do');
- assert.equal(testMoment.year(), 2014,
- 'lenient ordinal parsing ' + i + ' year check');
- assert.equal(testMoment.month(), 0,
- 'lenient ordinal parsing ' + i + ' month check');
- assert.equal(testMoment.date(), i,
- 'lenient ordinal parsing ' + i + ' date check');
- }
-});
-
-test('lenient ordinal parsing of number', function (assert) {
- var i, testMoment;
- for (i = 1; i <= 31; ++i) {
- testMoment = moment('2014 01 ' + i, 'YYYY MM Do');
- assert.equal(testMoment.year(), 2014,
- 'lenient ordinal parsing of number ' + i + ' year check');
- assert.equal(testMoment.month(), 0,
- 'lenient ordinal parsing of number ' + i + ' month check');
- assert.equal(testMoment.date(), i,
- 'lenient ordinal parsing of number ' + i + ' date check');
- }
-});
-
-test('strict ordinal parsing', function (assert) {
- var i, ordinalStr, testMoment;
- for (i = 1; i <= 31; ++i) {
- ordinalStr = moment([2014, 0, i]).format('YYYY MM Do');
- testMoment = moment(ordinalStr, 'YYYY MM Do', true);
- assert.ok(testMoment.isValid(), 'strict ordinal parsing ' + i);
- }
-});
diff --git a/src/test/locale/ml.js b/src/test/locale/ml.js
index 8dd74f0..b1588fb 100644
--- a/src/test/locale/ml.js
+++ b/src/test/locale/ml.js
@@ -150,14 +150,14 @@
});
test('calendar day', function (assert) {
- var a = moment().hours(2).minutes(0).seconds(0);
-
- assert.equal(moment(a).calendar(), 'ഇന്ന് രാത്രി 2:00 -നു', 'today at the same time');
- assert.equal(moment(a).add({m: 25}).calendar(), 'ഇന്ന് രാത്രി 2:25 -നു', 'Now plus 25 min');
- assert.equal(moment(a).add({h: 3}).calendar(), 'ഇന്ന് രാവിലെ 5:00 -നു', 'Now plus 3 hour');
- assert.equal(moment(a).add({d: 1}).calendar(), 'നാളെ രാത്രി 2:00 -നു', 'tomorrow at the same time');
- assert.equal(moment(a).subtract({h: 1}).calendar(), 'ഇന്ന് രാത്രി 1:00 -നു', 'Now minus 1 hour');
- assert.equal(moment(a).subtract({d: 1}).calendar(), 'ഇന്നലെ രാത്രി 2:00 -നു', 'yesterday at the same time');
+ var a = moment().hours(12).minutes(0).seconds(0);
+
+ assert.equal(moment(a).calendar(), 'ഇന്ന് ഉച്ച കഴിഞ്ഞ് 12:00 -നു', 'today at the same time');
+ assert.equal(moment(a).add({m: 25}).calendar(), 'ഇന്ന് ഉച്ച കഴിഞ്ഞ് 12:25 -നു', 'Now plus 25 min');
+ assert.equal(moment(a).add({h: 3}).calendar(), 'ഇന്ന് ഉച്ച കഴിഞ്ഞ് 3:00 -നു', 'Now plus 3 hours');
+ assert.equal(moment(a).add({d: 1}).calendar(), 'നാളെ ഉച്ച കഴിഞ്ഞ് 12:00 -നു', 'tomorrow at the same time');
+ assert.equal(moment(a).subtract({h: 1}).calendar(), 'ഇന്ന് രാവിലെ 11:00 -നു', 'Now minus 1 hour');
+ assert.equal(moment(a).subtract({d: 1}).calendar(), 'ഇന്നലെ ഉച്ച കഴിഞ്ഞ് 12:00 -നു', 'yesterday at the same time');
});
test('calendar next week', function (assert) {
@@ -215,67 +215,6 @@
assert.equal(moment([2011, 2, 23, 21, 20]).format('A'), 'രാത്രി', 'night');
});
-test('weeks year starting sunday', function (assert) {
- assert.equal(moment([2012, 0, 1]).week(), 1, 'Jan 1 2012 should be week 1');
- assert.equal(moment([2012, 0, 7]).week(), 1, 'Jan 7 2012 should be week 1');
- assert.equal(moment([2012, 0, 8]).week(), 2, 'Jan 8 2012 should be week 2');
- assert.equal(moment([2012, 0, 14]).week(), 2, 'Jan 14 2012 should be week 2');
- assert.equal(moment([2012, 0, 15]).week(), 3, 'Jan 15 2012 should be week 3');
-});
-
-test('weeks year starting monday', function (assert) {
- assert.equal(moment([2006, 11, 31]).week(), 1, 'Dec 31 2006 should be week 1');
- assert.equal(moment([2007, 0, 1]).week(), 1, 'Jan 1 2007 should be week 1');
- assert.equal(moment([2007, 0, 6]).week(), 1, 'Jan 6 2007 should be week 1');
- assert.equal(moment([2007, 0, 7]).week(), 2, 'Jan 7 2007 should be week 2');
- assert.equal(moment([2007, 0, 13]).week(), 2, 'Jan 13 2007 should be week 2');
- assert.equal(moment([2007, 0, 14]).week(), 3, 'Jan 14 2007 should be week 3');
-});
-
-test('weeks year starting tuesday', function (assert) {
- assert.equal(moment([2007, 11, 29]).week(), 52, 'Dec 29 2007 should be week 52');
- assert.equal(moment([2008, 0, 1]).week(), 1, 'Jan 1 2008 should be week 1');
- assert.equal(moment([2008, 0, 5]).week(), 1, 'Jan 5 2008 should be week 1');
- assert.equal(moment([2008, 0, 6]).week(), 2, 'Jan 6 2008 should be week 2');
- assert.equal(moment([2008, 0, 12]).week(), 2, 'Jan 12 2008 should be week 2');
- assert.equal(moment([2008, 0, 13]).week(), 3, 'Jan 13 2008 should be week 3');
-});
-
-test('weeks year starting wednesday', function (assert) {
- assert.equal(moment([2002, 11, 29]).week(), 1, 'Dec 29 2002 should be week 1');
- assert.equal(moment([2003, 0, 1]).week(), 1, 'Jan 1 2003 should be week 1');
- assert.equal(moment([2003, 0, 4]).week(), 1, 'Jan 4 2003 should be week 1');
- assert.equal(moment([2003, 0, 5]).week(), 2, 'Jan 5 2003 should be week 2');
- assert.equal(moment([2003, 0, 11]).week(), 2, 'Jan 11 2003 should be week 2');
- assert.equal(moment([2003, 0, 12]).week(), 3, 'Jan 12 2003 should be week 3');
-});
-
-test('weeks year starting thursday', function (assert) {
- assert.equal(moment([2008, 11, 28]).week(), 1, 'Dec 28 2008 should be week 1');
- assert.equal(moment([2009, 0, 1]).week(), 1, 'Jan 1 2009 should be week 1');
- assert.equal(moment([2009, 0, 3]).week(), 1, 'Jan 3 2009 should be week 1');
- assert.equal(moment([2009, 0, 4]).week(), 2, 'Jan 4 2009 should be week 2');
- assert.equal(moment([2009, 0, 10]).week(), 2, 'Jan 10 2009 should be week 2');
- assert.equal(moment([2009, 0, 11]).week(), 3, 'Jan 11 2009 should be week 3');
-});
-
-test('weeks year starting friday', function (assert) {
- assert.equal(moment([2009, 11, 27]).week(), 1, 'Dec 27 2009 should be week 1');
- assert.equal(moment([2010, 0, 1]).week(), 1, 'Jan 1 2010 should be week 1');
- assert.equal(moment([2010, 0, 2]).week(), 1, 'Jan 2 2010 should be week 1');
- assert.equal(moment([2010, 0, 3]).week(), 2, 'Jan 3 2010 should be week 2');
- assert.equal(moment([2010, 0, 9]).week(), 2, 'Jan 9 2010 should be week 2');
- assert.equal(moment([2010, 0, 10]).week(), 3, 'Jan 10 2010 should be week 3');
-});
-
-test('weeks year starting saturday', function (assert) {
- assert.equal(moment([2010, 11, 26]).week(), 1, 'Dec 26 2010 should be week 1');
- assert.equal(moment([2011, 0, 1]).week(), 1, 'Jan 1 2011 should be week 1');
- assert.equal(moment([2011, 0, 2]).week(), 2, 'Jan 2 2011 should be week 2');
- assert.equal(moment([2011, 0, 8]).week(), 2, 'Jan 8 2011 should be week 2');
- assert.equal(moment([2011, 0, 9]).week(), 3, 'Jan 9 2011 should be week 3');
-});
-
test('weeks year starting sunday formatted', function (assert) {
assert.equal(moment([2012, 0, 1]).format('w ww wo'), '1 01 1', 'Jan 1 2012 should be week 1');
assert.equal(moment([2012, 0, 7]).format('w ww wo'), '1 01 1', 'Jan 7 2012 should be week 1');
@@ -284,38 +223,3 @@
assert.equal(moment([2012, 0, 15]).format('w ww wo'), '3 03 3', 'Jan 15 2012 should be week 3');
});
-test('lenient ordinal parsing', function (assert) {
- var i, ordinalStr, testMoment;
- for (i = 1; i <= 31; ++i) {
- ordinalStr = moment([2014, 0, i]).format('YYYY MM Do');
- testMoment = moment(ordinalStr, 'YYYY MM Do');
- assert.equal(testMoment.year(), 2014,
- 'lenient ordinal parsing ' + i + ' year check');
- assert.equal(testMoment.month(), 0,
- 'lenient ordinal parsing ' + i + ' month check');
- assert.equal(testMoment.date(), i,
- 'lenient ordinal parsing ' + i + ' date check');
- }
-});
-
-test('lenient ordinal parsing of number', function (assert) {
- var i, testMoment;
- for (i = 1; i <= 31; ++i) {
- testMoment = moment('2014 01 ' + i, 'YYYY MM Do');
- assert.equal(testMoment.year(), 2014,
- 'lenient ordinal parsing of number ' + i + ' year check');
- assert.equal(testMoment.month(), 0,
- 'lenient ordinal parsing of number ' + i + ' month check');
- assert.equal(testMoment.date(), i,
- 'lenient ordinal parsing of number ' + i + ' date check');
- }
-});
-
-test('strict ordinal parsing', function (assert) {
- var i, ordinalStr, testMoment;
- for (i = 1; i <= 31; ++i) {
- ordinalStr = moment([2014, 0, i]).format('YYYY MM Do');
- testMoment = moment(ordinalStr, 'YYYY MM Do', true);
- assert.ok(testMoment.isValid(), 'strict ordinal parsing ' + i);
- }
-});
diff --git a/src/test/locale/mr.js b/src/test/locale/mr.js
index 4a7186b..2122b16 100644
--- a/src/test/locale/mr.js
+++ b/src/test/locale/mr.js
@@ -150,14 +150,14 @@
});
test('calendar day', function (assert) {
- var a = moment().hours(2).minutes(0).seconds(0);
-
- assert.equal(moment(a).calendar(), 'आज रात्री २:०० वाजता', 'today at the same time');
- assert.equal(moment(a).add({m: 25}).calendar(), 'आज रात्री २:२५ वाजता', 'Now plus 25 min');
- assert.equal(moment(a).add({h: 3}).calendar(), 'आज सकाळी ५:०० वाजता', 'Now plus 3 hour');
- assert.equal(moment(a).add({d: 1}).calendar(), 'उद्या रात्री २:०० वाजता', 'tomorrow at the same time');
- assert.equal(moment(a).subtract({h: 1}).calendar(), 'आज रात्री १:०० वाजता', 'Now minus 1 hour');
- assert.equal(moment(a).subtract({d: 1}).calendar(), 'काल रात्री २:०० वाजता', 'yesterday at the same time');
+ var a = moment().hours(12).minutes(0).seconds(0);
+
+ assert.equal(moment(a).calendar(), 'आज दुपारी १२:०० वाजता', 'today at the same time');
+ assert.equal(moment(a).add({m: 25}).calendar(), 'आज दुपारी १२:२५ वाजता', 'Now plus 25 min');
+ assert.equal(moment(a).add({h: 3}).calendar(), 'आज दुपारी ३:०० वाजता', 'Now plus 3 hours');
+ assert.equal(moment(a).add({d: 1}).calendar(), 'उद्या दुपारी १२:०० वाजता', 'tomorrow at the same time');
+ assert.equal(moment(a).subtract({h: 1}).calendar(), 'आज दुपारी ११:०० वाजता', 'Now minus 1 hour');
+ assert.equal(moment(a).subtract({d: 1}).calendar(), 'काल दुपारी १२:०० वाजता', 'yesterday at the same time');
});
test('calendar next week', function (assert) {
@@ -215,67 +215,6 @@
assert.equal(moment([2011, 2, 23, 21, 20]).format('A'), 'रात्री', 'night');
});
-test('weeks year starting sunday', function (assert) {
- assert.equal(moment([2012, 0, 1]).week(), 1, 'Jan 1 2012 should be week 1');
- assert.equal(moment([2012, 0, 7]).week(), 1, 'Jan 7 2012 should be week 1');
- assert.equal(moment([2012, 0, 8]).week(), 2, 'Jan 8 2012 should be week 2');
- assert.equal(moment([2012, 0, 14]).week(), 2, 'Jan 14 2012 should be week 2');
- assert.equal(moment([2012, 0, 15]).week(), 3, 'Jan 15 2012 should be week 3');
-});
-
-test('weeks year starting monday', function (assert) {
- assert.equal(moment([2006, 11, 31]).week(), 1, 'Dec 31 2006 should be week 1');
- assert.equal(moment([2007, 0, 1]).week(), 1, 'Jan 1 2007 should be week 1');
- assert.equal(moment([2007, 0, 6]).week(), 1, 'Jan 6 2007 should be week 1');
- assert.equal(moment([2007, 0, 7]).week(), 2, 'Jan 7 2007 should be week 2');
- assert.equal(moment([2007, 0, 13]).week(), 2, 'Jan 13 2007 should be week 2');
- assert.equal(moment([2007, 0, 14]).week(), 3, 'Jan 14 2007 should be week 3');
-});
-
-test('weeks year starting tuesday', function (assert) {
- assert.equal(moment([2007, 11, 29]).week(), 52, 'Dec 29 2007 should be week 52');
- assert.equal(moment([2008, 0, 1]).week(), 1, 'Jan 1 2008 should be week 1');
- assert.equal(moment([2008, 0, 5]).week(), 1, 'Jan 5 2008 should be week 1');
- assert.equal(moment([2008, 0, 6]).week(), 2, 'Jan 6 2008 should be week 2');
- assert.equal(moment([2008, 0, 12]).week(), 2, 'Jan 12 2008 should be week 2');
- assert.equal(moment([2008, 0, 13]).week(), 3, 'Jan 13 2008 should be week 3');
-});
-
-test('weeks year starting wednesday', function (assert) {
- assert.equal(moment([2002, 11, 29]).week(), 1, 'Dec 29 2002 should be week 1');
- assert.equal(moment([2003, 0, 1]).week(), 1, 'Jan 1 2003 should be week 1');
- assert.equal(moment([2003, 0, 4]).week(), 1, 'Jan 4 2003 should be week 1');
- assert.equal(moment([2003, 0, 5]).week(), 2, 'Jan 5 2003 should be week 2');
- assert.equal(moment([2003, 0, 11]).week(), 2, 'Jan 11 2003 should be week 2');
- assert.equal(moment([2003, 0, 12]).week(), 3, 'Jan 12 2003 should be week 3');
-});
-
-test('weeks year starting thursday', function (assert) {
- assert.equal(moment([2008, 11, 28]).week(), 1, 'Dec 28 2008 should be week 1');
- assert.equal(moment([2009, 0, 1]).week(), 1, 'Jan 1 2009 should be week 1');
- assert.equal(moment([2009, 0, 3]).week(), 1, 'Jan 3 2009 should be week 1');
- assert.equal(moment([2009, 0, 4]).week(), 2, 'Jan 4 2009 should be week 2');
- assert.equal(moment([2009, 0, 10]).week(), 2, 'Jan 10 2009 should be week 2');
- assert.equal(moment([2009, 0, 11]).week(), 3, 'Jan 11 2009 should be week 3');
-});
-
-test('weeks year starting friday', function (assert) {
- assert.equal(moment([2009, 11, 27]).week(), 1, 'Dec 27 2009 should be week 1');
- assert.equal(moment([2010, 0, 1]).week(), 1, 'Jan 1 2010 should be week 1');
- assert.equal(moment([2010, 0, 2]).week(), 1, 'Jan 2 2010 should be week 1');
- assert.equal(moment([2010, 0, 3]).week(), 2, 'Jan 3 2010 should be week 2');
- assert.equal(moment([2010, 0, 9]).week(), 2, 'Jan 9 2010 should be week 2');
- assert.equal(moment([2010, 0, 10]).week(), 3, 'Jan 10 2010 should be week 3');
-});
-
-test('weeks year starting saturday', function (assert) {
- assert.equal(moment([2010, 11, 26]).week(), 1, 'Dec 26 2010 should be week 1');
- assert.equal(moment([2011, 0, 1]).week(), 1, 'Jan 1 2011 should be week 1');
- assert.equal(moment([2011, 0, 2]).week(), 2, 'Jan 2 2011 should be week 2');
- assert.equal(moment([2011, 0, 8]).week(), 2, 'Jan 8 2011 should be week 2');
- assert.equal(moment([2011, 0, 9]).week(), 3, 'Jan 9 2011 should be week 3');
-});
-
test('weeks year starting sunday formatted', function (assert) {
assert.equal(moment([2012, 0, 1]).format('w ww wo'), '१ ०१ १', 'Jan 1 2012 should be week 1');
assert.equal(moment([2012, 0, 7]).format('w ww wo'), '१ ०१ १', 'Jan 7 2012 should be week 1');
@@ -284,50 +223,4 @@
assert.equal(moment([2012, 0, 15]).format('w ww wo'), '३ ०३ ३', 'Jan 15 2012 should be week 3');
});
-test('lenient ordinal parsing', function (assert) {
- var i, ordinalStr, testMoment;
- for (i = 1; i <= 31; ++i) {
- ordinalStr = moment([2014, 0, i]).format('YYYY MM Do');
- testMoment = moment(ordinalStr, 'YYYY MM Do');
- assert.equal(testMoment.year(), 2014,
- 'lenient ordinal parsing ' + i + ' year check');
- assert.equal(testMoment.month(), 0,
- 'lenient ordinal parsing ' + i + ' month check');
- assert.equal(testMoment.date(), i,
- 'lenient ordinal parsing ' + i + ' date check');
- }
-});
-
-test('lenient ordinal parsing of number', function (assert) {
- var i, testMoment;
- for (i = 1; i <= 31; ++i) {
- testMoment = moment('2014 01 ' + i, 'YYYY MM Do');
- assert.equal(testMoment.year(), 2014,
- 'lenient ordinal parsing of number ' + i + ' year check');
- assert.equal(testMoment.month(), 0,
- 'lenient ordinal parsing of number ' + i + ' month check');
- assert.equal(testMoment.date(), i,
- 'lenient ordinal parsing of number ' + i + ' date check');
- }
-});
-
-test('meridiem invariant', function (assert) {
- var h, m, t1, t2;
- for (h = 0; h < 24; ++h) {
- for (m = 0; m < 60; m += 15) {
- t1 = moment.utc([2000, 0, 1, h, m]);
- t2 = moment(t1.format('A h:mm'), 'A h:mm');
- assert.equal(t2.format('HH:mm'), t1.format('HH:mm'),
- 'meridiem at ' + t1.format('HH:mm'));
- }
- }
-});
-
-test('strict ordinal parsing', function (assert) {
- var i, ordinalStr, testMoment;
- for (i = 1; i <= 31; ++i) {
- ordinalStr = moment([2014, 0, i]).format('YYYY MM Do');
- testMoment = moment(ordinalStr, 'YYYY MM Do', true);
- assert.ok(testMoment.isValid(), 'strict ordinal parsing ' + i);
- }
-});
+
diff --git a/src/test/locale/ms-my.js b/src/test/locale/ms-my.js
index d1cde53..12576be 100644
--- a/src/test/locale/ms-my.js
+++ b/src/test/locale/ms-my.js
@@ -160,14 +160,14 @@
});
test('calendar day', function (assert) {
- var a = moment().hours(2).minutes(0).seconds(0);
-
- assert.equal(moment(a).calendar(), 'Hari ini pukul 02.00', 'hari ini pada waktu yang sama');
- assert.equal(moment(a).add({m: 25}).calendar(), 'Hari ini pukul 02.25', 'Sekarang tambah 25 minit');
- assert.equal(moment(a).add({h: 1}).calendar(), 'Hari ini pukul 03.00', 'Sekarang tambah 1 jam');
- assert.equal(moment(a).add({d: 1}).calendar(), 'Esok pukul 02.00', 'esok pada waktu yang sama');
- assert.equal(moment(a).subtract({h: 1}).calendar(), 'Hari ini pukul 01.00', 'Sekarang tolak 1 jam');
- assert.equal(moment(a).subtract({d: 1}).calendar(), 'Kelmarin pukul 02.00', 'kelmarin pada waktu yang sama');
+ var a = moment().hours(12).minutes(0).seconds(0);
+
+ assert.equal(moment(a).calendar(), 'Hari ini pukul 12.00', 'hari ini pada waktu yang sama');
+ assert.equal(moment(a).add({m: 25}).calendar(), 'Hari ini pukul 12.25', 'Sekarang tambah 25 minit');
+ assert.equal(moment(a).add({h: 1}).calendar(), 'Hari ini pukul 13.00', 'Sekarang tambah 1 jam');
+ assert.equal(moment(a).add({d: 1}).calendar(), 'Esok pukul 12.00', 'esok pada waktu yang sama');
+ assert.equal(moment(a).subtract({h: 1}).calendar(), 'Hari ini pukul 11.00', 'Sekarang tolak 1 jam');
+ assert.equal(moment(a).subtract({d: 1}).calendar(), 'Kelmarin pukul 12.00', 'kelmarin pada waktu yang sama');
});
test('calendar next week', function (assert) {
@@ -208,67 +208,6 @@
assert.equal(weeksFromNow.calendar(), weeksFromNow.format('L'), 'dalam 2 minggu');
});
-test('weeks year starting sunday', function (assert) {
- assert.equal(moment([2012, 0, 1]).week(), 1, 'Jan 1 2012 sepatutnya minggu 1');
- assert.equal(moment([2012, 0, 7]).week(), 2, 'Jan 7 2012 sepatutnya minggu 2');
- assert.equal(moment([2012, 0, 8]).week(), 2, 'Jan 8 2012 sepatutnya minggu 2');
- assert.equal(moment([2012, 0, 14]).week(), 3, 'Jan 14 2012 sepatutnya minggu 3');
- assert.equal(moment([2012, 0, 15]).week(), 3, 'Jan 15 2012 sepatutnya minggu 3');
-});
-
-test('weeks year starting monday', function (assert) {
- assert.equal(moment([2006, 11, 31]).week(), 53, 'Dec 31 2006 sepatutnya minggu 53');
- assert.equal(moment([2007, 0, 1]).week(), 1, 'Jan 1 2007 sepatutnya minggu 1');
- assert.equal(moment([2007, 0, 6]).week(), 1, 'Jan 6 2007 sepatutnya minggu 1');
- assert.equal(moment([2007, 0, 7]).week(), 1, 'Jan 7 2007 sepatutnya minggu 1');
- assert.equal(moment([2007, 0, 13]).week(), 2, 'Jan 13 2007 sepatutnya minggu 2');
- assert.equal(moment([2007, 0, 14]).week(), 2, 'Jan 14 2007 sepatutnya minggu 2');
-});
-
-test('weeks year starting tuesday', function (assert) {
- assert.equal(moment([2007, 11, 30]).week(), 52, 'Dec 30 2007 sepatutnya minggu 52');
- assert.equal(moment([2008, 0, 1]).week(), 1, 'Jan 1 2008 sepatutnya minggu 1');
- assert.equal(moment([2008, 0, 5]).week(), 1, 'Jan 5 2008 sepatutnya minggu 1');
- assert.equal(moment([2008, 0, 6]).week(), 1, 'Jan 6 2008 sepatutnya minggu 1');
- assert.equal(moment([2008, 0, 12]).week(), 2, 'Jan 12 2008 sepatutnya minggu 2');
- assert.equal(moment([2008, 0, 13]).week(), 2, 'Jan 13 2008 sepatutnya minggu 2');
-});
-
-test('weeks year starting wednesday', function (assert) {
- assert.equal(moment([2002, 11, 29]).week(), 52, 'Dec 29 2002 sepatutnya minggu 52');
- assert.equal(moment([2003, 0, 1]).week(), 1, 'Jan 1 2003 sepatutnya minggu 1');
- assert.equal(moment([2003, 0, 4]).week(), 1, 'Jan 4 2003 sepatutnya minggu 1');
- assert.equal(moment([2003, 0, 5]).week(), 1, 'Jan 5 2003 sepatutnya minggu 1');
- assert.equal(moment([2003, 0, 11]).week(), 2, 'Jan 11 2003 sepatutnya minggu 2');
- assert.equal(moment([2003, 0, 12]).week(), 2, 'Jan 12 2003 sepatutnya minggu 2');
-});
-
-test('weeks year starting thursday', function (assert) {
- assert.equal(moment([2008, 11, 28]).week(), 52, 'Dec 28 2008 sepatutnya minggu 52');
- assert.equal(moment([2009, 0, 1]).week(), 1, 'Jan 1 2009 sepatutnya minggu 1');
- assert.equal(moment([2009, 0, 3]).week(), 1, 'Jan 3 2009 sepatutnya minggu 1');
- assert.equal(moment([2009, 0, 4]).week(), 1, 'Jan 4 2009 sepatutnya minggu 1');
- assert.equal(moment([2009, 0, 10]).week(), 2, 'Jan 10 2009 sepatutnya minggu 2');
- assert.equal(moment([2009, 0, 11]).week(), 2, 'Jan 11 2009 sepatutnya minggu 2');
-});
-
-test('weeks year starting friday', function (assert) {
- assert.equal(moment([2009, 11, 27]).week(), 52, 'Dec 27 2009 sepatutnya minggu 52');
- assert.equal(moment([2010, 0, 1]).week(), 1, 'Jan 1 2010 sepatutnya minggu 1');
- assert.equal(moment([2010, 0, 2]).week(), 1, 'Jan 2 2010 sepatutnya minggu 1');
- assert.equal(moment([2010, 0, 3]).week(), 1, 'Jan 3 2010 sepatutnya minggu 1');
- assert.equal(moment([2010, 0, 9]).week(), 2, 'Jan 9 2010 sepatutnya minggu 2');
- assert.equal(moment([2010, 0, 10]).week(), 2, 'Jan 10 2010 sepatutnya minggu 2');
-});
-
-test('weeks year starting saturday', function (assert) {
- assert.equal(moment([2010, 11, 26]).week(), 52, 'Dec 26 2010 sepatutnya minggu 52');
- assert.equal(moment([2011, 0, 1]).week(), 1, 'Jan 1 2011 sepatutnya minggu 1');
- assert.equal(moment([2011, 0, 2]).week(), 1, 'Jan 2 2011 sepatutnya minggu 1');
- assert.equal(moment([2011, 0, 8]).week(), 2, 'Jan 8 2011 sepatutnya minggu 2');
- assert.equal(moment([2011, 0, 9]).week(), 2, 'Jan 9 2011 sepatutnya minggu 2');
-});
-
test('weeks year starting sunday format', function (assert) {
assert.equal(moment([2012, 0, 1]).format('w ww wo'), '1 01 1', 'Jan 1 2012 sepatutnya minggu 1');
assert.equal(moment([2012, 0, 7]).format('w ww wo'), '2 02 2', 'Jan 7 2012 sepatutnya minggu 2');
@@ -277,50 +216,4 @@
assert.equal(moment([2012, 0, 15]).format('w ww wo'), '3 03 3', 'Jan 15 2012 sepatutnya minggu 3');
});
-test('lenient ordinal parsing', function (assert) {
- var i, ordinalStr, testMoment;
- for (i = 1; i <= 31; ++i) {
- ordinalStr = moment([2014, 0, i]).format('YYYY MM Do');
- testMoment = moment(ordinalStr, 'YYYY MM Do');
- assert.equal(testMoment.year(), 2014,
- 'lenient ordinal parsing ' + i + ' year check');
- assert.equal(testMoment.month(), 0,
- 'lenient ordinal parsing ' + i + ' month check');
- assert.equal(testMoment.date(), i,
- 'lenient ordinal parsing ' + i + ' date check');
- }
-});
-
-test('meridiem invariant', function (assert) {
- var h, m, t1, t2;
- for (h = 0; h < 24; ++h) {
- for (m = 0; m < 60; m += 15) {
- t1 = moment.utc([2000, 0, 1, h, m]);
- t2 = moment(t1.format('A h:mm'), 'A h:mm');
- assert.equal(t2.format('HH:mm'), t1.format('HH:mm'),
- 'meridiem at ' + t1.format('HH:mm'));
- }
- }
-});
-
-test('lenient ordinal parsing of number', function (assert) {
- var i, testMoment;
- for (i = 1; i <= 31; ++i) {
- testMoment = moment('2014 01 ' + i, 'YYYY MM Do');
- assert.equal(testMoment.year(), 2014,
- 'lenient ordinal parsing of number ' + i + ' year check');
- assert.equal(testMoment.month(), 0,
- 'lenient ordinal parsing of number ' + i + ' month check');
- assert.equal(testMoment.date(), i,
- 'lenient ordinal parsing of number ' + i + ' date check');
- }
-});
-
-test('strict ordinal parsing', function (assert) {
- var i, ordinalStr, testMoment;
- for (i = 1; i <= 31; ++i) {
- ordinalStr = moment([2014, 0, i]).format('YYYY MM Do');
- testMoment = moment(ordinalStr, 'YYYY MM Do', true);
- assert.ok(testMoment.isValid(), 'strict ordinal parsing ' + i);
- }
-});
+
diff --git a/src/test/locale/ms.js b/src/test/locale/ms.js
index 16d06d3..ed5f588 100644
--- a/src/test/locale/ms.js
+++ b/src/test/locale/ms.js
@@ -160,14 +160,14 @@
});
test('calendar day', function (assert) {
- var a = moment().hours(2).minutes(0).seconds(0);
-
- assert.equal(moment(a).calendar(), 'Hari ini pukul 02.00', 'hari ini pada waktu yang sama');
- assert.equal(moment(a).add({m: 25}).calendar(), 'Hari ini pukul 02.25', 'Sekarang tambah 25 minit');
- assert.equal(moment(a).add({h: 1}).calendar(), 'Hari ini pukul 03.00', 'Sekarang tambah 1 jam');
- assert.equal(moment(a).add({d: 1}).calendar(), 'Esok pukul 02.00', 'esok pada waktu yang sama');
- assert.equal(moment(a).subtract({h: 1}).calendar(), 'Hari ini pukul 01.00', 'Sekarang tolak 1 jam');
- assert.equal(moment(a).subtract({d: 1}).calendar(), 'Kelmarin pukul 02.00', 'kelmarin pada waktu yang sama');
+ var a = moment().hours(12).minutes(0).seconds(0);
+
+ assert.equal(moment(a).calendar(), 'Hari ini pukul 12.00', 'hari ini pada waktu yang sama');
+ assert.equal(moment(a).add({m: 25}).calendar(), 'Hari ini pukul 12.25', 'Sekarang tambah 25 minit');
+ assert.equal(moment(a).add({h: 1}).calendar(), 'Hari ini pukul 13.00', 'Sekarang tambah 1 jam');
+ assert.equal(moment(a).add({d: 1}).calendar(), 'Esok pukul 12.00', 'esok pada waktu yang sama');
+ assert.equal(moment(a).subtract({h: 1}).calendar(), 'Hari ini pukul 11.00', 'Sekarang tolak 1 jam');
+ assert.equal(moment(a).subtract({d: 1}).calendar(), 'Kelmarin pukul 12.00', 'kelmarin pada waktu yang sama');
});
test('calendar next week', function (assert) {
@@ -208,67 +208,6 @@
assert.equal(weeksFromNow.calendar(), weeksFromNow.format('L'), 'dalam 2 minggu');
});
-test('weeks year starting sunday', function (assert) {
- assert.equal(moment([2012, 0, 1]).week(), 1, 'Jan 1 2012 sepatutnya minggu 1');
- assert.equal(moment([2012, 0, 7]).week(), 2, 'Jan 7 2012 sepatutnya minggu 2');
- assert.equal(moment([2012, 0, 8]).week(), 2, 'Jan 8 2012 sepatutnya minggu 2');
- assert.equal(moment([2012, 0, 14]).week(), 3, 'Jan 14 2012 sepatutnya minggu 3');
- assert.equal(moment([2012, 0, 15]).week(), 3, 'Jan 15 2012 sepatutnya minggu 3');
-});
-
-test('weeks year starting monday', function (assert) {
- assert.equal(moment([2006, 11, 31]).week(), 53, 'Dec 31 2006 sepatutnya minggu 53');
- assert.equal(moment([2007, 0, 1]).week(), 1, 'Jan 1 2007 sepatutnya minggu 1');
- assert.equal(moment([2007, 0, 6]).week(), 1, 'Jan 6 2007 sepatutnya minggu 1');
- assert.equal(moment([2007, 0, 7]).week(), 1, 'Jan 7 2007 sepatutnya minggu 1');
- assert.equal(moment([2007, 0, 13]).week(), 2, 'Jan 13 2007 sepatutnya minggu 2');
- assert.equal(moment([2007, 0, 14]).week(), 2, 'Jan 14 2007 sepatutnya minggu 2');
-});
-
-test('weeks year starting tuesday', function (assert) {
- assert.equal(moment([2007, 11, 30]).week(), 52, 'Dec 30 2007 sepatutnya minggu 52');
- assert.equal(moment([2008, 0, 1]).week(), 1, 'Jan 1 2008 sepatutnya minggu 1');
- assert.equal(moment([2008, 0, 5]).week(), 1, 'Jan 5 2008 sepatutnya minggu 1');
- assert.equal(moment([2008, 0, 6]).week(), 1, 'Jan 6 2008 sepatutnya minggu 1');
- assert.equal(moment([2008, 0, 12]).week(), 2, 'Jan 12 2008 sepatutnya minggu 2');
- assert.equal(moment([2008, 0, 13]).week(), 2, 'Jan 13 2008 sepatutnya minggu 2');
-});
-
-test('weeks year starting wednesday', function (assert) {
- assert.equal(moment([2002, 11, 29]).week(), 52, 'Dec 29 2002 sepatutnya minggu 52');
- assert.equal(moment([2003, 0, 1]).week(), 1, 'Jan 1 2003 sepatutnya minggu 1');
- assert.equal(moment([2003, 0, 4]).week(), 1, 'Jan 4 2003 sepatutnya minggu 1');
- assert.equal(moment([2003, 0, 5]).week(), 1, 'Jan 5 2003 sepatutnya minggu 1');
- assert.equal(moment([2003, 0, 11]).week(), 2, 'Jan 11 2003 sepatutnya minggu 2');
- assert.equal(moment([2003, 0, 12]).week(), 2, 'Jan 12 2003 sepatutnya minggu 2');
-});
-
-test('weeks year starting thursday', function (assert) {
- assert.equal(moment([2008, 11, 28]).week(), 52, 'Dec 28 2008 sepatutnya minggu 52');
- assert.equal(moment([2009, 0, 1]).week(), 1, 'Jan 1 2009 sepatutnya minggu 1');
- assert.equal(moment([2009, 0, 3]).week(), 1, 'Jan 3 2009 sepatutnya minggu 1');
- assert.equal(moment([2009, 0, 4]).week(), 1, 'Jan 4 2009 sepatutnya minggu 1');
- assert.equal(moment([2009, 0, 10]).week(), 2, 'Jan 10 2009 sepatutnya minggu 2');
- assert.equal(moment([2009, 0, 11]).week(), 2, 'Jan 11 2009 sepatutnya minggu 2');
-});
-
-test('weeks year starting friday', function (assert) {
- assert.equal(moment([2009, 11, 27]).week(), 52, 'Dec 27 2009 sepatutnya minggu 52');
- assert.equal(moment([2010, 0, 1]).week(), 1, 'Jan 1 2010 sepatutnya minggu 1');
- assert.equal(moment([2010, 0, 2]).week(), 1, 'Jan 2 2010 sepatutnya minggu 1');
- assert.equal(moment([2010, 0, 3]).week(), 1, 'Jan 3 2010 sepatutnya minggu 1');
- assert.equal(moment([2010, 0, 9]).week(), 2, 'Jan 9 2010 sepatutnya minggu 2');
- assert.equal(moment([2010, 0, 10]).week(), 2, 'Jan 10 2010 sepatutnya minggu 2');
-});
-
-test('weeks year starting saturday', function (assert) {
- assert.equal(moment([2010, 11, 26]).week(), 52, 'Dec 26 2010 sepatutnya minggu 52');
- assert.equal(moment([2011, 0, 1]).week(), 1, 'Jan 1 2011 sepatutnya minggu 1');
- assert.equal(moment([2011, 0, 2]).week(), 1, 'Jan 2 2011 sepatutnya minggu 1');
- assert.equal(moment([2011, 0, 8]).week(), 2, 'Jan 8 2011 sepatutnya minggu 2');
- assert.equal(moment([2011, 0, 9]).week(), 2, 'Jan 9 2011 sepatutnya minggu 2');
-});
-
test('weeks year starting sunday format', function (assert) {
assert.equal(moment([2012, 0, 1]).format('w ww wo'), '1 01 1', 'Jan 1 2012 sepatutnya minggu 1');
assert.equal(moment([2012, 0, 7]).format('w ww wo'), '2 02 2', 'Jan 7 2012 sepatutnya minggu 2');
@@ -277,50 +216,4 @@
assert.equal(moment([2012, 0, 15]).format('w ww wo'), '3 03 3', 'Jan 15 2012 sepatutnya minggu 3');
});
-test('lenient ordinal parsing', function (assert) {
- var i, ordinalStr, testMoment;
- for (i = 1; i <= 31; ++i) {
- ordinalStr = moment([2014, 0, i]).format('YYYY MM Do');
- testMoment = moment(ordinalStr, 'YYYY MM Do');
- assert.equal(testMoment.year(), 2014,
- 'lenient ordinal parsing ' + i + ' year check');
- assert.equal(testMoment.month(), 0,
- 'lenient ordinal parsing ' + i + ' month check');
- assert.equal(testMoment.date(), i,
- 'lenient ordinal parsing ' + i + ' date check');
- }
-});
-
-test('meridiem invariant', function (assert) {
- var h, m, t1, t2;
- for (h = 0; h < 24; ++h) {
- for (m = 0; m < 60; m += 15) {
- t1 = moment.utc([2000, 0, 1, h, m]);
- t2 = moment(t1.format('A h:mm'), 'A h:mm');
- assert.equal(t2.format('HH:mm'), t1.format('HH:mm'),
- 'meridiem at ' + t1.format('HH:mm'));
- }
- }
-});
-
-test('lenient ordinal parsing of number', function (assert) {
- var i, testMoment;
- for (i = 1; i <= 31; ++i) {
- testMoment = moment('2014 01 ' + i, 'YYYY MM Do');
- assert.equal(testMoment.year(), 2014,
- 'lenient ordinal parsing of number ' + i + ' year check');
- assert.equal(testMoment.month(), 0,
- 'lenient ordinal parsing of number ' + i + ' month check');
- assert.equal(testMoment.date(), i,
- 'lenient ordinal parsing of number ' + i + ' date check');
- }
-});
-
-test('strict ordinal parsing', function (assert) {
- var i, ordinalStr, testMoment;
- for (i = 1; i <= 31; ++i) {
- ordinalStr = moment([2014, 0, i]).format('YYYY MM Do');
- testMoment = moment(ordinalStr, 'YYYY MM Do', true);
- assert.ok(testMoment.isValid(), 'strict ordinal parsing ' + i);
- }
-});
+
diff --git a/src/test/locale/my.js b/src/test/locale/my.js
index d497622..64f40bc 100644
--- a/src/test/locale/my.js
+++ b/src/test/locale/my.js
@@ -216,24 +216,14 @@
});
test('calendar day', function (assert) {
- var a = moment().hours(2).minutes(0).seconds(0);
-
- assert.equal(moment(a).calendar(), 'ယနေ. ၀၂:၀၀ မှာ', 'ယနေ. ဒီအချိန်');
- assert.equal(moment(a).add({
- m: 25
- }).calendar(), 'ယနေ. ၀၂:၂၅ မှာ', 'ယခုမှ ၂၅ မိနစ်ပေါင်းထည့်');
- assert.equal(moment(a).add({
- h: 1
- }).calendar(), 'ယနေ. ၀၃:၀၀ မှာ', 'ယခုမှ ၁ နာရီပေါင်းထည့်');
- assert.equal(moment(a).add({
- d: 1
- }).calendar(), 'မနက်ဖြန် ၀၂:၀၀ မှာ', 'မနက်ဖြန် ဒီအချိန်');
- assert.equal(moment(a).subtract({
- h: 1
- }).calendar(), 'ယနေ. ၀၁:၀၀ မှာ', 'ယခုမှ ၁ နာရီနှုတ်');
- assert.equal(moment(a).subtract({
- d: 1
- }).calendar(), 'မနေ.က ၀၂:၀၀ မှာ', 'မနေ.က ဒီအချိန်');
+ var a = moment().hours(12).minutes(0).seconds(0);
+
+ assert.equal(moment(a).calendar(), 'ယနေ. ၁၂:၀၀ မှာ', 'ယနေ. ဒီအချိန်');
+ assert.equal(moment(a).add({m: 25}).calendar(), 'ယနေ. ၁၂:၂၅ မှာ', 'ယခုမှ ၂၅ မိနစ်ပေါင်းထည့်');
+ assert.equal(moment(a).add({h: 1}).calendar(), 'ယနေ. ၁၃:၀၀ မှာ', 'ယခုမှ ၁ နာရီပေါင်းထည့်');
+ assert.equal(moment(a).add({d: 1}).calendar(), 'မနက်ဖြန် ၁၂:၀၀ မှာ', 'မနက်ဖြန် ဒီအချိန်');
+ assert.equal(moment(a).subtract({h: 1}).calendar(), 'ယနေ. ၁၁:၀၀ မှာ', 'ယခုမှ ၁ နာရီနှုတ်');
+ assert.equal(moment(a).subtract({d: 1}).calendar(), 'မနေ.က ၁၂:၀၀ မှာ', 'မနေ.က ဒီအချိန်');
});
test('calendar next week', function (assert) {
@@ -287,67 +277,6 @@
assert.equal(weeksFromNow.calendar(), weeksFromNow.format('L'), '၂ ပတ် အတွင်း');
});
-test('weeks year starting sunday', function (assert) {
- assert.equal(moment([2012, 0, 1]).week(), 52, 'Jan 1 2012 should be week 52');
- assert.equal(moment([2012, 0, 2]).week(), 1, 'Jan 2 2012 should be week 1');
- assert.equal(moment([2012, 0, 8]).week(), 1, 'Jan 8 2012 should be week 1');
- assert.equal(moment([2012, 0, 9]).week(), 2, 'Jan 9 2012 should be week 2');
- assert.equal(moment([2012, 0, 15]).week(), 2, 'Jan 15 2012 should be week 2');
-});
-
-test('weeks year starting monday', function (assert) {
- assert.equal(moment([2007, 0, 1]).week(), 1, 'Jan 1 2007 should be week 1');
- assert.equal(moment([2007, 0, 7]).week(), 1, 'Jan 7 2007 should be week 1');
- assert.equal(moment([2007, 0, 8]).week(), 2, 'Jan 8 2007 should be week 2');
- assert.equal(moment([2007, 0, 14]).week(), 2, 'Jan 14 2007 should be week 2');
- assert.equal(moment([2007, 0, 15]).week(), 3, 'Jan 15 2007 should be week 3');
-});
-
-test('weeks year starting tuesday', function (assert) {
- assert.equal(moment([2007, 11, 31]).week(), 1, 'Dec 31 2007 should be week 1');
- assert.equal(moment([2008, 0, 1]).week(), 1, 'Jan 1 2008 should be week 1');
- assert.equal(moment([2008, 0, 6]).week(), 1, 'Jan 6 2008 should be week 1');
- assert.equal(moment([2008, 0, 7]).week(), 2, 'Jan 7 2008 should be week 2');
- assert.equal(moment([2008, 0, 13]).week(), 2, 'Jan 13 2008 should be week 2');
- assert.equal(moment([2008, 0, 14]).week(), 3, 'Jan 14 2008 should be week 3');
-});
-
-test('weeks year starting wednesday', function (assert) {
- assert.equal(moment([2002, 11, 30]).week(), 1, 'Dec 30 2002 should be week 1');
- assert.equal(moment([2003, 0, 1]).week(), 1, 'Jan 1 2003 should be week 1');
- assert.equal(moment([2003, 0, 5]).week(), 1, 'Jan 5 2003 should be week 1');
- assert.equal(moment([2003, 0, 6]).week(), 2, 'Jan 6 2003 should be week 2');
- assert.equal(moment([2003, 0, 12]).week(), 2, 'Jan 12 2003 should be week 2');
- assert.equal(moment([2003, 0, 13]).week(), 3, 'Jan 13 2003 should be week 3');
-});
-
-test('weeks year starting thursday', function (assert) {
- assert.equal(moment([2008, 11, 29]).week(), 1, 'Dec 29 2008 should be week 1');
- assert.equal(moment([2009, 0, 1]).week(), 1, 'Jan 1 2009 should be week 1');
- assert.equal(moment([2009, 0, 4]).week(), 1, 'Jan 4 2009 should be week 1');
- assert.equal(moment([2009, 0, 5]).week(), 2, 'Jan 5 2009 should be week 2');
- assert.equal(moment([2009, 0, 11]).week(), 2, 'Jan 11 2009 should be week 2');
- assert.equal(moment([2009, 0, 13]).week(), 3, 'Jan 12 2009 should be week 3');
-});
-
-test('weeks year starting friday', function (assert) {
- assert.equal(moment([2009, 11, 28]).week(), 53, 'Dec 28 2009 should be week 53');
- assert.equal(moment([2010, 0, 1]).week(), 53, 'Jan 1 2010 should be week 53');
- assert.equal(moment([2010, 0, 3]).week(), 53, 'Jan 3 2010 should be week 53');
- assert.equal(moment([2010, 0, 4]).week(), 1, 'Jan 4 2010 should be week 1');
- assert.equal(moment([2010, 0, 10]).week(), 1, 'Jan 10 2010 should be week 1');
- assert.equal(moment([2010, 0, 11]).week(), 2, 'Jan 11 2010 should be week 2');
-});
-
-test('weeks year starting saturday', function (assert) {
- assert.equal(moment([2010, 11, 27]).week(), 52, 'Dec 27 2010 should be week 52');
- assert.equal(moment([2011, 0, 1]).week(), 52, 'Jan 1 2011 should be week 52');
- assert.equal(moment([2011, 0, 2]).week(), 52, 'Jan 2 2011 should be week 52');
- assert.equal(moment([2011, 0, 3]).week(), 1, 'Jan 3 2011 should be week 1');
- assert.equal(moment([2011, 0, 9]).week(), 1, 'Jan 9 2011 should be week 1');
- assert.equal(moment([2011, 0, 10]).week(), 2, 'Jan 10 2011 should be week 2');
-});
-
test('weeks year starting sunday formatted', function (assert) {
assert.equal(moment([2012, 0, 1]).format('w ww wo'), '၅၂ ၅၂ ၅၂', 'Jan 1 2012 should be week 52');
assert.equal(moment([2012, 0, 2]).format('w ww wo'), '၁ ၀၁ ၁', 'Jan 2 2012 should be week 1');
@@ -356,38 +285,3 @@
assert.equal(moment([2012, 0, 15]).format('w ww wo'), '၂ ၀၂ ၂', 'Jan 15 2012 should be week 2');
});
-test('lenient ordinal parsing', function (assert) {
- var i, ordinalStr, testMoment;
- for (i = 1; i <= 31; ++i) {
- ordinalStr = moment([2014, 0, i]).format('YYYY MM Do');
- testMoment = moment(ordinalStr, 'YYYY MM Do');
- assert.equal(testMoment.year(), 2014,
- 'lenient ordinal parsing ' + i + ' year check');
- assert.equal(testMoment.month(), 0,
- 'lenient ordinal parsing ' + i + ' month check');
- assert.equal(testMoment.date(), i,
- 'lenient ordinal parsing ' + i + ' date check');
- }
-});
-
-test('lenient ordinal parsing of number', function (assert) {
- var i, testMoment;
- for (i = 1; i <= 31; ++i) {
- testMoment = moment('2014 01 ' + i, 'YYYY MM Do');
- assert.equal(testMoment.year(), 2014,
- 'lenient ordinal parsing of number ' + i + ' year check');
- assert.equal(testMoment.month(), 0,
- 'lenient ordinal parsing of number ' + i + ' month check');
- assert.equal(testMoment.date(), i,
- 'lenient ordinal parsing of number ' + i + ' date check');
- }
-});
-
-test('strict ordinal parsing', function (assert) {
- var i, ordinalStr, testMoment;
- for (i = 1; i <= 31; ++i) {
- ordinalStr = moment([2014, 0, i]).format('YYYY MM Do');
- testMoment = moment(ordinalStr, 'YYYY MM Do', true);
- assert.ok(testMoment.isValid(), 'strict ordinal parsing ' + i);
- }
-});
diff --git a/src/test/locale/nb.js b/src/test/locale/nb.js
index 06be407..b9aa970 100644
--- a/src/test/locale/nb.js
+++ b/src/test/locale/nb.js
@@ -139,11 +139,11 @@
test('suffix', function (assert) {
assert.equal(moment(30000).from(0), 'om noen sekunder', 'prefix');
- assert.equal(moment(0).from(30000), 'for noen sekunder siden', 'suffix');
+ assert.equal(moment(0).from(30000), 'noen sekunder siden', 'suffix');
});
test('now from now', function (assert) {
- assert.equal(moment().fromNow(), 'for noen sekunder siden', 'now from now should display as in the past');
+ assert.equal(moment().fromNow(), 'noen sekunder siden', 'now from now should display as in the past');
});
test('fromNow', function (assert) {
@@ -152,14 +152,14 @@
});
test('calendar day', function (assert) {
- var a = moment().hours(2).minutes(0).seconds(0);
-
- assert.equal(moment(a).calendar(), 'i dag kl. 02:00', 'today at the same time');
- assert.equal(moment(a).add({m: 25}).calendar(), 'i dag kl. 02:25', 'Now plus 25 min');
- assert.equal(moment(a).add({h: 1}).calendar(), 'i dag kl. 03:00', 'Now plus 1 hour');
- assert.equal(moment(a).add({d: 1}).calendar(), 'i morgen kl. 02:00', 'tomorrow at the same time');
- assert.equal(moment(a).subtract({h: 1}).calendar(), 'i dag kl. 01:00', 'Now minus 1 hour');
- assert.equal(moment(a).subtract({d: 1}).calendar(), 'i går kl. 02:00', 'yesterday at the same time');
+ var a = moment().hours(12).minutes(0).seconds(0);
+
+ assert.equal(moment(a).calendar(), 'i dag kl. 12:00', 'today at the same time');
+ assert.equal(moment(a).add({m: 25}).calendar(), 'i dag kl. 12:25', 'Now plus 25 min');
+ assert.equal(moment(a).add({h: 1}).calendar(), 'i dag kl. 13:00', 'Now plus 1 hour');
+ assert.equal(moment(a).add({d: 1}).calendar(), 'i morgen kl. 12:00', 'tomorrow at the same time');
+ assert.equal(moment(a).subtract({h: 1}).calendar(), 'i dag kl. 11:00', 'Now minus 1 hour');
+ assert.equal(moment(a).subtract({d: 1}).calendar(), 'i går kl. 12:00', 'yesterday at the same time');
});
test('calendar next week', function (assert) {
@@ -200,67 +200,6 @@
assert.equal(weeksFromNow.calendar(), weeksFromNow.format('L'), 'in 2 weeks');
});
-test('weeks year starting sunday', function (assert) {
- assert.equal(moment([2012, 0, 1]).week(), 52, 'Jan 1 2012 should be week 52');
- assert.equal(moment([2012, 0, 2]).week(), 1, 'Jan 2 2012 should be week 1');
- assert.equal(moment([2012, 0, 8]).week(), 1, 'Jan 8 2012 should be week 1');
- assert.equal(moment([2012, 0, 9]).week(), 2, 'Jan 9 2012 should be week 2');
- assert.equal(moment([2012, 0, 15]).week(), 2, 'Jan 15 2012 should be week 2');
-});
-
-test('weeks year starting monday', function (assert) {
- assert.equal(moment([2007, 0, 1]).week(), 1, 'Jan 1 2007 should be week 1');
- assert.equal(moment([2007, 0, 7]).week(), 1, 'Jan 7 2007 should be week 1');
- assert.equal(moment([2007, 0, 8]).week(), 2, 'Jan 8 2007 should be week 2');
- assert.equal(moment([2007, 0, 14]).week(), 2, 'Jan 14 2007 should be week 2');
- assert.equal(moment([2007, 0, 15]).week(), 3, 'Jan 15 2007 should be week 3');
-});
-
-test('weeks year starting tuesday', function (assert) {
- assert.equal(moment([2007, 11, 31]).week(), 1, 'Dec 31 2007 should be week 1');
- assert.equal(moment([2008, 0, 1]).week(), 1, 'Jan 1 2008 should be week 1');
- assert.equal(moment([2008, 0, 6]).week(), 1, 'Jan 6 2008 should be week 1');
- assert.equal(moment([2008, 0, 7]).week(), 2, 'Jan 7 2008 should be week 2');
- assert.equal(moment([2008, 0, 13]).week(), 2, 'Jan 13 2008 should be week 2');
- assert.equal(moment([2008, 0, 14]).week(), 3, 'Jan 14 2008 should be week 3');
-});
-
-test('weeks year starting wednesday', function (assert) {
- assert.equal(moment([2002, 11, 30]).week(), 1, 'Dec 30 2002 should be week 1');
- assert.equal(moment([2003, 0, 1]).week(), 1, 'Jan 1 2003 should be week 1');
- assert.equal(moment([2003, 0, 5]).week(), 1, 'Jan 5 2003 should be week 1');
- assert.equal(moment([2003, 0, 6]).week(), 2, 'Jan 6 2003 should be week 2');
- assert.equal(moment([2003, 0, 12]).week(), 2, 'Jan 12 2003 should be week 2');
- assert.equal(moment([2003, 0, 13]).week(), 3, 'Jan 13 2003 should be week 3');
-});
-
-test('weeks year starting thursday', function (assert) {
- assert.equal(moment([2008, 11, 29]).week(), 1, 'Dec 29 2008 should be week 1');
- assert.equal(moment([2009, 0, 1]).week(), 1, 'Jan 1 2009 should be week 1');
- assert.equal(moment([2009, 0, 4]).week(), 1, 'Jan 4 2009 should be week 1');
- assert.equal(moment([2009, 0, 5]).week(), 2, 'Jan 5 2009 should be week 2');
- assert.equal(moment([2009, 0, 11]).week(), 2, 'Jan 11 2009 should be week 2');
- assert.equal(moment([2009, 0, 13]).week(), 3, 'Jan 12 2009 should be week 3');
-});
-
-test('weeks year starting friday', function (assert) {
- assert.equal(moment([2009, 11, 28]).week(), 53, 'Dec 28 2009 should be week 53');
- assert.equal(moment([2010, 0, 1]).week(), 53, 'Jan 1 2010 should be week 53');
- assert.equal(moment([2010, 0, 3]).week(), 53, 'Jan 3 2010 should be week 53');
- assert.equal(moment([2010, 0, 4]).week(), 1, 'Jan 4 2010 should be week 1');
- assert.equal(moment([2010, 0, 10]).week(), 1, 'Jan 10 2010 should be week 1');
- assert.equal(moment([2010, 0, 11]).week(), 2, 'Jan 11 2010 should be week 2');
-});
-
-test('weeks year starting saturday', function (assert) {
- assert.equal(moment([2010, 11, 27]).week(), 52, 'Dec 27 2010 should be week 52');
- assert.equal(moment([2011, 0, 1]).week(), 52, 'Jan 1 2011 should be week 52');
- assert.equal(moment([2011, 0, 2]).week(), 52, 'Jan 2 2011 should be week 52');
- assert.equal(moment([2011, 0, 3]).week(), 1, 'Jan 3 2011 should be week 1');
- assert.equal(moment([2011, 0, 9]).week(), 1, 'Jan 9 2011 should be week 1');
- assert.equal(moment([2011, 0, 10]).week(), 2, 'Jan 10 2011 should be week 2');
-});
-
test('weeks year starting sunday formatted', function (assert) {
assert.equal(moment([2012, 0, 1]).format('w ww wo'), '52 52 52.', 'Jan 1 2012 should be week 52');
assert.equal(moment([2012, 0, 2]).format('w ww wo'), '1 01 1.', 'Jan 2 2012 should be week 1');
@@ -269,38 +208,3 @@
assert.equal(moment([2012, 0, 15]).format('w ww wo'), '2 02 2.', 'Jan 15 2012 should be week 2');
});
-test('lenient ordinal parsing', function (assert) {
- var i, ordinalStr, testMoment;
- for (i = 1; i <= 31; ++i) {
- ordinalStr = moment([2014, 0, i]).format('YYYY MM Do');
- testMoment = moment(ordinalStr, 'YYYY MM Do');
- assert.equal(testMoment.year(), 2014,
- 'lenient ordinal parsing ' + i + ' year check');
- assert.equal(testMoment.month(), 0,
- 'lenient ordinal parsing ' + i + ' month check');
- assert.equal(testMoment.date(), i,
- 'lenient ordinal parsing ' + i + ' date check');
- }
-});
-
-test('lenient ordinal parsing of number', function (assert) {
- var i, testMoment;
- for (i = 1; i <= 31; ++i) {
- testMoment = moment('2014 01 ' + i, 'YYYY MM Do');
- assert.equal(testMoment.year(), 2014,
- 'lenient ordinal parsing of number ' + i + ' year check');
- assert.equal(testMoment.month(), 0,
- 'lenient ordinal parsing of number ' + i + ' month check');
- assert.equal(testMoment.date(), i,
- 'lenient ordinal parsing of number ' + i + ' date check');
- }
-});
-
-test('strict ordinal parsing', function (assert) {
- var i, ordinalStr, testMoment;
- for (i = 1; i <= 31; ++i) {
- ordinalStr = moment([2014, 0, i]).format('YYYY MM Do');
- testMoment = moment(ordinalStr, 'YYYY MM Do', true);
- assert.ok(testMoment.isValid(), 'strict ordinal parsing ' + i);
- }
-});
diff --git a/src/test/locale/ne.js b/src/test/locale/ne.js
index 7e42a0b..8f61e19 100644
--- a/src/test/locale/ne.js
+++ b/src/test/locale/ne.js
@@ -150,14 +150,14 @@
});
test('calendar day', function (assert) {
- var a = moment().hours(2).minutes(0).seconds(0);
-
- assert.equal(moment(a).calendar(), 'आज रातिको २:०० बजे', 'today at the same time');
- assert.equal(moment(a).add({m: 25}).calendar(), 'आज रातिको २:२५ बजे', 'Now plus 25 min');
- assert.equal(moment(a).add({h: 1}).calendar(), 'आज बिहानको ३:०० बजे', 'Now plus 1 hour');
- assert.equal(moment(a).add({d: 1}).calendar(), 'भोलि रातिको २:०० बजे', 'tomorrow at the same time');
- assert.equal(moment(a).subtract({h: 1}).calendar(), 'आज रातिको १:०० बजे', 'Now minus 1 hour');
- assert.equal(moment(a).subtract({d: 1}).calendar(), 'हिजो रातिको २:०० बजे', 'yesterday at the same time');
+ var a = moment().hours(12).minutes(0).seconds(0);
+
+ assert.equal(moment(a).calendar(), 'आज दिउँसोको १२:०० बजे', 'today at the same time');
+ assert.equal(moment(a).add({m: 25}).calendar(), 'आज दिउँसोको १२:२५ बजे', 'Now plus 25 min');
+ assert.equal(moment(a).add({h: 1}).calendar(), 'आज दिउँसोको १:०० बजे', 'Now plus 1 hour');
+ assert.equal(moment(a).add({d: 1}).calendar(), 'भोलि दिउँसोको १२:०० बजे', 'tomorrow at the same time');
+ assert.equal(moment(a).subtract({h: 1}).calendar(), 'आज बिहानको ११:०० बजे', 'Now minus 1 hour');
+ assert.equal(moment(a).subtract({d: 1}).calendar(), 'हिजो दिउँसोको १२:०० बजे', 'yesterday at the same time');
});
test('calendar next week', function (assert) {
@@ -214,68 +214,6 @@
assert.equal(moment([2011, 2, 23, 21, 20]).format('A'), 'राति', 'night');
});
-test('weeks year starting sunday', function (assert) {
- assert.equal(moment([2012, 0, 1]).week(), 1, 'Jan 1 2012 should be week 1');
- assert.equal(moment([2012, 0, 7]).week(), 1, 'Jan 7 2012 should be week 1');
- assert.equal(moment([2012, 0, 8]).week(), 2, 'Jan 8 2012 should be week 2');
- assert.equal(moment([2012, 0, 14]).week(), 2, 'Jan 14 2012 should be week 2');
- assert.equal(moment([2012, 0, 15]).week(), 3, 'Jan 15 2012 should be week 3');
-});
-
-test('weeks year starting monday', function (assert) {
- assert.equal(moment([2006, 11, 31]).week(), 1, 'Dec 31 2006 should be week 1');
- assert.equal(moment([2007, 0, 1]).week(), 1, 'Jan 1 2007 should be week 1');
- assert.equal(moment([2007, 0, 6]).week(), 1, 'Jan 6 2007 should be week 1');
- assert.equal(moment([2007, 0, 7]).week(), 2, 'Jan 7 2007 should be week 2');
- assert.equal(moment([2007, 0, 13]).week(), 2, 'Jan 13 2007 should be week 2');
- assert.equal(moment([2007, 0, 14]).week(), 3, 'Jan 14 2007 should be week 3');
-});
-
-test('weeks year starting tuesday', function (assert) {
- assert.equal(moment([2007, 11, 29]).week(), 52, 'Dec 29 2007 should be week 52');
- assert.equal(moment([2008, 0, 1]).week(), 1, 'Jan 1 2008 should be week 1');
- assert.equal(moment([2008, 0, 5]).week(), 1, 'Jan 5 2008 should be week 1');
- assert.equal(moment([2008, 0, 6]).week(), 2, 'Jan 6 2008 should be week 2');
- assert.equal(moment([2008, 0, 12]).week(), 2, 'Jan 12 2008 should be week 2');
- assert.equal(moment([2008, 0, 13]).week(), 3, 'Jan 13 2008 should be week 3');
-});
-
-test('weeks year starting wednesday', function (assert) {
- assert.equal(moment([2002, 11, 29]).week(), 1, 'Dec 29 2002 should be week 1');
- assert.equal(moment([2003, 0, 1]).week(), 1, 'Jan 1 2003 should be week 1');
- assert.equal(moment([2003, 0, 4]).week(), 1, 'Jan 4 2003 should be week 1');
- assert.equal(moment([2003, 0, 5]).week(), 2, 'Jan 5 2003 should be week 2');
- assert.equal(moment([2003, 0, 11]).week(), 2, 'Jan 11 2003 should be week 2');
- assert.equal(moment([2003, 0, 12]).week(), 3, 'Jan 12 2003 should be week 3');
-});
-
-test('weeks year starting thursday', function (assert) {
- assert.equal(moment([2008, 11, 28]).week(), 1, 'Dec 28 2008 should be week 1');
- assert.equal(moment([2009, 0, 1]).week(), 1, 'Jan 1 2009 should be week 1');
- assert.equal(moment([2009, 0, 3]).week(), 1, 'Jan 3 2009 should be week 1');
- assert.equal(moment([2009, 0, 4]).week(), 2, 'Jan 4 2009 should be week 2');
- assert.equal(moment([2009, 0, 10]).week(), 2, 'Jan 10 2009 should be week 2');
- assert.equal(moment([2009, 0, 11]).week(), 3, 'Jan 11 2009 should be week 3');
-});
-
-test('weeks year starting friday', function (assert) {
- assert.equal(moment([2009, 11, 27]).week(), 1, 'Dec 27 2009 should be week 1');
- assert.equal(moment([2010, 0, 1]).week(), 1, 'Jan 1 2010 should be week 1');
- assert.equal(moment([2010, 0, 2]).week(), 1, 'Jan 2 2010 should be week 1');
- assert.equal(moment([2010, 0, 3]).week(), 2, 'Jan 3 2010 should be week 2');
- assert.equal(moment([2010, 0, 9]).week(), 2, 'Jan 9 2010 should be week 2');
- assert.equal(moment([2010, 0, 10]).week(), 3, 'Jan 10 2010 should be week 3');
-});
-
-test('weeks year starting saturday', function (assert) {
- assert.equal(moment([2010, 11, 26]).week(), 1, 'Dec 26 2010 should be week 1');
- assert.equal(moment([2011, 0, 1]).week(), 1, 'Jan 1 2011 should be week 1');
- assert.equal(moment([2011, 0, 2]).week(), 2, 'Jan 2 2011 should be week 2');
- assert.equal(moment([2011, 0, 8]).week(), 2, 'Jan 8 2011 should be week 2');
- assert.equal(moment([2011, 0, 9]).week(), 3, 'Jan 9 2011 should be week 3');
-});
-
-
test('weeks year starting sunday formatted', function (assert) {
assert.equal(moment([2011, 11, 26]).format('w ww wo'), '५३ ५३ ५३', 'Dec 26 2011 should be week 53');
assert.equal(moment([2012, 0, 1]).format('w ww wo'), '१ ०१ १', 'Jan 1 2012 should be week 1');
@@ -284,50 +222,4 @@
assert.equal(moment([2012, 0, 9]).format('w ww wo'), '२ ०२ २', 'Jan 9 2012 should be week 2');
});
-test('lenient ordinal parsing', function (assert) {
- var i, ordinalStr, testMoment;
- for (i = 1; i <= 31; ++i) {
- ordinalStr = moment([2014, 0, i]).format('YYYY MM Do');
- testMoment = moment(ordinalStr, 'YYYY MM Do');
- assert.equal(testMoment.year(), 2014,
- 'lenient ordinal parsing ' + i + ' year check');
- assert.equal(testMoment.month(), 0,
- 'lenient ordinal parsing ' + i + ' month check');
- assert.equal(testMoment.date(), i,
- 'lenient ordinal parsing ' + i + ' date check');
- }
-});
-
-test('lenient ordinal parsing of number', function (assert) {
- var i, testMoment;
- for (i = 1; i <= 31; ++i) {
- testMoment = moment('2014 01 ' + i, 'YYYY MM Do');
- assert.equal(testMoment.year(), 2014,
- 'lenient ordinal parsing of number ' + i + ' year check');
- assert.equal(testMoment.month(), 0,
- 'lenient ordinal parsing of number ' + i + ' month check');
- assert.equal(testMoment.date(), i,
- 'lenient ordinal parsing of number ' + i + ' date check');
- }
-});
-
-test('meridiem invariant', function (assert) {
- var h, m, t1, t2;
- for (h = 0; h < 24; ++h) {
- for (m = 0; m < 60; m += 15) {
- t1 = moment.utc([2000, 0, 1, h, m]);
- t2 = moment(t1.format('A h:mm'), 'A h:mm');
- assert.equal(t2.format('HH:mm'), t1.format('HH:mm'),
- 'meridiem at ' + t1.format('HH:mm'));
- }
- }
-});
-
-test('strict ordinal parsing', function (assert) {
- var i, ordinalStr, testMoment;
- for (i = 1; i <= 31; ++i) {
- ordinalStr = moment([2014, 0, i]).format('YYYY MM Do');
- testMoment = moment(ordinalStr, 'YYYY MM Do', true);
- assert.ok(testMoment.isValid(), 'strict ordinal parsing ' + i);
- }
-});
+
diff --git a/src/test/locale/nl.js b/src/test/locale/nl.js
index 60be3be..d0f7533 100644
--- a/src/test/locale/nl.js
+++ b/src/test/locale/nl.js
@@ -151,14 +151,14 @@
});
test('calendar day', function (assert) {
- var a = moment().hours(2).minutes(0).seconds(0);
-
- assert.equal(moment(a).calendar(), 'vandaag om 02:00', 'today at the same time');
- assert.equal(moment(a).add({m: 25}).calendar(), 'vandaag om 02:25', 'Now plus 25 min');
- assert.equal(moment(a).add({h: 1}).calendar(), 'vandaag om 03:00', 'Now plus 1 hour');
- assert.equal(moment(a).add({d: 1}).calendar(), 'morgen om 02:00', 'tomorrow at the same time');
- assert.equal(moment(a).subtract({h: 1}).calendar(), 'vandaag om 01:00', 'Now minus 1 hour');
- assert.equal(moment(a).subtract({d: 1}).calendar(), 'gisteren om 02:00', 'yesterday at the same time');
+ var a = moment().hours(12).minutes(0).seconds(0);
+
+ assert.equal(moment(a).calendar(), 'vandaag om 12:00', 'today at the same time');
+ assert.equal(moment(a).add({m: 25}).calendar(), 'vandaag om 12:25', 'Now plus 25 min');
+ assert.equal(moment(a).add({h: 1}).calendar(), 'vandaag om 13:00', 'Now plus 1 hour');
+ assert.equal(moment(a).add({d: 1}).calendar(), 'morgen om 12:00', 'tomorrow at the same time');
+ assert.equal(moment(a).subtract({h: 1}).calendar(), 'vandaag om 11:00', 'Now minus 1 hour');
+ assert.equal(moment(a).subtract({d: 1}).calendar(), 'gisteren om 12:00', 'yesterday at the same time');
});
test('calendar next week', function (assert) {
@@ -204,67 +204,6 @@
assert.equal(moment([2012, 5, 23]).format('D MMM YYYY'), '23 jun. 2012', 'format month abbreviation not surrounded by dashes should include a dot');
});
-test('weeks year starting sunday', function (assert) {
- assert.equal(moment([2012, 0, 1]).week(), 52, 'Jan 1 2012 should be week 52');
- assert.equal(moment([2012, 0, 2]).week(), 1, 'Jan 2 2012 should be week 1');
- assert.equal(moment([2012, 0, 8]).week(), 1, 'Jan 8 2012 should be week 1');
- assert.equal(moment([2012, 0, 9]).week(), 2, 'Jan 9 2012 should be week 2');
- assert.equal(moment([2012, 0, 15]).week(), 2, 'Jan 15 2012 should be week 2');
-});
-
-test('weeks year starting monday', function (assert) {
- assert.equal(moment([2007, 0, 1]).week(), 1, 'Jan 1 2007 should be week 1');
- assert.equal(moment([2007, 0, 7]).week(), 1, 'Jan 7 2007 should be week 1');
- assert.equal(moment([2007, 0, 8]).week(), 2, 'Jan 8 2007 should be week 2');
- assert.equal(moment([2007, 0, 14]).week(), 2, 'Jan 14 2007 should be week 2');
- assert.equal(moment([2007, 0, 15]).week(), 3, 'Jan 15 2007 should be week 3');
-});
-
-test('weeks year starting tuesday', function (assert) {
- assert.equal(moment([2007, 11, 31]).week(), 1, 'Dec 31 2007 should be week 1');
- assert.equal(moment([2008, 0, 1]).week(), 1, 'Jan 1 2008 should be week 1');
- assert.equal(moment([2008, 0, 6]).week(), 1, 'Jan 6 2008 should be week 1');
- assert.equal(moment([2008, 0, 7]).week(), 2, 'Jan 7 2008 should be week 2');
- assert.equal(moment([2008, 0, 13]).week(), 2, 'Jan 13 2008 should be week 2');
- assert.equal(moment([2008, 0, 14]).week(), 3, 'Jan 14 2008 should be week 3');
-});
-
-test('weeks year starting wednesday', function (assert) {
- assert.equal(moment([2002, 11, 30]).week(), 1, 'Dec 30 2002 should be week 1');
- assert.equal(moment([2003, 0, 1]).week(), 1, 'Jan 1 2003 should be week 1');
- assert.equal(moment([2003, 0, 5]).week(), 1, 'Jan 5 2003 should be week 1');
- assert.equal(moment([2003, 0, 6]).week(), 2, 'Jan 6 2003 should be week 2');
- assert.equal(moment([2003, 0, 12]).week(), 2, 'Jan 12 2003 should be week 2');
- assert.equal(moment([2003, 0, 13]).week(), 3, 'Jan 13 2003 should be week 3');
-});
-
-test('weeks year starting thursday', function (assert) {
- assert.equal(moment([2008, 11, 29]).week(), 1, 'Dec 29 2008 should be week 1');
- assert.equal(moment([2009, 0, 1]).week(), 1, 'Jan 1 2009 should be week 1');
- assert.equal(moment([2009, 0, 4]).week(), 1, 'Jan 4 2009 should be week 1');
- assert.equal(moment([2009, 0, 5]).week(), 2, 'Jan 5 2009 should be week 2');
- assert.equal(moment([2009, 0, 11]).week(), 2, 'Jan 11 2009 should be week 2');
- assert.equal(moment([2009, 0, 13]).week(), 3, 'Jan 12 2009 should be week 3');
-});
-
-test('weeks year starting friday', function (assert) {
- assert.equal(moment([2009, 11, 28]).week(), 53, 'Dec 28 2009 should be week 53');
- assert.equal(moment([2010, 0, 1]).week(), 53, 'Jan 1 2010 should be week 53');
- assert.equal(moment([2010, 0, 3]).week(), 53, 'Jan 3 2010 should be week 53');
- assert.equal(moment([2010, 0, 4]).week(), 1, 'Jan 4 2010 should be week 1');
- assert.equal(moment([2010, 0, 10]).week(), 1, 'Jan 10 2010 should be week 1');
- assert.equal(moment([2010, 0, 11]).week(), 2, 'Jan 11 2010 should be week 2');
-});
-
-test('weeks year starting saturday', function (assert) {
- assert.equal(moment([2010, 11, 27]).week(), 52, 'Dec 27 2010 should be week 52');
- assert.equal(moment([2011, 0, 1]).week(), 52, 'Jan 1 2011 should be week 52');
- assert.equal(moment([2011, 0, 2]).week(), 52, 'Jan 2 2011 should be week 52');
- assert.equal(moment([2011, 0, 3]).week(), 1, 'Jan 3 2011 should be week 1');
- assert.equal(moment([2011, 0, 9]).week(), 1, 'Jan 9 2011 should be week 1');
- assert.equal(moment([2011, 0, 10]).week(), 2, 'Jan 10 2011 should be week 2');
-});
-
test('weeks year starting sunday formatted', function (assert) {
assert.equal(moment([2012, 0, 1]).format('w ww wo'), '52 52 52ste', 'Jan 1 2012 should be week 52');
assert.equal(moment([2012, 0, 2]).format('w ww wo'), '1 01 1ste', 'Jan 2 2012 should be week 1');
@@ -273,38 +212,3 @@
assert.equal(moment([2012, 0, 15]).format('w ww wo'), '2 02 2de', 'Jan 15 2012 should be week 2');
});
-test('lenient ordinal parsing', function (assert) {
- var i, ordinalStr, testMoment;
- for (i = 1; i <= 31; ++i) {
- ordinalStr = moment([2014, 0, i]).format('YYYY MM Do');
- testMoment = moment(ordinalStr, 'YYYY MM Do');
- assert.equal(testMoment.year(), 2014,
- 'lenient ordinal parsing ' + i + ' year check');
- assert.equal(testMoment.month(), 0,
- 'lenient ordinal parsing ' + i + ' month check');
- assert.equal(testMoment.date(), i,
- 'lenient ordinal parsing ' + i + ' date check');
- }
-});
-
-test('lenient ordinal parsing of number', function (assert) {
- var i, testMoment;
- for (i = 1; i <= 31; ++i) {
- testMoment = moment('2014 01 ' + i, 'YYYY MM Do');
- assert.equal(testMoment.year(), 2014,
- 'lenient ordinal parsing of number ' + i + ' year check');
- assert.equal(testMoment.month(), 0,
- 'lenient ordinal parsing of number ' + i + ' month check');
- assert.equal(testMoment.date(), i,
- 'lenient ordinal parsing of number ' + i + ' date check');
- }
-});
-
-test('strict ordinal parsing', function (assert) {
- var i, ordinalStr, testMoment;
- for (i = 1; i <= 31; ++i) {
- ordinalStr = moment([2014, 0, i]).format('YYYY MM Do');
- testMoment = moment(ordinalStr, 'YYYY MM Do', true);
- assert.ok(testMoment.isValid(), 'strict ordinal parsing ' + i);
- }
-});
diff --git a/src/test/locale/nn.js b/src/test/locale/nn.js
index a928995..08b9c84 100644
--- a/src/test/locale/nn.js
+++ b/src/test/locale/nn.js
@@ -138,11 +138,11 @@
test('suffix', function (assert) {
assert.equal(moment(30000).from(0), 'om nokre sekund', 'prefix');
- assert.equal(moment(0).from(30000), 'for nokre sekund sidan', 'suffix');
+ assert.equal(moment(0).from(30000), 'nokre sekund sidan', 'suffix');
});
test('now from now', function (assert) {
- assert.equal(moment().fromNow(), 'for nokre sekund sidan', 'now from now should display as in the past');
+ assert.equal(moment().fromNow(), 'nokre sekund sidan', 'now from now should display as in the past');
});
test('fromNow', function (assert) {
@@ -151,14 +151,14 @@
});
test('calendar day', function (assert) {
- var a = moment().hours(2).minutes(0).seconds(0);
-
- assert.equal(moment(a).calendar(), 'I dag klokka 02:00', 'today at the same time');
- assert.equal(moment(a).add({m: 25}).calendar(), 'I dag klokka 02:25', 'Now plus 25 min');
- assert.equal(moment(a).add({h: 1}).calendar(), 'I dag klokka 03:00', 'Now plus 1 hour');
- assert.equal(moment(a).add({d: 1}).calendar(), 'I morgon klokka 02:00', 'tomorrow at the same time');
- assert.equal(moment(a).subtract({h: 1}).calendar(), 'I dag klokka 01:00', 'Now minus 1 hour');
- assert.equal(moment(a).subtract({d: 1}).calendar(), 'I går klokka 02:00', 'yesterday at the same time');
+ var a = moment().hours(12).minutes(0).seconds(0);
+
+ assert.equal(moment(a).calendar(), 'I dag klokka 12:00', 'today at the same time');
+ assert.equal(moment(a).add({m: 25}).calendar(), 'I dag klokka 12:25', 'Now plus 25 min');
+ assert.equal(moment(a).add({h: 1}).calendar(), 'I dag klokka 13:00', 'Now plus 1 hour');
+ assert.equal(moment(a).add({d: 1}).calendar(), 'I morgon klokka 12:00', 'tomorrow at the same time');
+ assert.equal(moment(a).subtract({h: 1}).calendar(), 'I dag klokka 11:00', 'Now minus 1 hour');
+ assert.equal(moment(a).subtract({d: 1}).calendar(), 'I går klokka 12:00', 'yesterday at the same time');
});
test('calendar next week', function (assert) {
@@ -199,67 +199,6 @@
assert.equal(weeksFromNow.calendar(), weeksFromNow.format('L'), 'in 2 weeks');
});
-test('weeks year starting sunday', function (assert) {
- assert.equal(moment([2012, 0, 1]).week(), 52, 'Jan 1 2012 should be week 52');
- assert.equal(moment([2012, 0, 2]).week(), 1, 'Jan 2 2012 should be week 1');
- assert.equal(moment([2012, 0, 8]).week(), 1, 'Jan 8 2012 should be week 1');
- assert.equal(moment([2012, 0, 9]).week(), 2, 'Jan 9 2012 should be week 2');
- assert.equal(moment([2012, 0, 15]).week(), 2, 'Jan 15 2012 should be week 2');
-});
-
-test('weeks year starting monday', function (assert) {
- assert.equal(moment([2007, 0, 1]).week(), 1, 'Jan 1 2007 should be week 1');
- assert.equal(moment([2007, 0, 7]).week(), 1, 'Jan 7 2007 should be week 1');
- assert.equal(moment([2007, 0, 8]).week(), 2, 'Jan 8 2007 should be week 2');
- assert.equal(moment([2007, 0, 14]).week(), 2, 'Jan 14 2007 should be week 2');
- assert.equal(moment([2007, 0, 15]).week(), 3, 'Jan 15 2007 should be week 3');
-});
-
-test('weeks year starting tuesday', function (assert) {
- assert.equal(moment([2007, 11, 31]).week(), 1, 'Dec 31 2007 should be week 1');
- assert.equal(moment([2008, 0, 1]).week(), 1, 'Jan 1 2008 should be week 1');
- assert.equal(moment([2008, 0, 6]).week(), 1, 'Jan 6 2008 should be week 1');
- assert.equal(moment([2008, 0, 7]).week(), 2, 'Jan 7 2008 should be week 2');
- assert.equal(moment([2008, 0, 13]).week(), 2, 'Jan 13 2008 should be week 2');
- assert.equal(moment([2008, 0, 14]).week(), 3, 'Jan 14 2008 should be week 3');
-});
-
-test('weeks year starting wednesday', function (assert) {
- assert.equal(moment([2002, 11, 30]).week(), 1, 'Dec 30 2002 should be week 1');
- assert.equal(moment([2003, 0, 1]).week(), 1, 'Jan 1 2003 should be week 1');
- assert.equal(moment([2003, 0, 5]).week(), 1, 'Jan 5 2003 should be week 1');
- assert.equal(moment([2003, 0, 6]).week(), 2, 'Jan 6 2003 should be week 2');
- assert.equal(moment([2003, 0, 12]).week(), 2, 'Jan 12 2003 should be week 2');
- assert.equal(moment([2003, 0, 13]).week(), 3, 'Jan 13 2003 should be week 3');
-});
-
-test('weeks year starting thursday', function (assert) {
- assert.equal(moment([2008, 11, 29]).week(), 1, 'Dec 29 2008 should be week 1');
- assert.equal(moment([2009, 0, 1]).week(), 1, 'Jan 1 2009 should be week 1');
- assert.equal(moment([2009, 0, 4]).week(), 1, 'Jan 4 2009 should be week 1');
- assert.equal(moment([2009, 0, 5]).week(), 2, 'Jan 5 2009 should be week 2');
- assert.equal(moment([2009, 0, 11]).week(), 2, 'Jan 11 2009 should be week 2');
- assert.equal(moment([2009, 0, 13]).week(), 3, 'Jan 12 2009 should be week 3');
-});
-
-test('weeks year starting friday', function (assert) {
- assert.equal(moment([2009, 11, 28]).week(), 53, 'Dec 28 2009 should be week 53');
- assert.equal(moment([2010, 0, 1]).week(), 53, 'Jan 1 2010 should be week 53');
- assert.equal(moment([2010, 0, 3]).week(), 53, 'Jan 3 2010 should be week 53');
- assert.equal(moment([2010, 0, 4]).week(), 1, 'Jan 4 2010 should be week 1');
- assert.equal(moment([2010, 0, 10]).week(), 1, 'Jan 10 2010 should be week 1');
- assert.equal(moment([2010, 0, 11]).week(), 2, 'Jan 11 2010 should be week 2');
-});
-
-test('weeks year starting saturday', function (assert) {
- assert.equal(moment([2010, 11, 27]).week(), 52, 'Dec 27 2010 should be week 52');
- assert.equal(moment([2011, 0, 1]).week(), 52, 'Jan 1 2011 should be week 52');
- assert.equal(moment([2011, 0, 2]).week(), 52, 'Jan 2 2011 should be week 52');
- assert.equal(moment([2011, 0, 3]).week(), 1, 'Jan 3 2011 should be week 1');
- assert.equal(moment([2011, 0, 9]).week(), 1, 'Jan 9 2011 should be week 1');
- assert.equal(moment([2011, 0, 10]).week(), 2, 'Jan 10 2011 should be week 2');
-});
-
test('weeks year starting sunday formatted', function (assert) {
assert.equal(moment([2012, 0, 1]).format('w ww wo'), '52 52 52.', 'Jan 1 2012 should be week 52');
assert.equal(moment([2012, 0, 2]).format('w ww wo'), '1 01 1.', 'Jan 2 2012 should be week 1');
@@ -268,38 +207,3 @@
assert.equal(moment([2012, 0, 15]).format('w ww wo'), '2 02 2.', 'Jan 15 2012 should be week 2');
});
-test('lenient ordinal parsing', function (assert) {
- var i, ordinalStr, testMoment;
- for (i = 1; i <= 31; ++i) {
- ordinalStr = moment([2014, 0, i]).format('YYYY MM Do');
- testMoment = moment(ordinalStr, 'YYYY MM Do');
- assert.equal(testMoment.year(), 2014,
- 'lenient ordinal parsing ' + i + ' year check');
- assert.equal(testMoment.month(), 0,
- 'lenient ordinal parsing ' + i + ' month check');
- assert.equal(testMoment.date(), i,
- 'lenient ordinal parsing ' + i + ' date check');
- }
-});
-
-test('lenient ordinal parsing of number', function (assert) {
- var i, testMoment;
- for (i = 1; i <= 31; ++i) {
- testMoment = moment('2014 01 ' + i, 'YYYY MM Do');
- assert.equal(testMoment.year(), 2014,
- 'lenient ordinal parsing of number ' + i + ' year check');
- assert.equal(testMoment.month(), 0,
- 'lenient ordinal parsing of number ' + i + ' month check');
- assert.equal(testMoment.date(), i,
- 'lenient ordinal parsing of number ' + i + ' date check');
- }
-});
-
-test('strict ordinal parsing', function (assert) {
- var i, ordinalStr, testMoment;
- for (i = 1; i <= 31; ++i) {
- ordinalStr = moment([2014, 0, i]).format('YYYY MM Do');
- testMoment = moment(ordinalStr, 'YYYY MM Do', true);
- assert.ok(testMoment.isValid(), 'strict ordinal parsing ' + i);
- }
-});
diff --git a/src/test/locale/pa-in.js b/src/test/locale/pa-in.js
new file mode 100644
index 0000000..73f45a9
--- /dev/null
+++ b/src/test/locale/pa-in.js
@@ -0,0 +1,321 @@
+import {localeModule, test} from '../qunit';
+import moment from '../../moment';
+localeModule('pa-in');
+
+test('parse', function (assert) {
+ var tests = 'ਜਨਵਰੀ ਜਨਵਰੀ_ਫ਼ਰਵਰੀ ਫ਼ਰਵਰੀ_ਮਾਰਚ ਮਾਰਚ_ਅਪ੍ਰੈਲ ਅਪ੍ਰੈਲ_ਮਈ ਮਈ_ਜੂਨ ਜੂਨ_ਜੁਲਾਈ ਜੁਲਾਈ_ਅਗਸਤ ਅਗਸਤ_ਸਤੰਬਰ ਸਤੰਬਰ_ਅਕਤੂਬਰ ਅਕਤੂਬਰ_ਨਵੰਬਰ ਨਵੰਬਰ_ਦਸੰਬਰ ਦਸੰਬਰ'.split('_'), i;
+ function equalTest(input, mmm, i) {
+ assert.equal(moment(input, mmm).month(), i, input + ' should be month ' + (i + 1));
+ }
+ for (i = 0; i < 12; i++) {
+ tests[i] = tests[i].split(' ');
+ equalTest(tests[i][0], 'MMM', i);
+ equalTest(tests[i][1], 'MMM', i);
+ equalTest(tests[i][0], 'MMMM', i);
+ equalTest(tests[i][1], 'MMMM', i);
+ equalTest(tests[i][0].toLocaleLowerCase(), 'MMMM', i);
+ equalTest(tests[i][1].toLocaleLowerCase(), 'MMMM', i);
+ equalTest(tests[i][0].toLocaleUpperCase(), 'MMMM', i);
+ equalTest(tests[i][1].toLocaleUpperCase(), 'MMMM', i);
+ }
+});
+
+test('format', function (assert) {
+ var a = [
+ ['dddd, Do MMMM YYYY, a h:mm:ss ਵਜੇ', 'ਐਤਵਾਰ, ੧੪ ਫ਼ਰਵਰੀ ੨੦੧੦, ਦੁਪਹਿਰ ੩:੨੫:੫੦ ਵਜੇ'],
+ ['ddd, a h ਵਜੇ', 'ਐਤ, ਦੁਪਹਿਰ ੩ ਵਜੇ'],
+ ['M Mo MM MMMM MMM', '੨ ੨ ੦੨ ਫ਼ਰਵਰੀ ਫ਼ਰਵਰੀ'],
+ ['YYYY YY', '੨੦੧੦ ੧੦'],
+ ['D Do DD', '੧੪ ੧੪ ੧੪'],
+ ['d do dddd ddd dd', '੦ ੦ ਐਤਵਾਰ ਐਤ ਐਤ'],
+ ['DDD DDDo DDDD', '੪੫ ੪੫ ੦੪੫'],
+ ['w wo ww', '੮ ੮ ੦੮'],
+ ['h hh', '੩ ੦੩'],
+ ['H HH', '੧੫ ੧੫'],
+ ['m mm', '੨੫ ੨੫'],
+ ['s ss', '੫੦ ੫੦'],
+ ['a A', 'ਦੁਪਹਿਰ ਦੁਪਹਿਰ'],
+ ['LTS', 'ਦੁਪਹਿਰ ੩:੨੫:੫੦ ਵਜੇ'],
+ ['L', '੧੪/੦੨/੨੦੧੦'],
+ ['LL', '੧੪ ਫ਼ਰਵਰੀ ੨੦੧੦'],
+ ['LLL', '੧੪ ਫ਼ਰਵਰੀ ੨੦੧੦, ਦੁਪਹਿਰ ੩:੨੫ ਵਜੇ'],
+ ['LLLL', 'ਐਤਵਾਰ, ੧੪ ਫ਼ਰਵਰੀ ੨੦੧੦, ਦੁਪਹਿਰ ੩:੨੫ ਵਜੇ'],
+ ['l', '੧੪/੨/੨੦੧੦'],
+ ['ll', '੧੪ ਫ਼ਰਵਰੀ ੨੦੧੦'],
+ ['lll', '੧੪ ਫ਼ਰਵਰੀ ੨੦੧੦, ਦੁਪਹਿਰ ੩:੨੫ ਵਜੇ'],
+ ['llll', 'ਐਤ, ੧੪ ਫ਼ਰਵਰੀ ੨੦੧੦, ਦੁਪਹਿਰ ੩:੨੫ ਵਜੇ']
+ ],
+ b = moment(new Date(2010, 1, 14, 15, 25, 50, 125)),
+ i;
+ for (i = 0; i < a.length; i++) {
+ assert.equal(b.format(a[i][0]), a[i][1], a[i][0] + ' ---> ' + a[i][1]);
+ }
+});
+
+test('format ordinal', function (assert) {
+ assert.equal(moment([2011, 0, 1]).format('DDDo'), '੧', '੧');
+ assert.equal(moment([2011, 0, 2]).format('DDDo'), '੨', '੨');
+ assert.equal(moment([2011, 0, 3]).format('DDDo'), '੩', '੩');
+ assert.equal(moment([2011, 0, 4]).format('DDDo'), '੪', '੪');
+ assert.equal(moment([2011, 0, 5]).format('DDDo'), '੫', '੫');
+ assert.equal(moment([2011, 0, 6]).format('DDDo'), '੬', '੬');
+ assert.equal(moment([2011, 0, 7]).format('DDDo'), '੭', '੭');
+ assert.equal(moment([2011, 0, 8]).format('DDDo'), '੮', '੮');
+ assert.equal(moment([2011, 0, 9]).format('DDDo'), '੯', '੯');
+ assert.equal(moment([2011, 0, 10]).format('DDDo'), '੧੦', '੧੦');
+
+ assert.equal(moment([2011, 0, 11]).format('DDDo'), '੧੧', '੧੧');
+ assert.equal(moment([2011, 0, 12]).format('DDDo'), '੧੨', '੧੨');
+ assert.equal(moment([2011, 0, 13]).format('DDDo'), '੧੩', '੧੩');
+ assert.equal(moment([2011, 0, 14]).format('DDDo'), '੧੪', '੧੪');
+ assert.equal(moment([2011, 0, 15]).format('DDDo'), '੧੫', '੧੫');
+ assert.equal(moment([2011, 0, 16]).format('DDDo'), '੧੬', '੧੬');
+ assert.equal(moment([2011, 0, 17]).format('DDDo'), '੧੭', '੧੭');
+ assert.equal(moment([2011, 0, 18]).format('DDDo'), '੧੮', '੧੮');
+ assert.equal(moment([2011, 0, 19]).format('DDDo'), '੧੯', '੧੯');
+ assert.equal(moment([2011, 0, 20]).format('DDDo'), '੨੦', '੨੦');
+
+ assert.equal(moment([2011, 0, 21]).format('DDDo'), '੨੧', '੨੧');
+ assert.equal(moment([2011, 0, 22]).format('DDDo'), '੨੨', '੨੨');
+ assert.equal(moment([2011, 0, 23]).format('DDDo'), '੨੩', '੨੩');
+ assert.equal(moment([2011, 0, 24]).format('DDDo'), '੨੪', '੨੪');
+ assert.equal(moment([2011, 0, 25]).format('DDDo'), '੨੫', '੨੫');
+ assert.equal(moment([2011, 0, 26]).format('DDDo'), '੨੬', '੨੬');
+ assert.equal(moment([2011, 0, 27]).format('DDDo'), '੨੭', '੨੭');
+ assert.equal(moment([2011, 0, 28]).format('DDDo'), '੨੮', '੨੮');
+ assert.equal(moment([2011, 0, 29]).format('DDDo'), '੨੯', '੨੯');
+ assert.equal(moment([2011, 0, 30]).format('DDDo'), '੩੦', '੩੦');
+
+ assert.equal(moment([2011, 0, 31]).format('DDDo'), '੩੧', '੩੧');
+});
+
+test('format month', function (assert) {
+ var expected = 'ਜਨਵਰੀ ਜਨਵਰੀ_ਫ਼ਰਵਰੀ ਫ਼ਰਵਰੀ_ਮਾਰਚ ਮਾਰਚ_ਅਪ੍ਰੈਲ ਅਪ੍ਰੈਲ_ਮਈ ਮਈ_ਜੂਨ ਜੂਨ_ਜੁਲਾਈ ਜੁਲਾਈ_ਅਗਸਤ ਅਗਸਤ_ਸਤੰਬਰ ਸਤੰਬਰ_ਅਕਤੂਬਰ ਅਕਤੂਬਰ_ਨਵੰਬਰ ਨਵੰਬਰ_ਦਸੰਬਰ ਦਸੰਬਰ'.split('_'), i;
+ for (i = 0; i < expected.length; i++) {
+ assert.equal(moment([2011, i, 1]).format('MMMM MMM'), expected[i], expected[i]);
+ }
+});
+
+test('format week', function (assert) {
+ var expected = 'ਐਤਵਾਰ ਐਤ ਐਤ_ਸੋਮਵਾਰ ਸੋਮ ਸੋਮ_ਮੰਗਲਵਾਰ ਮੰਗਲ ਮੰਗਲ_ਬੁਧਵਾਰ ਬੁਧ ਬੁਧ_ਵੀਰਵਾਰ ਵੀਰ ਵੀਰ_ਸ਼ੁੱਕਰਵਾਰ ਸ਼ੁਕਰ ਸ਼ੁਕਰ_ਸ਼ਨੀਚਰਵਾਰ ਸ਼ਨੀ ਸ਼ਨੀ'.split('_'), i;
+ for (i = 0; i < expected.length; i++) {
+ assert.equal(moment([2011, 0, 2 + i]).format('dddd ddd dd'), expected[i], expected[i]);
+ }
+});
+
+test('from', function (assert) {
+ var start = moment([2007, 1, 28]);
+ assert.equal(start.from(moment([2007, 1, 28]).add({s: 44}), true), 'ਕੁਝ ਸਕਿੰਟ', '44 seconds = a few seconds');
+ assert.equal(start.from(moment([2007, 1, 28]).add({s: 45}), true), 'ਇਕ ਮਿੰਟ', '45 seconds = a minute');
+ assert.equal(start.from(moment([2007, 1, 28]).add({s: 89}), true), 'ਇਕ ਮਿੰਟ', '89 seconds = a minute');
+ assert.equal(start.from(moment([2007, 1, 28]).add({s: 90}), true), '੨ ਮਿੰਟ', '90 seconds = 2 minutes');
+ assert.equal(start.from(moment([2007, 1, 28]).add({m: 44}), true), '੪੪ ਮਿੰਟ', '44 minutes = 44 minutes');
+ assert.equal(start.from(moment([2007, 1, 28]).add({m: 45}), true), 'ਇੱਕ ਘੰਟਾ', '45 minutes = an hour');
+ assert.equal(start.from(moment([2007, 1, 28]).add({m: 89}), true), 'ਇੱਕ ਘੰਟਾ', '89 minutes = an hour');
+ assert.equal(start.from(moment([2007, 1, 28]).add({m: 90}), true), '੨ ਘੰਟੇ', '90 minutes = 2 hours');
+ assert.equal(start.from(moment([2007, 1, 28]).add({h: 5}), true), '੫ ਘੰਟੇ', '5 hours = 5 hours');
+ assert.equal(start.from(moment([2007, 1, 28]).add({h: 21}), true), '੨੧ ਘੰਟੇ', '21 hours = 21 hours');
+ assert.equal(start.from(moment([2007, 1, 28]).add({h: 22}), true), 'ਇੱਕ ਦਿਨ', '22 hours = a day');
+ assert.equal(start.from(moment([2007, 1, 28]).add({h: 35}), true), 'ਇੱਕ ਦਿਨ', '35 hours = a day');
+ assert.equal(start.from(moment([2007, 1, 28]).add({h: 36}), true), '੨ ਦਿਨ', '36 hours = 2 days');
+ assert.equal(start.from(moment([2007, 1, 28]).add({d: 1}), true), 'ਇੱਕ ਦਿਨ', '1 day = a day');
+ assert.equal(start.from(moment([2007, 1, 28]).add({d: 5}), true), '੫ ਦਿਨ', '5 days = 5 days');
+ assert.equal(start.from(moment([2007, 1, 28]).add({d: 25}), true), '੨੫ ਦਿਨ', '25 days = 25 days');
+ assert.equal(start.from(moment([2007, 1, 28]).add({d: 26}), true), 'ਇੱਕ ਮਹੀਨਾ', '26 days = a month');
+ assert.equal(start.from(moment([2007, 1, 28]).add({d: 30}), true), 'ਇੱਕ ਮਹੀਨਾ', '30 days = a month');
+ assert.equal(start.from(moment([2007, 1, 28]).add({d: 43}), true), 'ਇੱਕ ਮਹੀਨਾ', '43 days = a month');
+ assert.equal(start.from(moment([2007, 1, 28]).add({d: 46}), true), '੨ ਮਹੀਨੇ', '46 days = 2 months');
+ assert.equal(start.from(moment([2007, 1, 28]).add({d: 74}), true), '੨ ਮਹੀਨੇ', '75 days = 2 months');
+ assert.equal(start.from(moment([2007, 1, 28]).add({d: 76}), true), '੩ ਮਹੀਨੇ', '76 days = 3 months');
+ assert.equal(start.from(moment([2007, 1, 28]).add({M: 1}), true), 'ਇੱਕ ਮਹੀਨਾ', '1 month = a month');
+ assert.equal(start.from(moment([2007, 1, 28]).add({M: 5}), true), '੫ ਮਹੀਨੇ', '5 months = 5 months');
+ assert.equal(start.from(moment([2007, 1, 28]).add({d: 345}), true), 'ਇੱਕ ਸਾਲ', '345 days = a year');
+ assert.equal(start.from(moment([2007, 1, 28]).add({d: 548}), true), '੨ ਸਾਲ', '548 days = 2 years');
+ assert.equal(start.from(moment([2007, 1, 28]).add({y: 1}), true), 'ਇੱਕ ਸਾਲ', '1 year = a year');
+ assert.equal(start.from(moment([2007, 1, 28]).add({y: 5}), true), '੫ ਸਾਲ', '5 years = 5 years');
+});
+
+test('suffix', function (assert) {
+ assert.equal(moment(30000).from(0), 'ਕੁਝ ਸਕਿੰਟ ਵਿੱਚ', 'prefix');
+ assert.equal(moment(0).from(30000), 'ਕੁਝ ਸਕਿੰਟ ਪਿਛਲੇ', 'suffix');
+});
+
+test('now from now', function (assert) {
+ assert.equal(moment().fromNow(), 'ਕੁਝ ਸਕਿੰਟ ਪਿਛਲੇ', 'now from now should display as in the past');
+});
+
+test('fromNow', function (assert) {
+ assert.equal(moment().add({s: 30}).fromNow(), 'ਕੁਝ ਸਕਿੰਟ ਵਿੱਚ', 'ਕੁਝ ਸਕਿੰਟ ਵਿੱਚ');
+ assert.equal(moment().add({d: 5}).fromNow(), '੫ ਦਿਨ ਵਿੱਚ', '੫ ਦਿਨ ਵਿੱਚ');
+});
+
+test('calendar day', function (assert) {
+ var a = moment().hours(12).minutes(0).seconds(0);
+
+ assert.equal(moment(a).calendar(), 'ਅਜ ਦੁਪਹਿਰ ੧੨:੦੦ ਵਜੇ', 'today at the same time');
+ assert.equal(moment(a).add({m: 25}).calendar(), 'ਅਜ ਦੁਪਹਿਰ ੧੨:੨੫ ਵਜੇ', 'Now plus 25 min');
+ assert.equal(moment(a).add({h: 3}).calendar(), 'ਅਜ ਦੁਪਹਿਰ ੩:੦੦ ਵਜੇ', 'Now plus 3 hours');
+ assert.equal(moment(a).add({d: 1}).calendar(), 'ਕਲ ਦੁਪਹਿਰ ੧੨:੦੦ ਵਜੇ', 'tomorrow at the same time');
+ assert.equal(moment(a).subtract({h: 1}).calendar(), 'ਅਜ ਦੁਪਹਿਰ ੧੧:੦੦ ਵਜੇ', 'Now minus 1 hour');
+ assert.equal(moment(a).subtract({d: 1}).calendar(), 'ਕਲ ਦੁਪਹਿਰ ੧੨:੦੦ ਵਜੇ', 'yesterday at the same time');
+});
+
+test('calendar next week', function (assert) {
+ var i, m;
+ for (i = 2; i < 7; i++) {
+ m = moment().add({d: i});
+ assert.equal(m.calendar(), m.format('dddd[,] LT'), 'Today + ' + i + ' days current time');
+ m.hours(0).minutes(0).seconds(0).milliseconds(0);
+ assert.equal(m.calendar(), m.format('dddd[,] LT'), 'Today + ' + i + ' days beginning of day');
+ m.hours(23).minutes(59).seconds(59).milliseconds(999);
+ assert.equal(m.calendar(), m.format('dddd[,] LT'), 'Today + ' + i + ' days end of day');
+ }
+});
+
+test('calendar last week', function (assert) {
+ var i, m;
+
+ for (i = 2; i < 7; i++) {
+ m = moment().subtract({d: i});
+ assert.equal(m.calendar(), m.format('[ਪਿਛਲੇ] dddd[,] LT'), 'Today - ' + i + ' days current time');
+ m.hours(0).minutes(0).seconds(0).milliseconds(0);
+ assert.equal(m.calendar(), m.format('[ਪਿਛਲੇ] dddd[,] LT'), 'Today - ' + i + ' days beginning of day');
+ m.hours(23).minutes(59).seconds(59).milliseconds(999);
+ assert.equal(m.calendar(), m.format('[ਪਿਛਲੇ] dddd[,] LT'), 'Today - ' + i + ' days end of day');
+ }
+});
+
+test('calendar all else', function (assert) {
+ var weeksAgo = moment().subtract({w: 1}),
+ weeksFromNow = moment().add({w: 1});
+
+ assert.equal(weeksAgo.calendar(), weeksAgo.format('L'), '1 week ago');
+ assert.equal(weeksFromNow.calendar(), weeksFromNow.format('L'), 'in 1 week');
+
+ weeksAgo = moment().subtract({w: 2});
+ weeksFromNow = moment().add({w: 2});
+
+ assert.equal(weeksAgo.calendar(), weeksAgo.format('L'), '2 weeks ago');
+ assert.equal(weeksFromNow.calendar(), weeksFromNow.format('L'), 'in 2 weeks');
+});
+
+test('meridiem invariant', function (assert) {
+ assert.equal(moment([2011, 2, 23, 2, 30]).format('a'), 'ਰਾਤ', 'before dawn');
+ assert.equal(moment([2011, 2, 23, 9, 30]).format('a'), 'ਸਵੇਰ', 'morning');
+ assert.equal(moment([2011, 2, 23, 14, 30]).format('a'), 'ਦੁਪਹਿਰ', 'during day');
+ assert.equal(moment([2011, 2, 23, 17, 30]).format('a'), 'ਸ਼ਾਮ', 'evening');
+ assert.equal(moment([2011, 2, 23, 19, 30]).format('a'), 'ਸ਼ਾਮ', 'late evening');
+ assert.equal(moment([2011, 2, 23, 21, 20]).format('a'), 'ਰਾਤ', 'night');
+
+ assert.equal(moment([2011, 2, 23, 2, 30]).format('A'), 'ਰਾਤ', 'before dawn');
+ assert.equal(moment([2011, 2, 23, 9, 30]).format('A'), 'ਸਵੇਰ', 'morning');
+ assert.equal(moment([2011, 2, 23, 14, 30]).format('A'), 'ਦੁਪਹਿਰ', ' during day');
+ assert.equal(moment([2011, 2, 23, 17, 30]).format('A'), 'ਸ਼ਾਮ', 'evening');
+ assert.equal(moment([2011, 2, 23, 19, 30]).format('A'), 'ਸ਼ਾਮ', 'late evening');
+ assert.equal(moment([2011, 2, 23, 21, 20]).format('A'), 'ਰਾਤ', 'night');
+});
+
+test('weeks year starting sunday', function (assert) {
+ assert.equal(moment([2012, 0, 1]).week(), 1, 'Jan 1 2012 should be week 1');
+ assert.equal(moment([2012, 0, 7]).week(), 1, 'Jan 7 2012 should be week 1');
+ assert.equal(moment([2012, 0, 8]).week(), 2, 'Jan 8 2012 should be week 2');
+ assert.equal(moment([2012, 0, 14]).week(), 2, 'Jan 14 2012 should be week 2');
+ assert.equal(moment([2012, 0, 15]).week(), 3, 'Jan 15 2012 should be week 3');
+});
+
+test('weeks year starting monday', function (assert) {
+ assert.equal(moment([2006, 11, 31]).week(), 1, 'Dec 31 2006 should be week 1');
+ assert.equal(moment([2007, 0, 1]).week(), 1, 'Jan 1 2007 should be week 1');
+ assert.equal(moment([2007, 0, 6]).week(), 1, 'Jan 6 2007 should be week 1');
+ assert.equal(moment([2007, 0, 7]).week(), 2, 'Jan 7 2007 should be week 2');
+ assert.equal(moment([2007, 0, 13]).week(), 2, 'Jan 13 2007 should be week 2');
+ assert.equal(moment([2007, 0, 14]).week(), 3, 'Jan 14 2007 should be week 3');
+});
+
+test('weeks year starting tuesday', function (assert) {
+ assert.equal(moment([2007, 11, 29]).week(), 52, 'Dec 29 2007 should be week 52');
+ assert.equal(moment([2008, 0, 1]).week(), 1, 'Jan 1 2008 should be week 1');
+ assert.equal(moment([2008, 0, 5]).week(), 1, 'Jan 5 2008 should be week 1');
+ assert.equal(moment([2008, 0, 6]).week(), 2, 'Jan 6 2008 should be week 2');
+ assert.equal(moment([2008, 0, 12]).week(), 2, 'Jan 12 2008 should be week 2');
+ assert.equal(moment([2008, 0, 13]).week(), 3, 'Jan 13 2008 should be week 3');
+});
+
+test('weeks year starting wednesday', function (assert) {
+ assert.equal(moment([2002, 11, 29]).week(), 1, 'Dec 29 2002 should be week 1');
+ assert.equal(moment([2003, 0, 1]).week(), 1, 'Jan 1 2003 should be week 1');
+ assert.equal(moment([2003, 0, 4]).week(), 1, 'Jan 4 2003 should be week 1');
+ assert.equal(moment([2003, 0, 5]).week(), 2, 'Jan 5 2003 should be week 2');
+ assert.equal(moment([2003, 0, 11]).week(), 2, 'Jan 11 2003 should be week 2');
+ assert.equal(moment([2003, 0, 12]).week(), 3, 'Jan 12 2003 should be week 3');
+});
+
+test('weeks year starting thursday', function (assert) {
+ assert.equal(moment([2008, 11, 28]).week(), 1, 'Dec 28 2008 should be week 1');
+ assert.equal(moment([2009, 0, 1]).week(), 1, 'Jan 1 2009 should be week 1');
+ assert.equal(moment([2009, 0, 3]).week(), 1, 'Jan 3 2009 should be week 1');
+ assert.equal(moment([2009, 0, 4]).week(), 2, 'Jan 4 2009 should be week 2');
+ assert.equal(moment([2009, 0, 10]).week(), 2, 'Jan 10 2009 should be week 2');
+ assert.equal(moment([2009, 0, 11]).week(), 3, 'Jan 11 2009 should be week 3');
+});
+
+test('weeks year starting friday', function (assert) {
+ assert.equal(moment([2009, 11, 27]).week(), 1, 'Dec 27 2009 should be week 1');
+ assert.equal(moment([2010, 0, 1]).week(), 1, 'Jan 1 2010 should be week 1');
+ assert.equal(moment([2010, 0, 2]).week(), 1, 'Jan 2 2010 should be week 1');
+ assert.equal(moment([2010, 0, 3]).week(), 2, 'Jan 3 2010 should be week 2');
+ assert.equal(moment([2010, 0, 9]).week(), 2, 'Jan 9 2010 should be week 2');
+ assert.equal(moment([2010, 0, 10]).week(), 3, 'Jan 10 2010 should be week 3');
+});
+
+test('weeks year starting saturday', function (assert) {
+ assert.equal(moment([2010, 11, 26]).week(), 1, 'Dec 26 2010 should be week 1');
+ assert.equal(moment([2011, 0, 1]).week(), 1, 'Jan 1 2011 should be week 1');
+ assert.equal(moment([2011, 0, 2]).week(), 2, 'Jan 2 2011 should be week 2');
+ assert.equal(moment([2011, 0, 8]).week(), 2, 'Jan 8 2011 should be week 2');
+ assert.equal(moment([2011, 0, 9]).week(), 3, 'Jan 9 2011 should be week 3');
+});
+
+test('weeks year starting sunday formatted', function (assert) {
+ assert.equal(moment([2012, 0, 1]).format('w ww wo'), '੧ ੦੧ ੧', 'Jan 1 2012 should be week 1');
+ assert.equal(moment([2012, 0, 7]).format('w ww wo'), '੧ ੦੧ ੧', 'Jan 7 2012 should be week 1');
+ assert.equal(moment([2012, 0, 8]).format('w ww wo'), '੨ ੦੨ ੨', 'Jan 8 2012 should be week 2');
+ assert.equal(moment([2012, 0, 14]).format('w ww wo'), '੨ ੦੨ ੨', 'Jan 14 2012 should be week 2');
+ assert.equal(moment([2012, 0, 15]).format('w ww wo'), '੩ ੦੩ ੩', 'Jan 15 2012 should be week 3');
+});
+
+test('lenient ordinal parsing', function (assert) {
+ var i, ordinalStr, testMoment;
+ for (i = 1; i <= 31; ++i) {
+ ordinalStr = moment([2014, 0, i]).format('YYYY MM Do');
+ testMoment = moment(ordinalStr, 'YYYY MM Do');
+ assert.equal(testMoment.year(), 2014,
+ 'lenient ordinal parsing ' + i + ' year check');
+ assert.equal(testMoment.month(), 0,
+ 'lenient ordinal parsing ' + i + ' month check');
+ assert.equal(testMoment.date(), i,
+ 'lenient ordinal parsing ' + i + ' date check');
+ }
+});
+
+test('lenient ordinal parsing of number', function (assert) {
+ var i, testMoment;
+ for (i = 1; i <= 31; ++i) {
+ testMoment = moment('2014 01 ' + i, 'YYYY MM Do');
+ assert.equal(testMoment.year(), 2014,
+ 'lenient ordinal parsing of number ' + i + ' year check');
+ assert.equal(testMoment.month(), 0,
+ 'lenient ordinal parsing of number ' + i + ' month check');
+ assert.equal(testMoment.date(), i,
+ 'lenient ordinal parsing of number ' + i + ' date check');
+ }
+});
+
+test('strict ordinal parsing', function (assert) {
+ var i, ordinalStr, testMoment;
+ for (i = 1; i <= 31; ++i) {
+ ordinalStr = moment([2014, 0, i]).format('YYYY MM Do');
+ testMoment = moment(ordinalStr, 'YYYY MM Do', true);
+ assert.ok(testMoment.isValid(), 'strict ordinal parsing ' + i);
+ }
+});
diff --git a/src/test/locale/pl.js b/src/test/locale/pl.js
index adff3ac..e35d0a6 100644
--- a/src/test/locale/pl.js
+++ b/src/test/locale/pl.js
@@ -179,14 +179,14 @@
});
test('calendar day', function (assert) {
- var a = moment().hours(2).minutes(0).seconds(0);
-
- assert.equal(moment(a).calendar(), 'Dziś o 02:00', 'today at the same time');
- assert.equal(moment(a).add({m: 25}).calendar(), 'Dziś o 02:25', 'Now plus 25 min');
- assert.equal(moment(a).add({h: 1}).calendar(), 'Dziś o 03:00', 'Now plus 1 hour');
- assert.equal(moment(a).add({d: 1}).calendar(), 'Jutro o 02:00', 'tomorrow at the same time');
- assert.equal(moment(a).subtract({h: 1}).calendar(), 'Dziś o 01:00', 'Now minus 1 hour');
- assert.equal(moment(a).subtract({d: 1}).calendar(), 'Wczoraj o 02:00', 'yesterday at the same time');
+ var a = moment().hours(12).minutes(0).seconds(0);
+
+ assert.equal(moment(a).calendar(), 'Dziś o 12:00', 'today at the same time');
+ assert.equal(moment(a).add({m: 25}).calendar(), 'Dziś o 12:25', 'Now plus 25 min');
+ assert.equal(moment(a).add({h: 1}).calendar(), 'Dziś o 13:00', 'Now plus 1 hour');
+ assert.equal(moment(a).add({d: 1}).calendar(), 'Jutro o 12:00', 'tomorrow at the same time');
+ assert.equal(moment(a).subtract({h: 1}).calendar(), 'Dziś o 11:00', 'Now minus 1 hour');
+ assert.equal(moment(a).subtract({d: 1}).calendar(), 'Wczoraj o 12:00', 'yesterday at the same time');
});
test('calendar next week', function (assert) {
@@ -243,67 +243,6 @@
assert.equal(weeksFromNow.calendar(), weeksFromNow.format('L'), 'in 2 weeks');
});
-test('weeks year starting sunday', function (assert) {
- assert.equal(moment([2012, 0, 1]).week(), 52, 'Jan 1 2012 should be week 52');
- assert.equal(moment([2012, 0, 2]).week(), 1, 'Jan 2 2012 should be week 1');
- assert.equal(moment([2012, 0, 8]).week(), 1, 'Jan 8 2012 should be week 1');
- assert.equal(moment([2012, 0, 9]).week(), 2, 'Jan 9 2012 should be week 2');
- assert.equal(moment([2012, 0, 15]).week(), 2, 'Jan 15 2012 should be week 2');
-});
-
-test('weeks year starting monday', function (assert) {
- assert.equal(moment([2007, 0, 1]).week(), 1, 'Jan 1 2007 should be week 1');
- assert.equal(moment([2007, 0, 7]).week(), 1, 'Jan 7 2007 should be week 1');
- assert.equal(moment([2007, 0, 8]).week(), 2, 'Jan 8 2007 should be week 2');
- assert.equal(moment([2007, 0, 14]).week(), 2, 'Jan 14 2007 should be week 2');
- assert.equal(moment([2007, 0, 15]).week(), 3, 'Jan 15 2007 should be week 3');
-});
-
-test('weeks year starting tuesday', function (assert) {
- assert.equal(moment([2007, 11, 31]).week(), 1, 'Dec 31 2007 should be week 1');
- assert.equal(moment([2008, 0, 1]).week(), 1, 'Jan 1 2008 should be week 1');
- assert.equal(moment([2008, 0, 6]).week(), 1, 'Jan 6 2008 should be week 1');
- assert.equal(moment([2008, 0, 7]).week(), 2, 'Jan 7 2008 should be week 2');
- assert.equal(moment([2008, 0, 13]).week(), 2, 'Jan 13 2008 should be week 2');
- assert.equal(moment([2008, 0, 14]).week(), 3, 'Jan 14 2008 should be week 3');
-});
-
-test('weeks year starting wednesday', function (assert) {
- assert.equal(moment([2002, 11, 30]).week(), 1, 'Dec 30 2002 should be week 1');
- assert.equal(moment([2003, 0, 1]).week(), 1, 'Jan 1 2003 should be week 1');
- assert.equal(moment([2003, 0, 5]).week(), 1, 'Jan 5 2003 should be week 1');
- assert.equal(moment([2003, 0, 6]).week(), 2, 'Jan 6 2003 should be week 2');
- assert.equal(moment([2003, 0, 12]).week(), 2, 'Jan 12 2003 should be week 2');
- assert.equal(moment([2003, 0, 13]).week(), 3, 'Jan 13 2003 should be week 3');
-});
-
-test('weeks year starting thursday', function (assert) {
- assert.equal(moment([2008, 11, 29]).week(), 1, 'Dec 29 2008 should be week 1');
- assert.equal(moment([2009, 0, 1]).week(), 1, 'Jan 1 2009 should be week 1');
- assert.equal(moment([2009, 0, 4]).week(), 1, 'Jan 4 2009 should be week 1');
- assert.equal(moment([2009, 0, 5]).week(), 2, 'Jan 5 2009 should be week 2');
- assert.equal(moment([2009, 0, 11]).week(), 2, 'Jan 11 2009 should be week 2');
- assert.equal(moment([2009, 0, 13]).week(), 3, 'Jan 12 2009 should be week 3');
-});
-
-test('weeks year starting friday', function (assert) {
- assert.equal(moment([2009, 11, 28]).week(), 53, 'Dec 28 2009 should be week 53');
- assert.equal(moment([2010, 0, 1]).week(), 53, 'Jan 1 2010 should be week 53');
- assert.equal(moment([2010, 0, 3]).week(), 53, 'Jan 3 2010 should be week 53');
- assert.equal(moment([2010, 0, 4]).week(), 1, 'Jan 4 2010 should be week 1');
- assert.equal(moment([2010, 0, 10]).week(), 1, 'Jan 10 2010 should be week 1');
- assert.equal(moment([2010, 0, 11]).week(), 2, 'Jan 11 2010 should be week 2');
-});
-
-test('weeks year starting saturday', function (assert) {
- assert.equal(moment([2010, 11, 27]).week(), 52, 'Dec 27 2010 should be week 52');
- assert.equal(moment([2011, 0, 1]).week(), 52, 'Jan 1 2011 should be week 52');
- assert.equal(moment([2011, 0, 2]).week(), 52, 'Jan 2 2011 should be week 52');
- assert.equal(moment([2011, 0, 3]).week(), 1, 'Jan 3 2011 should be week 1');
- assert.equal(moment([2011, 0, 9]).week(), 1, 'Jan 9 2011 should be week 1');
- assert.equal(moment([2011, 0, 10]).week(), 2, 'Jan 10 2011 should be week 2');
-});
-
test('weeks year starting sunday formatted', function (assert) {
assert.equal(moment([2012, 0, 1]).format('w ww wo'), '52 52 52.', 'Jan 1 2012 should be week 52');
assert.equal(moment([2012, 0, 2]).format('w ww wo'), '1 01 1.', 'Jan 2 2012 should be week 1');
@@ -312,38 +251,3 @@
assert.equal(moment([2012, 0, 15]).format('w ww wo'), '2 02 2.', 'Jan 15 2012 should be week 2');
});
-test('lenient ordinal parsing', function (assert) {
- var i, ordinalStr, testMoment;
- for (i = 1; i <= 31; ++i) {
- ordinalStr = moment([2014, 0, i]).format('YYYY MM Do');
- testMoment = moment(ordinalStr, 'YYYY MM Do');
- assert.equal(testMoment.year(), 2014,
- 'lenient ordinal parsing ' + i + ' year check');
- assert.equal(testMoment.month(), 0,
- 'lenient ordinal parsing ' + i + ' month check');
- assert.equal(testMoment.date(), i,
- 'lenient ordinal parsing ' + i + ' date check');
- }
-});
-
-test('lenient ordinal parsing of number', function (assert) {
- var i, testMoment;
- for (i = 1; i <= 31; ++i) {
- testMoment = moment('2014 01 ' + i, 'YYYY MM Do');
- assert.equal(testMoment.year(), 2014,
- 'lenient ordinal parsing of number ' + i + ' year check');
- assert.equal(testMoment.month(), 0,
- 'lenient ordinal parsing of number ' + i + ' month check');
- assert.equal(testMoment.date(), i,
- 'lenient ordinal parsing of number ' + i + ' date check');
- }
-});
-
-test('strict ordinal parsing', function (assert) {
- var i, ordinalStr, testMoment;
- for (i = 1; i <= 31; ++i) {
- ordinalStr = moment([2014, 0, i]).format('YYYY MM Do');
- testMoment = moment(ordinalStr, 'YYYY MM Do', true);
- assert.ok(testMoment.isValid(), 'strict ordinal parsing ' + i);
- }
-});
diff --git a/src/test/locale/pt-br.js b/src/test/locale/pt-br.js
index 0e0e840..2ac4263 100644
--- a/src/test/locale/pt-br.js
+++ b/src/test/locale/pt-br.js
@@ -100,7 +100,7 @@
});
test('format week', function (assert) {
- 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('_'), i;
+ 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('_'), i;
for (i = 0; i < expected.length; i++) {
assert.equal(moment([2011, 0, 2 + i]).format('dddd ddd'), expected[i], expected[i]);
}
@@ -149,14 +149,14 @@
});
test('calendar day', function (assert) {
- var a = moment().hours(2).minutes(0).seconds(0);
-
- assert.equal(moment(a).calendar(), 'Hoje às 02:00', 'today at the same time');
- assert.equal(moment(a).add({m: 25}).calendar(), 'Hoje às 02:25', 'Now plus 25 min');
- assert.equal(moment(a).add({h: 1}).calendar(), 'Hoje às 03:00', 'Now plus 1 hour');
- assert.equal(moment(a).add({d: 1}).calendar(), 'Amanhã às 02:00', 'tomorrow at the same time');
- assert.equal(moment(a).subtract({h: 1}).calendar(), 'Hoje às 01:00', 'Now minus 1 hour');
- assert.equal(moment(a).subtract({d: 1}).calendar(), 'Ontem às 02:00', 'yesterday at the same time');
+ var a = moment().hours(12).minutes(0).seconds(0);
+
+ assert.equal(moment(a).calendar(), 'Hoje às 12:00', 'today at the same time');
+ assert.equal(moment(a).add({m: 25}).calendar(), 'Hoje às 12:25', 'Now plus 25 min');
+ assert.equal(moment(a).add({h: 1}).calendar(), 'Hoje às 13:00', 'Now plus 1 hour');
+ assert.equal(moment(a).add({d: 1}).calendar(), 'Amanhã às 12:00', 'tomorrow at the same time');
+ assert.equal(moment(a).subtract({h: 1}).calendar(), 'Hoje às 11:00', 'Now minus 1 hour');
+ assert.equal(moment(a).subtract({d: 1}).calendar(), 'Ontem às 12:00', 'yesterday at the same time');
});
test('calendar next week', function (assert) {
@@ -197,67 +197,6 @@
assert.equal(weeksFromNow.calendar(), weeksFromNow.format('L'), 'in 2 weeks');
});
-test('weeks year starting sunday', function (assert) {
- assert.equal(moment([2012, 0, 1]).week(), 1, 'Jan 1 2012 should be week 1');
- assert.equal(moment([2012, 0, 7]).week(), 1, 'Jan 7 2012 should be week 1');
- assert.equal(moment([2012, 0, 8]).week(), 2, 'Jan 8 2012 should be week 2');
- assert.equal(moment([2012, 0, 14]).week(), 2, 'Jan 14 2012 should be week 2');
- assert.equal(moment([2012, 0, 15]).week(), 3, 'Jan 15 2012 should be week 3');
-});
-
-test('weeks year starting monday', function (assert) {
- assert.equal(moment([2006, 11, 31]).week(), 1, 'Dec 31 2006 should be week 1');
- assert.equal(moment([2007, 0, 1]).week(), 1, 'Jan 1 2007 should be week 1');
- assert.equal(moment([2007, 0, 6]).week(), 1, 'Jan 6 2007 should be week 1');
- assert.equal(moment([2007, 0, 7]).week(), 2, 'Jan 7 2007 should be week 2');
- assert.equal(moment([2007, 0, 13]).week(), 2, 'Jan 13 2007 should be week 2');
- assert.equal(moment([2007, 0, 14]).week(), 3, 'Jan 14 2007 should be week 3');
-});
-
-test('weeks year starting tuesday', function (assert) {
- assert.equal(moment([2007, 11, 29]).week(), 52, 'Dec 29 2007 should be week 52');
- assert.equal(moment([2008, 0, 1]).week(), 1, 'Jan 1 2008 should be week 1');
- assert.equal(moment([2008, 0, 5]).week(), 1, 'Jan 5 2008 should be week 1');
- assert.equal(moment([2008, 0, 6]).week(), 2, 'Jan 6 2008 should be week 2');
- assert.equal(moment([2008, 0, 12]).week(), 2, 'Jan 12 2008 should be week 2');
- assert.equal(moment([2008, 0, 13]).week(), 3, 'Jan 13 2008 should be week 3');
-});
-
-test('weeks year starting wednesday', function (assert) {
- assert.equal(moment([2002, 11, 29]).week(), 1, 'Dec 29 2002 should be week 1');
- assert.equal(moment([2003, 0, 1]).week(), 1, 'Jan 1 2003 should be week 1');
- assert.equal(moment([2003, 0, 4]).week(), 1, 'Jan 4 2003 should be week 1');
- assert.equal(moment([2003, 0, 5]).week(), 2, 'Jan 5 2003 should be week 2');
- assert.equal(moment([2003, 0, 11]).week(), 2, 'Jan 11 2003 should be week 2');
- assert.equal(moment([2003, 0, 12]).week(), 3, 'Jan 12 2003 should be week 3');
-});
-
-test('weeks year starting thursday', function (assert) {
- assert.equal(moment([2008, 11, 28]).week(), 1, 'Dec 28 2008 should be week 1');
- assert.equal(moment([2009, 0, 1]).week(), 1, 'Jan 1 2009 should be week 1');
- assert.equal(moment([2009, 0, 3]).week(), 1, 'Jan 3 2009 should be week 1');
- assert.equal(moment([2009, 0, 4]).week(), 2, 'Jan 4 2009 should be week 2');
- assert.equal(moment([2009, 0, 10]).week(), 2, 'Jan 10 2009 should be week 2');
- assert.equal(moment([2009, 0, 11]).week(), 3, 'Jan 11 2009 should be week 3');
-});
-
-test('weeks year starting friday', function (assert) {
- assert.equal(moment([2009, 11, 27]).week(), 1, 'Dec 27 2009 should be week 1');
- assert.equal(moment([2010, 0, 1]).week(), 1, 'Jan 1 2010 should be week 1');
- assert.equal(moment([2010, 0, 2]).week(), 1, 'Jan 2 2010 should be week 1');
- assert.equal(moment([2010, 0, 3]).week(), 2, 'Jan 3 2010 should be week 2');
- assert.equal(moment([2010, 0, 9]).week(), 2, 'Jan 9 2010 should be week 2');
- assert.equal(moment([2010, 0, 10]).week(), 3, 'Jan 10 2010 should be week 3');
-});
-
-test('weeks year starting saturday', function (assert) {
- assert.equal(moment([2010, 11, 26]).week(), 1, 'Dec 26 2010 should be week 1');
- assert.equal(moment([2011, 0, 1]).week(), 1, 'Jan 1 2011 should be week 1');
- assert.equal(moment([2011, 0, 2]).week(), 2, 'Jan 2 2011 should be week 2');
- assert.equal(moment([2011, 0, 8]).week(), 2, 'Jan 8 2011 should be week 2');
- assert.equal(moment([2011, 0, 9]).week(), 3, 'Jan 9 2011 should be week 3');
-});
-
test('weeks year starting sunday format', function (assert) {
assert.equal(moment([2012, 0, 1]).format('w ww wo'), '1 01 1º', 'Jan 1 2012 should be week 1');
assert.equal(moment([2012, 0, 7]).format('w ww wo'), '1 01 1º', 'Jan 7 2012 should be week 1');
@@ -266,38 +205,3 @@
assert.equal(moment([2012, 0, 15]).format('w ww wo'), '3 03 3º', 'Jan 15 2012 should be week 3');
});
-test('lenient ordinal parsing', function (assert) {
- var i, ordinalStr, testMoment;
- for (i = 1; i <= 31; ++i) {
- ordinalStr = moment([2014, 0, i]).format('YYYY MM Do');
- testMoment = moment(ordinalStr, 'YYYY MM Do');
- assert.equal(testMoment.year(), 2014,
- 'lenient ordinal parsing ' + i + ' year check');
- assert.equal(testMoment.month(), 0,
- 'lenient ordinal parsing ' + i + ' month check');
- assert.equal(testMoment.date(), i,
- 'lenient ordinal parsing ' + i + ' date check');
- }
-});
-
-test('lenient ordinal parsing of number', function (assert) {
- var i, testMoment;
- for (i = 1; i <= 31; ++i) {
- testMoment = moment('2014 01 ' + i, 'YYYY MM Do');
- assert.equal(testMoment.year(), 2014,
- 'lenient ordinal parsing of number ' + i + ' year check');
- assert.equal(testMoment.month(), 0,
- 'lenient ordinal parsing of number ' + i + ' month check');
- assert.equal(testMoment.date(), i,
- 'lenient ordinal parsing of number ' + i + ' date check');
- }
-});
-
-test('strict ordinal parsing', function (assert) {
- var i, ordinalStr, testMoment;
- for (i = 1; i <= 31; ++i) {
- ordinalStr = moment([2014, 0, i]).format('YYYY MM Do');
- testMoment = moment(ordinalStr, 'YYYY MM Do', true);
- assert.ok(testMoment.isValid(), 'strict ordinal parsing ' + i);
- }
-});
diff --git a/src/test/locale/pt.js b/src/test/locale/pt.js
index 14ad0ff..3235acc 100644
--- a/src/test/locale/pt.js
+++ b/src/test/locale/pt.js
@@ -147,14 +147,14 @@
});
test('calendar day', function (assert) {
- var a = moment().hours(2).minutes(0).seconds(0);
-
- assert.equal(moment(a).calendar(), 'Hoje às 02:00', 'today at the same time');
- assert.equal(moment(a).add({m: 25}).calendar(), 'Hoje às 02:25', 'Now plus 25 min');
- assert.equal(moment(a).add({h: 1}).calendar(), 'Hoje às 03:00', 'Now plus 1 hour');
- assert.equal(moment(a).add({d: 1}).calendar(), 'Amanhã às 02:00', 'tomorrow at the same time');
- assert.equal(moment(a).subtract({h: 1}).calendar(), 'Hoje às 01:00', 'Now minus 1 hour');
- assert.equal(moment(a).subtract({d: 1}).calendar(), 'Ontem às 02:00', 'yesterday at the same time');
+ var a = moment().hours(12).minutes(0).seconds(0);
+
+ assert.equal(moment(a).calendar(), 'Hoje às 12:00', 'today at the same time');
+ assert.equal(moment(a).add({m: 25}).calendar(), 'Hoje às 12:25', 'Now plus 25 min');
+ assert.equal(moment(a).add({h: 1}).calendar(), 'Hoje às 13:00', 'Now plus 1 hour');
+ assert.equal(moment(a).add({d: 1}).calendar(), 'Amanhã às 12:00', 'tomorrow at the same time');
+ assert.equal(moment(a).subtract({h: 1}).calendar(), 'Hoje às 11:00', 'Now minus 1 hour');
+ assert.equal(moment(a).subtract({d: 1}).calendar(), 'Ontem às 12:00', 'yesterday at the same time');
});
test('calendar next week', function (assert) {
@@ -195,67 +195,6 @@
assert.equal(weeksFromNow.calendar(), weeksFromNow.format('L'), 'in 2 weeks');
});
-test('weeks year starting sunday', function (assert) {
- assert.equal(moment([2012, 0, 1]).week(), 52, 'Jan 1 2012 should be week 52');
- assert.equal(moment([2012, 0, 2]).week(), 1, 'Jan 2 2012 should be week 1');
- assert.equal(moment([2012, 0, 8]).week(), 1, 'Jan 8 2012 should be week 1');
- assert.equal(moment([2012, 0, 9]).week(), 2, 'Jan 9 2012 should be week 2');
- assert.equal(moment([2012, 0, 15]).week(), 2, 'Jan 15 2012 should be week 2');
-});
-
-test('weeks year starting monday', function (assert) {
- assert.equal(moment([2007, 0, 1]).week(), 1, 'Jan 1 2007 should be week 1');
- assert.equal(moment([2007, 0, 7]).week(), 1, 'Jan 7 2007 should be week 1');
- assert.equal(moment([2007, 0, 8]).week(), 2, 'Jan 8 2007 should be week 2');
- assert.equal(moment([2007, 0, 14]).week(), 2, 'Jan 14 2007 should be week 2');
- assert.equal(moment([2007, 0, 15]).week(), 3, 'Jan 15 2007 should be week 3');
-});
-
-test('weeks year starting tuesday', function (assert) {
- assert.equal(moment([2007, 11, 31]).week(), 1, 'Dec 31 2007 should be week 1');
- assert.equal(moment([2008, 0, 1]).week(), 1, 'Jan 1 2008 should be week 1');
- assert.equal(moment([2008, 0, 6]).week(), 1, 'Jan 6 2008 should be week 1');
- assert.equal(moment([2008, 0, 7]).week(), 2, 'Jan 7 2008 should be week 2');
- assert.equal(moment([2008, 0, 13]).week(), 2, 'Jan 13 2008 should be week 2');
- assert.equal(moment([2008, 0, 14]).week(), 3, 'Jan 14 2008 should be week 3');
-});
-
-test('weeks year starting wednesday', function (assert) {
- assert.equal(moment([2002, 11, 30]).week(), 1, 'Dec 30 2002 should be week 1');
- assert.equal(moment([2003, 0, 1]).week(), 1, 'Jan 1 2003 should be week 1');
- assert.equal(moment([2003, 0, 5]).week(), 1, 'Jan 5 2003 should be week 1');
- assert.equal(moment([2003, 0, 6]).week(), 2, 'Jan 6 2003 should be week 2');
- assert.equal(moment([2003, 0, 12]).week(), 2, 'Jan 12 2003 should be week 2');
- assert.equal(moment([2003, 0, 13]).week(), 3, 'Jan 13 2003 should be week 3');
-});
-
-test('weeks year starting thursday', function (assert) {
- assert.equal(moment([2008, 11, 29]).week(), 1, 'Dec 29 2008 should be week 1');
- assert.equal(moment([2009, 0, 1]).week(), 1, 'Jan 1 2009 should be week 1');
- assert.equal(moment([2009, 0, 4]).week(), 1, 'Jan 4 2009 should be week 1');
- assert.equal(moment([2009, 0, 5]).week(), 2, 'Jan 5 2009 should be week 2');
- assert.equal(moment([2009, 0, 11]).week(), 2, 'Jan 11 2009 should be week 2');
- assert.equal(moment([2009, 0, 13]).week(), 3, 'Jan 12 2009 should be week 3');
-});
-
-test('weeks year starting friday', function (assert) {
- assert.equal(moment([2009, 11, 28]).week(), 53, 'Dec 28 2009 should be week 53');
- assert.equal(moment([2010, 0, 1]).week(), 53, 'Jan 1 2010 should be week 53');
- assert.equal(moment([2010, 0, 3]).week(), 53, 'Jan 3 2010 should be week 53');
- assert.equal(moment([2010, 0, 4]).week(), 1, 'Jan 4 2010 should be week 1');
- assert.equal(moment([2010, 0, 10]).week(), 1, 'Jan 10 2010 should be week 1');
- assert.equal(moment([2010, 0, 11]).week(), 2, 'Jan 11 2010 should be week 2');
-});
-
-test('weeks year starting saturday', function (assert) {
- assert.equal(moment([2010, 11, 27]).week(), 52, 'Dec 27 2010 should be week 52');
- assert.equal(moment([2011, 0, 1]).week(), 52, 'Jan 1 2011 should be week 52');
- assert.equal(moment([2011, 0, 2]).week(), 52, 'Jan 2 2011 should be week 52');
- assert.equal(moment([2011, 0, 3]).week(), 1, 'Jan 3 2011 should be week 1');
- assert.equal(moment([2011, 0, 9]).week(), 1, 'Jan 9 2011 should be week 1');
- assert.equal(moment([2011, 0, 10]).week(), 2, 'Jan 10 2011 should be week 2');
-});
-
test('weeks year starting sunday formatted', function (assert) {
assert.equal(moment([2012, 0, 1]).format('w ww wo'), '52 52 52º', 'Jan 1 2012 should be week 52');
assert.equal(moment([2012, 0, 2]).format('w ww wo'), '1 01 1º', 'Jan 2 2012 should be week 1');
@@ -264,38 +203,3 @@
assert.equal(moment([2012, 0, 15]).format('w ww wo'), '2 02 2º', 'Jan 15 2012 should be week 2');
});
-test('lenient ordinal parsing', function (assert) {
- var i, ordinalStr, testMoment;
- for (i = 1; i <= 31; ++i) {
- ordinalStr = moment([2014, 0, i]).format('YYYY MM Do');
- testMoment = moment(ordinalStr, 'YYYY MM Do');
- assert.equal(testMoment.year(), 2014,
- 'lenient ordinal parsing ' + i + ' year check');
- assert.equal(testMoment.month(), 0,
- 'lenient ordinal parsing ' + i + ' month check');
- assert.equal(testMoment.date(), i,
- 'lenient ordinal parsing ' + i + ' date check');
- }
-});
-
-test('lenient ordinal parsing of number', function (assert) {
- var i, testMoment;
- for (i = 1; i <= 31; ++i) {
- testMoment = moment('2014 01 ' + i, 'YYYY MM Do');
- assert.equal(testMoment.year(), 2014,
- 'lenient ordinal parsing of number ' + i + ' year check');
- assert.equal(testMoment.month(), 0,
- 'lenient ordinal parsing of number ' + i + ' month check');
- assert.equal(testMoment.date(), i,
- 'lenient ordinal parsing of number ' + i + ' date check');
- }
-});
-
-test('strict ordinal parsing', function (assert) {
- var i, ordinalStr, testMoment;
- for (i = 1; i <= 31; ++i) {
- ordinalStr = moment([2014, 0, i]).format('YYYY MM Do');
- testMoment = moment(ordinalStr, 'YYYY MM Do', true);
- assert.ok(testMoment.isValid(), 'strict ordinal parsing ' + i);
- }
-});
diff --git a/src/test/locale/ro.js b/src/test/locale/ro.js
index 86bd351..1713d37 100644
--- a/src/test/locale/ro.js
+++ b/src/test/locale/ro.js
@@ -159,14 +159,14 @@
});
test('calendar day', function (assert) {
- var a = moment().hours(2).minutes(0).seconds(0);
-
- assert.equal(moment(a).calendar(), 'azi la 2:00', 'today at the same time');
- assert.equal(moment(a).add({m: 25}).calendar(), 'azi la 2:25', 'Now plus 25 min');
- assert.equal(moment(a).add({h: 1}).calendar(), 'azi la 3:00', 'Now plus 1 hour');
- assert.equal(moment(a).add({d: 1}).calendar(), 'mâine la 2:00', 'tomorrow at the same time');
- assert.equal(moment(a).subtract({h: 1}).calendar(), 'azi la 1:00', 'Now minus 1 hour');
- assert.equal(moment(a).subtract({d: 1}).calendar(), 'ieri la 2:00', 'yesterday at the same time');
+ var a = moment().hours(12).minutes(0).seconds(0);
+
+ assert.equal(moment(a).calendar(), 'azi la 12:00', 'today at the same time');
+ assert.equal(moment(a).add({m: 25}).calendar(), 'azi la 12:25', 'Now plus 25 min');
+ assert.equal(moment(a).add({h: 1}).calendar(), 'azi la 13:00', 'Now plus 1 hour');
+ assert.equal(moment(a).add({d: 1}).calendar(), 'mâine la 12:00', 'tomorrow at the same time');
+ assert.equal(moment(a).subtract({h: 1}).calendar(), 'azi la 11:00', 'Now minus 1 hour');
+ assert.equal(moment(a).subtract({d: 1}).calendar(), 'ieri la 12:00', 'yesterday at the same time');
});
test('calendar next week', function (assert) {
@@ -207,67 +207,6 @@
assert.equal(weeksFromNow.calendar(), weeksFromNow.format('L'), 'in 2 weeks');
});
-test('weeks year starting sunday', function (assert) {
- assert.equal(moment([2011, 11, 26]).week(), 1, 'Dec 26 2011 should be week 1');
- assert.equal(moment([2012, 0, 1]).week(), 1, 'Jan 1 2012 should be week 1');
- assert.equal(moment([2012, 0, 2]).week(), 2, 'Jan 2 2012 should be week 2');
- assert.equal(moment([2012, 0, 8]).week(), 2, 'Jan 8 2012 should be week 2');
- assert.equal(moment([2012, 0, 9]).week(), 3, 'Jan 9 2012 should be week 3');
-});
-
-test('weeks year starting monday', function (assert) {
- assert.equal(moment([2007, 0, 1]).week(), 1, 'Jan 1 2007 should be week 1');
- assert.equal(moment([2007, 0, 7]).week(), 1, 'Jan 7 2007 should be week 1');
- assert.equal(moment([2007, 0, 8]).week(), 2, 'Jan 8 2007 should be week 2');
- assert.equal(moment([2007, 0, 14]).week(), 2, 'Jan 14 2007 should be week 2');
- assert.equal(moment([2007, 0, 15]).week(), 3, 'Jan 15 2007 should be week 3');
-});
-
-test('weeks year starting tuesday', function (assert) {
- assert.equal(moment([2007, 11, 31]).week(), 1, 'Dec 31 2007 should be week 1');
- assert.equal(moment([2008, 0, 1]).week(), 1, 'Jan 1 2008 should be week 1');
- assert.equal(moment([2008, 0, 6]).week(), 1, 'Jan 6 2008 should be week 1');
- assert.equal(moment([2008, 0, 7]).week(), 2, 'Jan 7 2008 should be week 2');
- assert.equal(moment([2008, 0, 13]).week(), 2, 'Jan 13 2008 should be week 2');
- assert.equal(moment([2008, 0, 14]).week(), 3, 'Jan 14 2008 should be week 3');
-});
-
-test('weeks year starting wednesday', function (assert) {
- assert.equal(moment([2002, 11, 30]).week(), 1, 'Dec 30 2002 should be week 1');
- assert.equal(moment([2003, 0, 1]).week(), 1, 'Jan 1 2003 should be week 1');
- assert.equal(moment([2003, 0, 5]).week(), 1, 'Jan 5 2003 should be week 1');
- assert.equal(moment([2003, 0, 6]).week(), 2, 'Jan 6 2003 should be week 2');
- assert.equal(moment([2003, 0, 12]).week(), 2, 'Jan 12 2003 should be week 2');
- assert.equal(moment([2003, 0, 13]).week(), 3, 'Jan 13 2003 should be week 3');
-});
-
-test('weeks year starting thursday', function (assert) {
- assert.equal(moment([2008, 11, 29]).week(), 1, 'Dec 29 2008 should be week 1');
- assert.equal(moment([2009, 0, 1]).week(), 1, 'Jan 1 2009 should be week 1');
- assert.equal(moment([2009, 0, 4]).week(), 1, 'Jan 4 2009 should be week 1');
- assert.equal(moment([2009, 0, 5]).week(), 2, 'Jan 5 2009 should be week 2');
- assert.equal(moment([2009, 0, 11]).week(), 2, 'Jan 11 2009 should be week 2');
- assert.equal(moment([2009, 0, 12]).week(), 3, 'Jan 12 2009 should be week 3');
-});
-
-test('weeks year starting friday', function (assert) {
- assert.equal(moment([2009, 11, 28]).week(), 1, 'Dec 28 2009 should be week 1');
- assert.equal(moment([2010, 0, 1]).week(), 1, 'Jan 1 2010 should be week 1');
- assert.equal(moment([2010, 0, 3]).week(), 1, 'Jan 3 2010 should be week 1');
- assert.equal(moment([2010, 0, 4]).week(), 2, 'Jan 4 2010 should be week 2');
- assert.equal(moment([2010, 0, 10]).week(), 2, 'Jan 10 2010 should be week 2');
- assert.equal(moment([2010, 0, 11]).week(), 3, 'Jan 11 2010 should be week 3');
-});
-
-test('weeks year starting saturday', function (assert) {
- assert.equal(moment([2010, 11, 27]).week(), 1, 'Dec 27 2010 should be week 1');
- assert.equal(moment([2011, 0, 1]).week(), 1, 'Jan 1 2011 should be week 1');
- assert.equal(moment([2011, 0, 2]).week(), 1, 'Jan 2 2011 should be week 1');
- assert.equal(moment([2011, 0, 3]).week(), 2, 'Jan 3 2011 should be week 2');
- assert.equal(moment([2011, 0, 9]).week(), 2, 'Jan 9 2011 should be week 2');
- assert.equal(moment([2011, 0, 10]).week(), 3, 'Jan 10 2011 should be week 3');
-});
-
test('weeks year starting sunday formatted', function (assert) {
assert.equal(moment([2011, 11, 26]).format('w ww wo'), '1 01 1', 'Dec 26 2011 should be week 1');
assert.equal(moment([2012, 0, 1]).format('w ww wo'), '1 01 1', 'Jan 1 2012 should be week 1');
@@ -276,38 +215,3 @@
assert.equal(moment([2012, 0, 9]).format('w ww wo'), '3 03 3', 'Jan 9 2012 should be week 3');
});
-test('lenient ordinal parsing', function (assert) {
- var i, ordinalStr, testMoment;
- for (i = 1; i <= 31; ++i) {
- ordinalStr = moment([2014, 0, i]).format('YYYY MM Do');
- testMoment = moment(ordinalStr, 'YYYY MM Do');
- assert.equal(testMoment.year(), 2014,
- 'lenient ordinal parsing ' + i + ' year check');
- assert.equal(testMoment.month(), 0,
- 'lenient ordinal parsing ' + i + ' month check');
- assert.equal(testMoment.date(), i,
- 'lenient ordinal parsing ' + i + ' date check');
- }
-});
-
-test('lenient ordinal parsing of number', function (assert) {
- var i, testMoment;
- for (i = 1; i <= 31; ++i) {
- testMoment = moment('2014 01 ' + i, 'YYYY MM Do');
- assert.equal(testMoment.year(), 2014,
- 'lenient ordinal parsing of number ' + i + ' year check');
- assert.equal(testMoment.month(), 0,
- 'lenient ordinal parsing of number ' + i + ' month check');
- assert.equal(testMoment.date(), i,
- 'lenient ordinal parsing of number ' + i + ' date check');
- }
-});
-
-test('strict ordinal parsing', function (assert) {
- var i, ordinalStr, testMoment;
- for (i = 1; i <= 31; ++i) {
- ordinalStr = moment([2014, 0, i]).format('YYYY MM Do');
- testMoment = moment(ordinalStr, 'YYYY MM Do', true);
- assert.ok(testMoment.isValid(), 'strict ordinal parsing ' + i);
- }
-});
diff --git a/src/test/locale/ru.js b/src/test/locale/ru.js
index 6b0be6e..668bb9b 100644
--- a/src/test/locale/ru.js
+++ b/src/test/locale/ru.js
@@ -3,7 +3,7 @@
localeModule('ru');
test('parse', function (assert) {
- var tests = 'Январь янв_Февраль фев_Март март_Апрель апр_Май май_Июнь июнь_Июль июль_Август авг_Сентябрь сен_Октябрь окт_Ноябрь ноя_Декабрь дек'.split('_'), i;
+ var tests = 'январь янв._февраль февр._март март_апрель апр._май май_июнь июнь_июль июль_август авг._сентябрь сент._октябрь окт._ноябрь нояб._декабрь дек.'.split('_'), i;
function equalTest(input, mmm, i) {
assert.equal(moment(input, mmm).month(), i, input + ' should be month ' + (i + 1));
}
@@ -36,12 +36,12 @@
test('format', function (assert) {
var a = [
- ['dddd, Do MMMM YYYY, HH:mm:ss', 'Воскресенье, 14-го Февраля 2010, 15:25:50'],
- ['ddd, h A', 'Вс, 3 дня'],
- ['M Mo MM MMMM MMM', '2 2-й 02 Февраль фев'],
+ ['dddd, Do MMMM YYYY, HH:mm:ss', 'воскресенье, 14-го февраля 2010, 15:25:50'],
+ ['ddd, h A', 'вс, 3 дня'],
+ ['M Mo MM MMMM MMM', '2 2-й 02 февраль февр.'],
['YYYY YY', '2010 10'],
['D Do DD', '14 14-го 14'],
- ['d do dddd ddd dd', '0 0-й Воскресенье Вс Вс'],
+ ['d do dddd ddd dd', '0 0-й воскресенье вс вс'],
['DDD DDDo DDDD', '45 45-й 045'],
['w wo ww', '7 7-я 07'],
['h hh', '3 03'],
@@ -52,13 +52,13 @@
['DDDo [день года]', '45-й день года'],
['LTS', '15:25:50'],
['L', '14.02.2010'],
- ['LL', '14 Февраля 2010 г.'],
- ['LLL', '14 Февраля 2010 г., 15:25'],
- ['LLLL', 'Воскресенье, 14 Февраля 2010 г., 15:25'],
+ ['LL', '14 февраля 2010 г.'],
+ ['LLL', '14 февраля 2010 г., 15:25'],
+ ['LLLL', 'воскресенье, 14 февраля 2010 г., 15:25'],
['l', '14.2.2010'],
- ['ll', '14 фев 2010 г.'],
- ['lll', '14 фев 2010 г., 15:25'],
- ['llll', 'Вс, 14 фев 2010 г., 15:25']
+ ['ll', '14 февр. 2010 г.'],
+ ['lll', '14 февр. 2010 г., 15:25'],
+ ['llll', 'вс, 14 февр. 2010 г., 15:25']
],
b = moment(new Date(2010, 1, 14, 15, 25, 50, 125)),
i;
@@ -116,7 +116,7 @@
});
test('format month', function (assert) {
- var expected = 'Январь янв_Февраль фев_Март март_Апрель апр_Май май_Июнь июнь_Июль июль_Август авг_Сентябрь сен_Октябрь окт_Ноябрь ноя_Декабрь дек'.split('_'), i;
+ var expected = 'январь янв._февраль февр._март март_апрель апр._май май_июнь июнь_июль июль_август авг._сентябрь сент._октябрь окт._ноябрь нояб._декабрь дек.'.split('_'), i;
for (i = 0; i < expected.length; i++) {
assert.equal(moment([2011, i, 1]).format('MMMM MMM'), expected[i], expected[i]);
}
@@ -124,8 +124,8 @@
test('format month case', function (assert) {
var months = {
- 'nominative': 'Январь_Февраль_Март_Апрель_Май_Июнь_Июль_Август_Сентябрь_Октябрь_Ноябрь_Декабрь'.split('_'),
- 'accusative': 'Января_Февраля_Марта_Апреля_Мая_Июня_Июля_Августа_Сентября_Октября_Ноября_Декабря'.split('_')
+ 'nominative': 'январь_февраль_март_апрель_май_июнь_июль_август_сентябрь_октябрь_ноябрь_декабрь'.split('_'),
+ 'accusative': 'января_февраля_марта_апреля_мая_июня_июля_августа_сентября_октября_ноября_декабря'.split('_')
}, i;
for (i = 0; i < 12; i++) {
assert.equal(moment([2011, i, 1]).format('D MMMM'), '1 ' + months.accusative[i], '1 ' + months.accusative[i]);
@@ -135,8 +135,8 @@
test('format month short case', function (assert) {
var monthsShort = {
- 'nominative': 'янв_фев_март_апр_май_июнь_июль_авг_сен_окт_ноя_дек'.split('_'),
- 'accusative': 'янв_фев_мар_апр_мая_июня_июля_авг_сен_окт_ноя_дек'.split('_')
+ 'nominative': 'янв._февр._март_апр._май_июнь_июль_авг._сент._окт._нояб._дек.'.split('_'),
+ 'accusative': 'янв._февр._мар._апр._мая_июня_июля_авг._сент._окт._нояб._дек.'.split('_')
}, i;
for (i = 0; i < 12; i++) {
assert.equal(moment([2011, i, 1]).format('D MMM'), '1 ' + monthsShort.accusative[i], '1 ' + monthsShort.accusative[i]);
@@ -146,8 +146,8 @@
test('format month case with escaped symbols', function (assert) {
var months = {
- 'nominative': 'Январь_Февраль_Март_Апрель_Май_Июнь_Июль_Август_Сентябрь_Октябрь_Ноябрь_Декабрь'.split('_'),
- 'accusative': 'Января_Февраля_Марта_Апреля_Мая_Июня_Июля_Августа_Сентября_Октября_Ноября_Декабря'.split('_')
+ 'nominative': 'январь_февраль_март_апрель_май_июнь_июль_август_сентябрь_октябрь_ноябрь_декабрь'.split('_'),
+ 'accusative': 'января_февраля_марта_апреля_мая_июня_июля_августа_сентября_октября_ноября_декабря'.split('_')
}, i;
for (i = 0; i < 12; i++) {
assert.equal(moment([2013, i, 1]).format('D[] MMMM'), '1 ' + months.accusative[i], '1 ' + months.accusative[i]);
@@ -159,8 +159,8 @@
test('format month short case with escaped symbols', function (assert) {
var monthsShort = {
- 'nominative': 'янв_фев_март_апр_май_июнь_июль_авг_сен_окт_ноя_дек'.split('_'),
- 'accusative': 'янв_фев_мар_апр_мая_июня_июля_авг_сен_окт_ноя_дек'.split('_')
+ 'nominative': 'янв._февр._март_апр._май_июнь_июль_авг._сент._окт._нояб._дек.'.split('_'),
+ 'accusative': 'янв._февр._мар._апр._мая_июня_июля_авг._сент._окт._нояб._дек.'.split('_')
}, i;
for (i = 0; i < 12; i++) {
assert.equal(moment([2013, i, 1]).format('D[] MMM'), '1 ' + monthsShort.accusative[i], '1 ' + monthsShort.accusative[i]);
@@ -171,7 +171,7 @@
});
test('format week', function (assert) {
- var expected = 'Воскресенье Вс Вс_Понедельник Пн Пн_Вторник Вт Вт_Среда Ср Ср_Четверг Чт Чт_Пятница Пт Пт_Суббота Сб Сб'.split('_'), i;
+ var expected = 'воскресенье вс вс_понедельник пн пн_вторник вт вт_среда ср ср_четверг чт чт_пятница пт пт_суббота сб сб'.split('_'), i;
for (i = 0; i < expected.length; i++) {
assert.equal(moment([2011, 0, 2 + i]).format('dddd ddd dd'), expected[i], expected[i]);
}
@@ -225,14 +225,14 @@
});
test('calendar day', function (assert) {
- var a = moment().hours(2).minutes(0).seconds(0);
-
- assert.equal(moment(a).calendar(), 'Сегодня в 02:00', 'today at the same time');
- assert.equal(moment(a).add({m: 25}).calendar(), 'Сегодня в 02:25', 'Now plus 25 min');
- assert.equal(moment(a).add({h: 1}).calendar(), 'Сегодня в 03:00', 'Now plus 1 hour');
- assert.equal(moment(a).add({d: 1}).calendar(), 'Завтра в 02:00', 'tomorrow at the same time');
- assert.equal(moment(a).subtract({h: 1}).calendar(), 'Сегодня в 01:00', 'Now minus 1 hour');
- assert.equal(moment(a).subtract({d: 1}).calendar(), 'Вчера в 02:00', 'yesterday at the same time');
+ var a = moment().hours(12).minutes(0).seconds(0);
+
+ assert.equal(moment(a).calendar(), 'Сегодня в 12:00', 'today at the same time');
+ assert.equal(moment(a).add({m: 25}).calendar(), 'Сегодня в 12:25', 'Now plus 25 min');
+ assert.equal(moment(a).add({h: 1}).calendar(), 'Сегодня в 13:00', 'Now plus 1 hour');
+ assert.equal(moment(a).add({d: 1}).calendar(), 'Завтра в 12:00', 'tomorrow at the same time');
+ assert.equal(moment(a).subtract({h: 1}).calendar(), 'Сегодня в 11:00', 'Now minus 1 hour');
+ assert.equal(moment(a).subtract({d: 1}).calendar(), 'Вчера в 12:00', 'yesterday at the same time');
});
test('calendar next week', function (assert) {
@@ -345,67 +345,6 @@
assert.equal(weeksFromNow.calendar(), weeksFromNow.format('L'), 'in 2 weeks');
});
-test('weeks year starting sunday', function (assert) {
- assert.equal(moment([2011, 11, 26]).week(), 1, 'Dec 26 2011 should be week 1');
- assert.equal(moment([2012, 0, 1]).week(), 1, 'Jan 1 2012 should be week 1');
- assert.equal(moment([2012, 0, 2]).week(), 2, 'Jan 2 2012 should be week 2');
- assert.equal(moment([2012, 0, 8]).week(), 2, 'Jan 8 2012 should be week 2');
- assert.equal(moment([2012, 0, 9]).week(), 3, 'Jan 9 2012 should be week 3');
-});
-
-test('weeks year starting monday', function (assert) {
- assert.equal(moment([2007, 0, 1]).week(), 1, 'Jan 1 2007 should be week 1');
- assert.equal(moment([2007, 0, 7]).week(), 1, 'Jan 7 2007 should be week 1');
- assert.equal(moment([2007, 0, 8]).week(), 2, 'Jan 8 2007 should be week 2');
- assert.equal(moment([2007, 0, 14]).week(), 2, 'Jan 14 2007 should be week 2');
- assert.equal(moment([2007, 0, 15]).week(), 3, 'Jan 15 2007 should be week 3');
-});
-
-test('weeks year starting tuesday', function (assert) {
- assert.equal(moment([2007, 11, 31]).week(), 1, 'Dec 31 2007 should be week 1');
- assert.equal(moment([2008, 0, 1]).week(), 1, 'Jan 1 2008 should be week 1');
- assert.equal(moment([2008, 0, 6]).week(), 1, 'Jan 6 2008 should be week 1');
- assert.equal(moment([2008, 0, 7]).week(), 2, 'Jan 7 2008 should be week 2');
- assert.equal(moment([2008, 0, 13]).week(), 2, 'Jan 13 2008 should be week 2');
- assert.equal(moment([2008, 0, 14]).week(), 3, 'Jan 14 2008 should be week 3');
-});
-
-test('weeks year starting wednesday', function (assert) {
- assert.equal(moment([2002, 11, 30]).week(), 1, 'Dec 30 2002 should be week 1');
- assert.equal(moment([2003, 0, 1]).week(), 1, 'Jan 1 2003 should be week 1');
- assert.equal(moment([2003, 0, 5]).week(), 1, 'Jan 5 2003 should be week 1');
- assert.equal(moment([2003, 0, 6]).week(), 2, 'Jan 6 2003 should be week 2');
- assert.equal(moment([2003, 0, 12]).week(), 2, 'Jan 12 2003 should be week 2');
- assert.equal(moment([2003, 0, 13]).week(), 3, 'Jan 13 2003 should be week 3');
-});
-
-test('weeks year starting thursday', function (assert) {
- assert.equal(moment([2008, 11, 29]).week(), 1, 'Dec 29 2008 should be week 1');
- assert.equal(moment([2009, 0, 1]).week(), 1, 'Jan 1 2009 should be week 1');
- assert.equal(moment([2009, 0, 4]).week(), 1, 'Jan 4 2009 should be week 1');
- assert.equal(moment([2009, 0, 5]).week(), 2, 'Jan 5 2009 should be week 2');
- assert.equal(moment([2009, 0, 11]).week(), 2, 'Jan 11 2009 should be week 2');
- assert.equal(moment([2009, 0, 12]).week(), 3, 'Jan 12 2009 should be week 3');
-});
-
-test('weeks year starting friday', function (assert) {
- assert.equal(moment([2009, 11, 28]).week(), 1, 'Dec 28 2009 should be week 1');
- assert.equal(moment([2010, 0, 1]).week(), 1, 'Jan 1 2010 should be week 1');
- assert.equal(moment([2010, 0, 3]).week(), 1, 'Jan 3 2010 should be week 1');
- assert.equal(moment([2010, 0, 4]).week(), 2, 'Jan 4 2010 should be week 2');
- assert.equal(moment([2010, 0, 10]).week(), 2, 'Jan 10 2010 should be week 2');
- assert.equal(moment([2010, 0, 11]).week(), 3, 'Jan 11 2010 should be week 3');
-});
-
-test('weeks year starting saturday', function (assert) {
- assert.equal(moment([2010, 11, 27]).week(), 1, 'Dec 27 2010 should be week 1');
- assert.equal(moment([2011, 0, 1]).week(), 1, 'Jan 1 2011 should be week 1');
- assert.equal(moment([2011, 0, 2]).week(), 1, 'Jan 2 2011 should be week 1');
- assert.equal(moment([2011, 0, 3]).week(), 2, 'Jan 3 2011 should be week 2');
- assert.equal(moment([2011, 0, 9]).week(), 2, 'Jan 9 2011 should be week 2');
- assert.equal(moment([2011, 0, 10]).week(), 3, 'Jan 10 2011 should be week 3');
-});
-
test('weeks year starting sunday formatted', function (assert) {
assert.equal(moment([2011, 11, 26]).format('w ww wo'), '1 01 1-я', 'Dec 26 2011 should be week 1');
assert.equal(moment([2012, 0, 1]).format('w ww wo'), '1 01 1-я', 'Jan 1 2012 should be week 1');
@@ -414,38 +353,3 @@
assert.equal(moment([2012, 0, 9]).format('w ww wo'), '3 03 3-я', 'Jan 9 2012 should be week 3');
});
-test('lenient ordinal parsing', function (assert) {
- var i, ordinalStr, testMoment;
- for (i = 1; i <= 31; ++i) {
- ordinalStr = moment([2014, 0, i]).format('YYYY MM Do');
- testMoment = moment(ordinalStr, 'YYYY MM Do');
- assert.equal(testMoment.year(), 2014,
- 'lenient ordinal parsing ' + i + ' year check');
- assert.equal(testMoment.month(), 0,
- 'lenient ordinal parsing ' + i + ' month check');
- assert.equal(testMoment.date(), i,
- 'lenient ordinal parsing ' + i + ' date check');
- }
-});
-
-test('lenient ordinal parsing of number', function (assert) {
- var i, testMoment;
- for (i = 1; i <= 31; ++i) {
- testMoment = moment('2014 01 ' + i, 'YYYY MM Do');
- assert.equal(testMoment.year(), 2014,
- 'lenient ordinal parsing of number ' + i + ' year check');
- assert.equal(testMoment.month(), 0,
- 'lenient ordinal parsing of number ' + i + ' month check');
- assert.equal(testMoment.date(), i,
- 'lenient ordinal parsing of number ' + i + ' date check');
- }
-});
-
-test('strict ordinal parsing', function (assert) {
- var i, ordinalStr, testMoment;
- for (i = 1; i <= 31; ++i) {
- ordinalStr = moment([2014, 0, i]).format('YYYY MM Do');
- testMoment = moment(ordinalStr, 'YYYY MM Do', true);
- assert.ok(testMoment.isValid(), 'strict ordinal parsing ' + i);
- }
-});
diff --git a/src/test/locale/se.js b/src/test/locale/se.js
index bd731a8..d0f0534 100644
--- a/src/test/locale/se.js
+++ b/src/test/locale/se.js
@@ -160,14 +160,14 @@
});
test('calendar day', function (assert) {
- var a = moment().hours(2).minutes(0).seconds(0);
-
- assert.equal(moment(a).calendar(), 'otne ti 02:00', 'Today at the same time');
- assert.equal(moment(a).add({m: 25}).calendar(), 'otne ti 02:25', 'Now plus 25 min');
- assert.equal(moment(a).add({h: 1}).calendar(), 'otne ti 03:00', 'Now plus 1 hour');
- assert.equal(moment(a).add({d: 1}).calendar(), 'ihttin ti 02:00', 'Tomorrow at the same time');
- assert.equal(moment(a).subtract({h: 1}).calendar(), 'otne ti 01:00', 'Now minus 1 hour');
- assert.equal(moment(a).subtract({d: 1}).calendar(), 'ikte ti 02:00', 'yesterday at the same time');
+ var a = moment().hours(12).minutes(0).seconds(0);
+
+ assert.equal(moment(a).calendar(), 'otne ti 12:00', 'Today at the same time');
+ assert.equal(moment(a).add({m: 25}).calendar(), 'otne ti 12:25', 'Now plus 25 min');
+ assert.equal(moment(a).add({h: 1}).calendar(), 'otne ti 13:00', 'Now plus 1 hour');
+ assert.equal(moment(a).add({d: 1}).calendar(), 'ihttin ti 12:00', 'Tomorrow at the same time');
+ assert.equal(moment(a).subtract({h: 1}).calendar(), 'otne ti 11:00', 'Now minus 1 hour');
+ assert.equal(moment(a).subtract({d: 1}).calendar(), 'ikte ti 12:00', 'yesterday at the same time');
});
test('calendar next week', function (assert) {
@@ -210,67 +210,6 @@
assert.equal(weeksFromNow.calendar(), weeksFromNow.format('L'), 'in 2 weeks');
});
-test('weeks year starting sunday', function (assert) {
- assert.equal(moment([2012, 0, 1]).week(), 52, 'Jan 1 2012 should be week 52');
- assert.equal(moment([2012, 0, 2]).week(), 1, 'Jan 2 2012 should be week 1');
- assert.equal(moment([2012, 0, 8]).week(), 1, 'Jan 8 2012 should be week 1');
- assert.equal(moment([2012, 0, 9]).week(), 2, 'Jan 9 2012 should be week 2');
- assert.equal(moment([2012, 0, 15]).week(), 2, 'Jan 15 2012 should be week 2');
-});
-
-test('weeks year starting monday', function (assert) {
- assert.equal(moment([2007, 0, 1]).week(), 1, 'Jan 1 2007 should be week 1');
- assert.equal(moment([2007, 0, 7]).week(), 1, 'Jan 7 2007 should be week 1');
- assert.equal(moment([2007, 0, 8]).week(), 2, 'Jan 8 2007 should be week 2');
- assert.equal(moment([2007, 0, 14]).week(), 2, 'Jan 14 2007 should be week 2');
- assert.equal(moment([2007, 0, 15]).week(), 3, 'Jan 15 2007 should be week 3');
-});
-
-test('weeks year starting tuesday', function (assert) {
- assert.equal(moment([2007, 11, 31]).week(), 1, 'Dec 31 2007 should be week 1');
- assert.equal(moment([2008, 0, 1]).week(), 1, 'Jan 1 2008 should be week 1');
- assert.equal(moment([2008, 0, 6]).week(), 1, 'Jan 6 2008 should be week 1');
- assert.equal(moment([2008, 0, 7]).week(), 2, 'Jan 7 2008 should be week 2');
- assert.equal(moment([2008, 0, 13]).week(), 2, 'Jan 13 2008 should be week 2');
- assert.equal(moment([2008, 0, 14]).week(), 3, 'Jan 14 2008 should be week 3');
-});
-
-test('weeks year starting wednesday', function (assert) {
- assert.equal(moment([2002, 11, 30]).week(), 1, 'Dec 30 2002 should be week 1');
- assert.equal(moment([2003, 0, 1]).week(), 1, 'Jan 1 2003 should be week 1');
- assert.equal(moment([2003, 0, 5]).week(), 1, 'Jan 5 2003 should be week 1');
- assert.equal(moment([2003, 0, 6]).week(), 2, 'Jan 6 2003 should be week 2');
- assert.equal(moment([2003, 0, 12]).week(), 2, 'Jan 12 2003 should be week 2');
- assert.equal(moment([2003, 0, 13]).week(), 3, 'Jan 13 2003 should be week 3');
-});
-
-test('weeks year starting thursday', function (assert) {
- assert.equal(moment([2008, 11, 29]).week(), 1, 'Dec 29 2008 should be week 1');
- assert.equal(moment([2009, 0, 1]).week(), 1, 'Jan 1 2009 should be week 1');
- assert.equal(moment([2009, 0, 4]).week(), 1, 'Jan 4 2009 should be week 1');
- assert.equal(moment([2009, 0, 5]).week(), 2, 'Jan 5 2009 should be week 2');
- assert.equal(moment([2009, 0, 11]).week(), 2, 'Jan 11 2009 should be week 2');
- assert.equal(moment([2009, 0, 13]).week(), 3, 'Jan 12 2009 should be week 3');
-});
-
-test('weeks year starting friday', function (assert) {
- assert.equal(moment([2009, 11, 28]).week(), 53, 'Dec 28 2009 should be week 53');
- assert.equal(moment([2010, 0, 1]).week(), 53, 'Jan 1 2010 should be week 53');
- assert.equal(moment([2010, 0, 3]).week(), 53, 'Jan 3 2010 should be week 53');
- assert.equal(moment([2010, 0, 4]).week(), 1, 'Jan 4 2010 should be week 1');
- assert.equal(moment([2010, 0, 10]).week(), 1, 'Jan 10 2010 should be week 1');
- assert.equal(moment([2010, 0, 11]).week(), 2, 'Jan 11 2010 should be week 2');
-});
-
-test('weeks year starting saturday', function (assert) {
- assert.equal(moment([2010, 11, 27]).week(), 52, 'Dec 27 2010 should be week 52');
- assert.equal(moment([2011, 0, 1]).week(), 52, 'Jan 1 2011 should be week 52');
- assert.equal(moment([2011, 0, 2]).week(), 52, 'Jan 2 2011 should be week 52');
- assert.equal(moment([2011, 0, 3]).week(), 1, 'Jan 3 2011 should be week 1');
- assert.equal(moment([2011, 0, 9]).week(), 1, 'Jan 9 2011 should be week 1');
- assert.equal(moment([2011, 0, 10]).week(), 2, 'Jan 10 2011 should be week 2');
-});
-
test('weeks year starting sunday formatted', function (assert) {
assert.equal(moment([2012, 0, 1]).format('w ww wo'), '52 52 52.', 'Jan 1 2012 should be week 52');
assert.equal(moment([2012, 0, 2]).format('w ww wo'), '1 01 1.', 'Jan 2 2012 should be week 1');
@@ -279,38 +218,3 @@
assert.equal(moment([2012, 0, 15]).format('w ww wo'), '2 02 2.', 'Jan 15 2012 should be week 2');
});
-test('lenient ordinal parsing', function (assert) {
- var i, ordinalStr, testMoment;
- for (i = 1; i <= 31; ++i) {
- ordinalStr = moment([2014, 0, i]).format('YYYY MM Do');
- testMoment = moment(ordinalStr, 'YYYY MM Do');
- assert.equal(testMoment.year(), 2014,
- 'lenient ordinal parsing ' + i + ' year check');
- assert.equal(testMoment.month(), 0,
- 'lenient ordinal parsing ' + i + ' month check');
- assert.equal(testMoment.date(), i,
- 'lenient ordinal parsing ' + i + ' date check');
- }
-});
-
-test('lenient ordinal parsing of number', function (assert) {
- var i, testMoment;
- for (i = 1; i <= 31; ++i) {
- testMoment = moment('2014 01 ' + i, 'YYYY MM Do');
- assert.equal(testMoment.year(), 2014,
- 'lenient ordinal parsing of number ' + i + ' year check');
- assert.equal(testMoment.month(), 0,
- 'lenient ordinal parsing of number ' + i + ' month check');
- assert.equal(testMoment.date(), i,
- 'lenient ordinal parsing of number ' + i + ' date check');
- }
-});
-
-test('strict ordinal parsing', function (assert) {
- var i, ordinalStr, testMoment;
- for (i = 1; i <= 31; ++i) {
- ordinalStr = moment([2014, 0, i]).format('YYYY MM Do');
- testMoment = moment(ordinalStr, 'YYYY MM Do', true);
- assert.ok(testMoment.isValid(), 'strict ordinal parsing ' + i);
- }
-});
diff --git a/src/test/locale/si.js b/src/test/locale/si.js
index ba0f566..4b03324 100644
--- a/src/test/locale/si.js
+++ b/src/test/locale/si.js
@@ -153,14 +153,14 @@
});
test('calendar day', function (assert) {
- var a = moment().hours(2).minutes(0).seconds(0);
-
- assert.equal(moment(a).calendar(), 'අද පෙ.ව. 2:00ට', 'today at the same time');
- assert.equal(moment(a).add({m: 25}).calendar(), 'අද පෙ.ව. 2:25ට', 'Now plus 25 min');
- assert.equal(moment(a).add({h: 1}).calendar(), 'අද පෙ.ව. 3:00ට', 'Now plus 1 hour');
- assert.equal(moment(a).add({d: 1}).calendar(), 'හෙට පෙ.ව. 2:00ට', 'tomorrow at the same time');
- assert.equal(moment(a).subtract({h: 1}).calendar(), 'අද පෙ.ව. 1:00ට', 'Now minus 1 hour');
- assert.equal(moment(a).subtract({d: 1}).calendar(), 'ඊයේ පෙ.ව. 2:00ට', 'yesterday at the same time');
+ var a = moment().hours(12).minutes(0).seconds(0);
+
+ assert.equal(moment(a).calendar(), 'අද ප.ව. 12:00ට', 'today at the same time');
+ assert.equal(moment(a).add({m: 25}).calendar(), 'අද ප.ව. 12:25ට', 'Now plus 25 min');
+ assert.equal(moment(a).add({h: 1}).calendar(), 'අද ප.ව. 1:00ට', 'Now plus 1 hour');
+ assert.equal(moment(a).add({d: 1}).calendar(), 'හෙට ප.ව. 12:00ට', 'tomorrow at the same time');
+ assert.equal(moment(a).subtract({h: 1}).calendar(), 'අද පෙ.ව. 11:00ට', 'Now minus 1 hour');
+ assert.equal(moment(a).subtract({d: 1}).calendar(), 'ඊයේ ප.ව. 12:00ට', 'yesterday at the same time');
});
test('calendar next week', function (assert) {
@@ -202,38 +202,3 @@
assert.equal(weeksFromNow.calendar(), weeksFromNow.format('L'), 'in 2 weeks');
});
-test('lenient ordinal parsing', function (assert) {
- var i, ordinalStr, testMoment;
- for (i = 1; i <= 31; ++i) {
- ordinalStr = moment([2014, 0, i]).format('YYYY MM Do');
- testMoment = moment(ordinalStr, 'YYYY MM Do');
- assert.equal(testMoment.year(), 2014,
- 'lenient ordinal parsing ' + i + ' year check');
- assert.equal(testMoment.month(), 0,
- 'lenient ordinal parsing ' + i + ' month check');
- assert.equal(testMoment.date(), i,
- 'lenient ordinal parsing ' + i + ' date check');
- }
-});
-
-test('lenient ordinal parsing of number', function (assert) {
- var i, testMoment;
- for (i = 1; i <= 31; ++i) {
- testMoment = moment('2014 01 ' + i, 'YYYY MM Do');
- assert.equal(testMoment.year(), 2014,
- 'lenient ordinal parsing of number ' + i + ' year check');
- assert.equal(testMoment.month(), 0,
- 'lenient ordinal parsing of number ' + i + ' month check');
- assert.equal(testMoment.date(), i,
- 'lenient ordinal parsing of number ' + i + ' date check');
- }
-});
-
-test('strict ordinal parsing', function (assert) {
- var i, ordinalStr, testMoment;
- for (i = 1; i <= 31; ++i) {
- ordinalStr = moment([2014, 0, i]).format('YYYY MM Do');
- testMoment = moment(ordinalStr, 'YYYY MM Do', true);
- assert.ok(testMoment.isValid(), 'strict ordinal parsing ' + i);
- }
-});
diff --git a/src/test/locale/sk.js b/src/test/locale/sk.js
index 1ccaeb8..eda3734 100644
--- a/src/test/locale/sk.js
+++ b/src/test/locale/sk.js
@@ -184,14 +184,14 @@
});
test('calendar day', function (assert) {
- var a = moment().hours(2).minutes(0).seconds(0);
-
- assert.equal(moment(a).calendar(), 'dnes o 2:00', 'today at the same time');
- assert.equal(moment(a).add({m: 25}).calendar(), 'dnes o 2:25', 'Now plus 25 min');
- assert.equal(moment(a).add({h: 1}).calendar(), 'dnes o 3:00', 'Now plus 1 hour');
- assert.equal(moment(a).add({d: 1}).calendar(), 'zajtra o 2:00', 'tomorrow at the same time');
- assert.equal(moment(a).subtract({h: 1}).calendar(), 'dnes o 1:00', 'Now minus 1 hour');
- assert.equal(moment(a).subtract({d: 1}).calendar(), 'včera o 2:00', 'yesterday at the same time');
+ var a = moment().hours(12).minutes(0).seconds(0);
+
+ assert.equal(moment(a).calendar(), 'dnes o 12:00', 'today at the same time');
+ assert.equal(moment(a).add({m: 25}).calendar(), 'dnes o 12:25', 'Now plus 25 min');
+ assert.equal(moment(a).add({h: 1}).calendar(), 'dnes o 13:00', 'Now plus 1 hour');
+ assert.equal(moment(a).add({d: 1}).calendar(), 'zajtra o 12:00', 'tomorrow at the same time');
+ assert.equal(moment(a).subtract({h: 1}).calendar(), 'dnes o 11:00', 'Now minus 1 hour');
+ assert.equal(moment(a).subtract({d: 1}).calendar(), 'včera o 12:00', 'yesterday at the same time');
});
test('calendar next week', function (assert) {
@@ -287,67 +287,6 @@
assert.equal(moment.duration(-1, 'minutes').humanize(true), 'pred minútou', 'a minute ago');
});
-test('weeks year starting sunday', function (assert) {
- assert.equal(moment([2012, 0, 1]).week(), 52, 'Jan 1 2012 should be week 52');
- assert.equal(moment([2012, 0, 2]).week(), 1, 'Jan 2 2012 should be week 1');
- assert.equal(moment([2012, 0, 8]).week(), 1, 'Jan 8 2012 should be week 1');
- assert.equal(moment([2012, 0, 9]).week(), 2, 'Jan 9 2012 should be week 2');
- assert.equal(moment([2012, 0, 15]).week(), 2, 'Jan 15 2012 should be week 2');
-});
-
-test('weeks year starting monday', function (assert) {
- assert.equal(moment([2007, 0, 1]).week(), 1, 'Jan 1 2007 should be week 1');
- assert.equal(moment([2007, 0, 7]).week(), 1, 'Jan 7 2007 should be week 1');
- assert.equal(moment([2007, 0, 8]).week(), 2, 'Jan 8 2007 should be week 2');
- assert.equal(moment([2007, 0, 14]).week(), 2, 'Jan 14 2007 should be week 2');
- assert.equal(moment([2007, 0, 15]).week(), 3, 'Jan 15 2007 should be week 3');
-});
-
-test('weeks year starting tuesday', function (assert) {
- assert.equal(moment([2007, 11, 31]).week(), 1, 'Dec 31 2007 should be week 1');
- assert.equal(moment([2008, 0, 1]).week(), 1, 'Jan 1 2008 should be week 1');
- assert.equal(moment([2008, 0, 6]).week(), 1, 'Jan 6 2008 should be week 1');
- assert.equal(moment([2008, 0, 7]).week(), 2, 'Jan 7 2008 should be week 2');
- assert.equal(moment([2008, 0, 13]).week(), 2, 'Jan 13 2008 should be week 2');
- assert.equal(moment([2008, 0, 14]).week(), 3, 'Jan 14 2008 should be week 3');
-});
-
-test('weeks year starting wednesday', function (assert) {
- assert.equal(moment([2002, 11, 30]).week(), 1, 'Dec 30 2002 should be week 1');
- assert.equal(moment([2003, 0, 1]).week(), 1, 'Jan 1 2003 should be week 1');
- assert.equal(moment([2003, 0, 5]).week(), 1, 'Jan 5 2003 should be week 1');
- assert.equal(moment([2003, 0, 6]).week(), 2, 'Jan 6 2003 should be week 2');
- assert.equal(moment([2003, 0, 12]).week(), 2, 'Jan 12 2003 should be week 2');
- assert.equal(moment([2003, 0, 13]).week(), 3, 'Jan 13 2003 should be week 3');
-});
-
-test('weeks year starting thursday', function (assert) {
- assert.equal(moment([2008, 11, 29]).week(), 1, 'Dec 29 2008 should be week 1');
- assert.equal(moment([2009, 0, 1]).week(), 1, 'Jan 1 2009 should be week 1');
- assert.equal(moment([2009, 0, 4]).week(), 1, 'Jan 4 2009 should be week 1');
- assert.equal(moment([2009, 0, 5]).week(), 2, 'Jan 5 2009 should be week 2');
- assert.equal(moment([2009, 0, 11]).week(), 2, 'Jan 11 2009 should be week 2');
- assert.equal(moment([2009, 0, 13]).week(), 3, 'Jan 12 2009 should be week 3');
-});
-
-test('weeks year starting friday', function (assert) {
- assert.equal(moment([2009, 11, 28]).week(), 53, 'Dec 28 2009 should be week 53');
- assert.equal(moment([2010, 0, 1]).week(), 53, 'Jan 1 2010 should be week 53');
- assert.equal(moment([2010, 0, 3]).week(), 53, 'Jan 3 2010 should be week 53');
- assert.equal(moment([2010, 0, 4]).week(), 1, 'Jan 4 2010 should be week 1');
- assert.equal(moment([2010, 0, 10]).week(), 1, 'Jan 10 2010 should be week 1');
- assert.equal(moment([2010, 0, 11]).week(), 2, 'Jan 11 2010 should be week 2');
-});
-
-test('weeks year starting saturday', function (assert) {
- assert.equal(moment([2010, 11, 27]).week(), 52, 'Dec 27 2010 should be week 52');
- assert.equal(moment([2011, 0, 1]).week(), 52, 'Jan 1 2011 should be week 52');
- assert.equal(moment([2011, 0, 2]).week(), 52, 'Jan 2 2011 should be week 52');
- assert.equal(moment([2011, 0, 3]).week(), 1, 'Jan 3 2011 should be week 1');
- assert.equal(moment([2011, 0, 9]).week(), 1, 'Jan 9 2011 should be week 1');
- assert.equal(moment([2011, 0, 10]).week(), 2, 'Jan 10 2011 should be week 2');
-});
-
test('weeks year starting sunday formatted', function (assert) {
assert.equal(moment([2012, 0, 1]).format('w ww wo'), '52 52 52.', 'Jan 1 2012 should be week 52');
assert.equal(moment([2012, 0, 2]).format('w ww wo'), '1 01 1.', 'Jan 2 2012 should be week 1');
@@ -356,38 +295,3 @@
assert.equal(moment([2012, 0, 15]).format('w ww wo'), '2 02 2.', 'Jan 15 2012 should be week 2');
});
-test('lenient ordinal parsing', function (assert) {
- var i, ordinalStr, testMoment;
- for (i = 1; i <= 31; ++i) {
- ordinalStr = moment([2014, 0, i]).format('YYYY MM Do');
- testMoment = moment(ordinalStr, 'YYYY MM Do');
- assert.equal(testMoment.year(), 2014,
- 'lenient ordinal parsing ' + i + ' year check');
- assert.equal(testMoment.month(), 0,
- 'lenient ordinal parsing ' + i + ' month check');
- assert.equal(testMoment.date(), i,
- 'lenient ordinal parsing ' + i + ' date check');
- }
-});
-
-test('lenient ordinal parsing of number', function (assert) {
- var i, testMoment;
- for (i = 1; i <= 31; ++i) {
- testMoment = moment('2014 01 ' + i, 'YYYY MM Do');
- assert.equal(testMoment.year(), 2014,
- 'lenient ordinal parsing of number ' + i + ' year check');
- assert.equal(testMoment.month(), 0,
- 'lenient ordinal parsing of number ' + i + ' month check');
- assert.equal(testMoment.date(), i,
- 'lenient ordinal parsing of number ' + i + ' date check');
- }
-});
-
-test('strict ordinal parsing', function (assert) {
- var i, ordinalStr, testMoment;
- for (i = 1; i <= 31; ++i) {
- ordinalStr = moment([2014, 0, i]).format('YYYY MM Do');
- testMoment = moment(ordinalStr, 'YYYY MM Do', true);
- assert.ok(testMoment.isValid(), 'strict ordinal parsing ' + i);
- }
-});
diff --git a/src/test/locale/sl.js b/src/test/locale/sl.js
index b6ae0f0..70b868f 100644
--- a/src/test/locale/sl.js
+++ b/src/test/locale/sl.js
@@ -241,14 +241,14 @@
});
test('calendar day', function (assert) {
- var a = moment().hours(2).minutes(0).seconds(0);
-
- assert.equal(moment(a).calendar(), 'danes ob 2:00', 'today at the same time');
- assert.equal(moment(a).add({m: 25}).calendar(), 'danes ob 2:25', 'Now plus 25 min');
- assert.equal(moment(a).add({h: 1}).calendar(), 'danes ob 3:00', 'Now plus 1 hour');
- assert.equal(moment(a).add({d: 1}).calendar(), 'jutri ob 2:00', 'tomorrow at the same time');
- assert.equal(moment(a).subtract({h: 1}).calendar(), 'danes ob 1:00', 'Now minus 1 hour');
- assert.equal(moment(a).subtract({d: 1}).calendar(), 'včeraj ob 2:00', 'yesterday at the same time');
+ var a = moment().hours(12).minutes(0).seconds(0);
+
+ assert.equal(moment(a).calendar(), 'danes ob 12:00', 'today at the same time');
+ assert.equal(moment(a).add({m: 25}).calendar(), 'danes ob 12:25', 'Now plus 25 min');
+ assert.equal(moment(a).add({h: 1}).calendar(), 'danes ob 13:00', 'Now plus 1 hour');
+ assert.equal(moment(a).add({d: 1}).calendar(), 'jutri ob 12:00', 'tomorrow at the same time');
+ assert.equal(moment(a).subtract({h: 1}).calendar(), 'danes ob 11:00', 'Now minus 1 hour');
+ assert.equal(moment(a).subtract({d: 1}).calendar(), 'včeraj ob 12:00', 'yesterday at the same time');
});
test('calendar next week', function (assert) {
@@ -323,67 +323,6 @@
assert.equal(weeksFromNow.calendar(), weeksFromNow.format('L'), 'in 2 weeks');
});
-test('weeks year starting sunday', function (assert) {
- assert.equal(moment([2011, 11, 26]).week(), 1, 'Dec 26 2011 should be week 1');
- assert.equal(moment([2012, 0, 1]).week(), 1, 'Jan 1 2012 should be week 1');
- assert.equal(moment([2012, 0, 2]).week(), 2, 'Jan 2 2012 should be week 2');
- assert.equal(moment([2012, 0, 8]).week(), 2, 'Jan 8 2012 should be week 2');
- assert.equal(moment([2012, 0, 9]).week(), 3, 'Jan 9 2012 should be week 3');
-});
-
-test('weeks year starting monday', function (assert) {
- assert.equal(moment([2007, 0, 1]).week(), 1, 'Jan 1 2007 should be week 1');
- assert.equal(moment([2007, 0, 7]).week(), 1, 'Jan 7 2007 should be week 1');
- assert.equal(moment([2007, 0, 8]).week(), 2, 'Jan 8 2007 should be week 2');
- assert.equal(moment([2007, 0, 14]).week(), 2, 'Jan 14 2007 should be week 2');
- assert.equal(moment([2007, 0, 15]).week(), 3, 'Jan 15 2007 should be week 3');
-});
-
-test('weeks year starting tuesday', function (assert) {
- assert.equal(moment([2007, 11, 31]).week(), 1, 'Dec 31 2007 should be week 1');
- assert.equal(moment([2008, 0, 1]).week(), 1, 'Jan 1 2008 should be week 1');
- assert.equal(moment([2008, 0, 6]).week(), 1, 'Jan 6 2008 should be week 1');
- assert.equal(moment([2008, 0, 7]).week(), 2, 'Jan 7 2008 should be week 2');
- assert.equal(moment([2008, 0, 13]).week(), 2, 'Jan 13 2008 should be week 2');
- assert.equal(moment([2008, 0, 14]).week(), 3, 'Jan 14 2008 should be week 3');
-});
-
-test('weeks year starting wednesday', function (assert) {
- assert.equal(moment([2002, 11, 30]).week(), 1, 'Dec 30 2002 should be week 1');
- assert.equal(moment([2003, 0, 1]).week(), 1, 'Jan 1 2003 should be week 1');
- assert.equal(moment([2003, 0, 5]).week(), 1, 'Jan 5 2003 should be week 1');
- assert.equal(moment([2003, 0, 6]).week(), 2, 'Jan 6 2003 should be week 2');
- assert.equal(moment([2003, 0, 12]).week(), 2, 'Jan 12 2003 should be week 2');
- assert.equal(moment([2003, 0, 13]).week(), 3, 'Jan 13 2003 should be week 3');
-});
-
-test('weeks year starting thursday', function (assert) {
- assert.equal(moment([2008, 11, 29]).week(), 1, 'Dec 29 2008 should be week 1');
- assert.equal(moment([2009, 0, 1]).week(), 1, 'Jan 1 2009 should be week 1');
- assert.equal(moment([2009, 0, 4]).week(), 1, 'Jan 4 2009 should be week 1');
- assert.equal(moment([2009, 0, 5]).week(), 2, 'Jan 5 2009 should be week 2');
- assert.equal(moment([2009, 0, 11]).week(), 2, 'Jan 11 2009 should be week 2');
- assert.equal(moment([2009, 0, 12]).week(), 3, 'Jan 12 2009 should be week 3');
-});
-
-test('weeks year starting friday', function (assert) {
- assert.equal(moment([2009, 11, 28]).week(), 1, 'Dec 28 2009 should be week 1');
- assert.equal(moment([2010, 0, 1]).week(), 1, 'Jan 1 2010 should be week 1');
- assert.equal(moment([2010, 0, 3]).week(), 1, 'Jan 3 2010 should be week 1');
- assert.equal(moment([2010, 0, 4]).week(), 2, 'Jan 4 2010 should be week 2');
- assert.equal(moment([2010, 0, 10]).week(), 2, 'Jan 10 2010 should be week 2');
- assert.equal(moment([2010, 0, 11]).week(), 3, 'Jan 11 2010 should be week 3');
-});
-
-test('weeks year starting saturday', function (assert) {
- assert.equal(moment([2010, 11, 27]).week(), 1, 'Dec 27 2010 should be week 1');
- assert.equal(moment([2011, 0, 1]).week(), 1, 'Jan 1 2011 should be week 1');
- assert.equal(moment([2011, 0, 2]).week(), 1, 'Jan 2 2011 should be week 1');
- assert.equal(moment([2011, 0, 3]).week(), 2, 'Jan 3 2011 should be week 2');
- assert.equal(moment([2011, 0, 9]).week(), 2, 'Jan 9 2011 should be week 2');
- assert.equal(moment([2011, 0, 10]).week(), 3, 'Jan 10 2011 should be week 3');
-});
-
test('weeks year starting sunday formatted', function (assert) {
assert.equal(moment([2011, 11, 26]).format('w ww wo'), '1 01 1.', 'Dec 26 2011 should be week 1');
assert.equal(moment([2012, 0, 1]).format('w ww wo'), '1 01 1.', 'Jan 1 2012 should be week 1');
@@ -392,38 +331,3 @@
assert.equal(moment([2012, 0, 9]).format('w ww wo'), '3 03 3.', 'Jan 9 2012 should be week 3');
});
-test('lenient ordinal parsing', function (assert) {
- var i, ordinalStr, testMoment;
- for (i = 1; i <= 31; ++i) {
- ordinalStr = moment([2014, 0, i]).format('YYYY MM Do');
- testMoment = moment(ordinalStr, 'YYYY MM Do');
- assert.equal(testMoment.year(), 2014,
- 'lenient ordinal parsing ' + i + ' year check');
- assert.equal(testMoment.month(), 0,
- 'lenient ordinal parsing ' + i + ' month check');
- assert.equal(testMoment.date(), i,
- 'lenient ordinal parsing ' + i + ' date check');
- }
-});
-
-test('lenient ordinal parsing of number', function (assert) {
- var i, testMoment;
- for (i = 1; i <= 31; ++i) {
- testMoment = moment('2014 01 ' + i, 'YYYY MM Do');
- assert.equal(testMoment.year(), 2014,
- 'lenient ordinal parsing of number ' + i + ' year check');
- assert.equal(testMoment.month(), 0,
- 'lenient ordinal parsing of number ' + i + ' month check');
- assert.equal(testMoment.date(), i,
- 'lenient ordinal parsing of number ' + i + ' date check');
- }
-});
-
-test('strict ordinal parsing', function (assert) {
- var i, ordinalStr, testMoment;
- for (i = 1; i <= 31; ++i) {
- ordinalStr = moment([2014, 0, i]).format('YYYY MM Do');
- testMoment = moment(ordinalStr, 'YYYY MM Do', true);
- assert.ok(testMoment.isValid(), 'strict ordinal parsing ' + i);
- }
-});
diff --git a/src/test/locale/sq.js b/src/test/locale/sq.js
index 4a9b07e..37bf74b 100644
--- a/src/test/locale/sq.js
+++ b/src/test/locale/sq.js
@@ -165,14 +165,14 @@
});
test('calendar day', function (assert) {
- var a = moment().hours(2).minutes(0).seconds(0);
-
- assert.equal(moment(a).calendar(), 'Sot në 02:00', 'today at the same time');
- assert.equal(moment(a).add({m: 25}).calendar(), 'Sot në 02:25', 'Now plus 25 min');
- assert.equal(moment(a).add({h: 1}).calendar(), 'Sot në 03:00', 'Now plus 1 hour');
- assert.equal(moment(a).add({d: 1}).calendar(), 'Nesër në 02:00', 'tomorrow at the same time');
- assert.equal(moment(a).subtract({h: 1}).calendar(), 'Sot në 01:00', 'Now minus 1 hour');
- assert.equal(moment(a).subtract({d: 1}).calendar(), 'Dje në 02:00', 'yesterday at the same time');
+ var a = moment().hours(12).minutes(0).seconds(0);
+
+ assert.equal(moment(a).calendar(), 'Sot në 12:00', 'today at the same time');
+ assert.equal(moment(a).add({m: 25}).calendar(), 'Sot në 12:25', 'Now plus 25 min');
+ assert.equal(moment(a).add({h: 1}).calendar(), 'Sot në 13:00', 'Now plus 1 hour');
+ assert.equal(moment(a).add({d: 1}).calendar(), 'Nesër në 12:00', 'tomorrow at the same time');
+ assert.equal(moment(a).subtract({h: 1}).calendar(), 'Sot në 11:00', 'Now minus 1 hour');
+ assert.equal(moment(a).subtract({d: 1}).calendar(), 'Dje në 12:00', 'yesterday at the same time');
});
test('calendar next week', function (assert) {
@@ -215,67 +215,6 @@
assert.equal(weeksFromNow.calendar(), weeksFromNow.format('L'), 'in 2 weeks');
});
-test('weeks year starting sunday', function (assert) {
- assert.equal(moment([2012, 0, 1]).week(), 52, 'Jan 1 2012 should be week 52');
- assert.equal(moment([2012, 0, 2]).week(), 1, 'Jan 2 2012 should be week 1');
- assert.equal(moment([2012, 0, 8]).week(), 1, 'Jan 8 2012 should be week 1');
- assert.equal(moment([2012, 0, 9]).week(), 2, 'Jan 9 2012 should be week 2');
- assert.equal(moment([2012, 0, 15]).week(), 2, 'Jan 15 2012 should be week 2');
-});
-
-test('weeks year starting monday', function (assert) {
- assert.equal(moment([2007, 0, 1]).week(), 1, 'Jan 1 2007 should be week 1');
- assert.equal(moment([2007, 0, 7]).week(), 1, 'Jan 7 2007 should be week 1');
- assert.equal(moment([2007, 0, 8]).week(), 2, 'Jan 8 2007 should be week 2');
- assert.equal(moment([2007, 0, 14]).week(), 2, 'Jan 14 2007 should be week 2');
- assert.equal(moment([2007, 0, 15]).week(), 3, 'Jan 15 2007 should be week 3');
-});
-
-test('weeks year starting tuesday', function (assert) {
- assert.equal(moment([2007, 11, 31]).week(), 1, 'Dec 31 2007 should be week 1');
- assert.equal(moment([2008, 0, 1]).week(), 1, 'Jan 1 2008 should be week 1');
- assert.equal(moment([2008, 0, 6]).week(), 1, 'Jan 6 2008 should be week 1');
- assert.equal(moment([2008, 0, 7]).week(), 2, 'Jan 7 2008 should be week 2');
- assert.equal(moment([2008, 0, 13]).week(), 2, 'Jan 13 2008 should be week 2');
- assert.equal(moment([2008, 0, 14]).week(), 3, 'Jan 14 2008 should be week 3');
-});
-
-test('weeks year starting wednesday', function (assert) {
- assert.equal(moment([2002, 11, 30]).week(), 1, 'Dec 30 2002 should be week 1');
- assert.equal(moment([2003, 0, 1]).week(), 1, 'Jan 1 2003 should be week 1');
- assert.equal(moment([2003, 0, 5]).week(), 1, 'Jan 5 2003 should be week 1');
- assert.equal(moment([2003, 0, 6]).week(), 2, 'Jan 6 2003 should be week 2');
- assert.equal(moment([2003, 0, 12]).week(), 2, 'Jan 12 2003 should be week 2');
- assert.equal(moment([2003, 0, 13]).week(), 3, 'Jan 13 2003 should be week 3');
-});
-
-test('weeks year starting thursday', function (assert) {
- assert.equal(moment([2008, 11, 29]).week(), 1, 'Dec 29 2008 should be week 1');
- assert.equal(moment([2009, 0, 1]).week(), 1, 'Jan 1 2009 should be week 1');
- assert.equal(moment([2009, 0, 4]).week(), 1, 'Jan 4 2009 should be week 1');
- assert.equal(moment([2009, 0, 5]).week(), 2, 'Jan 5 2009 should be week 2');
- assert.equal(moment([2009, 0, 11]).week(), 2, 'Jan 11 2009 should be week 2');
- assert.equal(moment([2009, 0, 13]).week(), 3, 'Jan 12 2009 should be week 3');
-});
-
-test('weeks year starting friday', function (assert) {
- assert.equal(moment([2009, 11, 28]).week(), 53, 'Dec 28 2009 should be week 53');
- assert.equal(moment([2010, 0, 1]).week(), 53, 'Jan 1 2010 should be week 53');
- assert.equal(moment([2010, 0, 3]).week(), 53, 'Jan 3 2010 should be week 53');
- assert.equal(moment([2010, 0, 4]).week(), 1, 'Jan 4 2010 should be week 1');
- assert.equal(moment([2010, 0, 10]).week(), 1, 'Jan 10 2010 should be week 1');
- assert.equal(moment([2010, 0, 11]).week(), 2, 'Jan 11 2010 should be week 2');
-});
-
-test('weeks year starting saturday', function (assert) {
- assert.equal(moment([2010, 11, 27]).week(), 52, 'Dec 27 2010 should be week 52');
- assert.equal(moment([2011, 0, 1]).week(), 52, 'Jan 1 2011 should be week 52');
- assert.equal(moment([2011, 0, 2]).week(), 52, 'Jan 2 2011 should be week 52');
- assert.equal(moment([2011, 0, 3]).week(), 1, 'Jan 3 2011 should be week 1');
- assert.equal(moment([2011, 0, 9]).week(), 1, 'Jan 9 2011 should be week 1');
- assert.equal(moment([2011, 0, 10]).week(), 2, 'Jan 10 2011 should be week 2');
-});
-
test('weeks year starting sunday formatted', function (assert) {
assert.equal(moment([2012, 0, 1]).format('w ww wo'), '52 52 52.', 'Jan 1 2012 should be week 52');
assert.equal(moment([2012, 0, 2]).format('w ww wo'), '1 01 1.', 'Jan 2 2012 should be week 1');
@@ -284,38 +223,3 @@
assert.equal(moment([2012, 0, 15]).format('w ww wo'), '2 02 2.', 'Jan 15 2012 should be week 2');
});
-test('lenient ordinal parsing', function (assert) {
- var i, ordinalStr, testMoment;
- for (i = 1; i <= 31; ++i) {
- ordinalStr = moment([2014, 0, i]).format('YYYY MM Do');
- testMoment = moment(ordinalStr, 'YYYY MM Do');
- assert.equal(testMoment.year(), 2014,
- 'lenient ordinal parsing ' + i + ' year check');
- assert.equal(testMoment.month(), 0,
- 'lenient ordinal parsing ' + i + ' month check');
- assert.equal(testMoment.date(), i,
- 'lenient ordinal parsing ' + i + ' date check');
- }
-});
-
-test('lenient ordinal parsing of number', function (assert) {
- var i, testMoment;
- for (i = 1; i <= 31; ++i) {
- testMoment = moment('2014 01 ' + i, 'YYYY MM Do');
- assert.equal(testMoment.year(), 2014,
- 'lenient ordinal parsing of number ' + i + ' year check');
- assert.equal(testMoment.month(), 0,
- 'lenient ordinal parsing of number ' + i + ' month check');
- assert.equal(testMoment.date(), i,
- 'lenient ordinal parsing of number ' + i + ' date check');
- }
-});
-
-test('strict ordinal parsing', function (assert) {
- var i, ordinalStr, testMoment;
- for (i = 1; i <= 31; ++i) {
- ordinalStr = moment([2014, 0, i]).format('YYYY MM Do');
- testMoment = moment(ordinalStr, 'YYYY MM Do', true);
- assert.ok(testMoment.isValid(), 'strict ordinal parsing ' + i);
- }
-});
diff --git a/src/test/locale/sr-cyrl.js b/src/test/locale/sr-cyrl.js
index ea5019d..0dff56a 100644
--- a/src/test/locale/sr-cyrl.js
+++ b/src/test/locale/sr-cyrl.js
@@ -154,14 +154,14 @@
});
test('calendar day', function (assert) {
- var a = moment().hours(2).minutes(0).seconds(0);
-
- assert.equal(moment(a).calendar(), 'данас у 2:00', 'today at the same time');
- assert.equal(moment(a).add({m: 25}).calendar(), 'данас у 2:25', 'Now plus 25 min');
- assert.equal(moment(a).add({h: 1}).calendar(), 'данас у 3:00', 'Now plus 1 hour');
- assert.equal(moment(a).add({d: 1}).calendar(), 'сутра у 2:00', 'tomorrow at the same time');
- assert.equal(moment(a).subtract({h: 1}).calendar(), 'данас у 1:00', 'Now minus 1 hour');
- assert.equal(moment(a).subtract({d: 1}).calendar(), 'јуче у 2:00', 'yesterday at the same time');
+ var a = moment().hours(12).minutes(0).seconds(0);
+
+ assert.equal(moment(a).calendar(), 'данас у 12:00', 'today at the same time');
+ assert.equal(moment(a).add({m: 25}).calendar(), 'данас у 12:25', 'Now plus 25 min');
+ assert.equal(moment(a).add({h: 1}).calendar(), 'данас у 13:00', 'Now plus 1 hour');
+ assert.equal(moment(a).add({d: 1}).calendar(), 'сутра у 12:00', 'tomorrow at the same time');
+ assert.equal(moment(a).subtract({h: 1}).calendar(), 'данас у 11:00', 'Now minus 1 hour');
+ assert.equal(moment(a).subtract({d: 1}).calendar(), 'јуче у 12:00', 'yesterday at the same time');
});
test('calendar next week', function (assert) {
@@ -234,67 +234,6 @@
assert.equal(weeksFromNow.calendar(), weeksFromNow.format('L'), 'in 2 weeks');
});
-test('weeks year starting sunday', function (assert) {
- assert.equal(moment([2011, 11, 26]).week(), 1, 'Dec 26 2011 should be week 1');
- assert.equal(moment([2012, 0, 1]).week(), 1, 'Jan 1 2012 should be week 1');
- assert.equal(moment([2012, 0, 2]).week(), 2, 'Jan 2 2012 should be week 2');
- assert.equal(moment([2012, 0, 8]).week(), 2, 'Jan 8 2012 should be week 2');
- assert.equal(moment([2012, 0, 9]).week(), 3, 'Jan 9 2012 should be week 3');
-});
-
-test('weeks year starting monday', function (assert) {
- assert.equal(moment([2007, 0, 1]).week(), 1, 'Jan 1 2007 should be week 1');
- assert.equal(moment([2007, 0, 7]).week(), 1, 'Jan 7 2007 should be week 1');
- assert.equal(moment([2007, 0, 8]).week(), 2, 'Jan 8 2007 should be week 2');
- assert.equal(moment([2007, 0, 14]).week(), 2, 'Jan 14 2007 should be week 2');
- assert.equal(moment([2007, 0, 15]).week(), 3, 'Jan 15 2007 should be week 3');
-});
-
-test('weeks year starting tuesday', function (assert) {
- assert.equal(moment([2007, 11, 31]).week(), 1, 'Dec 31 2007 should be week 1');
- assert.equal(moment([2008, 0, 1]).week(), 1, 'Jan 1 2008 should be week 1');
- assert.equal(moment([2008, 0, 6]).week(), 1, 'Jan 6 2008 should be week 1');
- assert.equal(moment([2008, 0, 7]).week(), 2, 'Jan 7 2008 should be week 2');
- assert.equal(moment([2008, 0, 13]).week(), 2, 'Jan 13 2008 should be week 2');
- assert.equal(moment([2008, 0, 14]).week(), 3, 'Jan 14 2008 should be week 3');
-});
-
-test('weeks year starting wednesday', function (assert) {
- assert.equal(moment([2002, 11, 30]).week(), 1, 'Dec 30 2002 should be week 1');
- assert.equal(moment([2003, 0, 1]).week(), 1, 'Jan 1 2003 should be week 1');
- assert.equal(moment([2003, 0, 5]).week(), 1, 'Jan 5 2003 should be week 1');
- assert.equal(moment([2003, 0, 6]).week(), 2, 'Jan 6 2003 should be week 2');
- assert.equal(moment([2003, 0, 12]).week(), 2, 'Jan 12 2003 should be week 2');
- assert.equal(moment([2003, 0, 13]).week(), 3, 'Jan 13 2003 should be week 3');
-});
-
-test('weeks year starting thursday', function (assert) {
- assert.equal(moment([2008, 11, 29]).week(), 1, 'Dec 29 2008 should be week 1');
- assert.equal(moment([2009, 0, 1]).week(), 1, 'Jan 1 2009 should be week 1');
- assert.equal(moment([2009, 0, 4]).week(), 1, 'Jan 4 2009 should be week 1');
- assert.equal(moment([2009, 0, 5]).week(), 2, 'Jan 5 2009 should be week 2');
- assert.equal(moment([2009, 0, 11]).week(), 2, 'Jan 11 2009 should be week 2');
- assert.equal(moment([2009, 0, 12]).week(), 3, 'Jan 12 2009 should be week 3');
-});
-
-test('weeks year starting friday', function (assert) {
- assert.equal(moment([2009, 11, 28]).week(), 1, 'Dec 28 2009 should be week 1');
- assert.equal(moment([2010, 0, 1]).week(), 1, 'Jan 1 2010 should be week 1');
- assert.equal(moment([2010, 0, 3]).week(), 1, 'Jan 3 2010 should be week 1');
- assert.equal(moment([2010, 0, 4]).week(), 2, 'Jan 4 2010 should be week 2');
- assert.equal(moment([2010, 0, 10]).week(), 2, 'Jan 10 2010 should be week 2');
- assert.equal(moment([2010, 0, 11]).week(), 3, 'Jan 11 2010 should be week 3');
-});
-
-test('weeks year starting saturday', function (assert) {
- assert.equal(moment([2010, 11, 27]).week(), 1, 'Dec 27 2010 should be week 1');
- assert.equal(moment([2011, 0, 1]).week(), 1, 'Jan 1 2011 should be week 1');
- assert.equal(moment([2011, 0, 2]).week(), 1, 'Jan 2 2011 should be week 1');
- assert.equal(moment([2011, 0, 3]).week(), 2, 'Jan 3 2011 should be week 2');
- assert.equal(moment([2011, 0, 9]).week(), 2, 'Jan 9 2011 should be week 2');
- assert.equal(moment([2011, 0, 10]).week(), 3, 'Jan 10 2011 should be week 3');
-});
-
test('weeks year starting sunday formatted', function (assert) {
assert.equal(moment([2011, 11, 26]).format('w ww wo'), '1 01 1.', 'Dec 26 2011 should be week 1');
assert.equal(moment([2012, 0, 1]).format('w ww wo'), '1 01 1.', 'Jan 1 2012 should be week 1');
@@ -303,38 +242,3 @@
assert.equal(moment([2012, 0, 9]).format('w ww wo'), '3 03 3.', 'Jan 9 2012 should be week 3');
});
-test('lenient ordinal parsing', function (assert) {
- var i, ordinalStr, testMoment;
- for (i = 1; i <= 31; ++i) {
- ordinalStr = moment([2014, 0, i]).format('YYYY MM Do');
- testMoment = moment(ordinalStr, 'YYYY MM Do');
- assert.equal(testMoment.year(), 2014,
- 'lenient ordinal parsing ' + i + ' year check');
- assert.equal(testMoment.month(), 0,
- 'lenient ordinal parsing ' + i + ' month check');
- assert.equal(testMoment.date(), i,
- 'lenient ordinal parsing ' + i + ' date check');
- }
-});
-
-test('lenient ordinal parsing of number', function (assert) {
- var i, testMoment;
- for (i = 1; i <= 31; ++i) {
- testMoment = moment('2014 01 ' + i, 'YYYY MM Do');
- assert.equal(testMoment.year(), 2014,
- 'lenient ordinal parsing of number ' + i + ' year check');
- assert.equal(testMoment.month(), 0,
- 'lenient ordinal parsing of number ' + i + ' month check');
- assert.equal(testMoment.date(), i,
- 'lenient ordinal parsing of number ' + i + ' date check');
- }
-});
-
-test('strict ordinal parsing', function (assert) {
- var i, ordinalStr, testMoment;
- for (i = 1; i <= 31; ++i) {
- ordinalStr = moment([2014, 0, i]).format('YYYY MM Do');
- testMoment = moment(ordinalStr, 'YYYY MM Do', true);
- assert.ok(testMoment.isValid(), 'strict ordinal parsing ' + i);
- }
-});
diff --git a/src/test/locale/sr.js b/src/test/locale/sr.js
index 0299ce2..94650a4 100644
--- a/src/test/locale/sr.js
+++ b/src/test/locale/sr.js
@@ -154,14 +154,14 @@
});
test('calendar day', function (assert) {
- var a = moment().hours(2).minutes(0).seconds(0);
-
- assert.equal(moment(a).calendar(), 'danas u 2:00', 'today at the same time');
- assert.equal(moment(a).add({m: 25}).calendar(), 'danas u 2:25', 'Now plus 25 min');
- assert.equal(moment(a).add({h: 1}).calendar(), 'danas u 3:00', 'Now plus 1 hour');
- assert.equal(moment(a).add({d: 1}).calendar(), 'sutra u 2:00', 'tomorrow at the same time');
- assert.equal(moment(a).subtract({h: 1}).calendar(), 'danas u 1:00', 'Now minus 1 hour');
- assert.equal(moment(a).subtract({d: 1}).calendar(), 'juče u 2:00', 'yesterday at the same time');
+ var a = moment().hours(12).minutes(0).seconds(0);
+
+ assert.equal(moment(a).calendar(), 'danas u 12:00', 'today at the same time');
+ assert.equal(moment(a).add({m: 25}).calendar(), 'danas u 12:25', 'Now plus 25 min');
+ assert.equal(moment(a).add({h: 1}).calendar(), 'danas u 13:00', 'Now plus 1 hour');
+ assert.equal(moment(a).add({d: 1}).calendar(), 'sutra u 12:00', 'tomorrow at the same time');
+ assert.equal(moment(a).subtract({h: 1}).calendar(), 'danas u 11:00', 'Now minus 1 hour');
+ assert.equal(moment(a).subtract({d: 1}).calendar(), 'juče u 12:00', 'yesterday at the same time');
});
test('calendar next week', function (assert) {
@@ -234,67 +234,6 @@
assert.equal(weeksFromNow.calendar(), weeksFromNow.format('L'), 'in 2 weeks');
});
-test('weeks year starting sunday', function (assert) {
- assert.equal(moment([2011, 11, 26]).week(), 1, 'Dec 26 2011 should be week 1');
- assert.equal(moment([2012, 0, 1]).week(), 1, 'Jan 1 2012 should be week 1');
- assert.equal(moment([2012, 0, 2]).week(), 2, 'Jan 2 2012 should be week 2');
- assert.equal(moment([2012, 0, 8]).week(), 2, 'Jan 8 2012 should be week 2');
- assert.equal(moment([2012, 0, 9]).week(), 3, 'Jan 9 2012 should be week 3');
-});
-
-test('weeks year starting monday', function (assert) {
- assert.equal(moment([2007, 0, 1]).week(), 1, 'Jan 1 2007 should be week 1');
- assert.equal(moment([2007, 0, 7]).week(), 1, 'Jan 7 2007 should be week 1');
- assert.equal(moment([2007, 0, 8]).week(), 2, 'Jan 8 2007 should be week 2');
- assert.equal(moment([2007, 0, 14]).week(), 2, 'Jan 14 2007 should be week 2');
- assert.equal(moment([2007, 0, 15]).week(), 3, 'Jan 15 2007 should be week 3');
-});
-
-test('weeks year starting tuesday', function (assert) {
- assert.equal(moment([2007, 11, 31]).week(), 1, 'Dec 31 2007 should be week 1');
- assert.equal(moment([2008, 0, 1]).week(), 1, 'Jan 1 2008 should be week 1');
- assert.equal(moment([2008, 0, 6]).week(), 1, 'Jan 6 2008 should be week 1');
- assert.equal(moment([2008, 0, 7]).week(), 2, 'Jan 7 2008 should be week 2');
- assert.equal(moment([2008, 0, 13]).week(), 2, 'Jan 13 2008 should be week 2');
- assert.equal(moment([2008, 0, 14]).week(), 3, 'Jan 14 2008 should be week 3');
-});
-
-test('weeks year starting wednesday', function (assert) {
- assert.equal(moment([2002, 11, 30]).week(), 1, 'Dec 30 2002 should be week 1');
- assert.equal(moment([2003, 0, 1]).week(), 1, 'Jan 1 2003 should be week 1');
- assert.equal(moment([2003, 0, 5]).week(), 1, 'Jan 5 2003 should be week 1');
- assert.equal(moment([2003, 0, 6]).week(), 2, 'Jan 6 2003 should be week 2');
- assert.equal(moment([2003, 0, 12]).week(), 2, 'Jan 12 2003 should be week 2');
- assert.equal(moment([2003, 0, 13]).week(), 3, 'Jan 13 2003 should be week 3');
-});
-
-test('weeks year starting thursday', function (assert) {
- assert.equal(moment([2008, 11, 29]).week(), 1, 'Dec 29 2008 should be week 1');
- assert.equal(moment([2009, 0, 1]).week(), 1, 'Jan 1 2009 should be week 1');
- assert.equal(moment([2009, 0, 4]).week(), 1, 'Jan 4 2009 should be week 1');
- assert.equal(moment([2009, 0, 5]).week(), 2, 'Jan 5 2009 should be week 2');
- assert.equal(moment([2009, 0, 11]).week(), 2, 'Jan 11 2009 should be week 2');
- assert.equal(moment([2009, 0, 12]).week(), 3, 'Jan 12 2009 should be week 3');
-});
-
-test('weeks year starting friday', function (assert) {
- assert.equal(moment([2009, 11, 28]).week(), 1, 'Dec 28 2009 should be week 1');
- assert.equal(moment([2010, 0, 1]).week(), 1, 'Jan 1 2010 should be week 1');
- assert.equal(moment([2010, 0, 3]).week(), 1, 'Jan 3 2010 should be week 1');
- assert.equal(moment([2010, 0, 4]).week(), 2, 'Jan 4 2010 should be week 2');
- assert.equal(moment([2010, 0, 10]).week(), 2, 'Jan 10 2010 should be week 2');
- assert.equal(moment([2010, 0, 11]).week(), 3, 'Jan 11 2010 should be week 3');
-});
-
-test('weeks year starting saturday', function (assert) {
- assert.equal(moment([2010, 11, 27]).week(), 1, 'Dec 27 2010 should be week 1');
- assert.equal(moment([2011, 0, 1]).week(), 1, 'Jan 1 2011 should be week 1');
- assert.equal(moment([2011, 0, 2]).week(), 1, 'Jan 2 2011 should be week 1');
- assert.equal(moment([2011, 0, 3]).week(), 2, 'Jan 3 2011 should be week 2');
- assert.equal(moment([2011, 0, 9]).week(), 2, 'Jan 9 2011 should be week 2');
- assert.equal(moment([2011, 0, 10]).week(), 3, 'Jan 10 2011 should be week 3');
-});
-
test('weeks year starting sunday formatted', function (assert) {
assert.equal(moment([2011, 11, 26]).format('w ww wo'), '1 01 1.', 'Dec 26 2011 should be week 1');
assert.equal(moment([2012, 0, 1]).format('w ww wo'), '1 01 1.', 'Jan 1 2012 should be week 1');
@@ -303,38 +242,3 @@
assert.equal(moment([2012, 0, 9]).format('w ww wo'), '3 03 3.', 'Jan 9 2012 should be week 3');
});
-test('lenient ordinal parsing', function (assert) {
- var i, ordinalStr, testMoment;
- for (i = 1; i <= 31; ++i) {
- ordinalStr = moment([2014, 0, i]).format('YYYY MM Do');
- testMoment = moment(ordinalStr, 'YYYY MM Do');
- assert.equal(testMoment.year(), 2014,
- 'lenient ordinal parsing ' + i + ' year check');
- assert.equal(testMoment.month(), 0,
- 'lenient ordinal parsing ' + i + ' month check');
- assert.equal(testMoment.date(), i,
- 'lenient ordinal parsing ' + i + ' date check');
- }
-});
-
-test('lenient ordinal parsing of number', function (assert) {
- var i, testMoment;
- for (i = 1; i <= 31; ++i) {
- testMoment = moment('2014 01 ' + i, 'YYYY MM Do');
- assert.equal(testMoment.year(), 2014,
- 'lenient ordinal parsing of number ' + i + ' year check');
- assert.equal(testMoment.month(), 0,
- 'lenient ordinal parsing of number ' + i + ' month check');
- assert.equal(testMoment.date(), i,
- 'lenient ordinal parsing of number ' + i + ' date check');
- }
-});
-
-test('strict ordinal parsing', function (assert) {
- var i, ordinalStr, testMoment;
- for (i = 1; i <= 31; ++i) {
- ordinalStr = moment([2014, 0, i]).format('YYYY MM Do');
- testMoment = moment(ordinalStr, 'YYYY MM Do', true);
- assert.ok(testMoment.isValid(), 'strict ordinal parsing ' + i);
- }
-});
diff --git a/src/test/locale/ss.js b/src/test/locale/ss.js
new file mode 100644
index 0000000..e33681a
--- /dev/null
+++ b/src/test/locale/ss.js
@@ -0,0 +1,242 @@
+import {localeModule, test} from '../qunit';
+import moment from '../../moment';
+localeModule('ss');
+
+test('parse', function (assert) {
+ var tests = "Bhimbidvwane Bhi_Indlovana Ina_Indlov'lenkhulu Inu_Mabasa Mab_Inkhwekhweti Ink_Inhlaba Inh_Kholwane Kho_Ingci Igc_Inyoni Iny_Imphala Imp_Lweti lwe_Ingongoni Igo".split('_'), i;
+ function equalTest(input, mmm, i) {
+ assert.equal(moment(input, mmm).month(), i, input + ' should be month ' + (i + 1));
+ }
+ for (i = 0; i < 12; i++) {
+ tests[i] = tests[i].split(' ');
+ equalTest(tests[i][0], 'MMM', i);
+ equalTest(tests[i][1], 'MMM', i);
+ equalTest(tests[i][0], 'MMMM', i);
+ equalTest(tests[i][1], 'MMMM', i);
+ equalTest(tests[i][0].toLocaleLowerCase(), 'MMMM', i);
+ equalTest(tests[i][1].toLocaleLowerCase(), 'MMMM', i);
+ equalTest(tests[i][0].toLocaleUpperCase(), 'MMMM', i);
+ equalTest(tests[i][1].toLocaleUpperCase(), 'MMMM', i);
+ }
+});
+
+test('parse meridiem', function (assert) {
+ var i,
+ b = moment(),
+ meridiemTests = [
+ // h a patterns, expected hours, isValid
+ ['10 ekuseni', 10, true],
+ ['11 emini', 11, true],
+ ['3 entsambama', 15, true],
+ ['4 entsambama', 16, true],
+ ['6 entsambama', 18, true],
+ ['7 ebusuku', 19, true],
+ ['12 ebusuku', 0, true],
+ ['10 am', 10, false],
+ ['10 pm', 10, false]
+ ],
+ parsed;
+
+ // test that a formatted moment including meridiem string can be parsed back to the same moment
+ assert.ok(b.isSame(moment(b.format('h:mm:ss a'), 'h:mm:ss a', 'ss', true), 'seconds'), b.format('h:mm:ss a') + ' should be equal to ' + moment(b.format('h:mm:ss a'), 'h:mm:ss a', 'ss', true).format('h:mm:ss a'));
+
+ // test that a formatted moment having a meridiem string can be parsed with strict flag
+ assert.ok(moment(b.format('h:mm:ss a'), 'h:mm:ss a', 'ss', true).isValid(), b.format('h:mm:ss a') + ' should be parsed as valid');
+
+ for (i = 0; i < meridiemTests.length; i++) {
+ parsed = moment(meridiemTests[i][0], 'h a', 'ss', true);
+ assert.equal(parsed.isValid(), meridiemTests[i][2], 'validity for ' + meridiemTests[i][0]);
+ if (parsed.isValid()) {
+ assert.equal(parsed.hours(), meridiemTests[i][1], 'hours for ' + meridiemTests[i][0]);
+ }
+ }
+});
+
+test('format', function (assert) {
+ var a = [
+ ['dddd, MMMM Do YYYY, h:mm:ss a', 'Lisontfo, Indlovana 14 2010, 3:25:50 entsambama'],
+ ['ddd, h A', 'Lis, 3 entsambama'],
+ ['M Mo MM MMMM MMM', '2 2 02 Indlovana Ina'],
+ ['YYYY YY', '2010 10'],
+ ['D Do DD', '14 14 14'],
+ ['d do dddd ddd dd', '0 0 Lisontfo Lis Li'],
+ ['DDD DDDo DDDD', '45 45 045'],
+ ['w wo ww', '6 6 06'],
+ ['h hh', '3 03'],
+ ['H HH', '15 15'],
+ ['m mm', '25 25'],
+ ['s ss', '50 50'],
+ ['a A', 'entsambama entsambama'],
+ ['[Lilanga] DDDo [lilanga lelinyaka]', 'Lilanga 45 lilanga lelinyaka'],
+ ['LTS', '3:25:50 entsambama'],
+ ['L', '14/02/2010'],
+ ['LL', '14 Indlovana 2010'],
+ ['LLL', '14 Indlovana 2010 3:25 entsambama'],
+ ['LLLL', 'Lisontfo, 14 Indlovana 2010 3:25 entsambama'],
+ ['l', '14/2/2010'],
+ ['ll', '14 Ina 2010'],
+ ['lll', '14 Ina 2010 3:25 entsambama'],
+ ['llll', 'Lis, 14 Ina 2010 3:25 entsambama']
+ ],
+ b = moment(new Date(2010, 1, 14, 15, 25, 50, 125)),
+ i;
+ for (i = 0; i < a.length; i++) {
+ assert.equal(b.format(a[i][0]), a[i][1], a[i][0] + ' ---> ' + a[i][1]);
+ }
+});
+
+test('format ordinal', function (assert) {
+ assert.equal(moment([2011, 0, 1]).format('DDDo'), '1', '1');
+ assert.equal(moment([2011, 0, 2]).format('DDDo'), '2', '2');
+ assert.equal(moment([2011, 0, 3]).format('DDDo'), '3', '3');
+ assert.equal(moment([2011, 0, 4]).format('DDDo'), '4', '4');
+ assert.equal(moment([2011, 0, 5]).format('DDDo'), '5', '5');
+ assert.equal(moment([2011, 0, 6]).format('DDDo'), '6', '6');
+ assert.equal(moment([2011, 0, 7]).format('DDDo'), '7', '7');
+ assert.equal(moment([2011, 0, 8]).format('DDDo'), '8', '8');
+ assert.equal(moment([2011, 0, 9]).format('DDDo'), '9', '9');
+ assert.equal(moment([2011, 0, 10]).format('DDDo'), '10', '10');
+
+ assert.equal(moment([2011, 0, 11]).format('DDDo'), '11', '11');
+ assert.equal(moment([2011, 0, 12]).format('DDDo'), '12', '12');
+ assert.equal(moment([2011, 0, 13]).format('DDDo'), '13', '13');
+ assert.equal(moment([2011, 0, 14]).format('DDDo'), '14', '14');
+ assert.equal(moment([2011, 0, 15]).format('DDDo'), '15', '15');
+ assert.equal(moment([2011, 0, 16]).format('DDDo'), '16', '16');
+ assert.equal(moment([2011, 0, 17]).format('DDDo'), '17', '17');
+ assert.equal(moment([2011, 0, 18]).format('DDDo'), '18', '18');
+ assert.equal(moment([2011, 0, 19]).format('DDDo'), '19', '19');
+ assert.equal(moment([2011, 0, 20]).format('DDDo'), '20', '20');
+
+ assert.equal(moment([2011, 0, 21]).format('DDDo'), '21', '21');
+ assert.equal(moment([2011, 0, 22]).format('DDDo'), '22', '22');
+ assert.equal(moment([2011, 0, 23]).format('DDDo'), '23', '23');
+ assert.equal(moment([2011, 0, 24]).format('DDDo'), '24', '24');
+ assert.equal(moment([2011, 0, 25]).format('DDDo'), '25', '25');
+ assert.equal(moment([2011, 0, 26]).format('DDDo'), '26', '26');
+ assert.equal(moment([2011, 0, 27]).format('DDDo'), '27', '27');
+ assert.equal(moment([2011, 0, 28]).format('DDDo'), '28', '28');
+ assert.equal(moment([2011, 0, 29]).format('DDDo'), '29', '29');
+ assert.equal(moment([2011, 0, 30]).format('DDDo'), '30', '30');
+
+ assert.equal(moment([2011, 0, 31]).format('DDDo'), '31', '31');
+});
+
+test('format month', function (assert) {
+ var expected = "Bhimbidvwane Bhi_Indlovana Ina_Indlov'lenkhulu Inu_Mabasa Mab_Inkhwekhweti Ink_Inhlaba Inh_Kholwane Kho_Ingci Igc_Inyoni Iny_Imphala Imp_Lweti Lwe_Ingongoni Igo".split('_'), i;
+ for (i = 0; i < expected.length; i++) {
+ assert.equal(moment([2011, i, 1]).format('MMMM MMM'), expected[i], expected[i]);
+ }
+});
+
+test('format week', function (assert) {
+ var expected = 'Lisontfo Lis Li_Umsombuluko Umb Us_Lesibili Lsb Lb_Lesitsatfu Les Lt_Lesine Lsi Ls_Lesihlanu Lsh Lh_Umgcibelo Umg Ug'.split('_'), i;
+ for (i = 0; i < expected.length; i++) {
+ assert.equal(moment([2011, 0, 2 + i]).format('dddd ddd dd'), expected[i], expected[i]);
+ }
+});
+
+test('from', function (assert) {
+ var start = moment([2007, 1, 28]);
+ assert.equal(start.from(moment([2007, 1, 28]).add({s: 44}), true), 'emizuzwana lomcane', '44 seconds = a few seconds');
+ assert.equal(start.from(moment([2007, 1, 28]).add({s: 45}), true), 'umzuzu', '45 seconds = a minute');
+ assert.equal(start.from(moment([2007, 1, 28]).add({s: 89}), true), 'umzuzu', '89 seconds = a minute');
+ assert.equal(start.from(moment([2007, 1, 28]).add({s: 90}), true), '2 emizuzu', '90 seconds = 2 minutes');
+ assert.equal(start.from(moment([2007, 1, 28]).add({m: 44}), true), '44 emizuzu', '44 minutes = 44 minutes');
+ assert.equal(start.from(moment([2007, 1, 28]).add({m: 45}), true), 'lihora', '45 minutes = an hour');
+ assert.equal(start.from(moment([2007, 1, 28]).add({m: 89}), true), 'lihora', '89 minutes = an hour');
+ assert.equal(start.from(moment([2007, 1, 28]).add({m: 90}), true), '2 emahora', '90 minutes = 2 hours');
+ assert.equal(start.from(moment([2007, 1, 28]).add({h: 5}), true), '5 emahora', '5 hours = 5 hours');
+ assert.equal(start.from(moment([2007, 1, 28]).add({h: 21}), true), '21 emahora', '21 hours = 21 hours');
+ assert.equal(start.from(moment([2007, 1, 28]).add({h: 22}), true), 'lilanga', '22 hours = a day');
+ assert.equal(start.from(moment([2007, 1, 28]).add({h: 35}), true), 'lilanga', '35 hours = a day');
+ assert.equal(start.from(moment([2007, 1, 28]).add({h: 36}), true), '2 emalanga', '36 hours = 2 days');
+ assert.equal(start.from(moment([2007, 1, 28]).add({d: 1}), true), 'lilanga', '1 day = a day');
+ assert.equal(start.from(moment([2007, 1, 28]).add({d: 5}), true), '5 emalanga', '5 days = 5 days');
+ assert.equal(start.from(moment([2007, 1, 28]).add({d: 25}), true), '25 emalanga', '25 days = 25 days');
+ assert.equal(start.from(moment([2007, 1, 28]).add({d: 26}), true), 'inyanga', '26 days = a month');
+ assert.equal(start.from(moment([2007, 1, 28]).add({d: 30}), true), 'inyanga', '30 days = a month');
+ assert.equal(start.from(moment([2007, 1, 28]).add({d: 43}), true), 'inyanga', '43 days = a month');
+ assert.equal(start.from(moment([2007, 1, 28]).add({d: 46}), true), '2 tinyanga', '46 days = 2 months');
+ assert.equal(start.from(moment([2007, 1, 28]).add({d: 74}), true), '2 tinyanga', '75 days = 2 months');
+ assert.equal(start.from(moment([2007, 1, 28]).add({d: 76}), true), '3 tinyanga', '76 days = 3 months');
+ assert.equal(start.from(moment([2007, 1, 28]).add({M: 1}), true), 'inyanga', '1 month = a month');
+ assert.equal(start.from(moment([2007, 1, 28]).add({M: 5}), true), '5 tinyanga', '5 months = 5 months');
+ assert.equal(start.from(moment([2007, 1, 28]).add({d: 345}), true), 'umnyaka', '345 days = a year');
+ assert.equal(start.from(moment([2007, 1, 28]).add({d: 548}), true), '2 iminyaka', '548 days = 2 years');
+ assert.equal(start.from(moment([2007, 1, 28]).add({y: 1}), true), 'umnyaka', '1 year = a year');
+ assert.equal(start.from(moment([2007, 1, 28]).add({y: 5}), true), '5 iminyaka', '5 years = 5 years');
+});
+
+test('suffix', function (assert) {
+ assert.equal(moment(30000).from(0), 'nga emizuzwana lomcane', 'prefix');
+ assert.equal(moment(0).from(30000), 'wenteka nga emizuzwana lomcane', 'suffix');
+});
+
+test('now from now', function (assert) {
+ assert.equal(moment().fromNow(), 'wenteka nga emizuzwana lomcane', 'now from now should display as in the past');
+});
+
+test('fromNow', function (assert) {
+ assert.equal(moment().add({s: 30}).fromNow(), 'nga emizuzwana lomcane', 'in a few seconds');
+ assert.equal(moment().add({d: 5}).fromNow(), 'nga 5 emalanga', 'in 5 days');
+});
+
+test('calendar day', function (assert) {
+ var a = moment().hours(12).minutes(0).seconds(0);
+
+ assert.equal(moment(a).calendar(), 'Namuhla nga 12:00 emini', 'Today at the same time');
+ assert.equal(moment(a).add({m: 25}).calendar(), 'Namuhla nga 12:25 emini', 'Now plus 25 min');
+ assert.equal(moment(a).add({h: 1}).calendar(), 'Namuhla nga 1:00 emini', 'Now plus 1 hour');
+ assert.equal(moment(a).add({d: 1}).calendar(), 'Kusasa nga 12:00 emini', 'tomorrow at the same time');
+ assert.equal(moment(a).subtract({h: 1}).calendar(), 'Namuhla nga 11:00 emini', 'Now minus 1 hour');
+ assert.equal(moment(a).subtract({d: 1}).calendar(), 'Itolo nga 12:00 emini', 'yesterday at the same time');
+});
+
+test('calendar next week', function (assert) {
+ var i, m;
+ for (i = 2; i < 7; i++) {
+ m = moment().add({d: i});
+ assert.equal(m.calendar(), m.format('dddd [nga] LT'), 'Today + ' + i + ' days current time');
+ m.hours(0).minutes(0).seconds(0).milliseconds(0);
+ assert.equal(m.calendar(), m.format('dddd [nga] LT'), 'Today + ' + i + ' days beginning of day');
+ m.hours(23).minutes(59).seconds(59).milliseconds(999);
+ assert.equal(m.calendar(), m.format('dddd [nga] LT'), 'Today + ' + i + ' days end of day');
+ }
+});
+
+test('calendar last week', function (assert) {
+ var i, m;
+
+ for (i = 2; i < 7; i++) {
+ m = moment().subtract({d: i});
+ assert.equal(m.calendar(), m.format('dddd [leliphelile] [nga] LT'), 'Today - ' + i + ' days current time');
+ m.hours(0).minutes(0).seconds(0).milliseconds(0);
+ assert.equal(m.calendar(), m.format('dddd [leliphelile] [nga] LT'), 'Today - ' + i + ' days beginning of day');
+ m.hours(23).minutes(59).seconds(59).milliseconds(999);
+ assert.equal(m.calendar(), m.format('dddd [leliphelile] [nga] LT'), 'Today - ' + i + ' days end of day');
+ }
+});
+
+test('calendar all else', function (assert) {
+ var weeksAgo = moment().subtract({w: 1}),
+ weeksFromNow = moment().add({w: 1});
+
+ assert.equal(weeksAgo.calendar(), weeksAgo.format('L'), '1 week ago');
+ assert.equal(weeksFromNow.calendar(), weeksFromNow.format('L'), 'in 1 week');
+
+ weeksAgo = moment().subtract({w: 2});
+ weeksFromNow = moment().add({w: 2});
+
+ assert.equal(weeksAgo.calendar(), weeksAgo.format('L'), '2 weeks ago');
+ assert.equal(weeksFromNow.calendar(), weeksFromNow.format('L'), 'in 2 weeks');
+});
+
+test('weeks year starting sunday formatted', function (assert) {
+ assert.equal(moment([2012, 0, 1]).format('w ww wo'), '52 52 52', 'Jan 1 2012 should be week 52');
+ assert.equal(moment([2012, 0, 2]).format('w ww wo'), '1 01 1', 'Jan 4 2012 should be week 1');
+ assert.equal(moment([2012, 0, 8]).format('w ww wo'), '1 01 1', 'Jan 8 2012 should be week 1');
+ assert.equal(moment([2012, 0, 9]).format('w ww wo'), '2 02 2', 'Jan 9 2012 should be week 2');
+ assert.equal(moment([2012, 0, 15]).format('w ww wo'), '2 02 2', 'Jan 15 2012 should be week 2');
+});
+
diff --git a/src/test/locale/sv.js b/src/test/locale/sv.js
index 503c1c3..dfa2b2b 100644
--- a/src/test/locale/sv.js
+++ b/src/test/locale/sv.js
@@ -39,8 +39,8 @@
['LTS', '15:25:50'],
['L', '2010-02-14'],
['LL', '14 februari 2010'],
- ['LLL', '14 februari 2010 15:25'],
- ['LLLL', 'söndag 14 februari 2010 15:25'],
+ ['LLL', '14 februari 2010 kl. 15:25'],
+ ['LLLL', 'söndag 14 februari 2010 kl. 15:25'],
['l', '2010-2-14'],
['ll', '14 feb 2010'],
['lll', '14 feb 2010 15:25'],
@@ -151,14 +151,14 @@
});
test('calendar day', function (assert) {
- var a = moment().hours(2).minutes(0).seconds(0);
-
- assert.equal(moment(a).calendar(), 'Idag 02:00', 'today at the same time');
- assert.equal(moment(a).add({m: 25}).calendar(), 'Idag 02:25', 'Now plus 25 min');
- assert.equal(moment(a).add({h: 1}).calendar(), 'Idag 03:00', 'Now plus 1 hour');
- assert.equal(moment(a).add({d: 1}).calendar(), 'Imorgon 02:00', 'tomorrow at the same time');
- assert.equal(moment(a).subtract({h: 1}).calendar(), 'Idag 01:00', 'Now minus 1 hour');
- assert.equal(moment(a).subtract({d: 1}).calendar(), 'Igår 02:00', 'yesterday at the same time');
+ var a = moment().hours(12).minutes(0).seconds(0);
+
+ assert.equal(moment(a).calendar(), 'Idag 12:00', 'today at the same time');
+ assert.equal(moment(a).add({m: 25}).calendar(), 'Idag 12:25', 'Now plus 25 min');
+ assert.equal(moment(a).add({h: 1}).calendar(), 'Idag 13:00', 'Now plus 1 hour');
+ assert.equal(moment(a).add({d: 1}).calendar(), 'Imorgon 12:00', 'tomorrow at the same time');
+ assert.equal(moment(a).subtract({h: 1}).calendar(), 'Idag 11:00', 'Now minus 1 hour');
+ assert.equal(moment(a).subtract({d: 1}).calendar(), 'Igår 12:00', 'yesterday at the same time');
});
test('calendar next week', function (assert) {
@@ -199,67 +199,6 @@
assert.equal(weeksFromNow.calendar(), weeksFromNow.format('L'), 'in 2 weeks');
});
-test('weeks year starting sunday', function (assert) {
- assert.equal(moment([2012, 0, 1]).week(), 52, 'Jan 1 2012 should be week 52');
- assert.equal(moment([2012, 0, 2]).week(), 1, 'Jan 2 2012 should be week 1');
- assert.equal(moment([2012, 0, 8]).week(), 1, 'Jan 8 2012 should be week 1');
- assert.equal(moment([2012, 0, 9]).week(), 2, 'Jan 9 2012 should be week 2');
- assert.equal(moment([2012, 0, 15]).week(), 2, 'Jan 15 2012 should be week 2');
-});
-
-test('weeks year starting monday', function (assert) {
- assert.equal(moment([2007, 0, 1]).week(), 1, 'Jan 1 2007 should be week 1');
- assert.equal(moment([2007, 0, 7]).week(), 1, 'Jan 7 2007 should be week 1');
- assert.equal(moment([2007, 0, 8]).week(), 2, 'Jan 8 2007 should be week 2');
- assert.equal(moment([2007, 0, 14]).week(), 2, 'Jan 14 2007 should be week 2');
- assert.equal(moment([2007, 0, 15]).week(), 3, 'Jan 15 2007 should be week 3');
-});
-
-test('weeks year starting tuesday', function (assert) {
- assert.equal(moment([2007, 11, 31]).week(), 1, 'Dec 31 2007 should be week 1');
- assert.equal(moment([2008, 0, 1]).week(), 1, 'Jan 1 2008 should be week 1');
- assert.equal(moment([2008, 0, 6]).week(), 1, 'Jan 6 2008 should be week 1');
- assert.equal(moment([2008, 0, 7]).week(), 2, 'Jan 7 2008 should be week 2');
- assert.equal(moment([2008, 0, 13]).week(), 2, 'Jan 13 2008 should be week 2');
- assert.equal(moment([2008, 0, 14]).week(), 3, 'Jan 14 2008 should be week 3');
-});
-
-test('weeks year starting wednesday', function (assert) {
- assert.equal(moment([2002, 11, 30]).week(), 1, 'Dec 30 2002 should be week 1');
- assert.equal(moment([2003, 0, 1]).week(), 1, 'Jan 1 2003 should be week 1');
- assert.equal(moment([2003, 0, 5]).week(), 1, 'Jan 5 2003 should be week 1');
- assert.equal(moment([2003, 0, 6]).week(), 2, 'Jan 6 2003 should be week 2');
- assert.equal(moment([2003, 0, 12]).week(), 2, 'Jan 12 2003 should be week 2');
- assert.equal(moment([2003, 0, 13]).week(), 3, 'Jan 13 2003 should be week 3');
-});
-
-test('weeks year starting thursday', function (assert) {
- assert.equal(moment([2008, 11, 29]).week(), 1, 'Dec 29 2008 should be week 1');
- assert.equal(moment([2009, 0, 1]).week(), 1, 'Jan 1 2009 should be week 1');
- assert.equal(moment([2009, 0, 4]).week(), 1, 'Jan 4 2009 should be week 1');
- assert.equal(moment([2009, 0, 5]).week(), 2, 'Jan 5 2009 should be week 2');
- assert.equal(moment([2009, 0, 11]).week(), 2, 'Jan 11 2009 should be week 2');
- assert.equal(moment([2009, 0, 13]).week(), 3, 'Jan 12 2009 should be week 3');
-});
-
-test('weeks year starting friday', function (assert) {
- assert.equal(moment([2009, 11, 28]).week(), 53, 'Dec 28 2009 should be week 53');
- assert.equal(moment([2010, 0, 1]).week(), 53, 'Jan 1 2010 should be week 53');
- assert.equal(moment([2010, 0, 3]).week(), 53, 'Jan 3 2010 should be week 53');
- assert.equal(moment([2010, 0, 4]).week(), 1, 'Jan 4 2010 should be week 1');
- assert.equal(moment([2010, 0, 10]).week(), 1, 'Jan 10 2010 should be week 1');
- assert.equal(moment([2010, 0, 11]).week(), 2, 'Jan 11 2010 should be week 2');
-});
-
-test('weeks year starting saturday', function (assert) {
- assert.equal(moment([2010, 11, 27]).week(), 52, 'Dec 27 2010 should be week 52');
- assert.equal(moment([2011, 0, 1]).week(), 52, 'Jan 1 2011 should be week 52');
- assert.equal(moment([2011, 0, 2]).week(), 52, 'Jan 2 2011 should be week 52');
- assert.equal(moment([2011, 0, 3]).week(), 1, 'Jan 3 2011 should be week 1');
- assert.equal(moment([2011, 0, 9]).week(), 1, 'Jan 9 2011 should be week 1');
- assert.equal(moment([2011, 0, 10]).week(), 2, 'Jan 10 2011 should be week 2');
-});
-
test('weeks year starting sunday formatted', function (assert) {
assert.equal(moment([2012, 0, 1]).format('w ww wo'), '52 52 52a', 'Jan 1 2012 should be week 52');
assert.equal(moment([2012, 0, 2]).format('w ww wo'), '1 01 1a', 'Jan 2 2012 should be week 1');
@@ -268,38 +207,3 @@
assert.equal(moment([2012, 0, 15]).format('w ww wo'), '2 02 2a', 'Jan 15 2012 should be week 2');
});
-test('lenient ordinal parsing', function (assert) {
- var i, ordinalStr, testMoment;
- for (i = 1; i <= 31; ++i) {
- ordinalStr = moment([2014, 0, i]).format('YYYY MM Do');
- testMoment = moment(ordinalStr, 'YYYY MM Do');
- assert.equal(testMoment.year(), 2014,
- 'lenient ordinal parsing ' + i + ' year check');
- assert.equal(testMoment.month(), 0,
- 'lenient ordinal parsing ' + i + ' month check');
- assert.equal(testMoment.date(), i,
- 'lenient ordinal parsing ' + i + ' date check');
- }
-});
-
-test('lenient ordinal parsing of number', function (assert) {
- var i, testMoment;
- for (i = 1; i <= 31; ++i) {
- testMoment = moment('2014 01 ' + i, 'YYYY MM Do');
- assert.equal(testMoment.year(), 2014,
- 'lenient ordinal parsing of number ' + i + ' year check');
- assert.equal(testMoment.month(), 0,
- 'lenient ordinal parsing of number ' + i + ' month check');
- assert.equal(testMoment.date(), i,
- 'lenient ordinal parsing of number ' + i + ' date check');
- }
-});
-
-test('strict ordinal parsing', function (assert) {
- var i, ordinalStr, testMoment;
- for (i = 1; i <= 31; ++i) {
- ordinalStr = moment([2014, 0, i]).format('YYYY MM Do');
- testMoment = moment(ordinalStr, 'YYYY MM Do', true);
- assert.ok(testMoment.isValid(), 'strict ordinal parsing ' + i);
- }
-});
diff --git a/src/test/locale/sw.js b/src/test/locale/sw.js
index 0b6b732..c39fb71 100644
--- a/src/test/locale/sw.js
+++ b/src/test/locale/sw.js
@@ -151,13 +151,13 @@
});
test('calendar day', function (assert) {
- var a = moment().hours(2).minutes(0).seconds(0);
- assert.equal(moment(a).calendar(), 'leo saa 02:00', 'today at the same time');
- assert.equal(moment(a).add({m: 25}).calendar(), 'leo saa 02:25', 'Now plus 25 min');
- assert.equal(moment(a).add({h: 1}).calendar(), 'leo saa 03:00', 'Now plus 1 hour');
- assert.equal(moment(a).add({d: 1}).calendar(), 'kesho saa 02:00', 'tomorrow at the same time');
- assert.equal(moment(a).subtract({h: 1}).calendar(), 'leo saa 01:00', 'Now minus 1 hour');
- assert.equal(moment(a).subtract({d: 1}).calendar(), 'jana 02:00', 'yesterday at the same time');
+ var a = moment().hours(12).minutes(0).seconds(0);
+ assert.equal(moment(a).calendar(), 'leo saa 12:00', 'today at the same time');
+ assert.equal(moment(a).add({m: 25}).calendar(), 'leo saa 12:25', 'Now plus 25 min');
+ assert.equal(moment(a).add({h: 1}).calendar(), 'leo saa 13:00', 'Now plus 1 hour');
+ assert.equal(moment(a).add({d: 1}).calendar(), 'kesho saa 12:00', 'tomorrow at the same time');
+ assert.equal(moment(a).subtract({h: 1}).calendar(), 'leo saa 11:00', 'Now minus 1 hour');
+ assert.equal(moment(a).subtract({d: 1}).calendar(), 'jana 12:00', 'yesterday at the same time');
});
test('calendar next week', function (assert) {
@@ -199,67 +199,6 @@
assert.equal(weeksFromNow.calendar(), weeksFromNow.format('L'), 'in 2 weeks');
});
-test('weeks year starting sunday', function (assert) {
- assert.equal(moment([2011, 11, 26]).week(), 1, 'Dec 26 2011 should be week 1');
- assert.equal(moment([2012, 0, 1]).week(), 1, 'Jan 1 2012 should be week 1');
- assert.equal(moment([2012, 0, 2]).week(), 2, 'Jan 2 2012 should be week 2');
- assert.equal(moment([2012, 0, 8]).week(), 2, 'Jan 8 2012 should be week 2');
- assert.equal(moment([2012, 0, 9]).week(), 3, 'Jan 9 2012 should be week 3');
-});
-
-test('weeks year starting monday', function (assert) {
- assert.equal(moment([2007, 0, 1]).week(), 1, 'Jan 1 2007 should be week 1');
- assert.equal(moment([2007, 0, 7]).week(), 1, 'Jan 7 2007 should be week 1');
- assert.equal(moment([2007, 0, 8]).week(), 2, 'Jan 8 2007 should be week 2');
- assert.equal(moment([2007, 0, 14]).week(), 2, 'Jan 14 2007 should be week 2');
- assert.equal(moment([2007, 0, 15]).week(), 3, 'Jan 15 2007 should be week 3');
-});
-
-test('weeks year starting tuesday', function (assert) {
- assert.equal(moment([2007, 11, 31]).week(), 1, 'Dec 31 2007 should be week 1');
- assert.equal(moment([2008, 0, 1]).week(), 1, 'Jan 1 2008 should be week 1');
- assert.equal(moment([2008, 0, 6]).week(), 1, 'Jan 6 2008 should be week 1');
- assert.equal(moment([2008, 0, 7]).week(), 2, 'Jan 7 2008 should be week 2');
- assert.equal(moment([2008, 0, 13]).week(), 2, 'Jan 13 2008 should be week 2');
- assert.equal(moment([2008, 0, 14]).week(), 3, 'Jan 14 2008 should be week 3');
-});
-
-test('weeks year starting wednesday', function (assert) {
- assert.equal(moment([2002, 11, 30]).week(), 1, 'Dec 30 2002 should be week 1');
- assert.equal(moment([2003, 0, 1]).week(), 1, 'Jan 1 2003 should be week 1');
- assert.equal(moment([2003, 0, 5]).week(), 1, 'Jan 5 2003 should be week 1');
- assert.equal(moment([2003, 0, 6]).week(), 2, 'Jan 6 2003 should be week 2');
- assert.equal(moment([2003, 0, 12]).week(), 2, 'Jan 12 2003 should be week 2');
- assert.equal(moment([2003, 0, 13]).week(), 3, 'Jan 13 2003 should be week 3');
-});
-
-test('weeks year starting thursday', function (assert) {
- assert.equal(moment([2008, 11, 29]).week(), 1, 'Dec 29 2008 should be week 1');
- assert.equal(moment([2009, 0, 1]).week(), 1, 'Jan 1 2009 should be week 1');
- assert.equal(moment([2009, 0, 4]).week(), 1, 'Jan 4 2009 should be week 1');
- assert.equal(moment([2009, 0, 5]).week(), 2, 'Jan 5 2009 should be week 2');
- assert.equal(moment([2009, 0, 11]).week(), 2, 'Jan 11 2009 should be week 2');
- assert.equal(moment([2009, 0, 12]).week(), 3, 'Jan 12 2009 should be week 3');
-});
-
-test('weeks year starting friday', function (assert) {
- assert.equal(moment([2009, 11, 28]).week(), 1, 'Dec 28 2009 should be week 1');
- assert.equal(moment([2010, 0, 1]).week(), 1, 'Jan 1 2010 should be week 1');
- assert.equal(moment([2010, 0, 3]).week(), 1, 'Jan 3 2010 should be week 1');
- assert.equal(moment([2010, 0, 4]).week(), 2, 'Jan 4 2010 should be week 2');
- assert.equal(moment([2010, 0, 10]).week(), 2, 'Jan 10 2010 should be week 2');
- assert.equal(moment([2010, 0, 11]).week(), 3, 'Jan 11 2010 should be week 3');
-});
-
-test('weeks year starting saturday', function (assert) {
- assert.equal(moment([2010, 11, 27]).week(), 1, 'Dec 27 2010 should be week 1');
- assert.equal(moment([2011, 0, 1]).week(), 1, 'Jan 1 2011 should be week 1');
- assert.equal(moment([2011, 0, 2]).week(), 1, 'Jan 2 2011 should be week 1');
- assert.equal(moment([2011, 0, 3]).week(), 2, 'Jan 3 2011 should be week 2');
- assert.equal(moment([2011, 0, 9]).week(), 2, 'Jan 9 2011 should be week 2');
- assert.equal(moment([2011, 0, 10]).week(), 3, 'Jan 10 2011 should be week 3');
-});
-
test('weeks year starting sunday format', function (assert) {
assert.equal(moment([2011, 11, 26]).format('w ww wo'), '1 01 1', 'Dec 26 2011 should be week 1');
assert.equal(moment([2012, 0, 1]).format('w ww wo'), '1 01 1', 'Jan 1 2012 should be week 1');
@@ -268,38 +207,3 @@
assert.equal(moment([2012, 0, 9]).format('w ww wo'), '3 03 3', 'Jan 9 2012 should be week 3');
});
-test('lenient ordinal parsing', function (assert) {
- var i, ordinalStr, testMoment;
- for (i = 1; i <= 31; ++i) {
- ordinalStr = moment([2014, 0, i]).format('YYYY MM Do');
- testMoment = moment(ordinalStr, 'YYYY MM Do');
- assert.equal(testMoment.year(), 2014,
- 'lenient ordinal parsing ' + i + ' year check');
- assert.equal(testMoment.month(), 0,
- 'lenient ordinal parsing ' + i + ' month check');
- assert.equal(testMoment.date(), i,
- 'lenient ordinal parsing ' + i + ' date check');
- }
-});
-
-test('lenient ordinal parsing of number', function (assert) {
- var i, testMoment;
- for (i = 1; i <= 31; ++i) {
- testMoment = moment('2014 01 ' + i, 'YYYY MM Do');
- assert.equal(testMoment.year(), 2014,
- 'lenient ordinal parsing of number ' + i + ' year check');
- assert.equal(testMoment.month(), 0,
- 'lenient ordinal parsing of number ' + i + ' month check');
- assert.equal(testMoment.date(), i,
- 'lenient ordinal parsing of number ' + i + ' date check');
- }
-});
-
-test('strict ordinal parsing', function (assert) {
- var i, ordinalStr, testMoment;
- for (i = 1; i <= 31; ++i) {
- ordinalStr = moment([2014, 0, i]).format('YYYY MM Do');
- testMoment = moment(ordinalStr, 'YYYY MM Do', true);
- assert.ok(testMoment.isValid(), 'strict ordinal parsing ' + i);
- }
-});
diff --git a/src/test/locale/ta.js b/src/test/locale/ta.js
index a471433..305457a 100644
--- a/src/test/locale/ta.js
+++ b/src/test/locale/ta.js
@@ -151,14 +151,14 @@
});
test('calendar day', function (assert) {
- var a = moment().hours(2).minutes(0).seconds(0);
-
- assert.equal(moment(a).calendar(), 'இன்று ௦௨:௦௦', 'இன்று 02:00');
- assert.equal(moment(a).add({m: 25}).calendar(), 'இன்று ௦௨:௨௫', 'இன்று 02:25');
- assert.equal(moment(a).add({h: 1}).calendar(), 'இன்று ௦௩:௦௦', 'இன்று 03:00');
- assert.equal(moment(a).add({d: 1}).calendar(), 'நாளை ௦௨:௦௦', 'நாளை 02:00');
- assert.equal(moment(a).subtract({h: 1}).calendar(), 'இன்று ௦௧:௦௦', 'இன்று 0௧:00');
- assert.equal(moment(a).subtract({d: 1}).calendar(), 'நேற்று ௦௨:௦௦', 'நேற்று 02:00');
+ var a = moment().hours(12).minutes(0).seconds(0);
+
+ assert.equal(moment(a).calendar(), 'இன்று ௧௨:௦௦', 'இன்று 12:00');
+ assert.equal(moment(a).add({m: 25}).calendar(), 'இன்று ௧௨:௨௫', 'இன்று 12:25');
+ assert.equal(moment(a).add({h: 1}).calendar(), 'இன்று ௧௩:௦௦', 'இன்று 13:00');
+ assert.equal(moment(a).add({d: 1}).calendar(), 'நாளை ௧௨:௦௦', 'நாளை 12:00');
+ assert.equal(moment(a).subtract({h: 1}).calendar(), 'இன்று ௧௧:௦௦', 'இன்று 11:00');
+ assert.equal(moment(a).subtract({d: 1}).calendar(), 'நேற்று ௧௨:௦௦', 'நேற்று 12:00');
});
test('calendar next week', function (assert) {
@@ -200,67 +200,6 @@
assert.equal(weeksFromNow.calendar(), weeksFromNow.format('L'), 'in 2 weeks');
});
-test('weeks year starting sunday', function (assert) {
- assert.equal(moment([2012, 0, 1]).week(), 1, 'Jan 1 2012 should be week 1');
- assert.equal(moment([2012, 0, 7]).week(), 1, 'Jan 7 2012 should be week 1');
- assert.equal(moment([2012, 0, 8]).week(), 2, 'Jan 8 2012 should be week 2');
- assert.equal(moment([2012, 0, 14]).week(), 2, 'Jan 14 2012 should be week 2');
- assert.equal(moment([2012, 0, 15]).week(), 3, 'Jan 15 2012 should be week 3');
-});
-
-test('weeks year starting monday', function (assert) {
- assert.equal(moment([2006, 11, 31]).week(), 1, 'Dec 31 2006 should be week 1');
- assert.equal(moment([2007, 0, 1]).week(), 1, 'Jan 1 2007 should be week 1');
- assert.equal(moment([2007, 0, 6]).week(), 1, 'Jan 6 2007 should be week 1');
- assert.equal(moment([2007, 0, 7]).week(), 2, 'Jan 7 2007 should be week 2');
- assert.equal(moment([2007, 0, 13]).week(), 2, 'Jan 13 2007 should be week 2');
- assert.equal(moment([2007, 0, 14]).week(), 3, 'Jan 14 2007 should be week 3');
-});
-
-test('weeks year starting tuesday', function (assert) {
- assert.equal(moment([2007, 11, 29]).week(), 52, 'Dec 29 2007 should be week 52');
- assert.equal(moment([2008, 0, 1]).week(), 1, 'Jan 1 2008 should be week 1');
- assert.equal(moment([2008, 0, 5]).week(), 1, 'Jan 5 2008 should be week 1');
- assert.equal(moment([2008, 0, 6]).week(), 2, 'Jan 6 2008 should be week 2');
- assert.equal(moment([2008, 0, 12]).week(), 2, 'Jan 12 2008 should be week 2');
- assert.equal(moment([2008, 0, 13]).week(), 3, 'Jan 13 2008 should be week 3');
-});
-
-test('weeks year starting wednesday', function (assert) {
- assert.equal(moment([2002, 11, 29]).week(), 1, 'Dec 29 2002 should be week 1');
- assert.equal(moment([2003, 0, 1]).week(), 1, 'Jan 1 2003 should be week 1');
- assert.equal(moment([2003, 0, 4]).week(), 1, 'Jan 4 2003 should be week 1');
- assert.equal(moment([2003, 0, 5]).week(), 2, 'Jan 5 2003 should be week 2');
- assert.equal(moment([2003, 0, 11]).week(), 2, 'Jan 11 2003 should be week 2');
- assert.equal(moment([2003, 0, 12]).week(), 3, 'Jan 12 2003 should be week 3');
-});
-
-test('weeks year starting thursday', function (assert) {
- assert.equal(moment([2008, 11, 28]).week(), 1, 'Dec 28 2008 should be week 1');
- assert.equal(moment([2009, 0, 1]).week(), 1, 'Jan 1 2009 should be week 1');
- assert.equal(moment([2009, 0, 3]).week(), 1, 'Jan 3 2009 should be week 1');
- assert.equal(moment([2009, 0, 4]).week(), 2, 'Jan 4 2009 should be week 2');
- assert.equal(moment([2009, 0, 10]).week(), 2, 'Jan 10 2009 should be week 2');
- assert.equal(moment([2009, 0, 11]).week(), 3, 'Jan 11 2009 should be week 3');
-});
-
-test('weeks year starting friday', function (assert) {
- assert.equal(moment([2009, 11, 27]).week(), 1, 'Dec 27 2009 should be week 1');
- assert.equal(moment([2010, 0, 1]).week(), 1, 'Jan 1 2010 should be week 1');
- assert.equal(moment([2010, 0, 2]).week(), 1, 'Jan 2 2010 should be week 1');
- assert.equal(moment([2010, 0, 3]).week(), 2, 'Jan 3 2010 should be week 2');
- assert.equal(moment([2010, 0, 9]).week(), 2, 'Jan 9 2010 should be week 2');
- assert.equal(moment([2010, 0, 10]).week(), 3, 'Jan 10 2010 should be week 3');
-});
-
-test('weeks year starting saturday', function (assert) {
- assert.equal(moment([2010, 11, 26]).week(), 1, 'Dec 26 2010 should be week 1');
- assert.equal(moment([2011, 0, 1]).week(), 1, 'Jan 1 2011 should be week 1');
- assert.equal(moment([2011, 0, 2]).week(), 2, 'Jan 2 2011 should be week 2');
- assert.equal(moment([2011, 0, 8]).week(), 2, 'Jan 8 2011 should be week 2');
- assert.equal(moment([2011, 0, 9]).week(), 3, 'Jan 9 2011 should be week 3');
-});
-
test('meridiem', function (assert) {
assert.equal(moment([2011, 2, 23, 0, 30]).format('a'), ' யாமம்', '(after) midnight');
assert.equal(moment([2011, 2, 23, 2, 30]).format('a'), ' வைகறை', 'before dawn');
@@ -271,50 +210,4 @@
assert.equal(moment([2011, 2, 23, 23, 30]).format('a'), ' யாமம்', '(before) midnight');
});
-test('lenient ordinal parsing', function (assert) {
- var i, ordinalStr, testMoment;
- for (i = 1; i <= 31; ++i) {
- ordinalStr = moment([2014, 0, i]).format('YYYY MM Do');
- testMoment = moment(ordinalStr, 'YYYY MM Do');
- assert.equal(testMoment.year(), 2014,
- 'lenient ordinal parsing ' + i + ' year check');
- assert.equal(testMoment.month(), 0,
- 'lenient ordinal parsing ' + i + ' month check');
- assert.equal(testMoment.date(), i,
- 'lenient ordinal parsing ' + i + ' date check');
- }
-});
-
-test('lenient ordinal parsing of number', function (assert) {
- var i, testMoment;
- for (i = 1; i <= 31; ++i) {
- testMoment = moment('2014 01 ' + i, 'YYYY MM Do');
- assert.equal(testMoment.year(), 2014,
- 'lenient ordinal parsing of number ' + i + ' year check');
- assert.equal(testMoment.month(), 0,
- 'lenient ordinal parsing of number ' + i + ' month check');
- assert.equal(testMoment.date(), i,
- 'lenient ordinal parsing of number ' + i + ' date check');
- }
-});
-
-test('meridiem invariant', function (assert) {
- var h, m, t1, t2;
- for (h = 0; h < 24; ++h) {
- for (m = 0; m < 60; m += 15) {
- t1 = moment.utc([2000, 0, 1, h, m]);
- t2 = moment(t1.format('A h:mm'), 'A h:mm');
- assert.equal(t2.format('HH:mm'), t1.format('HH:mm'),
- 'meridiem at ' + t1.format('HH:mm'));
- }
- }
-});
-
-test('strict ordinal parsing', function (assert) {
- var i, ordinalStr, testMoment;
- for (i = 1; i <= 31; ++i) {
- ordinalStr = moment([2014, 0, i]).format('YYYY MM Do');
- testMoment = moment(ordinalStr, 'YYYY MM Do', true);
- assert.ok(testMoment.isValid(), 'strict ordinal parsing ' + i);
- }
-});
+
diff --git a/src/test/locale/te.js b/src/test/locale/te.js
index 9e6cc35..59f6352 100644
--- a/src/test/locale/te.js
+++ b/src/test/locale/te.js
@@ -150,14 +150,14 @@
});
test('calendar day', function (assert) {
- var a = moment().hours(2).minutes(0).seconds(0);
-
- assert.equal(moment(a).calendar(), 'నేడు రాత్రి 2:00', 'today at the same time');
- assert.equal(moment(a).add({m: 25}).calendar(), 'నేడు రాత్రి 2:25', 'Now plus 25 min');
- assert.equal(moment(a).add({h: 3}).calendar(), 'నేడు ఉదయం 5:00', 'Now plus 3 hour');
- assert.equal(moment(a).add({d: 1}).calendar(), 'రేపు రాత్రి 2:00', 'tomorrow at the same time');
- assert.equal(moment(a).subtract({h: 1}).calendar(), 'నేడు రాత్రి 1:00', 'Now minus 1 hour');
- assert.equal(moment(a).subtract({d: 1}).calendar(), 'నిన్న రాత్రి 2:00', 'yesterday at the same time');
+ var a = moment().hours(12).minutes(0).seconds(0);
+
+ assert.equal(moment(a).calendar(), 'నేడు మధ్యాహ్నం 12:00', 'today at the same time');
+ assert.equal(moment(a).add({m: 25}).calendar(), 'నేడు మధ్యాహ్నం 12:25', 'Now plus 25 min');
+ assert.equal(moment(a).add({h: 3}).calendar(), 'నేడు మధ్యాహ్నం 3:00', 'Now plus 3 hours');
+ assert.equal(moment(a).add({d: 1}).calendar(), 'రేపు మధ్యాహ్నం 12:00', 'tomorrow at the same time');
+ assert.equal(moment(a).subtract({h: 1}).calendar(), 'నేడు మధ్యాహ్నం 11:00', 'Now minus 1 hour');
+ assert.equal(moment(a).subtract({d: 1}).calendar(), 'నిన్న మధ్యాహ్నం 12:00', 'yesterday at the same time');
});
test('calendar next week', function (assert) {
@@ -199,7 +199,7 @@
assert.equal(weeksFromNow.calendar(), weeksFromNow.format('L'), 'in 2 weeks');
});
-test('meridiem invariant', function (assert) {
+test('meridiem', function (assert) {
assert.equal(moment([2011, 2, 23, 2, 30]).format('a'), 'రాత్రి', 'before dawn');
assert.equal(moment([2011, 2, 23, 9, 30]).format('a'), 'ఉదయం', 'morning');
assert.equal(moment([2011, 2, 23, 14, 30]).format('a'), 'మధ్యాహ్నం', 'during day');
@@ -215,67 +215,6 @@
assert.equal(moment([2011, 2, 23, 21, 20]).format('A'), 'రాత్రి', 'night');
});
-test('weeks year starting sunday', function (assert) {
- assert.equal(moment([2012, 0, 1]).week(), 1, 'Jan 1 2012 should be week 1');
- assert.equal(moment([2012, 0, 7]).week(), 1, 'Jan 7 2012 should be week 1');
- assert.equal(moment([2012, 0, 8]).week(), 2, 'Jan 8 2012 should be week 2');
- assert.equal(moment([2012, 0, 14]).week(), 2, 'Jan 14 2012 should be week 2');
- assert.equal(moment([2012, 0, 15]).week(), 3, 'Jan 15 2012 should be week 3');
-});
-
-test('weeks year starting monday', function (assert) {
- assert.equal(moment([2006, 11, 31]).week(), 1, 'Dec 31 2006 should be week 1');
- assert.equal(moment([2007, 0, 1]).week(), 1, 'Jan 1 2007 should be week 1');
- assert.equal(moment([2007, 0, 6]).week(), 1, 'Jan 6 2007 should be week 1');
- assert.equal(moment([2007, 0, 7]).week(), 2, 'Jan 7 2007 should be week 2');
- assert.equal(moment([2007, 0, 13]).week(), 2, 'Jan 13 2007 should be week 2');
- assert.equal(moment([2007, 0, 14]).week(), 3, 'Jan 14 2007 should be week 3');
-});
-
-test('weeks year starting tuesday', function (assert) {
- assert.equal(moment([2007, 11, 29]).week(), 52, 'Dec 29 2007 should be week 52');
- assert.equal(moment([2008, 0, 1]).week(), 1, 'Jan 1 2008 should be week 1');
- assert.equal(moment([2008, 0, 5]).week(), 1, 'Jan 5 2008 should be week 1');
- assert.equal(moment([2008, 0, 6]).week(), 2, 'Jan 6 2008 should be week 2');
- assert.equal(moment([2008, 0, 12]).week(), 2, 'Jan 12 2008 should be week 2');
- assert.equal(moment([2008, 0, 13]).week(), 3, 'Jan 13 2008 should be week 3');
-});
-
-test('weeks year starting wednesday', function (assert) {
- assert.equal(moment([2002, 11, 29]).week(), 1, 'Dec 29 2002 should be week 1');
- assert.equal(moment([2003, 0, 1]).week(), 1, 'Jan 1 2003 should be week 1');
- assert.equal(moment([2003, 0, 4]).week(), 1, 'Jan 4 2003 should be week 1');
- assert.equal(moment([2003, 0, 5]).week(), 2, 'Jan 5 2003 should be week 2');
- assert.equal(moment([2003, 0, 11]).week(), 2, 'Jan 11 2003 should be week 2');
- assert.equal(moment([2003, 0, 12]).week(), 3, 'Jan 12 2003 should be week 3');
-});
-
-test('weeks year starting thursday', function (assert) {
- assert.equal(moment([2008, 11, 28]).week(), 1, 'Dec 28 2008 should be week 1');
- assert.equal(moment([2009, 0, 1]).week(), 1, 'Jan 1 2009 should be week 1');
- assert.equal(moment([2009, 0, 3]).week(), 1, 'Jan 3 2009 should be week 1');
- assert.equal(moment([2009, 0, 4]).week(), 2, 'Jan 4 2009 should be week 2');
- assert.equal(moment([2009, 0, 10]).week(), 2, 'Jan 10 2009 should be week 2');
- assert.equal(moment([2009, 0, 11]).week(), 3, 'Jan 11 2009 should be week 3');
-});
-
-test('weeks year starting friday', function (assert) {
- assert.equal(moment([2009, 11, 27]).week(), 1, 'Dec 27 2009 should be week 1');
- assert.equal(moment([2010, 0, 1]).week(), 1, 'Jan 1 2010 should be week 1');
- assert.equal(moment([2010, 0, 2]).week(), 1, 'Jan 2 2010 should be week 1');
- assert.equal(moment([2010, 0, 3]).week(), 2, 'Jan 3 2010 should be week 2');
- assert.equal(moment([2010, 0, 9]).week(), 2, 'Jan 9 2010 should be week 2');
- assert.equal(moment([2010, 0, 10]).week(), 3, 'Jan 10 2010 should be week 3');
-});
-
-test('weeks year starting saturday', function (assert) {
- assert.equal(moment([2010, 11, 26]).week(), 1, 'Dec 26 2010 should be week 1');
- assert.equal(moment([2011, 0, 1]).week(), 1, 'Jan 1 2011 should be week 1');
- assert.equal(moment([2011, 0, 2]).week(), 2, 'Jan 2 2011 should be week 2');
- assert.equal(moment([2011, 0, 8]).week(), 2, 'Jan 8 2011 should be week 2');
- assert.equal(moment([2011, 0, 9]).week(), 3, 'Jan 9 2011 should be week 3');
-});
-
test('weeks year starting sunday formatted', function (assert) {
assert.equal(moment([2012, 0, 1]).format('w ww wo'), '1 01 1వ', 'Jan 1 2012 should be week 1');
assert.equal(moment([2012, 0, 7]).format('w ww wo'), '1 01 1వ', 'Jan 7 2012 should be week 1');
@@ -283,51 +222,3 @@
assert.equal(moment([2012, 0, 14]).format('w ww wo'), '2 02 2వ', 'Jan 14 2012 should be week 2');
assert.equal(moment([2012, 0, 15]).format('w ww wo'), '3 03 3వ', 'Jan 15 2012 should be week 3');
});
-
-test('lenient ordinal parsing', function (assert) {
- var i, ordinalStr, testMoment;
- for (i = 1; i <= 31; ++i) {
- ordinalStr = moment([2014, 0, i]).format('YYYY MM Do');
- testMoment = moment(ordinalStr, 'YYYY MM Do');
- assert.equal(testMoment.year(), 2014,
- 'lenient ordinal parsing ' + i + ' year check');
- assert.equal(testMoment.month(), 0,
- 'lenient ordinal parsing ' + i + ' month check');
- assert.equal(testMoment.date(), i,
- 'lenient ordinal parsing ' + i + ' date check');
- }
-});
-
-test('lenient ordinal parsing of number', function (assert) {
- var i, testMoment;
- for (i = 1; i <= 31; ++i) {
- testMoment = moment('2014 01 ' + i, 'YYYY MM Do');
- assert.equal(testMoment.year(), 2014,
- 'lenient ordinal parsing of number ' + i + ' year check');
- assert.equal(testMoment.month(), 0,
- 'lenient ordinal parsing of number ' + i + ' month check');
- assert.equal(testMoment.date(), i,
- 'lenient ordinal parsing of number ' + i + ' date check');
- }
-});
-
-test('meridiem', function (assert) {
- var h, m, t1, t2;
- for (h = 0; h < 24; ++h) {
- for (m = 0; m < 60; m += 15) {
- t1 = moment.utc([2000, 0, 1, h, m]);
- t2 = moment(t1.format('A h:mm'), 'A h:mm');
- assert.equal(t2.format('HH:mm'), t1.format('HH:mm'),
- 'meridiem at ' + t1.format('HH:mm'));
- }
- }
-});
-
-test('strict ordinal parsing', function (assert) {
- var i, ordinalStr, testMoment;
- for (i = 1; i <= 31; ++i) {
- ordinalStr = moment([2014, 0, i]).format('YYYY MM Do');
- testMoment = moment(ordinalStr, 'YYYY MM Do', true);
- assert.ok(testMoment.isValid(), 'strict ordinal parsing ' + i);
- }
-});
diff --git a/src/test/locale/th.js b/src/test/locale/th.js
index 975ec04..885f8c0 100644
--- a/src/test/locale/th.js
+++ b/src/test/locale/th.js
@@ -114,14 +114,14 @@
});
test('calendar day', function (assert) {
- var a = moment().hours(2).minutes(0).seconds(0);
+ var a = moment().hours(12).minutes(0).seconds(0);
- assert.equal(moment(a).calendar(), 'วันนี้ เวลา 2 นาฬิกา 0 นาที', 'today at the same time');
- assert.equal(moment(a).add({m: 25}).calendar(), 'วันนี้ เวลา 2 นาฬิกา 25 นาที', 'Now plus 25 min');
- assert.equal(moment(a).add({h: 1}).calendar(), 'วันนี้ เวลา 3 นาฬิกา 0 นาที', 'Now plus 1 hour');
- assert.equal(moment(a).add({d: 1}).calendar(), 'พรุ่งนี้ เวลา 2 นาฬิกา 0 นาที', 'tomorrow at the same time');
- assert.equal(moment(a).subtract({h: 1}).calendar(), 'วันนี้ เวลา 1 นาฬิกา 0 นาที', 'Now minus 1 hour');
- assert.equal(moment(a).subtract({d: 1}).calendar(), 'เมื่อวานนี้ เวลา 2 นาฬิกา 0 นาที', 'yesterday at the same time');
+ assert.equal(moment(a).calendar(), 'วันนี้ เวลา 12 นาฬิกา 0 นาที', 'today at the same time');
+ assert.equal(moment(a).add({m: 25}).calendar(), 'วันนี้ เวลา 12 นาฬิกา 25 นาที', 'Now plus 25 min');
+ assert.equal(moment(a).add({h: 1}).calendar(), 'วันนี้ เวลา 13 นาฬิกา 0 นาที', 'Now plus 1 hour');
+ assert.equal(moment(a).add({d: 1}).calendar(), 'พรุ่งนี้ เวลา 12 นาฬิกา 0 นาที', 'tomorrow at the same time');
+ assert.equal(moment(a).subtract({h: 1}).calendar(), 'วันนี้ เวลา 11 นาฬิกา 0 นาที', 'Now minus 1 hour');
+ assert.equal(moment(a).subtract({d: 1}).calendar(), 'เมื่อวานนี้ เวลา 12 นาฬิกา 0 นาที', 'yesterday at the same time');
});
test('calendar next week', function (assert) {
@@ -162,67 +162,6 @@
assert.equal(weeksFromNow.calendar(), weeksFromNow.format('L'), 'in 2 weeks');
});
-test('weeks year starting sunday', function (assert) {
- assert.equal(moment([2012, 0, 1]).week(), 1, 'Jan 1 2012 should be week 1');
- assert.equal(moment([2012, 0, 7]).week(), 1, 'Jan 7 2012 should be week 1');
- assert.equal(moment([2012, 0, 8]).week(), 2, 'Jan 8 2012 should be week 2');
- assert.equal(moment([2012, 0, 14]).week(), 2, 'Jan 14 2012 should be week 2');
- assert.equal(moment([2012, 0, 15]).week(), 3, 'Jan 15 2012 should be week 3');
-});
-
-test('weeks year starting monday', function (assert) {
- assert.equal(moment([2006, 11, 31]).week(), 1, 'Dec 31 2006 should be week 1');
- assert.equal(moment([2007, 0, 1]).week(), 1, 'Jan 1 2007 should be week 1');
- assert.equal(moment([2007, 0, 6]).week(), 1, 'Jan 6 2007 should be week 1');
- assert.equal(moment([2007, 0, 7]).week(), 2, 'Jan 7 2007 should be week 2');
- assert.equal(moment([2007, 0, 13]).week(), 2, 'Jan 13 2007 should be week 2');
- assert.equal(moment([2007, 0, 14]).week(), 3, 'Jan 14 2007 should be week 3');
-});
-
-test('weeks year starting tuesday', function (assert) {
- assert.equal(moment([2007, 11, 29]).week(), 52, 'Dec 29 2007 should be week 52');
- assert.equal(moment([2008, 0, 1]).week(), 1, 'Jan 1 2008 should be week 1');
- assert.equal(moment([2008, 0, 5]).week(), 1, 'Jan 5 2008 should be week 1');
- assert.equal(moment([2008, 0, 6]).week(), 2, 'Jan 6 2008 should be week 2');
- assert.equal(moment([2008, 0, 12]).week(), 2, 'Jan 12 2008 should be week 2');
- assert.equal(moment([2008, 0, 13]).week(), 3, 'Jan 13 2008 should be week 3');
-});
-
-test('weeks year starting wednesday', function (assert) {
- assert.equal(moment([2002, 11, 29]).week(), 1, 'Dec 29 2002 should be week 1');
- assert.equal(moment([2003, 0, 1]).week(), 1, 'Jan 1 2003 should be week 1');
- assert.equal(moment([2003, 0, 4]).week(), 1, 'Jan 4 2003 should be week 1');
- assert.equal(moment([2003, 0, 5]).week(), 2, 'Jan 5 2003 should be week 2');
- assert.equal(moment([2003, 0, 11]).week(), 2, 'Jan 11 2003 should be week 2');
- assert.equal(moment([2003, 0, 12]).week(), 3, 'Jan 12 2003 should be week 3');
-});
-
-test('weeks year starting thursday', function (assert) {
- assert.equal(moment([2008, 11, 28]).week(), 1, 'Dec 28 2008 should be week 1');
- assert.equal(moment([2009, 0, 1]).week(), 1, 'Jan 1 2009 should be week 1');
- assert.equal(moment([2009, 0, 3]).week(), 1, 'Jan 3 2009 should be week 1');
- assert.equal(moment([2009, 0, 4]).week(), 2, 'Jan 4 2009 should be week 2');
- assert.equal(moment([2009, 0, 10]).week(), 2, 'Jan 10 2009 should be week 2');
- assert.equal(moment([2009, 0, 11]).week(), 3, 'Jan 11 2009 should be week 3');
-});
-
-test('weeks year starting friday', function (assert) {
- assert.equal(moment([2009, 11, 27]).week(), 1, 'Dec 27 2009 should be week 1');
- assert.equal(moment([2010, 0, 1]).week(), 1, 'Jan 1 2010 should be week 1');
- assert.equal(moment([2010, 0, 2]).week(), 1, 'Jan 2 2010 should be week 1');
- assert.equal(moment([2010, 0, 3]).week(), 2, 'Jan 3 2010 should be week 2');
- assert.equal(moment([2010, 0, 9]).week(), 2, 'Jan 9 2010 should be week 2');
- assert.equal(moment([2010, 0, 10]).week(), 3, 'Jan 10 2010 should be week 3');
-});
-
-test('weeks year starting saturday', function (assert) {
- assert.equal(moment([2010, 11, 26]).week(), 1, 'Dec 26 2010 should be week 1');
- assert.equal(moment([2011, 0, 1]).week(), 1, 'Jan 1 2011 should be week 1');
- assert.equal(moment([2011, 0, 2]).week(), 2, 'Jan 2 2011 should be week 2');
- assert.equal(moment([2011, 0, 8]).week(), 2, 'Jan 8 2011 should be week 2');
- assert.equal(moment([2011, 0, 9]).week(), 3, 'Jan 9 2011 should be week 3');
-});
-
test('weeks year starting sunday format', function (assert) {
assert.equal(moment([2012, 0, 1]).format('w ww wo'), '1 01 1', 'Jan 1 2012 should be week 1');
assert.equal(moment([2012, 0, 7]).format('w ww wo'), '1 01 1', 'Jan 7 2012 should be week 1');
@@ -231,38 +170,3 @@
assert.equal(moment([2012, 0, 15]).format('w ww wo'), '3 03 3', 'Jan 15 2012 should be week 3');
});
-test('lenient ordinal parsing', function (assert) {
- var i, ordinalStr, testMoment;
- for (i = 1; i <= 31; ++i) {
- ordinalStr = moment([2014, 0, i]).format('YYYY MM Do');
- testMoment = moment(ordinalStr, 'YYYY MM Do');
- assert.equal(testMoment.year(), 2014,
- 'lenient ordinal parsing ' + i + ' year check');
- assert.equal(testMoment.month(), 0,
- 'lenient ordinal parsing ' + i + ' month check');
- assert.equal(testMoment.date(), i,
- 'lenient ordinal parsing ' + i + ' date check');
- }
-});
-
-test('lenient ordinal parsing of number', function (assert) {
- var i, testMoment;
- for (i = 1; i <= 31; ++i) {
- testMoment = moment('2014 01 ' + i, 'YYYY MM Do');
- assert.equal(testMoment.year(), 2014,
- 'lenient ordinal parsing of number ' + i + ' year check');
- assert.equal(testMoment.month(), 0,
- 'lenient ordinal parsing of number ' + i + ' month check');
- assert.equal(testMoment.date(), i,
- 'lenient ordinal parsing of number ' + i + ' date check');
- }
-});
-
-test('strict ordinal parsing', function (assert) {
- var i, ordinalStr, testMoment;
- for (i = 1; i <= 31; ++i) {
- ordinalStr = moment([2014, 0, i]).format('YYYY MM Do');
- testMoment = moment(ordinalStr, 'YYYY MM Do', true);
- assert.ok(testMoment.isValid(), 'strict ordinal parsing ' + i);
- }
-});
diff --git a/src/test/locale/tl-ph.js b/src/test/locale/tl-ph.js
index adabec5..97e56c3 100644
--- a/src/test/locale/tl-ph.js
+++ b/src/test/locale/tl-ph.js
@@ -148,14 +148,14 @@
});
test('same day', function (assert) {
- var a = moment().hours(2).minutes(0).seconds(0);
-
- assert.equal(moment(a).calendar(), 'Ngayon sa 02:00', 'today at the same time');
- assert.equal(moment(a).add({m: 25}).calendar(), 'Ngayon sa 02:25', 'Now plus 25 min');
- assert.equal(moment(a).add({h: 1}).calendar(), 'Ngayon sa 03:00', 'Now plus 1 hour');
- assert.equal(moment(a).add({d: 1}).calendar(), 'Bukas sa 02:00', 'tomorrow at the same time');
- assert.equal(moment(a).subtract({h: 1}).calendar(), 'Ngayon sa 01:00', 'Now minus 1 hour');
- assert.equal(moment(a).subtract({d: 1}).calendar(), 'Kahapon sa 02:00', 'yesterday at the same time');
+ var a = moment().hours(12).minutes(0).seconds(0);
+
+ assert.equal(moment(a).calendar(), 'Ngayon sa 12:00', 'today at the same time');
+ assert.equal(moment(a).add({m: 25}).calendar(), 'Ngayon sa 12:25', 'Now plus 25 min');
+ assert.equal(moment(a).add({h: 1}).calendar(), 'Ngayon sa 13:00', 'Now plus 1 hour');
+ assert.equal(moment(a).add({d: 1}).calendar(), 'Bukas sa 12:00', 'tomorrow at the same time');
+ assert.equal(moment(a).subtract({h: 1}).calendar(), 'Ngayon sa 11:00', 'Now minus 1 hour');
+ assert.equal(moment(a).subtract({d: 1}).calendar(), 'Kahapon sa 12:00', 'yesterday at the same time');
});
test('same next week', function (assert) {
@@ -198,67 +198,6 @@
assert.equal(weeksFromNow.calendar(), weeksFromNow.format('L'), 'in 2 weeks');
});
-test('weeks year starting sunday', function (assert) {
- assert.equal(moment([2012, 0, 1]).week(), 52, 'Jan 1 2012 should be week 52');
- assert.equal(moment([2012, 0, 2]).week(), 1, 'Jan 2 2012 should be week 1');
- assert.equal(moment([2012, 0, 8]).week(), 1, 'Jan 8 2012 should be week 1');
- assert.equal(moment([2012, 0, 9]).week(), 2, 'Jan 9 2012 should be week 2');
- assert.equal(moment([2012, 0, 15]).week(), 2, 'Jan 15 2012 should be week 2');
-});
-
-test('weeks year starting monday', function (assert) {
- assert.equal(moment([2007, 0, 1]).week(), 1, 'Jan 1 2007 should be week 1');
- assert.equal(moment([2007, 0, 7]).week(), 1, 'Jan 7 2007 should be week 1');
- assert.equal(moment([2007, 0, 8]).week(), 2, 'Jan 8 2007 should be week 2');
- assert.equal(moment([2007, 0, 14]).week(), 2, 'Jan 14 2007 should be week 2');
- assert.equal(moment([2007, 0, 15]).week(), 3, 'Jan 15 2007 should be week 3');
-});
-
-test('weeks year starting tuesday', function (assert) {
- assert.equal(moment([2007, 11, 31]).week(), 1, 'Dec 31 2007 should be week 1');
- assert.equal(moment([2008, 0, 1]).week(), 1, 'Jan 1 2008 should be week 1');
- assert.equal(moment([2008, 0, 6]).week(), 1, 'Jan 6 2008 should be week 1');
- assert.equal(moment([2008, 0, 7]).week(), 2, 'Jan 7 2008 should be week 2');
- assert.equal(moment([2008, 0, 13]).week(), 2, 'Jan 13 2008 should be week 2');
- assert.equal(moment([2008, 0, 14]).week(), 3, 'Jan 14 2008 should be week 3');
-});
-
-test('weeks year starting wednesday', function (assert) {
- assert.equal(moment([2002, 11, 30]).week(), 1, 'Dec 30 2002 should be week 1');
- assert.equal(moment([2003, 0, 1]).week(), 1, 'Jan 1 2003 should be week 1');
- assert.equal(moment([2003, 0, 5]).week(), 1, 'Jan 5 2003 should be week 1');
- assert.equal(moment([2003, 0, 6]).week(), 2, 'Jan 6 2003 should be week 2');
- assert.equal(moment([2003, 0, 12]).week(), 2, 'Jan 12 2003 should be week 2');
- assert.equal(moment([2003, 0, 13]).week(), 3, 'Jan 13 2003 should be week 3');
-});
-
-test('weeks year starting thursday', function (assert) {
- assert.equal(moment([2008, 11, 29]).week(), 1, 'Dec 29 2008 should be week 1');
- assert.equal(moment([2009, 0, 1]).week(), 1, 'Jan 1 2009 should be week 1');
- assert.equal(moment([2009, 0, 4]).week(), 1, 'Jan 4 2009 should be week 1');
- assert.equal(moment([2009, 0, 5]).week(), 2, 'Jan 5 2009 should be week 2');
- assert.equal(moment([2009, 0, 11]).week(), 2, 'Jan 11 2009 should be week 2');
- assert.equal(moment([2009, 0, 13]).week(), 3, 'Jan 12 2009 should be week 3');
-});
-
-test('weeks year starting friday', function (assert) {
- assert.equal(moment([2009, 11, 28]).week(), 53, 'Dec 28 2009 should be week 53');
- assert.equal(moment([2010, 0, 1]).week(), 53, 'Jan 1 2010 should be week 53');
- assert.equal(moment([2010, 0, 3]).week(), 53, 'Jan 3 2010 should be week 53');
- assert.equal(moment([2010, 0, 4]).week(), 1, 'Jan 4 2010 should be week 1');
- assert.equal(moment([2010, 0, 10]).week(), 1, 'Jan 10 2010 should be week 1');
- assert.equal(moment([2010, 0, 11]).week(), 2, 'Jan 11 2010 should be week 2');
-});
-
-test('weeks year starting saturday', function (assert) {
- assert.equal(moment([2010, 11, 27]).week(), 52, 'Dec 27 2010 should be week 52');
- assert.equal(moment([2011, 0, 1]).week(), 52, 'Jan 1 2011 should be week 52');
- assert.equal(moment([2011, 0, 2]).week(), 52, 'Jan 2 2011 should be week 52');
- assert.equal(moment([2011, 0, 3]).week(), 1, 'Jan 3 2011 should be week 1');
- assert.equal(moment([2011, 0, 9]).week(), 1, 'Jan 9 2011 should be week 1');
- assert.equal(moment([2011, 0, 10]).week(), 2, 'Jan 10 2011 should be week 2');
-});
-
test('weeks year starting sunday formatted', function (assert) {
assert.equal(moment([2012, 0, 1]).format('w ww wo'), '52 52 52', 'Jan 1 2012 should be week 52');
assert.equal(moment([2012, 0, 2]).format('w ww wo'), '1 01 1', 'Jan 2 2012 should be week 1');
@@ -267,38 +206,3 @@
assert.equal(moment([2012, 0, 15]).format('w ww wo'), '2 02 2', 'Jan 15 2012 should be week 2');
});
-test('lenient ordinal parsing', function (assert) {
- var i, ordinalStr, testMoment;
- for (i = 1; i <= 31; ++i) {
- ordinalStr = moment([2014, 0, i]).format('YYYY MM Do');
- testMoment = moment(ordinalStr, 'YYYY MM Do');
- assert.equal(testMoment.year(), 2014,
- 'lenient ordinal parsing ' + i + ' year check');
- assert.equal(testMoment.month(), 0,
- 'lenient ordinal parsing ' + i + ' month check');
- assert.equal(testMoment.date(), i,
- 'lenient ordinal parsing ' + i + ' date check');
- }
-});
-
-test('lenient ordinal parsing of number', function (assert) {
- var i, testMoment;
- for (i = 1; i <= 31; ++i) {
- testMoment = moment('2014 01 ' + i, 'YYYY MM Do');
- assert.equal(testMoment.year(), 2014,
- 'lenient ordinal parsing of number ' + i + ' year check');
- assert.equal(testMoment.month(), 0,
- 'lenient ordinal parsing of number ' + i + ' month check');
- assert.equal(testMoment.date(), i,
- 'lenient ordinal parsing of number ' + i + ' date check');
- }
-});
-
-test('strict ordinal parsing', function (assert) {
- var i, ordinalStr, testMoment;
- for (i = 1; i <= 31; ++i) {
- ordinalStr = moment([2014, 0, i]).format('YYYY MM Do');
- testMoment = moment(ordinalStr, 'YYYY MM Do', true);
- assert.ok(testMoment.isValid(), 'strict ordinal parsing ' + i);
- }
-});
diff --git a/src/test/locale/tlh.js b/src/test/locale/tlh.js
index 4adb29d..35ca6c0 100644
--- a/src/test/locale/tlh.js
+++ b/src/test/locale/tlh.js
@@ -165,14 +165,14 @@
});
test('calendar day', function (assert) {
- var a = moment().hours(2).minutes(0).seconds(0);
-
- assert.equal(moment(a).calendar(), 'DaHjaj 02:00', 'today at the same time');
- assert.equal(moment(a).add({m: 25}).calendar(), 'DaHjaj 02:25', 'Now plus 25 min');
- assert.equal(moment(a).add({h: 1}).calendar(), 'DaHjaj 03:00', 'Now plus 1 hour');
- assert.equal(moment(a).add({d: 1}).calendar(), 'wa’leS 02:00', 'tomorrow at the same time');
- assert.equal(moment(a).subtract({h: 1}).calendar(), 'DaHjaj 01:00', 'Now minus 1 hour');
- assert.equal(moment(a).subtract({d: 1}).calendar(), 'wa’Hu’ 02:00', 'yesterday at the same time');
+ var a = moment().hours(12).minutes(0).seconds(0);
+
+ assert.equal(moment(a).calendar(), 'DaHjaj 12:00', 'today at the same time');
+ assert.equal(moment(a).add({m: 25}).calendar(), 'DaHjaj 12:25', 'Now plus 25 min');
+ assert.equal(moment(a).add({h: 1}).calendar(), 'DaHjaj 13:00', 'Now plus 1 hour');
+ assert.equal(moment(a).add({d: 1}).calendar(), 'wa’leS 12:00', 'tomorrow at the same time');
+ assert.equal(moment(a).subtract({h: 1}).calendar(), 'DaHjaj 11:00', 'Now minus 1 hour');
+ assert.equal(moment(a).subtract({d: 1}).calendar(), 'wa’Hu’ 12:00', 'yesterday at the same time');
});
test('calendar next week', function (assert) {
@@ -215,67 +215,6 @@
assert.equal(weeksFromNow.calendar(), weeksFromNow.format('L'), 'in 2 weeks');
});
-test('weeks year starting sunday', function (assert) {
- assert.equal(moment([2012, 0, 1]).week(), 52, 'Jan 1 2012 should be week 52');
- assert.equal(moment([2012, 0, 2]).week(), 1, 'Jan 2 2012 should be week 1');
- assert.equal(moment([2012, 0, 8]).week(), 1, 'Jan 8 2012 should be week 1');
- assert.equal(moment([2012, 0, 9]).week(), 2, 'Jan 9 2012 should be week 2');
- assert.equal(moment([2012, 0, 15]).week(), 2, 'Jan 15 2012 should be week 2');
-});
-
-test('weeks year starting monday', function (assert) {
- assert.equal(moment([2007, 0, 1]).week(), 1, 'Jan 1 2007 should be week 1');
- assert.equal(moment([2007, 0, 7]).week(), 1, 'Jan 7 2007 should be week 1');
- assert.equal(moment([2007, 0, 8]).week(), 2, 'Jan 8 2007 should be week 2');
- assert.equal(moment([2007, 0, 14]).week(), 2, 'Jan 14 2007 should be week 2');
- assert.equal(moment([2007, 0, 15]).week(), 3, 'Jan 15 2007 should be week 3');
-});
-
-test('weeks year starting tuesday', function (assert) {
- assert.equal(moment([2007, 11, 31]).week(), 1, 'Dec 31 2007 should be week 1');
- assert.equal(moment([2008, 0, 1]).week(), 1, 'Jan 1 2008 should be week 1');
- assert.equal(moment([2008, 0, 6]).week(), 1, 'Jan 6 2008 should be week 1');
- assert.equal(moment([2008, 0, 7]).week(), 2, 'Jan 7 2008 should be week 2');
- assert.equal(moment([2008, 0, 13]).week(), 2, 'Jan 13 2008 should be week 2');
- assert.equal(moment([2008, 0, 14]).week(), 3, 'Jan 14 2008 should be week 3');
-});
-
-test('weeks year starting wednesday', function (assert) {
- assert.equal(moment([2002, 11, 30]).week(), 1, 'Dec 30 2002 should be week 1');
- assert.equal(moment([2003, 0, 1]).week(), 1, 'Jan 1 2003 should be week 1');
- assert.equal(moment([2003, 0, 5]).week(), 1, 'Jan 5 2003 should be week 1');
- assert.equal(moment([2003, 0, 6]).week(), 2, 'Jan 6 2003 should be week 2');
- assert.equal(moment([2003, 0, 12]).week(), 2, 'Jan 12 2003 should be week 2');
- assert.equal(moment([2003, 0, 13]).week(), 3, 'Jan 13 2003 should be week 3');
-});
-
-test('weeks year starting thursday', function (assert) {
- assert.equal(moment([2008, 11, 29]).week(), 1, 'Dec 29 2008 should be week 1');
- assert.equal(moment([2009, 0, 1]).week(), 1, 'Jan 1 2009 should be week 1');
- assert.equal(moment([2009, 0, 4]).week(), 1, 'Jan 4 2009 should be week 1');
- assert.equal(moment([2009, 0, 5]).week(), 2, 'Jan 5 2009 should be week 2');
- assert.equal(moment([2009, 0, 11]).week(), 2, 'Jan 11 2009 should be week 2');
- assert.equal(moment([2009, 0, 13]).week(), 3, 'Jan 12 2009 should be week 3');
-});
-
-test('weeks year starting friday', function (assert) {
- assert.equal(moment([2009, 11, 28]).week(), 53, 'Dec 28 2009 should be week 53');
- assert.equal(moment([2010, 0, 1]).week(), 53, 'Jan 1 2010 should be week 53');
- assert.equal(moment([2010, 0, 3]).week(), 53, 'Jan 3 2010 should be week 53');
- assert.equal(moment([2010, 0, 4]).week(), 1, 'Jan 4 2010 should be week 1');
- assert.equal(moment([2010, 0, 10]).week(), 1, 'Jan 10 2010 should be week 1');
- assert.equal(moment([2010, 0, 11]).week(), 2, 'Jan 11 2010 should be week 2');
-});
-
-test('weeks year starting saturday', function (assert) {
- assert.equal(moment([2010, 11, 27]).week(), 52, 'Dec 27 2010 should be week 52');
- assert.equal(moment([2011, 0, 1]).week(), 52, 'Jan 1 2011 should be week 52');
- assert.equal(moment([2011, 0, 2]).week(), 52, 'Jan 2 2011 should be week 52');
- assert.equal(moment([2011, 0, 3]).week(), 1, 'Jan 3 2011 should be week 1');
- assert.equal(moment([2011, 0, 9]).week(), 1, 'Jan 9 2011 should be week 1');
- assert.equal(moment([2011, 0, 10]).week(), 2, 'Jan 10 2011 should be week 2');
-});
-
test('weeks year starting sunday formatted', function (assert) {
assert.equal(moment([2012, 0, 1]).format('w ww wo'), '52 52 52.', 'Jan 1 2012 should be week 52');
assert.equal(moment([2012, 0, 2]).format('w ww wo'), '1 01 1.', 'Jan 2 2012 should be week 1');
@@ -284,38 +223,3 @@
assert.equal(moment([2012, 0, 15]).format('w ww wo'), '2 02 2.', 'Jan 15 2012 should be week 2');
});
-test('lenient ordinal parsing', function (assert) {
- var i, ordinalStr, testMoment;
- for (i = 1; i <= 31; ++i) {
- ordinalStr = moment([2014, 0, i]).format('YYYY MM Do');
- testMoment = moment(ordinalStr, 'YYYY MM Do');
- assert.equal(testMoment.year(), 2014,
- 'lenient ordinal parsing ' + i + ' year check');
- assert.equal(testMoment.month(), 0,
- 'lenient ordinal parsing ' + i + ' month check');
- assert.equal(testMoment.date(), i,
- 'lenient ordinal parsing ' + i + ' date check');
- }
-});
-
-test('lenient ordinal parsing of number', function (assert) {
- var i, testMoment;
- for (i = 1; i <= 31; ++i) {
- testMoment = moment('2014 01 ' + i, 'YYYY MM Do');
- assert.equal(testMoment.year(), 2014,
- 'lenient ordinal parsing of number ' + i + ' year check');
- assert.equal(testMoment.month(), 0,
- 'lenient ordinal parsing of number ' + i + ' month check');
- assert.equal(testMoment.date(), i,
- 'lenient ordinal parsing of number ' + i + ' date check');
- }
-});
-
-test('strict ordinal parsing', function (assert) {
- var i, ordinalStr, testMoment;
- for (i = 1; i <= 31; ++i) {
- ordinalStr = moment([2014, 0, i]).format('YYYY MM Do');
- testMoment = moment(ordinalStr, 'YYYY MM Do', true);
- assert.ok(testMoment.isValid(), 'strict ordinal parsing ' + i);
- }
-});
diff --git a/src/test/locale/tr.js b/src/test/locale/tr.js
index 6140ba2..e16c3bc 100644
--- a/src/test/locale/tr.js
+++ b/src/test/locale/tr.js
@@ -162,14 +162,14 @@
});
test('calendar day', function (assert) {
- var a = moment().hours(2).minutes(0).seconds(0);
-
- assert.equal(moment(a).calendar(), 'bugün saat 02:00', 'today at the same time');
- assert.equal(moment(a).add({m: 25}).calendar(), 'bugün saat 02:25', 'Now plus 25 min');
- assert.equal(moment(a).add({h: 1}).calendar(), 'bugün saat 03:00', 'Now plus 1 hour');
- assert.equal(moment(a).add({d: 1}).calendar(), 'yarın saat 02:00', 'tomorrow at the same time');
- assert.equal(moment(a).subtract({h: 1}).calendar(), 'bugün saat 01:00', 'Now minus 1 hour');
- assert.equal(moment(a).subtract({d: 1}).calendar(), 'dün 02:00', 'yesterday at the same time');
+ var a = moment().hours(12).minutes(0).seconds(0);
+
+ assert.equal(moment(a).calendar(), 'bugün saat 12:00', 'today at the same time');
+ assert.equal(moment(a).add({m: 25}).calendar(), 'bugün saat 12:25', 'Now plus 25 min');
+ assert.equal(moment(a).add({h: 1}).calendar(), 'bugün saat 13:00', 'Now plus 1 hour');
+ assert.equal(moment(a).add({d: 1}).calendar(), 'yarın saat 12:00', 'tomorrow at the same time');
+ assert.equal(moment(a).subtract({h: 1}).calendar(), 'bugün saat 11:00', 'Now minus 1 hour');
+ assert.equal(moment(a).subtract({d: 1}).calendar(), 'dün 12:00', 'yesterday at the same time');
});
test('calendar next week', function (assert) {
@@ -210,67 +210,6 @@
assert.equal(weeksFromNow.calendar(), weeksFromNow.format('L'), 'in 2 weeks');
});
-test('weeks year starting sunday', function (assert) {
- assert.equal(moment([2011, 11, 26]).week(), 1, 'Dec 26 2011 should be week 1');
- assert.equal(moment([2012, 0, 1]).week(), 1, 'Jan 1 2012 should be week 1');
- assert.equal(moment([2012, 0, 2]).week(), 2, 'Jan 2 2012 should be week 2');
- assert.equal(moment([2012, 0, 8]).week(), 2, 'Jan 8 2012 should be week 2');
- assert.equal(moment([2012, 0, 9]).week(), 3, 'Jan 9 2012 should be week 3');
-});
-
-test('weeks year starting monday', function (assert) {
- assert.equal(moment([2007, 0, 1]).week(), 1, 'Jan 1 2007 should be week 1');
- assert.equal(moment([2007, 0, 7]).week(), 1, 'Jan 7 2007 should be week 1');
- assert.equal(moment([2007, 0, 8]).week(), 2, 'Jan 8 2007 should be week 2');
- assert.equal(moment([2007, 0, 14]).week(), 2, 'Jan 14 2007 should be week 2');
- assert.equal(moment([2007, 0, 15]).week(), 3, 'Jan 15 2007 should be week 3');
-});
-
-test('weeks year starting tuesday', function (assert) {
- assert.equal(moment([2007, 11, 31]).week(), 1, 'Dec 31 2007 should be week 1');
- assert.equal(moment([2008, 0, 1]).week(), 1, 'Jan 1 2008 should be week 1');
- assert.equal(moment([2008, 0, 6]).week(), 1, 'Jan 6 2008 should be week 1');
- assert.equal(moment([2008, 0, 7]).week(), 2, 'Jan 7 2008 should be week 2');
- assert.equal(moment([2008, 0, 13]).week(), 2, 'Jan 13 2008 should be week 2');
- assert.equal(moment([2008, 0, 14]).week(), 3, 'Jan 14 2008 should be week 3');
-});
-
-test('weeks year starting wednesday', function (assert) {
- assert.equal(moment([2002, 11, 30]).week(), 1, 'Dec 30 2002 should be week 1');
- assert.equal(moment([2003, 0, 1]).week(), 1, 'Jan 1 2003 should be week 1');
- assert.equal(moment([2003, 0, 5]).week(), 1, 'Jan 5 2003 should be week 1');
- assert.equal(moment([2003, 0, 6]).week(), 2, 'Jan 6 2003 should be week 2');
- assert.equal(moment([2003, 0, 12]).week(), 2, 'Jan 12 2003 should be week 2');
- assert.equal(moment([2003, 0, 13]).week(), 3, 'Jan 13 2003 should be week 3');
-});
-
-test('weeks year starting thursday', function (assert) {
- assert.equal(moment([2008, 11, 29]).week(), 1, 'Dec 29 2008 should be week 1');
- assert.equal(moment([2009, 0, 1]).week(), 1, 'Jan 1 2009 should be week 1');
- assert.equal(moment([2009, 0, 4]).week(), 1, 'Jan 4 2009 should be week 1');
- assert.equal(moment([2009, 0, 5]).week(), 2, 'Jan 5 2009 should be week 2');
- assert.equal(moment([2009, 0, 11]).week(), 2, 'Jan 11 2009 should be week 2');
- assert.equal(moment([2009, 0, 12]).week(), 3, 'Jan 12 2009 should be week 3');
-});
-
-test('weeks year starting friday', function (assert) {
- assert.equal(moment([2009, 11, 28]).week(), 1, 'Dec 28 2009 should be week 1');
- assert.equal(moment([2010, 0, 1]).week(), 1, 'Jan 1 2010 should be week 1');
- assert.equal(moment([2010, 0, 3]).week(), 1, 'Jan 3 2010 should be week 1');
- assert.equal(moment([2010, 0, 4]).week(), 2, 'Jan 4 2010 should be week 2');
- assert.equal(moment([2010, 0, 10]).week(), 2, 'Jan 10 2010 should be week 2');
- assert.equal(moment([2010, 0, 11]).week(), 3, 'Jan 11 2010 should be week 3');
-});
-
-test('weeks year starting saturday', function (assert) {
- assert.equal(moment([2010, 11, 27]).week(), 1, 'Dec 27 2010 should be week 1');
- assert.equal(moment([2011, 0, 1]).week(), 1, 'Jan 1 2011 should be week 1');
- assert.equal(moment([2011, 0, 2]).week(), 1, 'Jan 2 2011 should be week 1');
- assert.equal(moment([2011, 0, 3]).week(), 2, 'Jan 3 2011 should be week 2');
- assert.equal(moment([2011, 0, 9]).week(), 2, 'Jan 9 2011 should be week 2');
- assert.equal(moment([2011, 0, 10]).week(), 3, 'Jan 10 2011 should be week 3');
-});
-
test('weeks year starting sunday formatted', function (assert) {
assert.equal(moment([2011, 11, 26]).format('w ww wo'), '1 01 1\'inci', 'Dec 26 2011 should be week 1');
assert.equal(moment([2012, 0, 1]).format('w ww wo'), '1 01 1\'inci', 'Jan 1 2012 should be week 1');
@@ -279,38 +218,3 @@
assert.equal(moment([2012, 0, 9]).format('w ww wo'), '3 03 3\'üncü', 'Jan 9 2012 should be week 3');
});
-test('lenient ordinal parsing', function (assert) {
- var i, ordinalStr, testMoment;
- for (i = 1; i <= 31; ++i) {
- ordinalStr = moment([2014, 0, i]).format('YYYY MM Do');
- testMoment = moment(ordinalStr, 'YYYY MM Do');
- assert.equal(testMoment.year(), 2014,
- 'lenient ordinal parsing ' + i + ' year check');
- assert.equal(testMoment.month(), 0,
- 'lenient ordinal parsing ' + i + ' month check');
- assert.equal(testMoment.date(), i,
- 'lenient ordinal parsing ' + i + ' date check');
- }
-});
-
-test('lenient ordinal parsing of number', function (assert) {
- var i, testMoment;
- for (i = 1; i <= 31; ++i) {
- testMoment = moment('2014 01 ' + i, 'YYYY MM Do');
- assert.equal(testMoment.year(), 2014,
- 'lenient ordinal parsing of number ' + i + ' year check');
- assert.equal(testMoment.month(), 0,
- 'lenient ordinal parsing of number ' + i + ' month check');
- assert.equal(testMoment.date(), i,
- 'lenient ordinal parsing of number ' + i + ' date check');
- }
-});
-
-test('strict ordinal parsing', function (assert) {
- var i, ordinalStr, testMoment;
- for (i = 1; i <= 31; ++i) {
- ordinalStr = moment([2014, 0, i]).format('YYYY MM Do');
- testMoment = moment(ordinalStr, 'YYYY MM Do', true);
- assert.ok(testMoment.isValid(), 'strict ordinal parsing ' + i);
- }
-});
diff --git a/src/test/locale/tzl.js b/src/test/locale/tzl.js
index b633400..2b0412c 100644
--- a/src/test/locale/tzl.js
+++ b/src/test/locale/tzl.js
@@ -151,14 +151,14 @@
});
test('calendar day', function (assert) {
- var a = moment().hours(2).minutes(0).seconds(0);
-
- assert.equal(moment(a).calendar(), 'oxhi à 02.00', 'today at the same time');
- assert.equal(moment(a).add({m: 25}).calendar(), 'oxhi à 02.25', 'Now plus 25 min');
- assert.equal(moment(a).add({h: 1}).calendar(), 'oxhi à 03.00', 'Now plus 1 hour');
- assert.equal(moment(a).add({d: 1}).calendar(), 'demà à 02.00', 'tomorrow at the same time');
- assert.equal(moment(a).subtract({h: 1}).calendar(), 'oxhi à 01.00', 'Now minus 1 hour');
- assert.equal(moment(a).subtract({d: 1}).calendar(), 'ieiri à 02.00', 'yesterday at the same time');
+ var a = moment().hours(12).minutes(0).seconds(0);
+
+ assert.equal(moment(a).calendar(), 'oxhi à 12.00', 'today at the same time');
+ assert.equal(moment(a).add({m: 25}).calendar(), 'oxhi à 12.25', 'Now plus 25 min');
+ assert.equal(moment(a).add({h: 1}).calendar(), 'oxhi à 13.00', 'Now plus 1 hour');
+ assert.equal(moment(a).add({d: 1}).calendar(), 'demà à 12.00', 'tomorrow at the same time');
+ assert.equal(moment(a).subtract({h: 1}).calendar(), 'oxhi à 11.00', 'Now minus 1 hour');
+ assert.equal(moment(a).subtract({d: 1}).calendar(), 'ieiri à 12.00', 'yesterday at the same time');
});
test('calendar next week', function (assert) {
@@ -203,67 +203,6 @@
// Monday is the first day of the week.
// The week that contains Jan 4th is the first week of the year.
-test('weeks year starting sunday', function (assert) {
- assert.equal(moment([2012, 0, 1]).week(), 52, 'Jan 1 2012 should be week 52');
- assert.equal(moment([2012, 0, 2]).week(), 1, 'Jan 2 2012 should be week 1');
- assert.equal(moment([2012, 0, 8]).week(), 1, 'Jan 8 2012 should be week 1');
- assert.equal(moment([2012, 0, 9]).week(), 2, 'Jan 9 2012 should be week 2');
- assert.equal(moment([2012, 0, 15]).week(), 2, 'Jan 15 2012 should be week 2');
-});
-
-test('weeks year starting monday', function (assert) {
- assert.equal(moment([2007, 0, 1]).week(), 1, 'Jan 1 2007 should be week 1');
- assert.equal(moment([2007, 0, 7]).week(), 1, 'Jan 7 2007 should be week 1');
- assert.equal(moment([2007, 0, 8]).week(), 2, 'Jan 8 2007 should be week 2');
- assert.equal(moment([2007, 0, 14]).week(), 2, 'Jan 14 2007 should be week 2');
- assert.equal(moment([2007, 0, 15]).week(), 3, 'Jan 15 2007 should be week 3');
-});
-
-test('weeks year starting tuesday', function (assert) {
- assert.equal(moment([2007, 11, 31]).week(), 1, 'Dec 31 2007 should be week 1');
- assert.equal(moment([2008, 0, 1]).week(), 1, 'Jan 1 2008 should be week 1');
- assert.equal(moment([2008, 0, 6]).week(), 1, 'Jan 6 2008 should be week 1');
- assert.equal(moment([2008, 0, 7]).week(), 2, 'Jan 7 2008 should be week 2');
- assert.equal(moment([2008, 0, 13]).week(), 2, 'Jan 13 2008 should be week 2');
- assert.equal(moment([2008, 0, 14]).week(), 3, 'Jan 14 2008 should be week 3');
-});
-
-test('weeks year starting wednesday', function (assert) {
- assert.equal(moment([2002, 11, 30]).week(), 1, 'Dec 30 2002 should be week 1');
- assert.equal(moment([2003, 0, 1]).week(), 1, 'Jan 1 2003 should be week 1');
- assert.equal(moment([2003, 0, 5]).week(), 1, 'Jan 5 2003 should be week 1');
- assert.equal(moment([2003, 0, 6]).week(), 2, 'Jan 6 2003 should be week 2');
- assert.equal(moment([2003, 0, 12]).week(), 2, 'Jan 12 2003 should be week 2');
- assert.equal(moment([2003, 0, 13]).week(), 3, 'Jan 13 2003 should be week 3');
-});
-
-test('weeks year starting thursday', function (assert) {
- assert.equal(moment([2008, 11, 29]).week(), 1, 'Dec 29 2008 should be week 1');
- assert.equal(moment([2009, 0, 1]).week(), 1, 'Jan 1 2009 should be week 1');
- assert.equal(moment([2009, 0, 4]).week(), 1, 'Jan 4 2009 should be week 1');
- assert.equal(moment([2009, 0, 5]).week(), 2, 'Jan 5 2009 should be week 2');
- assert.equal(moment([2009, 0, 11]).week(), 2, 'Jan 11 2009 should be week 2');
- assert.equal(moment([2009, 0, 13]).week(), 3, 'Jan 12 2009 should be week 3');
-});
-
-test('weeks year starting friday', function (assert) {
- assert.equal(moment([2009, 11, 28]).week(), 53, 'Dec 28 2009 should be week 53');
- assert.equal(moment([2010, 0, 1]).week(), 53, 'Jan 1 2010 should be week 53');
- assert.equal(moment([2010, 0, 3]).week(), 53, 'Jan 3 2010 should be week 53');
- assert.equal(moment([2010, 0, 4]).week(), 1, 'Jan 4 2010 should be week 1');
- assert.equal(moment([2010, 0, 10]).week(), 1, 'Jan 10 2010 should be week 1');
- assert.equal(moment([2010, 0, 11]).week(), 2, 'Jan 11 2010 should be week 2');
-});
-
-test('weeks year starting saturday', function (assert) {
- assert.equal(moment([2010, 11, 27]).week(), 52, 'Dec 27 2010 should be week 52');
- assert.equal(moment([2011, 0, 1]).week(), 52, 'Jan 1 2011 should be week 52');
- assert.equal(moment([2011, 0, 2]).week(), 52, 'Jan 2 2011 should be week 52');
- assert.equal(moment([2011, 0, 3]).week(), 1, 'Jan 3 2011 should be week 1');
- assert.equal(moment([2011, 0, 9]).week(), 1, 'Jan 9 2011 should be week 1');
- assert.equal(moment([2011, 0, 10]).week(), 2, 'Jan 10 2011 should be week 2');
-});
-
test('weeks year starting sunday formatted', function (assert) {
assert.equal(moment([2012, 0, 1]).format('w ww wo'), '52 52 52.', 'Jan 1 2012 should be week 52');
assert.equal(moment([2012, 0, 2]).format('w ww wo'), '1 01 1.', 'Jan 2 2012 should be week 1');
@@ -272,38 +211,3 @@
assert.equal(moment([2012, 0, 15]).format('w ww wo'), '2 02 2.', 'Jan 15 2012 should be week 2');
});
-test('lenient ordinal parsing', function (assert) {
- var i, ordinalStr, testMoment;
- for (i = 1; i <= 31; ++i) {
- ordinalStr = moment([2014, 0, i]).format('YYYY MM Do');
- testMoment = moment(ordinalStr, 'YYYY MM Do');
- assert.equal(testMoment.year(), 2014,
- 'lenient ordinal parsing ' + i + ' year check');
- assert.equal(testMoment.month(), 0,
- 'lenient ordinal parsing ' + i + ' month check');
- assert.equal(testMoment.date(), i,
- 'lenient ordinal parsing ' + i + ' date check');
- }
-});
-
-test('lenient ordinal parsing of number', function (assert) {
- var i, testMoment;
- for (i = 1; i <= 31; ++i) {
- testMoment = moment('2014 01 ' + i, 'YYYY MM Do');
- assert.equal(testMoment.year(), 2014,
- 'lenient ordinal parsing of number ' + i + ' year check');
- assert.equal(testMoment.month(), 0,
- 'lenient ordinal parsing of number ' + i + ' month check');
- assert.equal(testMoment.date(), i,
- 'lenient ordinal parsing of number ' + i + ' date check');
- }
-});
-
-test('strict ordinal parsing', function (assert) {
- var i, ordinalStr, testMoment;
- for (i = 1; i <= 31; ++i) {
- ordinalStr = moment([2014, 0, i]).format('YYYY MM Do');
- testMoment = moment(ordinalStr, 'YYYY MM Do', true);
- assert.ok(testMoment.isValid(), 'strict ordinal parsing ' + i);
- }
-});
diff --git a/src/test/locale/tzm-latn.js b/src/test/locale/tzm-latn.js
index 4e94f8b..2131427 100644
--- a/src/test/locale/tzm-latn.js
+++ b/src/test/locale/tzm-latn.js
@@ -151,14 +151,14 @@
});
test('calendar day', function (assert) {
- var a = moment().hours(2).minutes(0).seconds(0);
-
- assert.equal(moment(a).calendar(), 'asdkh g 02:00', 'today at the same time');
- assert.equal(moment(a).add({m: 25}).calendar(), 'asdkh g 02:25', 'Now plus 25 min');
- assert.equal(moment(a).add({h: 1}).calendar(), 'asdkh g 03:00', 'Now plus 1 hour');
- assert.equal(moment(a).add({d: 1}).calendar(), 'aska g 02:00', 'tomorrow at the same time');
- assert.equal(moment(a).subtract({h: 1}).calendar(), 'asdkh g 01:00', 'Now minus 1 hour');
- assert.equal(moment(a).subtract({d: 1}).calendar(), 'assant g 02:00', 'yesterday at the same time');
+ var a = moment().hours(12).minutes(0).seconds(0);
+
+ assert.equal(moment(a).calendar(), 'asdkh g 12:00', 'today at the same time');
+ assert.equal(moment(a).add({m: 25}).calendar(), 'asdkh g 12:25', 'Now plus 25 min');
+ assert.equal(moment(a).add({h: 1}).calendar(), 'asdkh g 13:00', 'Now plus 1 hour');
+ assert.equal(moment(a).add({d: 1}).calendar(), 'aska g 12:00', 'tomorrow at the same time');
+ assert.equal(moment(a).subtract({h: 1}).calendar(), 'asdkh g 11:00', 'Now minus 1 hour');
+ assert.equal(moment(a).subtract({d: 1}).calendar(), 'assant g 12:00', 'yesterday at the same time');
});
test('calendar next week', function (assert) {
@@ -199,65 +199,6 @@
assert.equal(weeksFromNow.calendar(), weeksFromNow.format('L'), 'in 2 weeks');
});
-test('weeks year starting sunday', function (assert) {
- assert.equal(moment([2011, 11, 31]).week(), 1, 'Dec 31 2011 should be week 1');
- assert.equal(moment([2012, 0, 6]).week(), 1, 'Jan 6 2012 should be week 1');
- assert.equal(moment([2012, 0, 7]).week(), 2, 'Jan 7 2012 should be week 2');
- assert.equal(moment([2012, 0, 13]).week(), 2, 'Jan 13 2012 should be week 2');
- assert.equal(moment([2012, 0, 14]).week(), 3, 'Jan 14 2012 should be week 3');
-});
-
-test('weeks year starting monday', function (assert) {
- assert.equal(moment([2006, 11, 30]).week(), 1, 'Dec 30 2006 should be week 1');
- assert.equal(moment([2007, 0, 5]).week(), 1, 'Jan 5 2007 should be week 1');
- assert.equal(moment([2007, 0, 6]).week(), 2, 'Jan 6 2007 should be week 2');
- assert.equal(moment([2007, 0, 12]).week(), 2, 'Jan 12 2007 should be week 2');
- assert.equal(moment([2007, 0, 13]).week(), 3, 'Jan 13 2007 should be week 3');
-});
-
-test('weeks year starting tuesday', function (assert) {
- assert.equal(moment([2007, 11, 29]).week(), 1, 'Dec 29 2007 should be week 1');
- assert.equal(moment([2008, 0, 1]).week(), 1, 'Jan 1 2008 should be week 1');
- assert.equal(moment([2008, 0, 4]).week(), 1, 'Jan 4 2008 should be week 1');
- assert.equal(moment([2008, 0, 5]).week(), 2, 'Jan 5 2008 should be week 2');
- assert.equal(moment([2008, 0, 11]).week(), 2, 'Jan 11 2008 should be week 2');
- assert.equal(moment([2008, 0, 12]).week(), 3, 'Jan 12 2008 should be week 3');
-});
-
-test('weeks year starting wednesday', function (assert) {
- assert.equal(moment([2002, 11, 28]).week(), 1, 'Dec 28 2002 should be week 1');
- assert.equal(moment([2003, 0, 1]).week(), 1, 'Jan 1 2003 should be week 1');
- assert.equal(moment([2003, 0, 3]).week(), 1, 'Jan 3 2003 should be week 1');
- assert.equal(moment([2003, 0, 4]).week(), 2, 'Jan 4 2003 should be week 2');
- assert.equal(moment([2003, 0, 10]).week(), 2, 'Jan 10 2003 should be week 2');
- assert.equal(moment([2003, 0, 11]).week(), 3, 'Jan 11 2003 should be week 3');
-});
-
-test('weeks year starting thursday', function (assert) {
- assert.equal(moment([2008, 11, 27]).week(), 1, 'Dec 27 2008 should be week 1');
- assert.equal(moment([2009, 0, 1]).week(), 1, 'Jan 1 2009 should be week 1');
- assert.equal(moment([2009, 0, 2]).week(), 1, 'Jan 2 2009 should be week 1');
- assert.equal(moment([2009, 0, 3]).week(), 2, 'Jan 3 2009 should be week 2');
- assert.equal(moment([2009, 0, 9]).week(), 2, 'Jan 9 2009 should be week 2');
- assert.equal(moment([2009, 0, 10]).week(), 3, 'Jan 10 2009 should be week 3');
-});
-
-test('weeks year starting friday', function (assert) {
- assert.equal(moment([2009, 11, 26]).week(), 1, 'Dec 26 2009 should be week 1');
- assert.equal(moment([2010, 0, 1]).week(), 1, 'Jan 1 2010 should be week 1');
- assert.equal(moment([2010, 0, 2]).week(), 2, 'Jan 2 2010 should be week 2');
- assert.equal(moment([2010, 0, 8]).week(), 2, 'Jan 8 2010 should be week 2');
- assert.equal(moment([2010, 0, 9]).week(), 3, 'Jan 9 2010 should be week 3');
-});
-
-test('weeks year starting saturday', function (assert) {
- assert.equal(moment([2011, 0, 1]).week(), 1, 'Jan 1 2011 should be week 1');
- assert.equal(moment([2011, 0, 7]).week(), 1, 'Jan 7 2011 should be week 1');
- assert.equal(moment([2011, 0, 8]).week(), 2, 'Jan 8 2011 should be week 2');
- assert.equal(moment([2011, 0, 14]).week(), 2, 'Jan 14 2011 should be week 2');
- assert.equal(moment([2011, 0, 15]).week(), 3, 'Jan 15 2011 should be week 3');
-});
-
test('weeks year starting sunday formatted', function (assert) {
assert.equal(moment([2011, 11, 31]).format('w ww wo'), '1 01 1', 'Dec 31 2011 should be week 1');
assert.equal(moment([2012, 0, 6]).format('w ww wo'), '1 01 1', 'Jan 6 2012 should be week 1');
@@ -266,38 +207,3 @@
assert.equal(moment([2012, 0, 14]).format('w ww wo'), '3 03 3', 'Jan 14 2012 should be week 3');
});
-test('lenient ordinal parsing', function (assert) {
- var i, ordinalStr, testMoment;
- for (i = 1; i <= 31; ++i) {
- ordinalStr = moment([2014, 0, i]).format('YYYY MM Do');
- testMoment = moment(ordinalStr, 'YYYY MM Do');
- assert.equal(testMoment.year(), 2014,
- 'lenient ordinal parsing ' + i + ' year check');
- assert.equal(testMoment.month(), 0,
- 'lenient ordinal parsing ' + i + ' month check');
- assert.equal(testMoment.date(), i,
- 'lenient ordinal parsing ' + i + ' date check');
- }
-});
-
-test('lenient ordinal parsing of number', function (assert) {
- var i, testMoment;
- for (i = 1; i <= 31; ++i) {
- testMoment = moment('2014 01 ' + i, 'YYYY MM Do');
- assert.equal(testMoment.year(), 2014,
- 'lenient ordinal parsing of number ' + i + ' year check');
- assert.equal(testMoment.month(), 0,
- 'lenient ordinal parsing of number ' + i + ' month check');
- assert.equal(testMoment.date(), i,
- 'lenient ordinal parsing of number ' + i + ' date check');
- }
-});
-
-test('strict ordinal parsing', function (assert) {
- var i, ordinalStr, testMoment;
- for (i = 1; i <= 31; ++i) {
- ordinalStr = moment([2014, 0, i]).format('YYYY MM Do');
- testMoment = moment(ordinalStr, 'YYYY MM Do', true);
- assert.ok(testMoment.isValid(), 'strict ordinal parsing ' + i);
- }
-});
diff --git a/src/test/locale/tzm.js b/src/test/locale/tzm.js
index 4e77e3d..ea7df54 100644
--- a/src/test/locale/tzm.js
+++ b/src/test/locale/tzm.js
@@ -151,14 +151,14 @@
});
test('calendar day', function (assert) {
- var a = moment().hours(2).minutes(0).seconds(0);
-
- assert.equal(moment(a).calendar(), 'ⴰⵙⴷⵅ ⴴ 02:00', 'today at the same time');
- assert.equal(moment(a).add({m: 25}).calendar(), 'ⴰⵙⴷⵅ ⴴ 02:25', 'Now plus 25 min');
- assert.equal(moment(a).add({h: 1}).calendar(), 'ⴰⵙⴷⵅ ⴴ 03:00', 'Now plus 1 hour');
- assert.equal(moment(a).add({d: 1}).calendar(), 'ⴰⵙⴽⴰ ⴴ 02:00', 'tomorrow at the same time');
- assert.equal(moment(a).subtract({h: 1}).calendar(), 'ⴰⵙⴷⵅ ⴴ 01:00', 'Now minus 1 hour');
- assert.equal(moment(a).subtract({d: 1}).calendar(), 'ⴰⵚⴰⵏⵜ ⴴ 02:00', 'yesterday at the same time');
+ var a = moment().hours(12).minutes(0).seconds(0);
+
+ assert.equal(moment(a).calendar(), 'ⴰⵙⴷⵅ ⴴ 12:00', 'today at the same time');
+ assert.equal(moment(a).add({m: 25}).calendar(), 'ⴰⵙⴷⵅ ⴴ 12:25', 'Now plus 25 min');
+ assert.equal(moment(a).add({h: 1}).calendar(), 'ⴰⵙⴷⵅ ⴴ 13:00', 'Now plus 1 hour');
+ assert.equal(moment(a).add({d: 1}).calendar(), 'ⴰⵙⴽⴰ ⴴ 12:00', 'tomorrow at the same time');
+ assert.equal(moment(a).subtract({h: 1}).calendar(), 'ⴰⵙⴷⵅ ⴴ 11:00', 'Now minus 1 hour');
+ assert.equal(moment(a).subtract({d: 1}).calendar(), 'ⴰⵚⴰⵏⵜ ⴴ 12:00', 'yesterday at the same time');
});
test('calendar next week', function (assert) {
@@ -199,65 +199,6 @@
assert.equal(weeksFromNow.calendar(), weeksFromNow.format('L'), 'in 2 weeks');
});
-test('weeks year starting sunday', function (assert) {
- assert.equal(moment([2011, 11, 31]).week(), 1, 'Dec 31 2011 should be week 1');
- assert.equal(moment([2012, 0, 6]).week(), 1, 'Jan 6 2012 should be week 1');
- assert.equal(moment([2012, 0, 7]).week(), 2, 'Jan 7 2012 should be week 2');
- assert.equal(moment([2012, 0, 13]).week(), 2, 'Jan 13 2012 should be week 2');
- assert.equal(moment([2012, 0, 14]).week(), 3, 'Jan 14 2012 should be week 3');
-});
-
-test('weeks year starting monday', function (assert) {
- assert.equal(moment([2006, 11, 30]).week(), 1, 'Dec 30 2006 should be week 1');
- assert.equal(moment([2007, 0, 5]).week(), 1, 'Jan 5 2007 should be week 1');
- assert.equal(moment([2007, 0, 6]).week(), 2, 'Jan 6 2007 should be week 2');
- assert.equal(moment([2007, 0, 12]).week(), 2, 'Jan 12 2007 should be week 2');
- assert.equal(moment([2007, 0, 13]).week(), 3, 'Jan 13 2007 should be week 3');
-});
-
-test('weeks year starting tuesday', function (assert) {
- assert.equal(moment([2007, 11, 29]).week(), 1, 'Dec 29 2007 should be week 1');
- assert.equal(moment([2008, 0, 1]).week(), 1, 'Jan 1 2008 should be week 1');
- assert.equal(moment([2008, 0, 4]).week(), 1, 'Jan 4 2008 should be week 1');
- assert.equal(moment([2008, 0, 5]).week(), 2, 'Jan 5 2008 should be week 2');
- assert.equal(moment([2008, 0, 11]).week(), 2, 'Jan 11 2008 should be week 2');
- assert.equal(moment([2008, 0, 12]).week(), 3, 'Jan 12 2008 should be week 3');
-});
-
-test('weeks year starting wednesday', function (assert) {
- assert.equal(moment([2002, 11, 28]).week(), 1, 'Dec 28 2002 should be week 1');
- assert.equal(moment([2003, 0, 1]).week(), 1, 'Jan 1 2003 should be week 1');
- assert.equal(moment([2003, 0, 3]).week(), 1, 'Jan 3 2003 should be week 1');
- assert.equal(moment([2003, 0, 4]).week(), 2, 'Jan 4 2003 should be week 2');
- assert.equal(moment([2003, 0, 10]).week(), 2, 'Jan 10 2003 should be week 2');
- assert.equal(moment([2003, 0, 11]).week(), 3, 'Jan 11 2003 should be week 3');
-});
-
-test('weeks year starting thursday', function (assert) {
- assert.equal(moment([2008, 11, 27]).week(), 1, 'Dec 27 2008 should be week 1');
- assert.equal(moment([2009, 0, 1]).week(), 1, 'Jan 1 2009 should be week 1');
- assert.equal(moment([2009, 0, 2]).week(), 1, 'Jan 2 2009 should be week 1');
- assert.equal(moment([2009, 0, 3]).week(), 2, 'Jan 3 2009 should be week 2');
- assert.equal(moment([2009, 0, 9]).week(), 2, 'Jan 9 2009 should be week 2');
- assert.equal(moment([2009, 0, 10]).week(), 3, 'Jan 10 2009 should be week 3');
-});
-
-test('weeks year starting friday', function (assert) {
- assert.equal(moment([2009, 11, 26]).week(), 1, 'Dec 26 2009 should be week 1');
- assert.equal(moment([2010, 0, 1]).week(), 1, 'Jan 1 2010 should be week 1');
- assert.equal(moment([2010, 0, 2]).week(), 2, 'Jan 2 2010 should be week 2');
- assert.equal(moment([2010, 0, 8]).week(), 2, 'Jan 8 2010 should be week 2');
- assert.equal(moment([2010, 0, 9]).week(), 3, 'Jan 9 2010 should be week 3');
-});
-
-test('weeks year starting saturday', function (assert) {
- assert.equal(moment([2011, 0, 1]).week(), 1, 'Jan 1 2011 should be week 1');
- assert.equal(moment([2011, 0, 7]).week(), 1, 'Jan 7 2011 should be week 1');
- assert.equal(moment([2011, 0, 8]).week(), 2, 'Jan 8 2011 should be week 2');
- assert.equal(moment([2011, 0, 14]).week(), 2, 'Jan 14 2011 should be week 2');
- assert.equal(moment([2011, 0, 15]).week(), 3, 'Jan 15 2011 should be week 3');
-});
-
test('weeks year starting sunday formatted', function (assert) {
assert.equal(moment([2011, 11, 31]).format('w ww wo'), '1 01 1', 'Dec 31 2011 should be week 1');
assert.equal(moment([2012, 0, 6]).format('w ww wo'), '1 01 1', 'Jan 6 2012 should be week 1');
@@ -266,38 +207,3 @@
assert.equal(moment([2012, 0, 14]).format('w ww wo'), '3 03 3', 'Jan 14 2012 should be week 3');
});
-test('lenient ordinal parsing', function (assert) {
- var i, ordinalStr, testMoment;
- for (i = 1; i <= 31; ++i) {
- ordinalStr = moment([2014, 0, i]).format('YYYY MM Do');
- testMoment = moment(ordinalStr, 'YYYY MM Do');
- assert.equal(testMoment.year(), 2014,
- 'lenient ordinal parsing ' + i + ' year check');
- assert.equal(testMoment.month(), 0,
- 'lenient ordinal parsing ' + i + ' month check');
- assert.equal(testMoment.date(), i,
- 'lenient ordinal parsing ' + i + ' date check');
- }
-});
-
-test('lenient ordinal parsing of number', function (assert) {
- var i, testMoment;
- for (i = 1; i <= 31; ++i) {
- testMoment = moment('2014 01 ' + i, 'YYYY MM Do');
- assert.equal(testMoment.year(), 2014,
- 'lenient ordinal parsing of number ' + i + ' year check');
- assert.equal(testMoment.month(), 0,
- 'lenient ordinal parsing of number ' + i + ' month check');
- assert.equal(testMoment.date(), i,
- 'lenient ordinal parsing of number ' + i + ' date check');
- }
-});
-
-test('strict ordinal parsing', function (assert) {
- var i, ordinalStr, testMoment;
- for (i = 1; i <= 31; ++i) {
- ordinalStr = moment([2014, 0, i]).format('YYYY MM Do');
- testMoment = moment(ordinalStr, 'YYYY MM Do', true);
- assert.ok(testMoment.isValid(), 'strict ordinal parsing ' + i);
- }
-});
diff --git a/src/test/locale/uk.js b/src/test/locale/uk.js
index 5f7f186..326c58a 100644
--- a/src/test/locale/uk.js
+++ b/src/test/locale/uk.js
@@ -167,16 +167,16 @@
});
test('calendar day', function (assert) {
- var a = moment().hours(2).minutes(0).seconds(0);
-
- assert.equal(moment(a).calendar(), 'Сьогодні о 02:00', 'today at the same time');
- assert.equal(moment(a).add({m: 25}).calendar(), 'Сьогодні о 02:25', 'Now plus 25 min');
- assert.equal(moment(a).add({h: 1}).calendar(), 'Сьогодні о 03:00', 'Now plus 1 hour');
- assert.equal(moment(a).add({d: 1}).calendar(), 'Завтра о 02:00', 'tomorrow at the same time');
- assert.equal(moment(a).subtract({h: 1}).calendar(), 'Сьогодні о 01:00', 'Now minus 1 hour');
- assert.equal(moment(a).subtract({d: 1}).calendar(), 'Вчора о 02:00', 'yesterday at the same time');
+ var a = moment().hours(12).minutes(0).seconds(0);
+
+ assert.equal(moment(a).calendar(), 'Сьогодні о 12:00', 'today at the same time');
+ assert.equal(moment(a).add({m: 25}).calendar(), 'Сьогодні о 12:25', 'Now plus 25 min');
+ assert.equal(moment(a).add({h: 1}).calendar(), 'Сьогодні о 13:00', 'Now plus 1 hour');
+ assert.equal(moment(a).add({d: 1}).calendar(), 'Завтра о 12:00', 'tomorrow at the same time');
+ assert.equal(moment(a).subtract({h: 2}).calendar(), 'Сьогодні о 10:00', 'Now minus 2 hours');
+ assert.equal(moment(a).subtract({d: 1}).calendar(), 'Вчора о 12:00', 'yesterday at the same time');
// A special case for Ukrainian since 11 hours have different preposition
- assert.equal(moment(a).add({h: 9}).calendar(), 'Сьогодні об 11:00', 'same day at 11 o\'clock');
+ assert.equal(moment(a).subtract({h: 1}).calendar(), 'Сьогодні об 11:00', 'same day at 11 o\'clock');
});
test('calendar next week', function (assert) {
@@ -232,67 +232,6 @@
assert.equal(weeksFromNow.calendar(), weeksFromNow.format('L'), 'in 2 weeks');
});
-test('weeks year starting sunday', function (assert) {
- assert.equal(moment([2011, 11, 26]).week(), 1, 'Dec 26 2011 should be week 1');
- assert.equal(moment([2012, 0, 1]).week(), 1, 'Jan 1 2012 should be week 1');
- assert.equal(moment([2012, 0, 2]).week(), 2, 'Jan 2 2012 should be week 2');
- assert.equal(moment([2012, 0, 8]).week(), 2, 'Jan 8 2012 should be week 2');
- assert.equal(moment([2012, 0, 9]).week(), 3, 'Jan 9 2012 should be week 3');
-});
-
-test('weeks year starting monday', function (assert) {
- assert.equal(moment([2007, 0, 1]).week(), 1, 'Jan 1 2007 should be week 1');
- assert.equal(moment([2007, 0, 7]).week(), 1, 'Jan 7 2007 should be week 1');
- assert.equal(moment([2007, 0, 8]).week(), 2, 'Jan 8 2007 should be week 2');
- assert.equal(moment([2007, 0, 14]).week(), 2, 'Jan 14 2007 should be week 2');
- assert.equal(moment([2007, 0, 15]).week(), 3, 'Jan 15 2007 should be week 3');
-});
-
-test('weeks year starting tuesday', function (assert) {
- assert.equal(moment([2007, 11, 31]).week(), 1, 'Dec 31 2007 should be week 1');
- assert.equal(moment([2008, 0, 1]).week(), 1, 'Jan 1 2008 should be week 1');
- assert.equal(moment([2008, 0, 6]).week(), 1, 'Jan 6 2008 should be week 1');
- assert.equal(moment([2008, 0, 7]).week(), 2, 'Jan 7 2008 should be week 2');
- assert.equal(moment([2008, 0, 13]).week(), 2, 'Jan 13 2008 should be week 2');
- assert.equal(moment([2008, 0, 14]).week(), 3, 'Jan 14 2008 should be week 3');
-});
-
-test('weeks year starting wednesday', function (assert) {
- assert.equal(moment([2002, 11, 30]).week(), 1, 'Dec 30 2002 should be week 1');
- assert.equal(moment([2003, 0, 1]).week(), 1, 'Jan 1 2003 should be week 1');
- assert.equal(moment([2003, 0, 5]).week(), 1, 'Jan 5 2003 should be week 1');
- assert.equal(moment([2003, 0, 6]).week(), 2, 'Jan 6 2003 should be week 2');
- assert.equal(moment([2003, 0, 12]).week(), 2, 'Jan 12 2003 should be week 2');
- assert.equal(moment([2003, 0, 13]).week(), 3, 'Jan 13 2003 should be week 3');
-});
-
-test('weeks year starting thursday', function (assert) {
- assert.equal(moment([2008, 11, 29]).week(), 1, 'Dec 29 2008 should be week 1');
- assert.equal(moment([2009, 0, 1]).week(), 1, 'Jan 1 2009 should be week 1');
- assert.equal(moment([2009, 0, 4]).week(), 1, 'Jan 4 2009 should be week 1');
- assert.equal(moment([2009, 0, 5]).week(), 2, 'Jan 5 2009 should be week 2');
- assert.equal(moment([2009, 0, 11]).week(), 2, 'Jan 11 2009 should be week 2');
- assert.equal(moment([2009, 0, 12]).week(), 3, 'Jan 12 2009 should be week 3');
-});
-
-test('weeks year starting friday', function (assert) {
- assert.equal(moment([2009, 11, 28]).week(), 1, 'Dec 28 2009 should be week 1');
- assert.equal(moment([2010, 0, 1]).week(), 1, 'Jan 1 2010 should be week 1');
- assert.equal(moment([2010, 0, 3]).week(), 1, 'Jan 3 2010 should be week 1');
- assert.equal(moment([2010, 0, 4]).week(), 2, 'Jan 4 2010 should be week 2');
- assert.equal(moment([2010, 0, 10]).week(), 2, 'Jan 10 2010 should be week 2');
- assert.equal(moment([2010, 0, 11]).week(), 3, 'Jan 11 2010 should be week 3');
-});
-
-test('weeks year starting saturday', function (assert) {
- assert.equal(moment([2010, 11, 27]).week(), 1, 'Dec 27 2010 should be week 1');
- assert.equal(moment([2011, 0, 1]).week(), 1, 'Jan 1 2011 should be week 1');
- assert.equal(moment([2011, 0, 2]).week(), 1, 'Jan 2 2011 should be week 1');
- assert.equal(moment([2011, 0, 3]).week(), 2, 'Jan 3 2011 should be week 2');
- assert.equal(moment([2011, 0, 9]).week(), 2, 'Jan 9 2011 should be week 2');
- assert.equal(moment([2011, 0, 10]).week(), 3, 'Jan 10 2011 should be week 3');
-});
-
test('weeks year starting sunday formatted', function (assert) {
assert.equal(moment([2011, 11, 26]).format('w ww wo'), '1 01 1-й', 'Dec 26 2011 should be week 1');
assert.equal(moment([2012, 0, 1]).format('w ww wo'), '1 01 1-й', 'Jan 1 2012 should be week 1');
@@ -301,38 +240,3 @@
assert.equal(moment([2012, 0, 9]).format('w ww wo'), '3 03 3-й', 'Jan 9 2012 should be week 3');
});
-test('lenient ordinal parsing', function (assert) {
- var i, ordinalStr, testMoment;
- for (i = 1; i <= 31; ++i) {
- ordinalStr = moment([2014, 0, i]).format('YYYY MM Do');
- testMoment = moment(ordinalStr, 'YYYY MM Do');
- assert.equal(testMoment.year(), 2014,
- 'lenient ordinal parsing ' + i + ' year check');
- assert.equal(testMoment.month(), 0,
- 'lenient ordinal parsing ' + i + ' month check');
- assert.equal(testMoment.date(), i,
- 'lenient ordinal parsing ' + i + ' date check');
- }
-});
-
-test('lenient ordinal parsing of number', function (assert) {
- var i, testMoment;
- for (i = 1; i <= 31; ++i) {
- testMoment = moment('2014 01 ' + i, 'YYYY MM Do');
- assert.equal(testMoment.year(), 2014,
- 'lenient ordinal parsing of number ' + i + ' year check');
- assert.equal(testMoment.month(), 0,
- 'lenient ordinal parsing of number ' + i + ' month check');
- assert.equal(testMoment.date(), i,
- 'lenient ordinal parsing of number ' + i + ' date check');
- }
-});
-
-test('strict ordinal parsing', function (assert) {
- var i, ordinalStr, testMoment;
- for (i = 1; i <= 31; ++i) {
- ordinalStr = moment([2014, 0, i]).format('YYYY MM Do');
- testMoment = moment(ordinalStr, 'YYYY MM Do', true);
- assert.ok(testMoment.isValid(), 'strict ordinal parsing ' + i);
- }
-});
diff --git a/src/test/locale/uz.js b/src/test/locale/uz.js
index a0a3ac5..fbf8138 100644
--- a/src/test/locale/uz.js
+++ b/src/test/locale/uz.js
@@ -151,14 +151,14 @@
});
test('calendar day', function (assert) {
- var a = moment().hours(2).minutes(0).seconds(0);
-
- assert.equal(moment(a).calendar(), 'Бугун соат 02:00 да', 'today at the same time');
- assert.equal(moment(a).add({m: 25}).calendar(), 'Бугун соат 02:25 да', 'Now plus 25 min');
- assert.equal(moment(a).add({h: 1}).calendar(), 'Бугун соат 03:00 да', 'Now plus 1 hour');
- assert.equal(moment(a).add({d: 1}).calendar(), 'Эртага 02:00 да', 'tomorrow at the same time');
- assert.equal(moment(a).subtract({h: 1}).calendar(), 'Бугун соат 01:00 да', 'Now minus 1 hour');
- assert.equal(moment(a).subtract({d: 1}).calendar(), 'Кеча соат 02:00 да', 'yesterday at the same time');
+ var a = moment().hours(12).minutes(0).seconds(0);
+
+ assert.equal(moment(a).calendar(), 'Бугун соат 12:00 да', 'today at the same time');
+ assert.equal(moment(a).add({m: 25}).calendar(), 'Бугун соат 12:25 да', 'Now plus 25 min');
+ assert.equal(moment(a).add({h: 1}).calendar(), 'Бугун соат 13:00 да', 'Now plus 1 hour');
+ assert.equal(moment(a).add({d: 1}).calendar(), 'Эртага 12:00 да', 'tomorrow at the same time');
+ assert.equal(moment(a).subtract({h: 1}).calendar(), 'Бугун соат 11:00 да', 'Now minus 1 hour');
+ assert.equal(moment(a).subtract({d: 1}).calendar(), 'Кеча соат 12:00 да', 'yesterday at the same time');
});
test('calendar next week', function (assert) {
@@ -200,67 +200,6 @@
assert.equal(weeksFromNow.calendar(), weeksFromNow.format('L'), 'in 2 weeks');
});
-test('weeks year starting sunday', function (assert) {
- assert.equal(moment([2012, 0, 1]).week(), 1, 'Jan 1 2012 should be week 52');
- assert.equal(moment([2012, 0, 2]).week(), 2, 'Jan 2 2012 should be week 1');
- assert.equal(moment([2012, 0, 8]).week(), 2, 'Jan 8 2012 should be week 1');
- assert.equal(moment([2012, 0, 9]).week(), 3, 'Jan 9 2012 should be week 2');
- assert.equal(moment([2012, 0, 15]).week(), 3, 'Jan 15 2012 should be week 2');
-});
-
-test('weeks year starting monday', function (assert) {
- assert.equal(moment([2007, 0, 1]).week(), 1, 'Jan 1 2007 should be week 1');
- assert.equal(moment([2007, 0, 7]).week(), 1, 'Jan 7 2007 should be week 1');
- assert.equal(moment([2007, 0, 8]).week(), 2, 'Jan 8 2007 should be week 2');
- assert.equal(moment([2007, 0, 14]).week(), 2, 'Jan 14 2007 should be week 2');
- assert.equal(moment([2007, 0, 15]).week(), 3, 'Jan 15 2007 should be week 3');
-});
-
-test('weeks year starting tuesday', function (assert) {
- assert.equal(moment([2007, 11, 31]).week(), 1, 'Dec 31 2007 should be week 1');
- assert.equal(moment([2008, 0, 1]).week(), 1, 'Jan 1 2008 should be week 1');
- assert.equal(moment([2008, 0, 6]).week(), 1, 'Jan 6 2008 should be week 1');
- assert.equal(moment([2008, 0, 7]).week(), 2, 'Jan 7 2008 should be week 2');
- assert.equal(moment([2008, 0, 13]).week(), 2, 'Jan 13 2008 should be week 2');
- assert.equal(moment([2008, 0, 14]).week(), 3, 'Jan 14 2008 should be week 3');
-});
-
-test('weeks year starting wednesday', function (assert) {
- assert.equal(moment([2002, 11, 30]).week(), 1, 'Dec 30 2002 should be week 1');
- assert.equal(moment([2003, 0, 1]).week(), 1, 'Jan 1 2003 should be week 1');
- assert.equal(moment([2003, 0, 5]).week(), 1, 'Jan 5 2003 should be week 1');
- assert.equal(moment([2003, 0, 6]).week(), 2, 'Jan 6 2003 should be week 2');
- assert.equal(moment([2003, 0, 12]).week(), 2, 'Jan 12 2003 should be week 2');
- assert.equal(moment([2003, 0, 13]).week(), 3, 'Jan 13 2003 should be week 3');
-});
-
-test('weeks year starting thursday', function (assert) {
- assert.equal(moment([2008, 11, 29]).week(), 1, 'Dec 29 2008 should be week 1');
- assert.equal(moment([2009, 0, 1]).week(), 1, 'Jan 1 2009 should be week 1');
- assert.equal(moment([2009, 0, 4]).week(), 1, 'Jan 4 2009 should be week 1');
- assert.equal(moment([2009, 0, 5]).week(), 2, 'Jan 5 2009 should be week 2');
- assert.equal(moment([2009, 0, 11]).week(), 2, 'Jan 11 2009 should be week 2');
- assert.equal(moment([2009, 0, 13]).week(), 3, 'Jan 12 2009 should be week 3');
-});
-
-test('weeks year starting friday', function (assert) {
- assert.equal(moment([2009, 11, 28]).week(), 1, 'Dec 28 2009 should be week 53');
- assert.equal(moment([2010, 0, 1]).week(), 1, 'Jan 1 2010 should be week 53');
- assert.equal(moment([2010, 0, 3]).week(), 1, 'Jan 3 2010 should be week 53');
- assert.equal(moment([2010, 0, 4]).week(), 2, 'Jan 4 2010 should be week 1');
- assert.equal(moment([2010, 0, 10]).week(), 2, 'Jan 10 2010 should be week 1');
- assert.equal(moment([2010, 0, 11]).week(), 3, 'Jan 11 2010 should be week 2');
-});
-
-test('weeks year starting saturday', function (assert) {
- assert.equal(moment([2010, 11, 27]).week(), 1, 'Dec 27 2010 should be week 52');
- assert.equal(moment([2011, 0, 1]).week(), 1, 'Jan 1 2011 should be week 52');
- assert.equal(moment([2011, 0, 2]).week(), 1, 'Jan 2 2011 should be week 52');
- assert.equal(moment([2011, 0, 3]).week(), 2, 'Jan 3 2011 should be week 1');
- assert.equal(moment([2011, 0, 9]).week(), 2, 'Jan 9 2011 should be week 1');
- assert.equal(moment([2011, 0, 10]).week(), 3, 'Jan 10 2011 should be week 2');
-});
-
test('weeks year starting sunday formatted', function (assert) {
assert.equal(moment([2012, 0, 1]).format('w ww wo'), '1 01 1', 'Jan 1 2012 should be week 52');
assert.equal(moment([2012, 0, 2]).format('w ww wo'), '2 02 2', 'Jan 2 2012 should be week 1');
@@ -269,38 +208,3 @@
assert.equal(moment([2012, 0, 15]).format('w ww wo'), '3 03 3', 'Jan 15 2012 should be week 2');
});
-test('lenient ordinal parsing', function (assert) {
- var i, ordinalStr, testMoment;
- for (i = 1; i <= 31; ++i) {
- ordinalStr = moment([2014, 0, i]).format('YYYY MM Do');
- testMoment = moment(ordinalStr, 'YYYY MM Do');
- assert.equal(testMoment.year(), 2014,
- 'lenient ordinal parsing ' + i + ' year check');
- assert.equal(testMoment.month(), 0,
- 'lenient ordinal parsing ' + i + ' month check');
- assert.equal(testMoment.date(), i,
- 'lenient ordinal parsing ' + i + ' date check');
- }
-});
-
-test('lenient ordinal parsing of number', function (assert) {
- var i, testMoment;
- for (i = 1; i <= 31; ++i) {
- testMoment = moment('2014 01 ' + i, 'YYYY MM Do');
- assert.equal(testMoment.year(), 2014,
- 'lenient ordinal parsing of number ' + i + ' year check');
- assert.equal(testMoment.month(), 0,
- 'lenient ordinal parsing of number ' + i + ' month check');
- assert.equal(testMoment.date(), i,
- 'lenient ordinal parsing of number ' + i + ' date check');
- }
-});
-
-test('strict ordinal parsing', function (assert) {
- var i, ordinalStr, testMoment;
- for (i = 1; i <= 31; ++i) {
- ordinalStr = moment([2014, 0, i]).format('YYYY MM Do');
- testMoment = moment(ordinalStr, 'YYYY MM Do', true);
- assert.ok(testMoment.isValid(), 'strict ordinal parsing ' + i);
- }
-});
diff --git a/src/test/locale/vi.js b/src/test/locale/vi.js
index 26fd2ef..c1893db 100644
--- a/src/test/locale/vi.js
+++ b/src/test/locale/vi.js
@@ -25,8 +25,8 @@
test('format', function (assert) {
var a = [
- ['dddd, MMMM Do YYYY, h:mm:ss a', 'chủ nhật, tháng 2 14 2010, 3:25:50 pm'],
- ['ddd, hA', 'CN, 3PM'],
+ ['dddd, MMMM Do YYYY, h:mm:ss a', 'chủ nhật, tháng 2 14 2010, 3:25:50 ch'],
+ ['ddd, hA', 'CN, 3CH'],
['M Mo MM MMMM MMM', '2 2 02 tháng 2 Th02'],
['YYYY YY', '2010 10'],
['D Do DD', '14 14 14'],
@@ -37,7 +37,7 @@
['H HH', '15 15'],
['m mm', '25 25'],
['s ss', '50 50'],
- ['a A', 'pm PM'],
+ ['a A', 'ch CH'],
['[ngày thứ] DDDo [của năm]', 'ngày thứ 45 của năm'],
['LTS', '15:25:50'],
['L', '14/02/2010'],
@@ -160,14 +160,14 @@
});
test('calendar day', function (assert) {
- var a = moment().hours(2).minutes(0).seconds(0);
-
- assert.equal(moment(a).calendar(), 'Hôm nay lúc 02:00', 'today at the same time');
- assert.equal(moment(a).add({m: 25}).calendar(), 'Hôm nay lúc 02:25', 'Now plus 25 min');
- assert.equal(moment(a).add({h: 1}).calendar(), 'Hôm nay lúc 03:00', 'Now plus 1 hour');
- assert.equal(moment(a).add({d: 1}).calendar(), 'Ngày mai lúc 02:00', 'tomorrow at the same time');
- assert.equal(moment(a).subtract({h: 1}).calendar(), 'Hôm nay lúc 01:00', 'Now minus 1 hour');
- assert.equal(moment(a).subtract({d: 1}).calendar(), 'Hôm qua lúc 02:00', 'yesterday at the same time');
+ var a = moment().hours(12).minutes(0).seconds(0);
+
+ assert.equal(moment(a).calendar(), 'Hôm nay lúc 12:00', 'today at the same time');
+ assert.equal(moment(a).add({m: 25}).calendar(), 'Hôm nay lúc 12:25', 'Now plus 25 min');
+ assert.equal(moment(a).add({h: 1}).calendar(), 'Hôm nay lúc 13:00', 'Now plus 1 hour');
+ assert.equal(moment(a).add({d: 1}).calendar(), 'Ngày mai lúc 12:00', 'tomorrow at the same time');
+ assert.equal(moment(a).subtract({h: 1}).calendar(), 'Hôm nay lúc 11:00', 'Now minus 1 hour');
+ assert.equal(moment(a).subtract({d: 1}).calendar(), 'Hôm qua lúc 12:00', 'yesterday at the same time');
});
test('calendar next week', function (assert) {
@@ -210,67 +210,6 @@
assert.equal(weeksFromNow.calendar(), weeksFromNow.format('L'), 'in 2 weeks');
});
-test('weeks year starting sunday', function (assert) {
- assert.equal(moment([2012, 0, 1]).week(), 52, 'Jan 1 2012 should be week 52');
- assert.equal(moment([2012, 0, 2]).week(), 1, 'Jan 2 2012 should be week 1');
- assert.equal(moment([2012, 0, 8]).week(), 1, 'Jan 8 2012 should be week 1');
- assert.equal(moment([2012, 0, 9]).week(), 2, 'Jan 9 2012 should be week 2');
- assert.equal(moment([2012, 0, 15]).week(), 2, 'Jan 15 2012 should be week 2');
-});
-
-test('weeks year starting monday', function (assert) {
- assert.equal(moment([2007, 0, 1]).week(), 1, 'Jan 1 2007 should be week 1');
- assert.equal(moment([2007, 0, 7]).week(), 1, 'Jan 7 2007 should be week 1');
- assert.equal(moment([2007, 0, 8]).week(), 2, 'Jan 8 2007 should be week 2');
- assert.equal(moment([2007, 0, 14]).week(), 2, 'Jan 14 2007 should be week 2');
- assert.equal(moment([2007, 0, 15]).week(), 3, 'Jan 15 2007 should be week 3');
-});
-
-test('weeks year starting tuesday', function (assert) {
- assert.equal(moment([2007, 11, 31]).week(), 1, 'Dec 31 2007 should be week 1');
- assert.equal(moment([2008, 0, 1]).week(), 1, 'Jan 1 2008 should be week 1');
- assert.equal(moment([2008, 0, 6]).week(), 1, 'Jan 6 2008 should be week 1');
- assert.equal(moment([2008, 0, 7]).week(), 2, 'Jan 7 2008 should be week 2');
- assert.equal(moment([2008, 0, 13]).week(), 2, 'Jan 13 2008 should be week 2');
- assert.equal(moment([2008, 0, 14]).week(), 3, 'Jan 14 2008 should be week 3');
-});
-
-test('weeks year starting wednesday', function (assert) {
- assert.equal(moment([2002, 11, 30]).week(), 1, 'Dec 30 2002 should be week 1');
- assert.equal(moment([2003, 0, 1]).week(), 1, 'Jan 1 2003 should be week 1');
- assert.equal(moment([2003, 0, 5]).week(), 1, 'Jan 5 2003 should be week 1');
- assert.equal(moment([2003, 0, 6]).week(), 2, 'Jan 6 2003 should be week 2');
- assert.equal(moment([2003, 0, 12]).week(), 2, 'Jan 12 2003 should be week 2');
- assert.equal(moment([2003, 0, 13]).week(), 3, 'Jan 13 2003 should be week 3');
-});
-
-test('weeks year starting thursday', function (assert) {
- assert.equal(moment([2008, 11, 29]).week(), 1, 'Dec 29 2008 should be week 1');
- assert.equal(moment([2009, 0, 1]).week(), 1, 'Jan 1 2009 should be week 1');
- assert.equal(moment([2009, 0, 4]).week(), 1, 'Jan 4 2009 should be week 1');
- assert.equal(moment([2009, 0, 5]).week(), 2, 'Jan 5 2009 should be week 2');
- assert.equal(moment([2009, 0, 11]).week(), 2, 'Jan 11 2009 should be week 2');
- assert.equal(moment([2009, 0, 13]).week(), 3, 'Jan 12 2009 should be week 3');
-});
-
-test('weeks year starting friday', function (assert) {
- assert.equal(moment([2009, 11, 28]).week(), 53, 'Dec 28 2009 should be week 53');
- assert.equal(moment([2010, 0, 1]).week(), 53, 'Jan 1 2010 should be week 53');
- assert.equal(moment([2010, 0, 3]).week(), 53, 'Jan 3 2010 should be week 53');
- assert.equal(moment([2010, 0, 4]).week(), 1, 'Jan 4 2010 should be week 1');
- assert.equal(moment([2010, 0, 10]).week(), 1, 'Jan 10 2010 should be week 1');
- assert.equal(moment([2010, 0, 11]).week(), 2, 'Jan 11 2010 should be week 2');
-});
-
-test('weeks year starting saturday', function (assert) {
- assert.equal(moment([2010, 11, 27]).week(), 52, 'Dec 27 2010 should be week 52');
- assert.equal(moment([2011, 0, 1]).week(), 52, 'Jan 1 2011 should be week 52');
- assert.equal(moment([2011, 0, 2]).week(), 52, 'Jan 2 2011 should be week 52');
- assert.equal(moment([2011, 0, 3]).week(), 1, 'Jan 3 2011 should be week 1');
- assert.equal(moment([2011, 0, 9]).week(), 1, 'Jan 9 2011 should be week 1');
- assert.equal(moment([2011, 0, 10]).week(), 2, 'Jan 10 2011 should be week 2');
-});
-
test('weeks year starting sunday formatted', function (assert) {
assert.equal(moment([2012, 0, 1]).format('w ww wo'), '52 52 52', 'Jan 1 2012 should be week 52');
assert.equal(moment([2012, 0, 2]).format('w ww wo'), '1 01 1', 'Jan 2 2012 should be week 1');
@@ -279,38 +218,3 @@
assert.equal(moment([2012, 0, 15]).format('w ww wo'), '2 02 2', 'Jan 15 2012 should be week 2');
});
-test('lenient ordinal parsing', function (assert) {
- var i, ordinalStr, testMoment;
- for (i = 1; i <= 31; ++i) {
- ordinalStr = moment([2014, 0, i]).format('YYYY MM Do');
- testMoment = moment(ordinalStr, 'YYYY MM Do');
- assert.equal(testMoment.year(), 2014,
- 'lenient ordinal parsing ' + i + ' year check');
- assert.equal(testMoment.month(), 0,
- 'lenient ordinal parsing ' + i + ' month check');
- assert.equal(testMoment.date(), i,
- 'lenient ordinal parsing ' + i + ' date check');
- }
-});
-
-test('lenient ordinal parsing of number', function (assert) {
- var i, testMoment;
- for (i = 1; i <= 31; ++i) {
- testMoment = moment('2014 01 ' + i, 'YYYY MM Do');
- assert.equal(testMoment.year(), 2014,
- 'lenient ordinal parsing of number ' + i + ' year check');
- assert.equal(testMoment.month(), 0,
- 'lenient ordinal parsing of number ' + i + ' month check');
- assert.equal(testMoment.date(), i,
- 'lenient ordinal parsing of number ' + i + ' date check');
- }
-});
-
-test('strict ordinal parsing', function (assert) {
- var i, ordinalStr, testMoment;
- for (i = 1; i <= 31; ++i) {
- ordinalStr = moment([2014, 0, i]).format('YYYY MM Do');
- testMoment = moment(ordinalStr, 'YYYY MM Do', true);
- assert.ok(testMoment.isValid(), 'strict ordinal parsing ' + i);
- }
-});
diff --git a/src/test/locale/x-pseudo.js b/src/test/locale/x-pseudo.js
new file mode 100644
index 0000000..2ab8ae8
--- /dev/null
+++ b/src/test/locale/x-pseudo.js
@@ -0,0 +1,209 @@
+import {localeModule, test} from '../qunit';
+import moment from '../../moment';
+localeModule('x-pseudo');
+
+test('parse', function (assert) {
+ var tests = 'J~áñúá~rý J~áñ_F~ébrú~árý ~Féb_~Márc~h ~Már_Áp~ríl ~Ápr_~Máý ~Máý_~Júñé~ ~Júñ_Júl~ý ~Júl_Áú~gúst~ ~Áúg_Sép~témb~ér ~Sép_Ó~ctób~ér ~Óct_Ñ~óvém~bér ~Ñóv_~Décé~mbér ~Déc'.split('_'), i;
+ function equalTest(input, mmm, i) {
+ assert.equal(moment(input, mmm).month(), i, input + ' should be month ' + (i + 1));
+ }
+ for (i = 0; i < 12; i++) {
+ tests[i] = tests[i].split(' ');
+ equalTest(tests[i][0], 'MMM', i);
+ equalTest(tests[i][1], 'MMM', i);
+ equalTest(tests[i][0], 'MMMM', i);
+ equalTest(tests[i][1], 'MMMM', i);
+ equalTest(tests[i][0].toLocaleLowerCase(), 'MMMM', i);
+ equalTest(tests[i][1].toLocaleLowerCase(), 'MMMM', i);
+ equalTest(tests[i][0].toLocaleUpperCase(), 'MMMM', i);
+ equalTest(tests[i][1].toLocaleUpperCase(), 'MMMM', i);
+ }
+});
+
+test('format', function (assert) {
+ var a = [
+ ['dddd, MMMM Do YYYY, h:mm:ss a', 'S~úñdá~ý, F~ébrú~árý 14th 2010, 3:25:50 pm'],
+ ['ddd, hA', 'S~úñ, 3PM'],
+ ['M Mo MM MMMM MMM', '2 2nd 02 F~ébrú~árý ~Féb'],
+ ['YYYY YY', '2010 10'],
+ ['D Do DD', '14 14th 14'],
+ ['d do dddd ddd dd', '0 0th S~úñdá~ý S~úñ S~ú'],
+ ['DDD DDDo DDDD', '45 45th 045'],
+ ['w wo ww', '6 6th 06'],
+ ['h hh', '3 03'],
+ ['H HH', '15 15'],
+ ['m mm', '25 25'],
+ ['s ss', '50 50'],
+ ['a A', 'pm PM'],
+ ['[the] DDDo [day of the year]', 'the 45th day of the year'],
+ ['LT', '15:25'],
+ ['L', '14/02/2010'],
+ ['LL', '14 F~ébrú~árý 2010'],
+ ['LLL', '14 F~ébrú~árý 2010 15:25'],
+ ['LLLL', 'S~úñdá~ý, 14 F~ébrú~árý 2010 15:25'],
+ ['l', '14/2/2010'],
+ ['ll', '14 ~Féb 2010'],
+ ['lll', '14 ~Féb 2010 15:25'],
+ ['llll', 'S~úñ, 14 ~Féb 2010 15:25']
+ ],
+ b = moment(new Date(2010, 1, 14, 15, 25, 50, 125)),
+ i;
+ for (i = 0; i < a.length; i++) {
+ assert.equal(b.format(a[i][0]), a[i][1], a[i][0] + ' ---> ' + a[i][1]);
+ }
+});
+
+test('format ordinal', function (assert) {
+ assert.equal(moment([2011, 0, 1]).format('DDDo'), '1st', '1st');
+ assert.equal(moment([2011, 0, 2]).format('DDDo'), '2nd', '2nd');
+ assert.equal(moment([2011, 0, 3]).format('DDDo'), '3rd', '3rd');
+ assert.equal(moment([2011, 0, 4]).format('DDDo'), '4th', '4th');
+ assert.equal(moment([2011, 0, 5]).format('DDDo'), '5th', '5th');
+ assert.equal(moment([2011, 0, 6]).format('DDDo'), '6th', '6th');
+ assert.equal(moment([2011, 0, 7]).format('DDDo'), '7th', '7th');
+ assert.equal(moment([2011, 0, 8]).format('DDDo'), '8th', '8th');
+ assert.equal(moment([2011, 0, 9]).format('DDDo'), '9th', '9th');
+ assert.equal(moment([2011, 0, 10]).format('DDDo'), '10th', '10th');
+
+ assert.equal(moment([2011, 0, 11]).format('DDDo'), '11th', '11th');
+ assert.equal(moment([2011, 0, 12]).format('DDDo'), '12th', '12th');
+ assert.equal(moment([2011, 0, 13]).format('DDDo'), '13th', '13th');
+ assert.equal(moment([2011, 0, 14]).format('DDDo'), '14th', '14th');
+ assert.equal(moment([2011, 0, 15]).format('DDDo'), '15th', '15th');
+ assert.equal(moment([2011, 0, 16]).format('DDDo'), '16th', '16th');
+ assert.equal(moment([2011, 0, 17]).format('DDDo'), '17th', '17th');
+ assert.equal(moment([2011, 0, 18]).format('DDDo'), '18th', '18th');
+ assert.equal(moment([2011, 0, 19]).format('DDDo'), '19th', '19th');
+ assert.equal(moment([2011, 0, 20]).format('DDDo'), '20th', '20th');
+
+ assert.equal(moment([2011, 0, 21]).format('DDDo'), '21st', '21st');
+ assert.equal(moment([2011, 0, 22]).format('DDDo'), '22nd', '22nd');
+ assert.equal(moment([2011, 0, 23]).format('DDDo'), '23rd', '23rd');
+ assert.equal(moment([2011, 0, 24]).format('DDDo'), '24th', '24th');
+ assert.equal(moment([2011, 0, 25]).format('DDDo'), '25th', '25th');
+ assert.equal(moment([2011, 0, 26]).format('DDDo'), '26th', '26th');
+ assert.equal(moment([2011, 0, 27]).format('DDDo'), '27th', '27th');
+ assert.equal(moment([2011, 0, 28]).format('DDDo'), '28th', '28th');
+ assert.equal(moment([2011, 0, 29]).format('DDDo'), '29th', '29th');
+ assert.equal(moment([2011, 0, 30]).format('DDDo'), '30th', '30th');
+
+ assert.equal(moment([2011, 0, 31]).format('DDDo'), '31st', '31st');
+});
+
+test('format month', function (assert) {
+ var expected = 'J~áñúá~rý J~áñ_F~ébrú~árý ~Féb_~Márc~h ~Már_Áp~ríl ~Ápr_~Máý ~Máý_~Júñé~ ~Júñ_Júl~ý ~Júl_Áú~gúst~ ~Áúg_Sép~témb~ér ~Sép_Ó~ctób~ér ~Óct_Ñ~óvém~bér ~Ñóv_~Décé~mbér ~Déc'.split('_'), i;
+ for (i = 0; i < expected.length; i++) {
+ assert.equal(moment([2011, i, 1]).format('MMMM MMM'), expected[i], expected[i]);
+ }
+});
+
+test('format week', function (assert) {
+ var expected = 'S~úñdá~ý S~úñ S~ú_Mó~ñdáý~ ~Móñ Mó~_Túé~sdáý~ ~Túé Tú_Wéd~ñésd~áý ~Wéd ~Wé_T~húrs~dáý ~Thú T~h_~Fríd~áý ~Frí Fr~_S~átúr~dáý ~Sát Sá'.split('_'), i;
+ for (i = 0; i < expected.length; i++) {
+ assert.equal(moment([2011, 0, 2 + i]).format('dddd ddd dd'), expected[i], expected[i]);
+ }
+});
+
+test('from', function (assert) {
+ var start = moment([2007, 1, 28]);
+ assert.equal(start.from(moment([2007, 1, 28]).add({s: 44}), true), 'á ~féw ~sécó~ñds', '44 seconds = a few seconds');
+ assert.equal(start.from(moment([2007, 1, 28]).add({s: 45}), true), 'á ~míñ~úté', '45 seconds = a minute');
+ assert.equal(start.from(moment([2007, 1, 28]).add({s: 89}), true), 'á ~míñ~úté', '89 seconds = a minute');
+ assert.equal(start.from(moment([2007, 1, 28]).add({s: 90}), true), '2 m~íñú~tés', '90 seconds = 2 minutes');
+ assert.equal(start.from(moment([2007, 1, 28]).add({m: 44}), true), '44 m~íñú~tés', '44 minutes = 44 minutes');
+ assert.equal(start.from(moment([2007, 1, 28]).add({m: 45}), true), 'á~ñ hó~úr', '45 minutes = an hour');
+ assert.equal(start.from(moment([2007, 1, 28]).add({m: 89}), true), 'á~ñ hó~úr', '89 minutes = an hour');
+ assert.equal(start.from(moment([2007, 1, 28]).add({m: 90}), true), '2 h~óúrs', '90 minutes = 2 hours');
+ assert.equal(start.from(moment([2007, 1, 28]).add({h: 5}), true), '5 h~óúrs', '5 hours = 5 hours');
+ assert.equal(start.from(moment([2007, 1, 28]).add({h: 21}), true), '21 h~óúrs', '21 hours = 21 hours');
+ assert.equal(start.from(moment([2007, 1, 28]).add({h: 22}), true), 'á ~dáý', '22 hours = a day');
+ assert.equal(start.from(moment([2007, 1, 28]).add({h: 35}), true), 'á ~dáý', '35 hours = a day');
+ assert.equal(start.from(moment([2007, 1, 28]).add({h: 36}), true), '2 d~áýs', '36 hours = 2 days');
+ assert.equal(start.from(moment([2007, 1, 28]).add({d: 1}), true), 'á ~dáý', '1 day = a day');
+ assert.equal(start.from(moment([2007, 1, 28]).add({d: 5}), true), '5 d~áýs', '5 days = 5 days');
+ assert.equal(start.from(moment([2007, 1, 28]).add({d: 25}), true), '25 d~áýs', '25 days = 25 days');
+ assert.equal(start.from(moment([2007, 1, 28]).add({d: 26}), true), 'á ~móñ~th', '26 days = a month');
+ assert.equal(start.from(moment([2007, 1, 28]).add({d: 30}), true), 'á ~móñ~th', '30 days = a month');
+ assert.equal(start.from(moment([2007, 1, 28]).add({d: 43}), true), 'á ~móñ~th', '43 days = a month');
+ assert.equal(start.from(moment([2007, 1, 28]).add({d: 46}), true), '2 m~óñt~hs', '46 days = 2 months');
+ assert.equal(start.from(moment([2007, 1, 28]).add({d: 74}), true), '2 m~óñt~hs', '75 days = 2 months');
+ assert.equal(start.from(moment([2007, 1, 28]).add({d: 76}), true), '3 m~óñt~hs', '76 days = 3 months');
+ assert.equal(start.from(moment([2007, 1, 28]).add({M: 1}), true), 'á ~móñ~th', '1 month = a month');
+ assert.equal(start.from(moment([2007, 1, 28]).add({M: 5}), true), '5 m~óñt~hs', '5 months = 5 months');
+ assert.equal(start.from(moment([2007, 1, 28]).add({d: 345}), true), 'á ~ýéár', '345 days = a year');
+ assert.equal(start.from(moment([2007, 1, 28]).add({d: 548}), true), '2 ý~éárs', '548 days = 2 years');
+ assert.equal(start.from(moment([2007, 1, 28]).add({y: 1}), true), 'á ~ýéár', '1 year = a year');
+ assert.equal(start.from(moment([2007, 1, 28]).add({y: 5}), true), '5 ý~éárs', '5 years = 5 years');
+});
+
+test('suffix', function (assert) {
+ assert.equal(moment(30000).from(0), 'í~ñ á ~féw ~sécó~ñds', 'prefix');
+ assert.equal(moment(0).from(30000), 'á ~féw ~sécó~ñds á~gó', 'suffix');
+});
+
+test('now from now', function (assert) {
+ assert.equal(moment().fromNow(), 'á ~féw ~sécó~ñds á~gó', 'now from now should display as in the past');
+});
+
+test('fromNow', function (assert) {
+ assert.equal(moment().add({s: 30}).fromNow(), 'í~ñ á ~féw ~sécó~ñds', 'in a few seconds');
+ assert.equal(moment().add({d: 5}).fromNow(), 'í~ñ 5 d~áýs', 'in 5 days');
+});
+
+test('calendar day', function (assert) {
+ var a = moment().hours(2).minutes(0).seconds(0);
+
+ assert.equal(moment(a).calendar(), 'T~ódá~ý át 02:00', 'today at the same time');
+ assert.equal(moment(a).add({m: 25}).calendar(), 'T~ódá~ý át 02:25', 'Now plus 25 min');
+ assert.equal(moment(a).add({h: 1}).calendar(), 'T~ódá~ý át 03:00', 'Now plus 1 hour');
+ assert.equal(moment(a).add({d: 1}).calendar(), 'T~ómó~rró~w át 02:00', 'tomorrow at the same time');
+ assert.equal(moment(a).subtract({h: 1}).calendar(), 'T~ódá~ý át 01:00', 'Now minus 1 hour');
+ assert.equal(moment(a).subtract({d: 1}).calendar(), 'Ý~ést~érdá~ý át 02:00', 'yesterday at the same time');
+});
+
+test('calendar next week', function (assert) {
+ var i, m;
+ for (i = 2; i < 7; i++) {
+ m = moment().add({d: i});
+ assert.equal(m.calendar(), m.format('dddd [át] LT'), 'Today + ' + i + ' days current time');
+ m.hours(0).minutes(0).seconds(0).milliseconds(0);
+ assert.equal(m.calendar(), m.format('dddd [át] LT'), 'Today + ' + i + ' days beginning of day');
+ m.hours(23).minutes(59).seconds(59).milliseconds(999);
+ assert.equal(m.calendar(), m.format('dddd [át] LT'), 'Today + ' + i + ' days end of day');
+ }
+});
+
+test('calendar last week', function (assert) {
+ var i, m;
+
+ for (i = 2; i < 7; i++) {
+ m = moment().subtract({d: i});
+ assert.equal(m.calendar(), m.format('[L~ást] dddd [át] LT'), 'Today - ' + i + ' days current time');
+ m.hours(0).minutes(0).seconds(0).milliseconds(0);
+ assert.equal(m.calendar(), m.format('[L~ást] dddd [át] LT'), 'Today - ' + i + ' days beginning of day');
+ m.hours(23).minutes(59).seconds(59).milliseconds(999);
+ assert.equal(m.calendar(), m.format('[L~ást] dddd [át] LT'), 'Today - ' + i + ' days end of day');
+ }
+});
+
+test('calendar all else', function (assert) {
+ var weeksAgo = moment().subtract({w: 1}),
+ weeksFromNow = moment().add({w: 1});
+
+ assert.equal(weeksAgo.calendar(), weeksAgo.format('L'), '1 week ago');
+ assert.equal(weeksFromNow.calendar(), weeksFromNow.format('L'), 'in 1 week');
+
+ weeksAgo = moment().subtract({w: 2});
+ weeksFromNow = moment().add({w: 2});
+
+ assert.equal(weeksAgo.calendar(), weeksAgo.format('L'), '2 weeks ago');
+ assert.equal(weeksFromNow.calendar(), weeksFromNow.format('L'), 'in 2 weeks');
+});
+
+test('weeks year starting sunday formatted', function (assert) {
+ assert.equal(moment([2012, 0, 1]).format('w ww wo'), '52 52 52nd', 'Jan 1 2012 should be week 52');
+ assert.equal(moment([2012, 0, 2]).format('w ww wo'), '1 01 1st', 'Jan 2 2012 should be week 1');
+ assert.equal(moment([2012, 0, 8]).format('w ww wo'), '1 01 1st', 'Jan 8 2012 should be week 1');
+ assert.equal(moment([2012, 0, 9]).format('w ww wo'), '2 02 2nd', 'Jan 9 2012 should be week 2');
+ assert.equal(moment([2012, 0, 15]).format('w ww wo'), '2 02 2nd', 'Jan 15 2012 should be week 2');
+});
diff --git a/src/test/locale/zh-cn.js b/src/test/locale/zh-cn.js
index b6a0681..86a6621 100644
--- a/src/test/locale/zh-cn.js
+++ b/src/test/locale/zh-cn.js
@@ -119,14 +119,14 @@
});
test('calendar day', function (assert) {
- var a = moment().hours(2).minutes(0).seconds(0);
-
- assert.equal(moment(a).calendar(), '今天凌晨2点整', 'today at the same time');
- assert.equal(moment(a).add({m: 25}).calendar(), '今天凌晨2点25分', 'Now plus 25 min');
- assert.equal(moment(a).add({h: 1}).calendar(), '今天凌晨3点整', 'Now plus 1 hour');
- assert.equal(moment(a).add({d: 1}).calendar(), '明天凌晨2点整', 'tomorrow at the same time');
- assert.equal(moment(a).subtract({h: 1}).calendar(), '今天凌晨1点整', 'Now minus 1 hour');
- assert.equal(moment(a).subtract({d: 1}).calendar(), '昨天凌晨2点整', 'yesterday at the same time');
+ var a = moment().hours(12).minutes(0).seconds(0);
+
+ assert.equal(moment(a).calendar(), '今天中午12点整', 'today at the same time');
+ assert.equal(moment(a).add({m: 25}).calendar(), '今天中午12点25分', 'Now plus 25 min');
+ assert.equal(moment(a).add({h: 1}).calendar(), '今天下午1点整', 'Now plus 1 hour');
+ assert.equal(moment(a).add({d: 1}).calendar(), '明天中午12点整', 'tomorrow at the same time');
+ assert.equal(moment(a).subtract({h: 1}).calendar(), '今天上午11点整', 'Now minus 1 hour');
+ assert.equal(moment(a).subtract({d: 1}).calendar(), '昨天中午12点整', 'yesterday at the same time');
});
test('calendar current week', function (assert) {
@@ -196,109 +196,10 @@
assert.equal(moment([2011, 2, 23, 18, 0]).format('A'), '晚上', 'night');
});
-test('weeks year starting sunday', function (assert) {
- assert.equal(moment([2012, 0, 1]).week(), 52, 'Jan 1 2012 should be week 52');
- assert.equal(moment([2012, 0, 2]).week(), 1, 'Jan 2 2012 should be week 52');
- assert.equal(moment([2012, 0, 7]).week(), 1, 'Jan 7 2012 should be week 1');
- assert.equal(moment([2012, 0, 14]).week(), 2, 'Jan 14 2012 should be week 2');
-});
-
-test('weeks year starting monday', function (assert) {
- assert.equal(moment([2006, 11, 31]).week(), 52, 'Dec 31 2006 should be week 52');
- assert.equal(moment([2007, 0, 1]).week(), 1, 'Jan 1 2007 should be week 1');
- assert.equal(moment([2007, 0, 6]).week(), 1, 'Jan 6 2007 should be week 1');
- assert.equal(moment([2007, 0, 7]).week(), 1, 'Jan 7 2007 should be week 1');
- assert.equal(moment([2007, 0, 13]).week(), 2, 'Jan 13 2007 should be week 2');
- assert.equal(moment([2007, 0, 14]).week(), 2, 'Jan 14 2007 should be week 2');
-});
-
-test('weeks year starting tuesday', function (assert) {
- assert.equal(moment([2007, 11, 29]).week(), 52, 'Dec 29 2007 should be week 52');
- assert.equal(moment([2008, 0, 1]).week(), 1, 'Jan 1 2008 should be week 1');
- assert.equal(moment([2008, 0, 5]).week(), 1, 'Jan 5 2008 should be week 1');
- assert.equal(moment([2008, 0, 6]).week(), 1, 'Jan 6 2008 should be week 1');
- assert.equal(moment([2008, 0, 12]).week(), 2, 'Jan 12 2008 should be week 2');
- assert.equal(moment([2008, 0, 13]).week(), 2, 'Jan 13 2008 should be week 2');
-});
-
-test('weeks year starting wednesday', function (assert) {
- assert.equal(moment([2002, 11, 29]).week(), 52, 'Dec 29 2002 should be week 52');
- assert.equal(moment([2003, 0, 1]).week(), 1, 'Jan 1 2003 should be week 1');
- assert.equal(moment([2003, 0, 4]).week(), 1, 'Jan 4 2003 should be week 1');
- assert.equal(moment([2003, 0, 5]).week(), 1, 'Jan 5 2003 should be week 1');
- assert.equal(moment([2003, 0, 11]).week(), 2, 'Jan 11 2003 should be week 2');
- assert.equal(moment([2003, 0, 12]).week(), 2, 'Jan 12 2003 should be week 2');
-});
-
-test('weeks year starting thursday', function (assert) {
- assert.equal(moment([2009, 0, 1]).week(), 1, 'Jan 1 2009 should be week 1');
- assert.equal(moment([2009, 0, 3]).week(), 1, 'Jan 3 2009 should be week 1');
- assert.equal(moment([2009, 0, 4]).week(), 1, 'Jan 4 2009 should be week 1');
- assert.equal(moment([2009, 0, 10]).week(), 2, 'Jan 10 2009 should be week 2');
- assert.equal(moment([2009, 0, 11]).week(), 2, 'Jan 11 2009 should be week 2');
-});
-
-test('weeks year starting friday', function (assert) {
- assert.equal(moment([2010, 0, 2]).week(), 53, 'Jan 2 2010 should be week 53');
- assert.equal(moment([2010, 0, 10]).week(), 1, 'Jan 10 2010 should be week 1');
-});
-
-test('weeks year starting saturday', function (assert) {
- assert.equal(moment([2011, 0, 2]).week(), 52, 'Jan 2 2011 should be week 52');
- assert.equal(moment([2011, 0, 8]).week(), 1, 'Jan 8 2011 should be week 1');
- assert.equal(moment([2011, 0, 9]).week(), 1, 'Jan 9 2011 should be week 1');
-});
-
test('weeks year starting sunday format', function (assert) {
assert.equal(moment([2012, 0, 1]).format('w ww wo'), '52 52 52周', 'Jan 1 2012 应该是第52周');
assert.equal(moment([2012, 0, 7]).format('w ww wo'), '1 01 1周', 'Jan 7 2012 应该是第 1周');
assert.equal(moment([2012, 0, 14]).format('w ww wo'), '2 02 2周', 'Jan 14 2012 应该是第 2周');
});
-test('lenient ordinal parsing', function (assert) {
- var i, ordinalStr, testMoment;
- for (i = 1; i <= 31; ++i) {
- ordinalStr = moment([2014, 0, i]).format('YYYY MM Do');
- testMoment = moment(ordinalStr, 'YYYY MM Do');
- assert.equal(testMoment.year(), 2014,
- 'lenient ordinal parsing ' + i + ' year check');
- assert.equal(testMoment.month(), 0,
- 'lenient ordinal parsing ' + i + ' month check');
- assert.equal(testMoment.date(), i,
- 'lenient ordinal parsing ' + i + ' date check');
- }
-});
-
-test('lenient ordinal parsing of number', function (assert) {
- var i, testMoment;
- for (i = 1; i <= 31; ++i) {
- testMoment = moment('2014 01 ' + i, 'YYYY MM Do');
- assert.equal(testMoment.year(), 2014,
- 'lenient ordinal parsing of number ' + i + ' year check');
- assert.equal(testMoment.month(), 0,
- 'lenient ordinal parsing of number ' + i + ' month check');
- assert.equal(testMoment.date(), i,
- 'lenient ordinal parsing of number ' + i + ' date check');
- }
-});
-
-test('meridiem invariant', function (assert) {
- var h, m, t1, t2;
- for (h = 0; h < 24; ++h) {
- for (m = 0; m < 60; m += 15) {
- t1 = moment.utc([2000, 0, 1, h, m]);
- t2 = moment(t1.format('A h:mm'), 'A h:mm');
- assert.equal(t2.format('HH:mm'), t1.format('HH:mm'),
- 'meridiem at ' + t1.format('HH:mm'));
- }
- }
-});
-
-test('strict ordinal parsing', function (assert) {
- var i, ordinalStr, testMoment;
- for (i = 1; i <= 31; ++i) {
- ordinalStr = moment([2014, 0, i]).format('YYYY MM Do');
- testMoment = moment(ordinalStr, 'YYYY MM Do', true);
- assert.ok(testMoment.isValid(), 'strict ordinal parsing ' + i);
- }
-});
+
diff --git a/src/test/locale/zh-tw.js b/src/test/locale/zh-tw.js
index 37e95bf..1451a2b 100644
--- a/src/test/locale/zh-tw.js
+++ b/src/test/locale/zh-tw.js
@@ -73,32 +73,32 @@
test('from', function (assert) {
var start = moment([2007, 1, 28]);
assert.equal(start.from(moment([2007, 1, 28]).add({s: 44}), true), '幾秒', '44 seconds = a few seconds');
- assert.equal(start.from(moment([2007, 1, 28]).add({s: 45}), true), '一分鐘', '45 seconds = a minute');
- assert.equal(start.from(moment([2007, 1, 28]).add({s: 89}), true), '一分鐘', '89 seconds = a minute');
+ assert.equal(start.from(moment([2007, 1, 28]).add({s: 45}), true), '1分鐘', '45 seconds = a minute');
+ assert.equal(start.from(moment([2007, 1, 28]).add({s: 89}), true), '1分鐘', '89 seconds = a minute');
assert.equal(start.from(moment([2007, 1, 28]).add({s: 90}), true), '2分鐘', '90 seconds = 2 minutes');
assert.equal(start.from(moment([2007, 1, 28]).add({m: 44}), true), '44分鐘', '44 minutes = 44 minutes');
- assert.equal(start.from(moment([2007, 1, 28]).add({m: 45}), true), '一小時', '45 minutes = an hour');
- assert.equal(start.from(moment([2007, 1, 28]).add({m: 89}), true), '一小時', '89 minutes = an hour');
+ assert.equal(start.from(moment([2007, 1, 28]).add({m: 45}), true), '1小時', '45 minutes = an hour');
+ assert.equal(start.from(moment([2007, 1, 28]).add({m: 89}), true), '1小時', '89 minutes = an hour');
assert.equal(start.from(moment([2007, 1, 28]).add({m: 90}), true), '2小時', '90 minutes = 2 hours');
assert.equal(start.from(moment([2007, 1, 28]).add({h: 5}), true), '5小時', '5 hours = 5 hours');
assert.equal(start.from(moment([2007, 1, 28]).add({h: 21}), true), '21小時', '21 hours = 21 hours');
- assert.equal(start.from(moment([2007, 1, 28]).add({h: 22}), true), '一天', '22 hours = a day');
- assert.equal(start.from(moment([2007, 1, 28]).add({h: 35}), true), '一天', '35 hours = a day');
+ assert.equal(start.from(moment([2007, 1, 28]).add({h: 22}), true), '1天', '22 hours = a day');
+ assert.equal(start.from(moment([2007, 1, 28]).add({h: 35}), true), '1天', '35 hours = a day');
assert.equal(start.from(moment([2007, 1, 28]).add({h: 36}), true), '2天', '36 hours = 2 days');
- assert.equal(start.from(moment([2007, 1, 28]).add({d: 1}), true), '一天', '1 day = a day');
+ assert.equal(start.from(moment([2007, 1, 28]).add({d: 1}), true), '1天', '1 day = a day');
assert.equal(start.from(moment([2007, 1, 28]).add({d: 5}), true), '5天', '5 days = 5 days');
assert.equal(start.from(moment([2007, 1, 28]).add({d: 25}), true), '25天', '25 days = 25 days');
- assert.equal(start.from(moment([2007, 1, 28]).add({d: 26}), true), '一個月', '26 days = a month');
- assert.equal(start.from(moment([2007, 1, 28]).add({d: 30}), true), '一個月', '30 days = a month');
- assert.equal(start.from(moment([2007, 1, 28]).add({d: 43}), true), '一個月', '43 days = a month');
+ assert.equal(start.from(moment([2007, 1, 28]).add({d: 26}), true), '1個月', '26 days = a month');
+ assert.equal(start.from(moment([2007, 1, 28]).add({d: 30}), true), '1個月', '30 days = a month');
+ assert.equal(start.from(moment([2007, 1, 28]).add({d: 43}), true), '1個月', '43 days = a month');
assert.equal(start.from(moment([2007, 1, 28]).add({d: 46}), true), '2個月', '46 days = 2 months');
assert.equal(start.from(moment([2007, 1, 28]).add({d: 74}), true), '2個月', '75 days = 2 months');
assert.equal(start.from(moment([2007, 1, 28]).add({d: 76}), true), '3個月', '76 days = 3 months');
- assert.equal(start.from(moment([2007, 1, 28]).add({M: 1}), true), '一個月', '1 month = a month');
+ assert.equal(start.from(moment([2007, 1, 28]).add({M: 1}), true), '1個月', '1 month = a month');
assert.equal(start.from(moment([2007, 1, 28]).add({M: 5}), true), '5個月', '5 months = 5 months');
- assert.equal(start.from(moment([2007, 1, 28]).add({d: 345}), true), '一年', '345 days = a year');
+ assert.equal(start.from(moment([2007, 1, 28]).add({d: 345}), true), '1年', '345 days = a year');
assert.equal(start.from(moment([2007, 1, 28]).add({d: 548}), true), '2年', '548 days = 2 years');
- assert.equal(start.from(moment([2007, 1, 28]).add({y: 1}), true), '一年', '1 year = a year');
+ assert.equal(start.from(moment([2007, 1, 28]).add({y: 1}), true), '1年', '1 year = a year');
assert.equal(start.from(moment([2007, 1, 28]).add({y: 5}), true), '5年', '5 years = 5 years');
});
@@ -117,14 +117,14 @@
});
test('calendar day', function (assert) {
- var a = moment().hours(2).minutes(0).seconds(0);
+ var a = moment().hours(12).minutes(0).seconds(0);
- assert.equal(moment(a).calendar(), '今天早上2點00分', 'today at the same time');
- assert.equal(moment(a).add({m: 25}).calendar(), '今天早上2點25分', 'Now plus 25 min');
- assert.equal(moment(a).add({h: 1}).calendar(), '今天早上3點00分', 'Now plus 1 hour');
- assert.equal(moment(a).add({d: 1}).calendar(), '明天早上2點00分', 'tomorrow at the same time');
- assert.equal(moment(a).subtract({h: 1}).calendar(), '今天早上1點00分', 'Now minus 1 hour');
- assert.equal(moment(a).subtract({d: 1}).calendar(), '昨天早上2點00分', 'yesterday at the same time');
+ assert.equal(moment(a).calendar(), '今天中午12點00分', 'today at the same time');
+ assert.equal(moment(a).add({m: 25}).calendar(), '今天中午12點25分', 'Now plus 25 min');
+ assert.equal(moment(a).add({h: 1}).calendar(), '今天下午1點00分', 'Now plus 1 hour');
+ assert.equal(moment(a).add({d: 1}).calendar(), '明天中午12點00分', 'tomorrow at the same time');
+ assert.equal(moment(a).subtract({h: 1}).calendar(), '今天上午11點00分', 'Now minus 1 hour');
+ assert.equal(moment(a).subtract({d: 1}).calendar(), '昨天中午12點00分', 'yesterday at the same time');
});
test('calendar next week', function (assert) {
@@ -179,67 +179,6 @@
assert.equal(moment([2011, 2, 23, 18, 0]).format('A'), '晚上', 'night');
});
-test('weeks year starting sunday', function (assert) {
- assert.equal(moment([2012, 0, 1]).week(), 1, 'Jan 1 2012 should be week 1');
- assert.equal(moment([2012, 0, 7]).week(), 1, 'Jan 7 2012 should be week 1');
- assert.equal(moment([2012, 0, 8]).week(), 2, 'Jan 8 2012 should be week 2');
- assert.equal(moment([2012, 0, 14]).week(), 2, 'Jan 14 2012 should be week 2');
- assert.equal(moment([2012, 0, 15]).week(), 3, 'Jan 15 2012 should be week 3');
-});
-
-test('weeks year starting monday', function (assert) {
- assert.equal(moment([2006, 11, 31]).week(), 1, 'Dec 31 2006 should be week 1');
- assert.equal(moment([2007, 0, 1]).week(), 1, 'Jan 1 2007 should be week 1');
- assert.equal(moment([2007, 0, 6]).week(), 1, 'Jan 6 2007 should be week 1');
- assert.equal(moment([2007, 0, 7]).week(), 2, 'Jan 7 2007 should be week 2');
- assert.equal(moment([2007, 0, 13]).week(), 2, 'Jan 13 2007 should be week 2');
- assert.equal(moment([2007, 0, 14]).week(), 3, 'Jan 14 2007 should be week 3');
-});
-
-test('weeks year starting tuesday', function (assert) {
- assert.equal(moment([2007, 11, 29]).week(), 52, 'Dec 29 2007 should be week 52');
- assert.equal(moment([2008, 0, 1]).week(), 1, 'Jan 1 2008 should be week 1');
- assert.equal(moment([2008, 0, 5]).week(), 1, 'Jan 5 2008 should be week 1');
- assert.equal(moment([2008, 0, 6]).week(), 2, 'Jan 6 2008 should be week 2');
- assert.equal(moment([2008, 0, 12]).week(), 2, 'Jan 12 2008 should be week 2');
- assert.equal(moment([2008, 0, 13]).week(), 3, 'Jan 13 2008 should be week 3');
-});
-
-test('weeks year starting wednesday', function (assert) {
- assert.equal(moment([2002, 11, 29]).week(), 1, 'Dec 29 2002 should be week 1');
- assert.equal(moment([2003, 0, 1]).week(), 1, 'Jan 1 2003 should be week 1');
- assert.equal(moment([2003, 0, 4]).week(), 1, 'Jan 4 2003 should be week 1');
- assert.equal(moment([2003, 0, 5]).week(), 2, 'Jan 5 2003 should be week 2');
- assert.equal(moment([2003, 0, 11]).week(), 2, 'Jan 11 2003 should be week 2');
- assert.equal(moment([2003, 0, 12]).week(), 3, 'Jan 12 2003 should be week 3');
-});
-
-test('weeks year starting thursday', function (assert) {
- assert.equal(moment([2008, 11, 28]).week(), 1, 'Dec 28 2008 should be week 1');
- assert.equal(moment([2009, 0, 1]).week(), 1, 'Jan 1 2009 should be week 1');
- assert.equal(moment([2009, 0, 3]).week(), 1, 'Jan 3 2009 should be week 1');
- assert.equal(moment([2009, 0, 4]).week(), 2, 'Jan 4 2009 should be week 2');
- assert.equal(moment([2009, 0, 10]).week(), 2, 'Jan 10 2009 should be week 2');
- assert.equal(moment([2009, 0, 11]).week(), 3, 'Jan 11 2009 should be week 3');
-});
-
-test('weeks year starting friday', function (assert) {
- assert.equal(moment([2009, 11, 27]).week(), 1, 'Dec 27 2009 should be week 1');
- assert.equal(moment([2010, 0, 1]).week(), 1, 'Jan 1 2010 should be week 1');
- assert.equal(moment([2010, 0, 2]).week(), 1, 'Jan 2 2010 should be week 1');
- assert.equal(moment([2010, 0, 3]).week(), 2, 'Jan 3 2010 should be week 2');
- assert.equal(moment([2010, 0, 9]).week(), 2, 'Jan 9 2010 should be week 2');
- assert.equal(moment([2010, 0, 10]).week(), 3, 'Jan 10 2010 should be week 3');
-});
-
-test('weeks year starting saturday', function (assert) {
- assert.equal(moment([2010, 11, 26]).week(), 1, 'Dec 26 2010 should be week 1');
- assert.equal(moment([2011, 0, 1]).week(), 1, 'Jan 1 2011 should be week 1');
- assert.equal(moment([2011, 0, 2]).week(), 2, 'Jan 2 2011 should be week 2');
- assert.equal(moment([2011, 0, 8]).week(), 2, 'Jan 8 2011 should be week 2');
- assert.equal(moment([2011, 0, 9]).week(), 3, 'Jan 9 2011 should be week 3');
-});
-
test('weeks year starting sunday format', function (assert) {
assert.equal(moment([2012, 0, 1]).format('w ww wo'), '1 01 1週', 'Jan 1 2012 應該是第 1週');
assert.equal(moment([2012, 0, 7]).format('w ww wo'), '1 01 1週', 'Jan 7 2012 應該是第 1週');
@@ -248,50 +187,4 @@
assert.equal(moment([2012, 0, 15]).format('w ww wo'), '3 03 3週', 'Jan 15 2012 應該是第 3週');
});
-test('lenient ordinal parsing', function (assert) {
- var i, ordinalStr, testMoment;
- for (i = 1; i <= 31; ++i) {
- ordinalStr = moment([2014, 0, i]).format('YYYY MM Do');
- testMoment = moment(ordinalStr, 'YYYY MM Do');
- assert.equal(testMoment.year(), 2014,
- 'lenient ordinal parsing ' + i + ' year check');
- assert.equal(testMoment.month(), 0,
- 'lenient ordinal parsing ' + i + ' month check');
- assert.equal(testMoment.date(), i,
- 'lenient ordinal parsing ' + i + ' date check');
- }
-});
-test('lenient ordinal parsing of number', function (assert) {
- var i, testMoment;
- for (i = 1; i <= 31; ++i) {
- testMoment = moment('2014 01 ' + i, 'YYYY MM Do');
- assert.equal(testMoment.year(), 2014,
- 'lenient ordinal parsing of number ' + i + ' year check');
- assert.equal(testMoment.month(), 0,
- 'lenient ordinal parsing of number ' + i + ' month check');
- assert.equal(testMoment.date(), i,
- 'lenient ordinal parsing of number ' + i + ' date check');
- }
-});
-
-test('meridiem invariant', function (assert) {
- var h, m, t1, t2;
- for (h = 0; h < 24; ++h) {
- for (m = 0; m < 60; m += 15) {
- t1 = moment.utc([2000, 0, 1, h, m]);
- t2 = moment(t1.format('A h:mm'), 'A h:mm');
- assert.equal(t2.format('HH:mm'), t1.format('HH:mm'),
- 'meridiem at ' + t1.format('HH:mm'));
- }
- }
-});
-
-test('strict ordinal parsing', function (assert) {
- var i, ordinalStr, testMoment;
- for (i = 1; i <= 31; ++i) {
- ordinalStr = moment([2014, 0, i]).format('YYYY MM Do');
- testMoment = moment(ordinalStr, 'YYYY MM Do', true);
- assert.ok(testMoment.isValid(), 'strict ordinal parsing ' + i);
- }
-});
diff --git a/src/test/moment/add_subtract.js b/src/test/moment/add_subtract.js
index 3a4077e..da1f22d 100644
--- a/src/test/moment/add_subtract.js
+++ b/src/test/moment/add_subtract.js
@@ -80,6 +80,9 @@
test('add string long reverse args', function (assert) {
var a = moment(), b;
+
+ test.expectedDeprecations('moment().add(period, number)');
+
a.year(2011);
a.month(9);
a.date(12);
@@ -104,6 +107,9 @@
test('add string long singular reverse args', function (assert) {
var a = moment(), b;
+
+ test.expectedDeprecations('moment().add(period, number)');
+
a.year(2011);
a.month(9);
a.date(12);
@@ -128,6 +134,8 @@
test('add string short reverse args', function (assert) {
var a = moment();
+ test.expectedDeprecations('moment().add(period, number)');
+
a.year(2011);
a.month(9);
a.date(12);
@@ -210,8 +218,10 @@
assert.equal(a.add(1, 'Q').month(), 1, 'Add quarter');
});
-test('add strings string short args', function (assert) {
- var a = moment();
+test('add strings string short reversed', function (assert) {
+ var a = moment();
+ test.expectedDeprecations('moment().add(period, number)');
+
a.year(2011);
a.month(9);
a.date(12);
@@ -231,8 +241,10 @@
assert.equal(a.add('Q', '1').month(), 1, 'Add quarter');
});
-test('subtract strings string short args', function (assert) {
- var a = moment();
+test('subtract strings string short reversed', function (assert) {
+ var a = moment();
+ test.expectedDeprecations('moment().subtract(period, number)');
+
a.year(2011);
a.month(9);
a.date(12);
@@ -323,3 +335,23 @@
assert.equal(c.hours(), 5, 'adding months over DST difference should result in the same hour');
assert.equal(e.hours(), 5, 'adding quarters over DST difference should result in the same hour');
});
+
+test('add decimal values of days and months', function (assert) {
+ assert.equal(moment([2016,3,3]).add(1.5, 'days').date(), 5, 'adding 1.5 days is rounded to adding 2 day');
+ assert.equal(moment([2016,3,3]).add(-1.5, 'days').date(), 1, 'adding -1.5 days is rounded to adding -2 day');
+ assert.equal(moment([2016,3,1]).add(-1.5, 'days').date(), 30, 'adding -1.5 days on first of month wraps around');
+ assert.equal(moment([2016,3,3]).add(1.5, 'months').month(), 5, 'adding 1.5 months adds 2 months');
+ assert.equal(moment([2016,3,3]).add(-1.5, 'months').month(), 1, 'adding -1.5 months adds -2 months');
+ assert.equal(moment([2016,0,3]).add(-1.5, 'months').month(), 10, 'adding -1.5 months at start of year wraps back');
+ assert.equal(moment([2016,3,3]).subtract(1.5, 'days').date(),1, 'subtract 1.5 days is rounded to subtract 2 day');
+ assert.equal(moment([2016,3,2]).subtract(1.5, 'days').date(), 31, 'subtract 1.5 days subtracts 2 days');
+ assert.equal(moment([2016,1,1]).subtract(1.1, 'days').date(), 31, 'subtract 1.1 days wraps to previous month');
+ assert.equal(moment([2016,3,3]).subtract(-1.5, 'days').date(), 5, 'subtract -1.5 days is rounded to subtract -2 day');
+ assert.equal(moment([2016,3,30]).subtract(-1.5, 'days').date(), 2, 'subtract -1.5 days on last of month wraps around');
+ assert.equal(moment([2016,3,3]).subtract(1.5, 'months').month(), 1, 'subtract 1.5 months subtract 2 months');
+ assert.equal(moment([2016,3,3]).subtract(-1.5, 'months').month(), 5, 'subtract -1.5 months subtract -2 month');
+ assert.equal(moment([2016,11,31]).subtract(-1.5, 'months').month(),1, 'subtract -1.5 months at end of year wraps back');
+ assert.equal(moment([2016, 0,1]).add(1.5, 'years').format('YYYY-MM-DD'), '2017-07-01', 'add 1.5 years adds 1 year six months');
+ assert.equal(moment([2016, 0,1]).add(1.6, 'years').format('YYYY-MM-DD'), '2017-08-01', 'add 1.6 years becomes 1.6*12 = 19.2, round, 19 months');
+ assert.equal(moment([2016,0,1]).add(1.1, 'quarters').format('YYYY-MM-DD'), '2016-04-01', 'add 1.1 quarters 1.1*3=3.3, round, 3 months');
+});
diff --git a/src/test/moment/calendar.js b/src/test/moment/calendar.js
index d388c41..b7cffaa 100644
--- a/src/test/moment/calendar.js
+++ b/src/test/moment/calendar.js
@@ -6,12 +6,12 @@
module('calendar');
test('passing a function', function (assert) {
- var a = moment().hours(2).minutes(0).seconds(0);
+ var a = moment().hours(13).minutes(0).seconds(0);
assert.equal(moment(a).calendar(null, {
'sameDay': function () {
return 'h:mmA';
}
- }), '2:00AM', 'should equate');
+ }), '1:00PM', 'should equate');
});
diff --git a/src/test/moment/create.js b/src/test/moment/create.js
index 17ee70d..e6222fe 100644
--- a/src/test/moment/create.js
+++ b/src/test/moment/create.js
@@ -234,11 +234,11 @@
['L', '09/02/1999'],
['l', '9/2/1999'],
['LL', 'September 2, 1999'],
- ['ll', 'Sept 2, 1999'],
+ ['ll', 'Sep 2, 1999'],
['LLL', 'September 2, 1999 12:30 AM'],
- ['lll', 'Sept 2, 1999 12:30 AM'],
+ ['lll', 'Sep 2, 1999 12:30 AM'],
['LLLL', 'Thursday, September 2, 1999 12:30 AM'],
- ['llll', 'Thu, Sept 2, 1999 12:30 AM']
+ ['llll', 'Thu, Sep 2, 1999 12:30 AM']
],
m,
i;
@@ -290,7 +290,7 @@
['MMDDYYYY', '12021999'],
['DDMMYYYY', '12021999'],
['YYYYMMDD', '19991202'],
- ['DDMMMYYYY', '10Sept2001']
+ ['DDMMMYYYY', '10Sep2001']
], i;
for (i = 0; i < a.length; i++) {
@@ -605,25 +605,25 @@
});
test('parsing iso week year/week/weekday', function (assert) {
- assert.equal(moment.utc('2007-W01').format(), '2007-01-01T00:00:00+00:00', '2008 week 1 (1st Jan Mon)');
- assert.equal(moment.utc('2008-W01').format(), '2007-12-31T00:00:00+00:00', '2008 week 1 (1st Jan Tue)');
- assert.equal(moment.utc('2003-W01').format(), '2002-12-30T00:00:00+00:00', '2008 week 1 (1st Jan Wed)');
- assert.equal(moment.utc('2009-W01').format(), '2008-12-29T00:00:00+00:00', '2009 week 1 (1st Jan Thu)');
- assert.equal(moment.utc('2010-W01').format(), '2010-01-04T00:00:00+00:00', '2010 week 1 (1st Jan Fri)');
- assert.equal(moment.utc('2011-W01').format(), '2011-01-03T00:00:00+00:00', '2011 week 1 (1st Jan Sat)');
- assert.equal(moment.utc('2012-W01').format(), '2012-01-02T00:00:00+00:00', '2012 week 1 (1st Jan Sun)');
+ assert.equal(moment.utc('2007-W01').format(), '2007-01-01T00:00:00Z', '2008 week 1 (1st Jan Mon)');
+ assert.equal(moment.utc('2008-W01').format(), '2007-12-31T00:00:00Z', '2008 week 1 (1st Jan Tue)');
+ assert.equal(moment.utc('2003-W01').format(), '2002-12-30T00:00:00Z', '2008 week 1 (1st Jan Wed)');
+ assert.equal(moment.utc('2009-W01').format(), '2008-12-29T00:00:00Z', '2009 week 1 (1st Jan Thu)');
+ assert.equal(moment.utc('2010-W01').format(), '2010-01-04T00:00:00Z', '2010 week 1 (1st Jan Fri)');
+ assert.equal(moment.utc('2011-W01').format(), '2011-01-03T00:00:00Z', '2011 week 1 (1st Jan Sat)');
+ assert.equal(moment.utc('2012-W01').format(), '2012-01-02T00:00:00Z', '2012 week 1 (1st Jan Sun)');
});
test('parsing week year/week/weekday (dow 1, doy 4)', function (assert) {
moment.locale('dow:1,doy:4', {week: {dow: 1, doy: 4}});
- assert.equal(moment.utc('2007-01', 'gggg-ww').format(), '2007-01-01T00:00:00+00:00', '2007 week 1 (1st Jan Mon)');
- assert.equal(moment.utc('2008-01', 'gggg-ww').format(), '2007-12-31T00:00:00+00:00', '2008 week 1 (1st Jan Tue)');
- assert.equal(moment.utc('2003-01', 'gggg-ww').format(), '2002-12-30T00:00:00+00:00', '2003 week 1 (1st Jan Wed)');
- assert.equal(moment.utc('2009-01', 'gggg-ww').format(), '2008-12-29T00:00:00+00:00', '2009 week 1 (1st Jan Thu)');
- assert.equal(moment.utc('2010-01', 'gggg-ww').format(), '2010-01-04T00:00:00+00:00', '2010 week 1 (1st Jan Fri)');
- assert.equal(moment.utc('2011-01', 'gggg-ww').format(), '2011-01-03T00:00:00+00:00', '2011 week 1 (1st Jan Sat)');
- assert.equal(moment.utc('2012-01', 'gggg-ww').format(), '2012-01-02T00:00:00+00:00', '2012 week 1 (1st Jan Sun)');
+ assert.equal(moment.utc('2007-01', 'gggg-ww').format(), '2007-01-01T00:00:00Z', '2007 week 1 (1st Jan Mon)');
+ assert.equal(moment.utc('2008-01', 'gggg-ww').format(), '2007-12-31T00:00:00Z', '2008 week 1 (1st Jan Tue)');
+ assert.equal(moment.utc('2003-01', 'gggg-ww').format(), '2002-12-30T00:00:00Z', '2003 week 1 (1st Jan Wed)');
+ assert.equal(moment.utc('2009-01', 'gggg-ww').format(), '2008-12-29T00:00:00Z', '2009 week 1 (1st Jan Thu)');
+ assert.equal(moment.utc('2010-01', 'gggg-ww').format(), '2010-01-04T00:00:00Z', '2010 week 1 (1st Jan Fri)');
+ assert.equal(moment.utc('2011-01', 'gggg-ww').format(), '2011-01-03T00:00:00Z', '2011 week 1 (1st Jan Sat)');
+ assert.equal(moment.utc('2012-01', 'gggg-ww').format(), '2012-01-02T00:00:00Z', '2012 week 1 (1st Jan Sun)');
moment.defineLocale('dow:1,doy:4', null);
});
@@ -631,39 +631,40 @@
test('parsing week year/week/weekday (dow 1, doy 7)', function (assert) {
moment.locale('dow:1,doy:7', {week: {dow: 1, doy: 7}});
- assert.equal(moment.utc('2007-01', 'gggg-ww').format(), '2007-01-01T00:00:00+00:00', '2007 week 1 (1st Jan Mon)');
- assert.equal(moment.utc('2008-01', 'gggg-ww').format(), '2007-12-31T00:00:00+00:00', '2008 week 1 (1st Jan Tue)');
- assert.equal(moment.utc('2003-01', 'gggg-ww').format(), '2002-12-30T00:00:00+00:00', '2003 week 1 (1st Jan Wed)');
- assert.equal(moment.utc('2009-01', 'gggg-ww').format(), '2008-12-29T00:00:00+00:00', '2009 week 1 (1st Jan Thu)');
- assert.equal(moment.utc('2010-01', 'gggg-ww').format(), '2009-12-28T00:00:00+00:00', '2010 week 1 (1st Jan Fri)');
- assert.equal(moment.utc('2011-01', 'gggg-ww').format(), '2010-12-27T00:00:00+00:00', '2011 week 1 (1st Jan Sat)');
- assert.equal(moment.utc('2012-01', 'gggg-ww').format(), '2011-12-26T00:00:00+00:00', '2012 week 1 (1st Jan Sun)');
+ assert.equal(moment.utc('2007-01', 'gggg-ww').format(), '2007-01-01T00:00:00Z', '2007 week 1 (1st Jan Mon)');
+ assert.equal(moment.utc('2008-01', 'gggg-ww').format(), '2007-12-31T00:00:00Z', '2008 week 1 (1st Jan Tue)');
+ assert.equal(moment.utc('2003-01', 'gggg-ww').format(), '2002-12-30T00:00:00Z', '2003 week 1 (1st Jan Wed)');
+ assert.equal(moment.utc('2009-01', 'gggg-ww').format(), '2008-12-29T00:00:00Z', '2009 week 1 (1st Jan Thu)');
+ assert.equal(moment.utc('2010-01', 'gggg-ww').format(), '2009-12-28T00:00:00Z', '2010 week 1 (1st Jan Fri)');
+ assert.equal(moment.utc('2011-01', 'gggg-ww').format(), '2010-12-27T00:00:00Z', '2011 week 1 (1st Jan Sat)');
+ assert.equal(moment.utc('2012-01', 'gggg-ww').format(), '2011-12-26T00:00:00Z', '2012 week 1 (1st Jan Sun)');
moment.defineLocale('dow:1,doy:7', null);
});
test('parsing week year/week/weekday (dow 0, doy 6)', function (assert) {
moment.locale('dow:0,doy:6', {week: {dow: 0, doy: 6}});
- assert.equal(moment.utc('2007-01', 'gggg-ww').format(), '2006-12-31T00:00:00+00:00', '2007 week 1 (1st Jan Mon)');
- assert.equal(moment.utc('2008-01', 'gggg-ww').format(), '2007-12-30T00:00:00+00:00', '2008 week 1 (1st Jan Tue)');
- assert.equal(moment.utc('2003-01', 'gggg-ww').format(), '2002-12-29T00:00:00+00:00', '2003 week 1 (1st Jan Wed)');
- assert.equal(moment.utc('2009-01', 'gggg-ww').format(), '2008-12-28T00:00:00+00:00', '2009 week 1 (1st Jan Thu)');
- assert.equal(moment.utc('2010-01', 'gggg-ww').format(), '2009-12-27T00:00:00+00:00', '2010 week 1 (1st Jan Fri)');
- assert.equal(moment.utc('2011-01', 'gggg-ww').format(), '2010-12-26T00:00:00+00:00', '2011 week 1 (1st Jan Sat)');
- assert.equal(moment.utc('2012-01', 'gggg-ww').format(), '2012-01-01T00:00:00+00:00', '2012 week 1 (1st Jan Sun)');
+ assert.equal(moment.utc('2007-01', 'gggg-ww').format(), '2006-12-31T00:00:00Z', '2007 week 1 (1st Jan Mon)');
+ assert.equal(moment.utc('2008-01', 'gggg-ww').format(), '2007-12-30T00:00:00Z', '2008 week 1 (1st Jan Tue)');
+ assert.equal(moment.utc('2003-01', 'gggg-ww').format(), '2002-12-29T00:00:00Z', '2003 week 1 (1st Jan Wed)');
+ assert.equal(moment.utc('2009-01', 'gggg-ww').format(), '2008-12-28T00:00:00Z', '2009 week 1 (1st Jan Thu)');
+ assert.equal(moment.utc('2010-01', 'gggg-ww').format(), '2009-12-27T00:00:00Z', '2010 week 1 (1st Jan Fri)');
+ assert.equal(moment.utc('2011-01', 'gggg-ww').format(), '2010-12-26T00:00:00Z', '2011 week 1 (1st Jan Sat)');
+ assert.equal(moment.utc('2012-01', 'gggg-ww').format(), '2012-01-01T00:00:00Z', '2012 week 1 (1st Jan Sun)');
moment.defineLocale('dow:0,doy:6', null);
});
test('parsing week year/week/weekday (dow 6, doy 12)', function (assert) {
moment.locale('dow:6,doy:12', {week: {dow: 6, doy: 12}});
- assert.equal(moment.utc('2007-01', 'gggg-ww').format(), '2006-12-30T00:00:00+00:00', '2007 week 1 (1st Jan Mon)');
- assert.equal(moment.utc('2008-01', 'gggg-ww').format(), '2007-12-29T00:00:00+00:00', '2008 week 1 (1st Jan Tue)');
- assert.equal(moment.utc('2003-01', 'gggg-ww').format(), '2002-12-28T00:00:00+00:00', '2003 week 1 (1st Jan Wed)');
- assert.equal(moment.utc('2009-01', 'gggg-ww').format(), '2008-12-27T00:00:00+00:00', '2009 week 1 (1st Jan Thu)');
- assert.equal(moment.utc('2010-01', 'gggg-ww').format(), '2009-12-26T00:00:00+00:00', '2010 week 1 (1st Jan Fri)');
- assert.equal(moment.utc('2011-01', 'gggg-ww').format(), '2011-01-01T00:00:00+00:00', '2011 week 1 (1st Jan Sat)');
- assert.equal(moment.utc('2012-01', 'gggg-ww').format(), '2011-12-31T00:00:00+00:00', '2012 week 1 (1st Jan Sun)');
+ assert.equal(moment.utc('2007-01', 'gggg-ww').format(), '2006-12-30T00:00:00Z', '2007 week 1 (1st Jan Mon)');
+ assert.equal(moment.utc('2008-01', 'gggg-ww').format(), '2007-12-29T00:00:00Z', '2008 week 1 (1st Jan Tue)');
+ assert.equal(moment.utc('2003-01', 'gggg-ww').format(), '2002-12-28T00:00:00Z', '2003 week 1 (1st Jan Wed)');
+ assert.equal(moment.utc('2009-01', 'gggg-ww').format(), '2008-12-27T00:00:00Z', '2009 week 1 (1st Jan Thu)');
+ assert.equal(moment.utc('2010-01', 'gggg-ww').format(), '2009-12-26T00:00:00Z', '2010 week 1 (1st Jan Fri)');
+ assert.equal(moment.utc('2011-01', 'gggg-ww').format(), '2011-01-01T00:00:00Z', '2011 week 1 (1st Jan Sat)');
+ assert.equal(moment.utc('2012-01', 'gggg-ww').format(), '2011-12-31T00:00:00Z', '2012 week 1 (1st Jan Sun)');
+ moment.defineLocale('dow:6,doy:12', null);
});
test('parsing ISO with Z', function (assert) {
@@ -728,7 +729,7 @@
});
test('parsing iso with more subsecond precision digits', function (assert) {
- assert.equal(moment.utc('2013-07-31T22:00:00.0000000Z').format(), '2013-07-31T22:00:00+00:00', 'more than 3 subsecond digits');
+ assert.equal(moment.utc('2013-07-31T22:00:00.0000000Z').format(), '2013-07-31T22:00:00Z', 'more than 3 subsecond digits');
});
test('null or empty', function (assert) {
@@ -952,6 +953,7 @@
ver('1999 37 Di', 'gggg ww dd', '1999 09 19', 'localized d uses 0-indexed days: 0 = sund');
}
finally {
+ moment.defineLocale('dow:1,doy:4', null);
moment.locale('en');
}
});
@@ -983,7 +985,7 @@
});
test('utc with array of formats', function (assert) {
- assert.equal(moment.utc('2014-01-01', ['YYYY-MM-DD', 'YYYY-MM']).format(), '2014-01-01T00:00:00+00:00', 'moment.utc works with array of formats');
+ assert.equal(moment.utc('2014-01-01', ['YYYY-MM-DD', 'YYYY-MM']).format(), '2014-01-01T00:00:00Z', 'moment.utc works with array of formats');
});
test('parsing invalid string weekdays', function (assert) {
@@ -1037,3 +1039,23 @@
assert.equal(moment('112345', 'Hmmss', true).format('HH:mm:ss'), '11:23:45', '112345 with Hmmss');
assert.equal(moment('172345', 'Hmmss', true).format('HH:mm:ss'), '17:23:45', '112345 with Hmmss');
});
+
+test('Y token', function (assert) {
+ assert.equal(moment('1-1-2010', 'M-D-Y', true).year(), 2010, 'parsing Y');
+});
+
+test('parsing flags retain parsed date parts', function (assert) {
+ var a = moment('10 p', 'hh:mm a');
+ assert.equal(a.parsingFlags().parsedDateParts[3], 10, 'parsed 10 as the hour');
+ assert.equal(a.parsingFlags().parsedDateParts[0], undefined, 'year was not parsed');
+ assert.equal(a.parsingFlags().meridiem, 'p', 'meridiem flag was added');
+ var b = moment('10:30', ['MMDDYY', 'HH:mm']);
+ assert.equal(b.parsingFlags().parsedDateParts[3], 10, 'multiple format parshing matched hour');
+ assert.equal(b.parsingFlags().parsedDateParts[0], undefined, 'array is properly copied, no residual data from first token parse');
+});
+
+test('parsing only meridiem results in invalid date', function (assert) {
+ assert.ok(!moment('alkj', 'hh:mm a').isValid(), 'because an a token is used, a meridiem will be parsed but nothing else was so invalid');
+ assert.ok(moment('02:30 p more extra stuff', 'hh:mm a').isValid(), 'because other tokens were parsed, date is valid');
+ assert.ok(moment('1/1/2016 extra data', ['a', 'M/D/YYYY']).isValid(), 'took second format, does not pick up on meridiem parsed from first format (good copy)');
+});
diff --git a/src/test/moment/deprecate.js b/src/test/moment/deprecate.js
index 455ab9f..eaf23ca 100644
--- a/src/test/moment/deprecate.js
+++ b/src/test/moment/deprecate.js
@@ -5,6 +5,8 @@
module('deprecate');
test('deprecate', function (assert) {
+ // NOTE: hooks inside deprecate.js and moment are different, so this is can
+ // not be test.expectedDeprecations(...)
var fn = function () {};
var deprecatedFn = deprecate('testing deprecation', fn);
deprecatedFn();
diff --git a/src/test/moment/diff.js b/src/test/moment/diff.js
index 6eb785b..1499cae 100644
--- a/src/test/moment/diff.js
+++ b/src/test/moment/diff.js
@@ -232,3 +232,12 @@
equal(assert, moment([2012, 0, 1]).diff([2013, 6, 1, 12], 'years', true), -1.5 - (0.5 / 31) / 12, 'Jan 1 2012 to Jul 1 2013 noon should be 1.5+(0.5 / 31) / 12 years');
equal(assert, moment([2012, 1, 29]).diff([2013, 1, 28], 'years', true), -1, 'Feb 29 2012 to Feb 28 2013 should be 1-(1 / 28.5) / 12 years');
});
+
+test('negative zero', function (assert) {
+ function isNegative (n) {
+ return (1 / n) < 0;
+ }
+ assert.ok(!isNegative(moment([2012, 0, 1]).diff(moment([2012, 0, 1]), 'months')), 'month diff on same date is zero, not -0');
+ assert.ok(!isNegative(moment([2012, 0, 1]).diff(moment([2012, 0, 1]), 'years')), 'year diff on same date is zero, not -0');
+ assert.ok(!isNegative(moment([2012, 0, 1]).diff(moment([2012, 0, 1]), 'quarters')), 'quarter diff on same date is zero, not -0');
+});
diff --git a/src/test/moment/duration.js b/src/test/moment/duration.js
index 809a648..e855f21 100644
--- a/src/test/moment/duration.js
+++ b/src/test/moment/duration.js
@@ -250,6 +250,7 @@
test('instantiation from ISO 8601 duration', function (assert) {
assert.equal(moment.duration('P1Y2M3DT4H5M6S').asSeconds(), moment.duration({y: 1, M: 2, d: 3, h: 4, m: 5, s: 6}).asSeconds(), 'all fields');
+ assert.equal(moment.duration('P3W3D').asSeconds(), moment.duration({w: 3, d: 3}).asSeconds(), 'week and day fields');
assert.equal(moment.duration('P1M').asSeconds(), moment.duration({M: 1}).asSeconds(), 'single month field');
assert.equal(moment.duration('PT1M').asSeconds(), moment.duration({m: 1}).asSeconds(), 'single minute field');
assert.equal(moment.duration('P1MT2H').asSeconds(), moment.duration({M: 1, h: 2}).asSeconds(), 'random fields missing');
@@ -279,6 +280,8 @@
});
test('toIsoString deprecation', function (assert) {
+ test.expectedDeprecations('toIsoString()');
+
assert.equal(moment.duration({}).toIsoString(), moment.duration({}).toISOString(), 'toIsoString delegates to toISOString');
});
@@ -307,6 +310,12 @@
assert.equal(moment.duration('-P2Y').asSeconds(), moment.duration({y: -2}).asSeconds(), 'python isodate 22');
assert.equal(moment.duration('-P3Y6M4DT12H30M5S').asSeconds(), moment.duration({y: -3, M: -6, d: -4, h: -12, m: -30, s: -5}).asSeconds(), 'python isodate 23');
assert.equal(moment.duration('-P1DT2H3M4S').asSeconds(), moment.duration({d: -1, h: -2, m: -3, s: -4}).asSeconds(), 'python isodate 24');
+ assert.equal(moment.duration('PT-6H3M').asSeconds(), moment.duration({h: -6, m: 3}).asSeconds(), 'python isodate 25');
+ assert.equal(moment.duration('-PT-6H3M').asSeconds(), moment.duration({h: 6, m: -3}).asSeconds(), 'python isodate 26');
+ assert.equal(moment.duration('-P-3Y-6M-4DT-12H-30M-5S').asSeconds(), moment.duration({y: 3, M: 6, d: 4, h: 12, m: 30, s: 5}).asSeconds(), 'python isodate 27');
+ assert.equal(moment.duration('P-3Y-6M-4DT-12H-30M-5S').asSeconds(), moment.duration({y: -3, M: -6, d: -4, h: -12, m: -30, s: -5}).asSeconds(), 'python isodate 28');
+ assert.equal(moment.duration('-P-2W').asSeconds(), moment.duration({w: 2}).asSeconds(), 'python isodate 29');
+ assert.equal(moment.duration('P-2W').asSeconds(), moment.duration({w: -2}).asSeconds(), 'python isodate 30');
});
test('ISO 8601 misuse cases', function (assert) {
@@ -317,7 +326,6 @@
assert.equal(moment.duration('PT.5S').asSeconds(), 0.5, 'accept no leading zero for decimal');
assert.equal(moment.duration('PT1,S').asSeconds(), 1, 'accept trailing decimal separator');
assert.equal(moment.duration('PT1M0,,5S').asSeconds(), 60, 'extra decimal separators are ignored as 0');
- assert.equal(moment.duration('P-1DS').asSeconds(), 0, 'wrong position of negative');
});
test('humanize', function (assert) {
@@ -540,6 +548,13 @@
assert.equal(dm.asMinutes(), 13, 'asMinutes()');
});
+test('minutes getter for floating point hours', function (assert) {
+ // Tests for issue #2978.
+ // For certain floating point hours, .minutes() getter produced incorrect values due to the rounding errors
+ assert.equal(moment.duration(2.3, 'h').minutes(), 18, 'minutes()');
+ assert.equal(moment.duration(4.1, 'h').minutes(), 6, 'minutes()');
+});
+
test('isDuration', function (assert) {
assert.ok(moment.isDuration(moment.duration(12345678)), 'correctly says true');
assert.ok(!moment.isDuration(moment()), 'moment object is not a duration');
@@ -628,4 +643,3 @@
};
durationObject.foo(5);
});
-
diff --git a/src/test/moment/format.js b/src/test/moment/format.js
index 017145f..d3084d0 100644
--- a/src/test/moment/format.js
+++ b/src/test/moment/format.js
@@ -1,4 +1,5 @@
import { module, test } from '../qunit';
+import each from '../helpers/each';
import moment from '../../moment';
module('format');
@@ -113,6 +114,11 @@
test('default format', function (assert) {
var isoRegex = /\d{4}.\d\d.\d\dT\d\d.\d\d.\d\d[\+\-]\d\d:\d\d/;
assert.ok(isoRegex.exec(moment().format()), 'default format (' + moment().format() + ') should match ISO');
+});
+
+test('default UTC format', function (assert) {
+ var isoRegex = /\d{4}.\d\d.\d\dT\d\d.\d\d.\d\dZ/;
+ assert.ok(isoRegex.exec(moment.utc().format()), 'default UTC format (' + moment.utc().format() + ') should match ISO');
});
test('toJSON', function (assert) {
@@ -241,7 +247,7 @@
'405-12-31': '0405-52'
}, i, isoWeekYear, formatted5, formatted4, formatted2;
- moment.locale('dow:1,doy:4', {week: {dow: 1, doy: 4}});
+ moment.defineLocale('dow:1,doy:4', {week: {dow: 1, doy: 4}});
for (i in cases) {
isoWeekYear = cases[i].split('-')[0];
@@ -252,6 +258,7 @@
formatted2 = moment(i, 'YYYY-MM-DD').format('gg');
assert.equal(isoWeekYear.slice(2, 4), formatted2, i + ': gg should be ' + isoWeekYear + ', but ' + formatted2);
}
+ moment.defineLocale('dow:1,doy:4', null);
});
test('iso weekday formats', function (assert) {
@@ -265,7 +272,7 @@
});
test('weekday formats', function (assert) {
- moment.locale('dow: 3,doy: 5', {week: {dow: 3, doy: 5}});
+ moment.defineLocale('dow: 3,doy: 5', {week: {dow: 3, doy: 5}});
assert.equal(moment([1985, 1, 6]).format('e'), '0', 'Feb 6 1985 is Wednesday -- 0th day');
assert.equal(moment([2029, 8, 20]).format('e'), '1', 'Sep 20 2029 is Thursday -- 1st day');
assert.equal(moment([2013, 3, 26]).format('e'), '2', 'Apr 26 2013 is Friday -- 2nd day');
@@ -273,6 +280,7 @@
assert.equal(moment([1970, 0, 4]).format('e'), '4', 'Jan 4 1970 is Sunday -- 4th day');
assert.equal(moment([2001, 4, 14]).format('e'), '5', 'May 14 2001 is Monday -- 5th day');
assert.equal(moment([2000, 0, 4]).format('e'), '6', 'Jan 4 2000 is Tuesday -- 6th day');
+ moment.defineLocale('dow: 3,doy: 5', null);
});
test('toString is just human readable format', function (assert) {
@@ -281,13 +289,13 @@
});
test('toJSON skips postformat', function (assert) {
- moment.locale('postformat', {
+ moment.defineLocale('postformat', {
postformat: function (s) {
s.replace(/./g, 'X');
}
});
assert.equal(moment.utc([2000, 0, 1]).toJSON(), '2000-01-01T00:00:00.000Z', 'toJSON doesn\'t postformat');
- moment.locale('postformat', null);
+ moment.defineLocale('postformat', null);
});
test('calendar day timezone', function (assert) {
@@ -341,54 +349,44 @@
assert.equal(moment([2000, 0, 2]).format('Qo [quarter] YYYY'), '1st quarter 2000', 'Jan 2 2000 is 1st quarter');
});
-test('full expanded format is returned from abbreviated formats', function (assert) {
- function forEach(ar, fn) {
- if (ar.forEach) {
- return ar.forEach(fn);
- } else {
- // IE8
- for (var i = 0; i < ar.length; i += 1) {
- fn(ar[i]);
- }
- }
- }
- function objectKeys(obj) {
- if (Object.keys) {
- return Object.keys(obj);
- } else {
- // IE8
- var res = [], i;
- for (i in obj) {
- if (obj.hasOwnProperty(i)) {
- res.push(i);
- }
- }
- return res;
- }
- }
-
- var locales =
- 'ar-sa ar-tn ar az be bg bn bo br bs ca cs cv cy da de-at de dv el ' +
- 'en-au en-ca en-gb en-ie en-nz eo es et eu fa fi fo fr-ca fr-ch fr fy ' +
- 'gd gl he hi hr hu hy-am id is it ja jv ka kk km ko lb lo lt lv me mk ml ' +
- 'mr ms-my ms my nb ne nl nn pl pt-br pt ro ru se si sk sl sq sr-cyrl ' +
- 'sr sv sw ta te th tl-ph tlh tr tzl tzm-latn tzm uk uz vi zh-cn zh-tw';
-
- forEach(locales.split(' '), function (locale) {
- var data, tokens;
- data = moment().locale(locale).localeData()._longDateFormat;
- tokens = objectKeys(data);
- forEach(tokens, function (token) {
- // Check each format string to make sure it does not contain any
- // tokens that need to be expanded.
- forEach(tokens, function (i) {
- // strip escaped sequences
- var format = data[i].replace(/(\[[^\]]*\])/g, '');
- assert.equal(false, !!~format.indexOf(token), 'locale ' + locale + ' contains ' + token + ' in ' + i);
- });
- });
- });
-});
+// test('full expanded format is returned from abbreviated formats', function (assert) {
+// function objectKeys(obj) {
+// if (Object.keys) {
+// return Object.keys(obj);
+// } else {
+// // IE8
+// var res = [], i;
+// for (i in obj) {
+// if (obj.hasOwnProperty(i)) {
+// res.push(i);
+// }
+// }
+// return res;
+// }
+// }
+
+// var locales =
+// 'ar-sa ar-tn ar az be bg bn bo br bs ca cs cv cy da de-at de dv el ' +
+// 'en-au en-ca en-gb en-ie en-nz eo es et eu fa fi fo fr-ca fr-ch fr fy ' +
+// 'gd gl he hi hr hu hy-am id is it ja jv ka kk km ko lb lo lt lv me mk ml ' +
+// 'mr ms-my ms my nb ne nl nn pl pt-br pt ro ru se si sk sl sq sr-cyrl ' +
+// 'sr sv sw ta te th tl-ph tlh tr tzl tzm-latn tzm uk uz vi zh-cn zh-tw';
+
+// each(locales.split(' '), function (locale) {
+// var data, tokens;
+// data = moment().locale(locale).localeData()._longDateFormat;
+// tokens = objectKeys(data);
+// each(tokens, function (token) {
+// // Check each format string to make sure it does not contain any
+// // tokens that need to be expanded.
+// each(tokens, function (i) {
+// // strip escaped sequences
+// var format = data[i].replace(/(\[[^\]]*\])/g, '');
+// assert.equal(false, !!~format.indexOf(token), 'locale ' + locale + ' contains ' + token + ' in ' + i);
+// });
+// });
+// });
+// });
test('milliseconds', function (assert) {
var m = moment('123', 'SSS');
@@ -424,3 +422,22 @@
assert.equal(moment('08:34:56', 'HH:mm:ss').format('Hmmss'), '83456');
assert.equal(moment('18:34:56', 'HH:mm:ss').format('Hmmss'), '183456');
});
+
+test('k and kk', function (assert) {
+ assert.equal(moment('01:23:45', 'HH:mm:ss').format('k'), '1');
+ assert.equal(moment('12:34:56', 'HH:mm:ss').format('k'), '12');
+ assert.equal(moment('01:23:45', 'HH:mm:ss').format('kk'), '01');
+ assert.equal(moment('12:34:56', 'HH:mm:ss').format('kk'), '12');
+ assert.equal(moment('00:34:56', 'HH:mm:ss').format('kk'), '24');
+ assert.equal(moment('00:00:00', 'HH:mm:ss').format('kk'), '24');
+});
+
+test('Y token', function (assert) {
+ assert.equal(moment('2010-01-01', 'YYYY-MM-DD', true).format('Y'), '2010', 'format 2010 with Y');
+ assert.equal(moment('-123-01-01', 'Y-MM-DD', true).format('Y'), '-123', 'format -123 with Y');
+ assert.equal(moment('12345-01-01', 'Y-MM-DD', true).format('Y'), '+12345', 'format 12345 with Y');
+ assert.equal(moment('0-01-01', 'Y-MM-DD', true).format('Y'), '0', 'format 0 with Y');
+ assert.equal(moment('1-01-01', 'Y-MM-DD', true).format('Y'), '1', 'format 1 with Y');
+ assert.equal(moment('9999-01-01', 'Y-MM-DD', true).format('Y'), '9999', 'format 9999 with Y');
+ assert.equal(moment('10000-01-01', 'Y-MM-DD', true).format('Y'), '+10000', 'format 10000 with Y');
+});
diff --git a/src/test/moment/getters_setters.js b/src/test/moment/getters_setters.js
index c8c9c96..8f23e68 100644
--- a/src/test/moment/getters_setters.js
+++ b/src/test/moment/getters_setters.js
@@ -36,6 +36,8 @@
test('setters plural', function (assert) {
var a = moment();
+ test.expectedDeprecations('years accessor', 'months accessor', 'dates accessor');
+
a.years(2011);
a.months(9);
a.dates(12);
@@ -120,36 +122,30 @@
assert.equal(a.month(), 3, 'month edge case');
});
-// Disable this, until we weekYear setter is fixed.
-// https://github.com/moment/moment/issues/1379
-// test('setters programatic with weeks', function (assert) {
-// var a = moment();
-// a.set('weekYear', 2001);
-// a.set('week', 49);
-// a.set('day', 4);
-// assert.equals(a.weekYear(), 2001);
-// assert.equals(a.week(), 49);
-// assert.equals(a.day(), 4);
-
-// a.set('weekday', 1);
-// assert.equals(a.weekday(), 1);
-
-// assert.done();
-//},
-
-// I think this suffers from the same issue as the non-iso version.
-// test('setters programatic with weeks ISO', function (assert) {
-// var a = moment();
-// a.set('isoWeekYear', 2001);
-// a.set('isoWeek', 49);
-// a.set('isoWeekday', 4);
-
-// assert.equals(a.weekYear(), 2001);
-// assert.equals(a.week(), 49);
-// assert.equals(a.day(), 4);
-
-// assert.done();
-//},
+test('setters programatic with weeks', function (assert) {
+ var a = moment();
+ a.set('weekYear', 2001);
+ a.set('week', 49);
+ a.set('day', 4);
+
+ assert.equal(a.weekYear(), 2001, 'weekYear');
+ assert.equal(a.week(), 49, 'week');
+ assert.equal(a.day(), 4, 'day');
+
+ a.set('weekday', 1);
+ assert.equal(a.weekday(), 1, 'weekday');
+});
+
+test('setters programatic with weeks ISO', function (assert) {
+ var a = moment();
+ a.set('isoWeekYear', 2001);
+ a.set('isoWeek', 49);
+ a.set('isoWeekday', 4);
+
+ assert.equal(a.isoWeekYear(), 2001, 'isoWeekYear');
+ assert.equal(a.isoWeek(), 49, 'isoWeek');
+ assert.equal(a.isoWeekday(), 4, 'isoWeekday');
+});
test('setters strings', function (assert) {
var a = moment([2012]).locale('en');
@@ -236,3 +232,88 @@
assert.equal(moment(a).day(20).date(), 29, 'set from wednesday to second next saturday');
assert.equal(moment(a).day(17).date(), 26, 'set from wednesday to second next wednesday');
});
+
+test('string setters', function (assert) {
+ var a = moment();
+ a.year('2011');
+ a.month('9');
+ a.date('12');
+ a.hours('6');
+ a.minutes('7');
+ a.seconds('8');
+ a.milliseconds('9');
+ assert.equal(a.year(), 2011, 'year');
+ assert.equal(a.month(), 9, 'month');
+ assert.equal(a.date(), 12, 'date');
+ assert.equal(a.day(), 3, 'day');
+ assert.equal(a.hours(), 6, 'hour');
+ assert.equal(a.minutes(), 7, 'minute');
+ assert.equal(a.seconds(), 8, 'second');
+ assert.equal(a.milliseconds(), 9, 'milliseconds');
+});
+
+test('setters across DST +1', function (assert) {
+ var oldUpdateOffset = moment.updateOffset,
+ // Based on a real story somewhere in America/Los_Angeles
+ dstAt = moment('2014-03-09T02:00:00-08:00').parseZone(),
+ m;
+
+ moment.updateOffset = function (mom, keepTime) {
+ if (mom.isBefore(dstAt)) {
+ mom.utcOffset(-8, keepTime);
+ } else {
+ mom.utcOffset(-7, keepTime);
+ }
+ };
+
+ m = moment('2014-03-15T00:00:00-07:00').parseZone();
+ m.year(2013);
+ assert.equal(m.format(), '2013-03-15T00:00:00-08:00', 'year across +1');
+
+ m = moment('2014-03-15T00:00:00-07:00').parseZone();
+ m.month(0);
+ assert.equal(m.format(), '2014-01-15T00:00:00-08:00', 'month across +1');
+
+ m = moment('2014-03-15T00:00:00-07:00').parseZone();
+ m.date(1);
+ assert.equal(m.format(), '2014-03-01T00:00:00-08:00', 'date across +1');
+
+ m = moment('2014-03-09T03:05:00-07:00').parseZone();
+ m.hour(0);
+ assert.equal(m.format(), '2014-03-09T00:05:00-08:00', 'hour across +1');
+
+ moment.updateOffset = oldUpdateOffset;
+});
+
+test('setters across DST -1', function (assert) {
+ var oldUpdateOffset = moment.updateOffset,
+ // Based on a real story somewhere in America/Los_Angeles
+ dstAt = moment('2014-11-02T02:00:00-07:00').parseZone(),
+ m;
+
+ moment.updateOffset = function (mom, keepTime) {
+ if (mom.isBefore(dstAt)) {
+ mom.utcOffset(-7, keepTime);
+ } else {
+ mom.utcOffset(-8, keepTime);
+ }
+ };
+
+ m = moment('2014-11-15T00:00:00-08:00').parseZone();
+ m.year(2013);
+ assert.equal(m.format(), '2013-11-15T00:00:00-07:00', 'year across -1');
+
+ m = moment('2014-11-15T00:00:00-08:00').parseZone();
+ m.month(0);
+ assert.equal(m.format(), '2014-01-15T00:00:00-07:00', 'month across -1');
+
+ m = moment('2014-11-15T00:00:00-08:00').parseZone();
+ m.date(1);
+ assert.equal(m.format(), '2014-11-01T00:00:00-07:00', 'date across -1');
+
+ m = moment('2014-11-02T03:30:00-08:00').parseZone();
+ m.hour(0);
+ assert.equal(m.format(), '2014-11-02T00:30:00-07:00', 'hour across -1');
+
+ moment.updateOffset = oldUpdateOffset;
+});
diff --git a/src/test/moment/invalid.js b/src/test/moment/invalid.js
index 7a97626..e10e650 100644
--- a/src/test/moment/invalid.js
+++ b/src/test/moment/invalid.js
@@ -36,6 +36,8 @@
i,
invalid,
valid = moment();
+
+ test.expectedDeprecations('moment().min', 'moment().max');
for (i = 0; i < invalids.length; ++i) {
invalid = invalids[i];
@@ -99,7 +101,7 @@
});
assert.ok(moment.isDate(invalid.toDate()));
assert.ok(isNaN(invalid.toDate().valueOf()));
- assert.equal(invalid.toJSON(), 'null');
+ assert.equal(invalid.toJSON(), null);
assert.equal(invalid.toString(), 'Invalid date');
assert.ok(isNaN(invalid.unix()));
assert.ok(isNaN(invalid.valueOf()));
diff --git a/src/test/moment/is_array.js b/src/test/moment/is_array.js
new file mode 100644
index 0000000..4602344
--- /dev/null
+++ b/src/test/moment/is_array.js
@@ -0,0 +1,19 @@
+import { module, test } from '../qunit';
+import isArray from '../../lib/utils/is-array.js';
+
+
+test('isArray recognizes Array objects', function (assert) {
+ assert.ok(isArray([1,2,3]), 'array args');
+ assert.ok(isArray([]), 'empty array');
+ assert.ok(isArray(new Array(1,2,3)), 'array constructor');
+});
+
+test('isArray rejects non-Array objects', function (assert) {
+ assert.ok(!isArray(), 'nothing');
+ assert.ok(!isArray(undefined), 'undefined');
+ assert.ok(!isArray(null), 'null');
+ assert.ok(!isArray(123), 'number');
+ assert.ok(!isArray('[1,2,3]'), 'string');
+ assert.ok(!isArray(new Date()), 'date');
+ assert.ok(!isArray({a:1,b:2}), 'object');
+});
diff --git a/src/test/moment/is_between.js b/src/test/moment/is_between.js
index a114b3c..b58f4ec 100644
--- a/src/test/moment/is_between.js
+++ b/src/test/moment/is_between.js
@@ -72,6 +72,143 @@
assert.equal(+m, +mCopy, 'isBetween second should not change moment');
});
+test('is between without units inclusivity', function (assert) {
+ var m = moment(new Date(2011, 3, 2, 3, 4, 5, 10)), mCopy = moment(m);
+ assert.equal(m.isBetween(
+ moment(new Date(2011, 3, 2, 3, 4, 5, 10)),
+ moment(new Date(2012, 3, 2, 3, 4, 5, 10)), null, '()'), false, 'start and end are excluded, start is equal to moment');
+ assert.equal(m.isBetween(
+ moment(new Date(2010, 3, 2, 3, 4, 5, 10)),
+ moment(new Date(2011, 3, 2, 3, 4, 5, 10)), null, '()'), false, 'start and end are excluded, end is equal to moment');
+ assert.equal(m.isBetween(
+ moment(new Date(2010, 3, 2, 3, 4, 5, 10)),
+ moment(new Date(2012, 3, 2, 3, 4, 5, 10)), null, '()'), true, 'start and end are excluded, is between');
+ assert.equal(m.isBetween(
+ moment(new Date(2009, 3, 2, 3, 4, 5, 10)),
+ moment(new Date(2010, 3, 2, 3, 4, 5, 10)), null, '()'), false, 'start and end are excluded, is not between');
+ assert.equal(m.isBetween(
+ moment(new Date(2011, 3, 2, 3, 4, 5, 10)),
+ moment(new Date(2011, 3, 2, 3, 4, 5, 10)), null, '()'), false, 'start and end are excluded, should fail on same start/end date.');
+
+ assert.equal(m.isBetween(
+ moment(new Date(2011, 3, 2, 3, 4, 5, 10)),
+ moment(new Date(2012, 3, 2, 3, 4, 5, 10)), null, '(]'), false, 'start is excluded and end is included should fail on same start date');
+ assert.equal(m.isBetween(
+ moment(new Date(2010, 3, 2, 3, 4, 5, 10)),
+ moment(new Date(2011, 3, 2, 3, 4, 5, 10)), null, '(]'), true, 'start is excluded and end is included should succeed on end date');
+ assert.equal(m.isBetween(
+ moment(new Date(2010, 3, 2, 3, 4, 5, 10)),
+ moment(new Date(2012, 3, 2, 3, 4, 5, 10)), null, '(]'), true, 'start is excluded and end is included, is between');
+ assert.equal(m.isBetween(
+ moment(new Date(2009, 3, 2, 3, 4, 5, 10)),
+ moment(new Date(2010, 3, 2, 3, 4, 5, 10)), null, '(]'), false, 'start is excluded and end is included, is not between');
+ assert.equal(m.isBetween(
+ moment(new Date(2011, 3, 2, 3, 4, 5, 10)),
+ moment(new Date(2011, 3, 2, 3, 4, 5, 10)), null, '(]'), false, 'start is excluded and end is included, should fail on same start/end date.');
+
+ assert.equal(m.isBetween(
+ moment(new Date(2011, 3, 2, 3, 4, 5, 10)),
+ moment(new Date(2012, 3, 2, 3, 4, 5, 10)), null, '[)'), true, 'start is included and end is excluded should succeed on same start date');
+ assert.equal(m.isBetween(
+ moment(new Date(2010, 3, 2, 3, 4, 5, 10)),
+ moment(new Date(2011, 3, 2, 3, 4, 5, 10)), null, '[)'), false, 'start is included and end is excluded should fail on same end date');
+ assert.equal(m.isBetween(
+ moment(new Date(2010, 3, 2, 3, 4, 5, 10)),
+ moment(new Date(2012, 3, 2, 3, 4, 5, 10)), null, '[)'), true, 'start is included and end is excluded, is between');
+ assert.equal(m.isBetween(
+ moment(new Date(2009, 3, 2, 3, 4, 5, 10)),
+ moment(new Date(2010, 3, 2, 3, 4, 5, 10)), null, '[)'), false, 'start is included and end is excluded, is not between');
+ assert.equal(m.isBetween(
+ moment(new Date(2011, 3, 2, 3, 4, 5, 10)),
+ moment(new Date(2011, 3, 2, 3, 4, 5, 10)), null, '[)'), false, 'start is included and end is excluded, should fail on same end and start date');
+
+ assert.equal(m.isBetween(
+ moment(new Date(2011, 3, 2, 3, 4, 5, 10)),
+ moment(new Date(2012, 3, 2, 3, 4, 5, 10)), null, '[]'), true, 'start and end inclusive should succeed on same start date');
+ assert.equal(m.isBetween(
+ moment(new Date(2010, 3, 2, 3, 4, 5, 10)),
+ moment(new Date(2011, 3, 2, 3, 4, 5, 10)), null, '[]'), true, 'start and end inclusive should succeed on same end date');
+ assert.equal(m.isBetween(
+ moment(new Date(2010, 3, 2, 3, 4, 5, 10)),
+ moment(new Date(2012, 3, 2, 3, 4, 5, 10)), null, '[]'), true, 'start and end inclusive, is between');
+ assert.equal(m.isBetween(
+ moment(new Date(2009, 3, 2, 3, 4, 5, 10)),
+ moment(new Date(2010, 3, 2, 3, 4, 5, 10)), null, '[]'), false, 'start and end inclusive, is not between');
+ assert.equal(m.isBetween(
+ moment(new Date(2011, 3, 2, 3, 4, 5, 10)),
+ moment(new Date(2011, 3, 2, 3, 4, 5, 10)), null, '[]'), true, 'start and end inclusive, should handle same end and start date');
+});
+
+test('is between milliseconds inclusivity', function (assert) {
+ var m = moment(new Date(2011, 3, 2, 3, 4, 5, 10)), mCopy = moment(m);
+ assert.equal(m.isBetween(
+ moment(new Date(2010, 3, 2, 3, 4, 5, 10)),
+ moment(new Date(2012, 3, 2, 3, 4, 5, 10)), 'milliseconds'), true, 'options, no inclusive');
+ assert.equal(m.isBetween(
+ moment(new Date(2011, 3, 2, 3, 4, 5, 10)),
+ moment(new Date(2012, 3, 2, 3, 4, 5, 10)), 'milliseconds', '()'), false, 'start and end are excluded, start is equal to moment');
+ assert.equal(m.isBetween(
+ moment(new Date(2010, 3, 2, 3, 4, 5, 10)),
+ moment(new Date(2011, 3, 2, 3, 4, 5, 10)), 'milliseconds', '()'), false, 'start and end are excluded, end is equal to moment');
+ assert.equal(m.isBetween(
+ moment(new Date(2010, 3, 2, 3, 4, 5, 10)),
+ moment(new Date(2012, 3, 2, 3, 4, 5, 10)), 'milliseconds', '()'), true, 'start and end are excluded, is between');
+ assert.equal(m.isBetween(
+ moment(new Date(2009, 3, 2, 3, 4, 5, 10)),
+ moment(new Date(2010, 3, 2, 3, 4, 5, 10)), 'milliseconds', '()'), false, 'start and end are excluded, is not between');
+ assert.equal(m.isBetween(
+ moment(new Date(2011, 3, 2, 3, 4, 5, 10)),
+ moment(new Date(2011, 3, 2, 3, 4, 5, 10)), 'milliseconds', '()'), false, 'start and end are excluded, should fail on same start/end date.');
+
+ assert.equal(m.isBetween(
+ moment(new Date(2011, 3, 2, 3, 4, 5, 10)),
+ moment(new Date(2012, 3, 2, 3, 4, 5, 10)), 'milliseconds', '(]'), false, 'start is excluded and end is included should fail on same start date');
+ assert.equal(m.isBetween(
+ moment(new Date(2010, 3, 2, 3, 4, 5, 10)),
+ moment(new Date(2011, 3, 2, 3, 4, 5, 10)), 'milliseconds', '(]'), true, 'start is excluded and end is included should succeed on end date');
+ assert.equal(m.isBetween(
+ moment(new Date(2010, 3, 2, 3, 4, 5, 10)),
+ moment(new Date(2012, 3, 2, 3, 4, 5, 10)), 'milliseconds', '(]'), true, 'start is excluded and end is included, is between');
+ assert.equal(m.isBetween(
+ moment(new Date(2009, 3, 2, 3, 4, 5, 10)),
+ moment(new Date(2010, 3, 2, 3, 4, 5, 10)), 'milliseconds', '(]'), false, 'start is excluded and end is included, is not between');
+ assert.equal(m.isBetween(
+ moment(new Date(2011, 3, 2, 3, 4, 5, 10)),
+ moment(new Date(2011, 3, 2, 3, 4, 5, 10)), 'milliseconds', '(]'), false, 'start is excluded and end is included, should fail on same start/end date.');
+
+ assert.equal(m.isBetween(
+ moment(new Date(2011, 3, 2, 3, 4, 5, 10)),
+ moment(new Date(2012, 3, 2, 3, 4, 5, 10)), 'milliseconds', '[)'), true, 'start is included and end is excluded should succeed on same start date');
+ assert.equal(m.isBetween(
+ moment(new Date(2010, 3, 2, 3, 4, 5, 10)),
+ moment(new Date(2011, 3, 2, 3, 4, 5, 10)), 'milliseconds', '[)'), false, 'start is included and end is excluded should fail on same end date');
+ assert.equal(m.isBetween(
+ moment(new Date(2010, 3, 2, 3, 4, 5, 10)),
+ moment(new Date(2012, 3, 2, 3, 4, 5, 10)), 'milliseconds', '[)'), true, 'start is included and end is excluded, is between');
+ assert.equal(m.isBetween(
+ moment(new Date(2009, 3, 2, 3, 4, 5, 10)),
+ moment(new Date(2010, 3, 2, 3, 4, 5, 10)), 'milliseconds', '[)'), false, 'start is included and end is excluded, is not between');
+ assert.equal(m.isBetween(
+ moment(new Date(2011, 3, 2, 3, 4, 5, 10)),
+ moment(new Date(2011, 3, 2, 3, 4, 5, 10)), 'milliseconds', '[)'), false, 'start is included and end is excluded, should fail on same end and start date');
+
+ assert.equal(m.isBetween(
+ moment(new Date(2011, 3, 2, 3, 4, 5, 10)),
+ moment(new Date(2012, 3, 2, 3, 4, 5, 10)), 'milliseconds', '[]'), true, 'start and end inclusive should succeed on same start date');
+ assert.equal(m.isBetween(
+ moment(new Date(2010, 3, 2, 3, 4, 5, 10)),
+ moment(new Date(2011, 3, 2, 3, 4, 5, 10)), 'milliseconds', '[]'), true, 'start and end inclusive should succeed on same end date');
+ assert.equal(m.isBetween(
+ moment(new Date(2010, 3, 2, 3, 4, 5, 10)),
+ moment(new Date(2012, 3, 2, 3, 4, 5, 10)), 'milliseconds', '[]'), true, 'start and end inclusive, is between');
+ assert.equal(m.isBetween(
+ moment(new Date(2009, 3, 2, 3, 4, 5, 10)),
+ moment(new Date(2010, 3, 2, 3, 4, 5, 10)), 'milliseconds', '[]'), false, 'start and end inclusive, is not between');
+ assert.equal(m.isBetween(
+ moment(new Date(2011, 3, 2, 3, 4, 5, 10)),
+ moment(new Date(2011, 3, 2, 3, 4, 5, 10)), 'milliseconds', '[]'), true, 'start and end inclusive, should handle same end and start date');
+});
+
test('is between year', function (assert) {
var m = moment(new Date(2011, 1, 2, 3, 4, 5, 6)), mCopy = moment(m);
assert.equal(m.isBetween(
diff --git a/src/test/moment/is_valid.js b/src/test/moment/is_valid.js
index adf2e5f..6b3abeb 100644
--- a/src/test/moment/is_valid.js
+++ b/src/test/moment/is_valid.js
@@ -77,7 +77,6 @@
test('string with spaceless format', function (assert) {
assert.equal(moment('10Sep2001', 'DDMMMYYYY').isValid(), true, 'Parsing 10Sep2001 should result in a valid date');
- assert.equal(moment('10Sept2001', 'DDMMMYYYY').isValid(), true, 'Parsing 10Sept2001 should result in a valid date');
});
test('invalid string iso 8601', function (assert) {
diff --git a/src/test/moment/listers.js b/src/test/moment/listers.js
index bbe9569..5088326 100644
--- a/src/test/moment/listers.js
+++ b/src/test/moment/listers.js
@@ -5,7 +5,7 @@
test('default', function (assert) {
assert.deepEqual(moment.months(), ['January', 'February', 'March', 'April', 'May', 'June', 'July', 'August', 'September', 'October', 'November', 'December']);
- assert.deepEqual(moment.monthsShort(), ['Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun', 'Jul', 'Aug', 'Sept', 'Oct', 'Nov', 'Dec']);
+ assert.deepEqual(moment.monthsShort(), ['Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun', 'Jul', 'Aug', 'Sep', 'Oct', 'Nov', 'Dec']);
assert.deepEqual(moment.weekdays(), ['Sunday', 'Monday', 'Tuesday', 'Wednesday', 'Thursday', 'Friday', 'Saturday']);
assert.deepEqual(moment.weekdaysShort(), ['Sun', 'Mon', 'Tue', 'Wed', 'Thu', 'Fri', 'Sat']);
assert.deepEqual(moment.weekdaysMin(), ['Su', 'Mo', 'Tu', 'We', 'Th', 'Fr', 'Sa']);
@@ -29,14 +29,22 @@
monthsShort = 'on_tw_th_fo_fi_si_se_ei_ni_te_el_tw'.split('_'),
weekdays = 'one_two_three_four_five_six_seven'.split('_'),
weekdaysShort = 'on_tw_th_fo_fi_si_se'.split('_'),
- weekdaysMin = '1_2_3_4_5_6_7'.split('_');
+ weekdaysMin = '1_2_3_4_5_6_7'.split('_'),
+ weekdaysLocale = 'four_five_six_seven_one_two_three'.split('_'),
+ weekdaysShortLocale = 'fo_fi_si_se_on_tw_th'.split('_'),
+ weekdaysMinLocale = '4_5_6_7_1_2_3'.split('_'),
+ week = {
+ dow : 3,
+ doy : 6
+ };
moment.locale('numerologists', {
months : months,
monthsShort : monthsShort,
weekdays : weekdays,
weekdaysShort: weekdaysShort,
- weekdaysMin: weekdaysMin
+ weekdaysMin: weekdaysMin,
+ week : week
});
assert.deepEqual(moment.months(), months);
@@ -56,6 +64,18 @@
assert.equal(moment.weekdays(2), 'three');
assert.equal(moment.weekdaysShort(2), 'th');
assert.equal(moment.weekdaysMin(2), '3');
+
+ assert.deepEqual(moment.weekdays(true), weekdaysLocale);
+ assert.deepEqual(moment.weekdaysShort(true), weekdaysShortLocale);
+ assert.deepEqual(moment.weekdaysMin(true), weekdaysMinLocale);
+
+ assert.equal(moment.weekdays(true, 0), 'four');
+ assert.equal(moment.weekdaysShort(true, 0), 'fo');
+ assert.equal(moment.weekdaysMin(true, 0), '4');
+
+ assert.equal(moment.weekdays(false, 2), 'three');
+ assert.equal(moment.weekdaysShort(false, 2), 'th');
+ assert.equal(moment.weekdaysMin(false, 2), '3');
});
test('with functions', function (assert) {
diff --git a/src/test/moment/locale.js b/src/test/moment/locale.js
index c69a438..186c649 100644
--- a/src/test/moment/locale.js
+++ b/src/test/moment/locale.js
@@ -1,6 +1,7 @@
import { module, test } from '../qunit';
import moment from '../../moment';
import each from '../helpers/each';
+import indexOf from '../../lib/utils/index-of';
module('locale', {
setup : function () {
@@ -139,10 +140,12 @@
});
test('library deprecations', function (assert) {
+ test.expectedDeprecations('moment.lang');
moment.lang('dude', {months: ['Movember']});
assert.equal(moment.locale(), 'dude', 'setting the lang sets the locale');
assert.equal(moment.lang(), moment.locale());
assert.equal(moment.langData(), moment.localeData(), 'langData is localeData');
+ moment.defineLocale('dude', null);
});
test('defineLocale', function (assert) {
@@ -150,12 +153,21 @@
moment.defineLocale('dude', {months: ['Movember']});
assert.equal(moment().locale(), 'dude', 'defineLocale also sets it');
assert.equal(moment().locale('dude').locale(), 'dude', 'defineLocale defines a locale');
+ moment.defineLocale('dude', null);
+});
+
+test('locales', function (assert) {
+ moment.defineLocale('dude', {months: ['Movember']});
+ assert.equal(true, !!~indexOf.call(moment.locales(), 'dude'), 'locales returns an array of defined locales');
+ assert.equal(true, !!~indexOf.call(moment.locales(), 'en'), 'locales should always include english');
+ moment.defineLocale('dude', null);
});
test('library convenience', function (assert) {
moment.locale('something', {week: {dow: 3}});
moment.locale('something');
assert.equal(moment.locale(), 'something', 'locale can be used to create the locale too');
+ moment.defineLocale('something', null);
});
test('firstDayOfWeek firstDayOfYear locale getters', function (assert) {
@@ -163,6 +175,7 @@
moment.locale('something');
assert.equal(moment.localeData().firstDayOfWeek(), 3, 'firstDayOfWeek');
assert.equal(moment.localeData().firstDayOfYear(), 4, 'firstDayOfYear');
+ moment.defineLocale('something', null);
});
test('instance locale method', function (assert) {
@@ -233,6 +246,7 @@
});
test('duration deprecations', function (assert) {
+ test.expectedDeprecations('moment().lang()');
assert.equal(moment.duration().lang(), moment.duration().localeData(), 'duration.lang is the same as duration.localeData');
});
@@ -324,6 +338,7 @@
test('instance localeData', function (assert) {
moment.defineLocale('dude', {week: {dow: 3}});
assert.equal(moment().locale('dude').localeData()._week.dow, 3);
+ moment.defineLocale('dude', null);
});
test('month name callback function', function (assert) {
@@ -351,6 +366,8 @@
});
test('changing parts of a locale config', function (assert) {
+ test.expectedDeprecations('defineLocaleOverride');
+
moment.locale('partial-lang', {
months : 'a b c d e f g h i j k l'.split(' ')
});
@@ -362,6 +379,8 @@
});
assert.equal(moment([2011, 0, 1]).format('MMMM MMM'), 'a A', 'should be able to set locale values after creating the localeuage');
+
+ moment.defineLocale('partial-lang', null);
});
test('start/endOf week feature for first-day-is-monday locales', function (assert) {
@@ -374,6 +393,7 @@
moment.locale('monday-lang');
assert.equal(moment([2013, 0, 1]).startOf('week').day(), 1, 'for locale monday-lang first day of the week should be monday');
assert.equal(moment([2013, 0, 1]).endOf('week').day(), 0, 'for locale monday-lang last day of the week should be sunday');
+ moment.defineLocale('monday-lang', null);
});
test('meridiem parsing', function (assert) {
@@ -387,6 +407,7 @@
moment.locale('meridiem-parsing');
assert.equal(moment('2012-01-01 3b', 'YYYY-MM-DD ha').hour(), 15, 'Custom parsing of meridiem should work');
assert.equal(moment('2012-01-01 3d', 'YYYY-MM-DD ha').hour(), 3, 'Custom parsing of meridiem should work');
+ moment.defineLocale('meridiem-parsing', null);
});
test('invalid date formatting', function (assert) {
@@ -396,12 +417,14 @@
assert.equal(moment.invalid().format(), 'KHAAAAAAAAAAAN!');
assert.equal(moment.invalid().format('YYYY-MM-DD'), 'KHAAAAAAAAAAAN!');
+ moment.defineLocale('has-invalid', null);
});
test('return locale name', function (assert) {
var registered = moment.locale('return-this', {});
assert.equal(registered, 'return-this', 'returns the locale configured');
+ moment.locale('return-this', null);
});
test('changing the global locale doesn\'t affect existing instances', function (assert) {
@@ -411,6 +434,7 @@
});
test('setting a language on instance returns the original moment for chaining', function (assert) {
+ test.expectedDeprecations('moment().lang()');
var mom = moment();
assert.equal(mom.lang('fr'), mom, 'setting the language (lang) returns the original moment for chaining');
@@ -418,6 +442,7 @@
});
test('lang(key) changes the language of the instance', function (assert) {
+ test.expectedDeprecations('moment().lang()');
var m = moment().month(0);
m.lang('fr');
assert.equal(m.locale(), 'fr', 'm.lang(key) changes instance locale');
@@ -441,7 +466,40 @@
});
test('moment().lang with missing key doesn\'t change locale', function (assert) {
+ test.expectedDeprecations('moment().lang()');
assert.equal(moment().lang('boo').localeData(), moment.localeData(),
'preserve global locale in case of bad locale id');
});
+
+// TODO: Enable this after fixing pl months parse hack hack
+// test('monthsParseExact', function (assert) {
+// var locale = 'test-months-parse-exact';
+
+// moment.defineLocale(locale, {
+// monthsParseExact: true,
+// months: 'A_AA_AAA_B_B B_BB B_C_C-C_C,C2C_D_D+D_D`D*D'.split('_'),
+// monthsShort: 'E_EE_EEE_F_FF_FFF_G_GG_GGG_H_HH_HHH'.split('_')
+// });
+
+// assert.equal(moment('A', 'MMMM', true).month(), 0, 'parse long month 0 with MMMM');
+// assert.equal(moment('AA', 'MMMM', true).month(), 1, 'parse long month 1 with MMMM');
+// assert.equal(moment('AAA', 'MMMM', true).month(), 2, 'parse long month 2 with MMMM');
+// assert.equal(moment('B B', 'MMMM', true).month(), 4, 'parse long month 4 with MMMM');
+// assert.equal(moment('BB B', 'MMMM', true).month(), 5, 'parse long month 5 with MMMM');
+// assert.equal(moment('C-C', 'MMMM', true).month(), 7, 'parse long month 7 with MMMM');
+// assert.equal(moment('C,C2C', 'MMMM', true).month(), 8, 'parse long month 8 with MMMM');
+// assert.equal(moment('D+D', 'MMMM', true).month(), 10, 'parse long month 10 with MMMM');
+// assert.equal(moment('D`D*D', 'MMMM', true).month(), 11, 'parse long month 11 with MMMM');
+
+// assert.equal(moment('E', 'MMM', true).month(), 0, 'parse long month 0 with MMM');
+// assert.equal(moment('EE', 'MMM', true).month(), 1, 'parse long month 1 with MMM');
+// assert.equal(moment('EEE', 'MMM', true).month(), 2, 'parse long month 2 with MMM');
+
+// assert.equal(moment('A', 'MMM').month(), 0, 'non-strict parse long month 0 with MMM');
+// assert.equal(moment('AA', 'MMM').month(), 1, 'non-strict parse long month 1 with MMM');
+// assert.equal(moment('AAA', 'MMM').month(), 2, 'non-strict parse long month 2 with MMM');
+// assert.equal(moment('E', 'MMMM').month(), 0, 'non-strict parse short month 0 with MMMM');
+// assert.equal(moment('EE', 'MMMM').month(), 1, 'non-strict parse short month 1 with MMMM');
+// assert.equal(moment('EEE', 'MMMM').month(), 2, 'non-strict parse short month 2 with MMMM');
+// });
diff --git a/src/test/moment/locale_inheritance.js b/src/test/moment/locale_inheritance.js
new file mode 100644
index 0000000..510d4b7
--- /dev/null
+++ b/src/test/moment/locale_inheritance.js
@@ -0,0 +1,165 @@
+import { module, test } from '../qunit';
+import moment from '../../moment';
+
+module('locale inheritance');
+
+test('calendar', function (assert) {
+ moment.defineLocale('base-cal', {
+ calendar : {
+ sameDay: '[Today at] HH:mm',
+ nextDay: '[Tomorrow at] HH:mm',
+ nextWeek: '[Next week at] HH:mm',
+ lastDay: '[Yesterday at] HH:mm',
+ lastWeek: '[Last week at] HH:mm',
+ sameElse: '[whatever]'
+ }
+ });
+ moment.defineLocale('child-cal', {
+ parentLocale: 'base-cal',
+ calendar: {
+ sameDay: '[Today] HH:mm',
+ nextDay: '[Tomorrow] HH:mm',
+ nextWeek: '[Next week] HH:mm'
+ }
+ });
+
+ moment.locale('child-cal');
+ var anchor = moment.utc('2015-05-05T12:00:00', moment.ISO_8601);
+ assert.equal(anchor.clone().add(3, 'hours').calendar(anchor), 'Today 15:00', 'today uses child version');
+ assert.equal(anchor.clone().add(1, 'day').calendar(anchor), 'Tomorrow 12:00', 'tomorrow uses child version');
+ assert.equal(anchor.clone().add(3, 'days').calendar(anchor), 'Next week 12:00', 'next week uses child version');
+
+ assert.equal(anchor.clone().subtract(1, 'day').calendar(anchor), 'Yesterday at 12:00', 'yesterday uses parent version');
+ assert.equal(anchor.clone().subtract(3, 'days').calendar(anchor), 'Last week at 12:00', 'last week uses parent version');
+ assert.equal(anchor.clone().subtract(7, 'days').calendar(anchor), 'whatever', 'sameElse uses parent version -');
+ assert.equal(anchor.clone().add(7, 'days').calendar(anchor), 'whatever', 'sameElse uses parent version +');
+});
+
+test('missing', function (assert) {
+ moment.defineLocale('base-cal-2', {
+ calendar: {
+ sameDay: '[Today at] HH:mm',
+ nextDay: '[Tomorrow at] HH:mm',
+ nextWeek: '[Next week at] HH:mm',
+ lastDay: '[Yesterday at] HH:mm',
+ lastWeek: '[Last week at] HH:mm',
+ sameElse: '[whatever]'
+ }
+ });
+ moment.defineLocale('child-cal-2', {
+ parentLocale: 'base-cal-2'
+ });
+ moment.locale('child-cal-2');
+ var anchor = moment.utc('2015-05-05T12:00:00', moment.ISO_8601);
+ assert.equal(anchor.clone().add(3, 'hours').calendar(anchor), 'Today at 15:00', 'today uses parent version');
+ assert.equal(anchor.clone().add(1, 'day').calendar(anchor), 'Tomorrow at 12:00', 'tomorrow uses parent version');
+ assert.equal(anchor.clone().add(3, 'days').calendar(anchor), 'Next week at 12:00', 'next week uses parent version');
+ assert.equal(anchor.clone().subtract(1, 'day').calendar(anchor), 'Yesterday at 12:00', 'yesterday uses parent version');
+ assert.equal(anchor.clone().subtract(3, 'days').calendar(anchor), 'Last week at 12:00', 'last week uses parent version');
+ assert.equal(anchor.clone().subtract(7, 'days').calendar(anchor), 'whatever', 'sameElse uses parent version -');
+ assert.equal(anchor.clone().add(7, 'days').calendar(anchor), 'whatever', 'sameElse uses parent version +');
+});
+
+// Test function vs obj both directions
+
+test('long date format', function (assert) {
+ moment.defineLocale('base-ldf', {
+ longDateFormat : {
+ LTS : 'h:mm:ss A',
+ LT : 'h:mm A',
+ L : 'MM/DD/YYYY',
+ LL : 'MMMM D, YYYY',
+ LLL : 'MMMM D, YYYY h:mm A',
+ LLLL : 'dddd, MMMM D, YYYY h:mm A'
+ }
+ });
+ moment.defineLocale('child-ldf', {
+ parentLocale: 'base-ldf',
+ longDateFormat: {
+ LLL : '[child] MMMM D, YYYY h:mm A',
+ LLLL : '[child] dddd, MMMM D, YYYY h:mm A'
+ }
+ });
+
+ moment.locale('child-ldf');
+ var anchor = moment.utc('2015-09-06T12:34:56', moment.ISO_8601);
+ assert.equal(anchor.format('LTS'), '12:34:56 PM', 'LTS uses base');
+ assert.equal(anchor.format('LT'), '12:34 PM', 'LT uses base');
+ assert.equal(anchor.format('L'), '09/06/2015', 'L uses base');
+ assert.equal(anchor.format('l'), '9/6/2015', 'l uses base');
+ assert.equal(anchor.format('LL'), 'September 6, 2015', 'LL uses base');
+ assert.equal(anchor.format('ll'), 'Sep 6, 2015', 'll uses base');
+ assert.equal(anchor.format('LLL'), 'child September 6, 2015 12:34 PM', 'LLL uses child');
+ assert.equal(anchor.format('lll'), 'child Sep 6, 2015 12:34 PM', 'lll uses child');
+ assert.equal(anchor.format('LLLL'), 'child Sunday, September 6, 2015 12:34 PM', 'LLLL uses child');
+ assert.equal(anchor.format('llll'), 'child Sun, Sep 6, 2015 12:34 PM', 'llll uses child');
+});
+
+test('ordinal', function (assert) {
+ moment.defineLocale('base-ordinal-1', {
+ ordinal : '%dx'
+ });
+ moment.defineLocale('child-ordinal-1', {
+ parentLocale: 'base-ordinal-1',
+ ordinal : '%dy'
+ });
+
+ assert.equal(moment.utc('2015-02-03', moment.ISO_8601).format('Do'), '3y', 'ordinal uses child string');
+
+ moment.defineLocale('base-ordinal-2', {
+ ordinal : '%dx'
+ });
+ moment.defineLocale('child-ordinal-2', {
+ parentLocale: 'base-ordinal-2',
+ ordinal : function (num) {
+ return num + 'y';
+ }
+ });
+
+ assert.equal(moment.utc('2015-02-03', moment.ISO_8601).format('Do'), '3y', 'ordinal uses child function');
+
+ moment.defineLocale('base-ordinal-3', {
+ ordinal : function (num) {
+ return num + 'x';
+ }
+ });
+ moment.defineLocale('child-ordinal-3', {
+ parentLocale: 'base-ordinal-3',
+ ordinal : '%dy'
+ });
+
+ assert.equal(moment.utc('2015-02-03', moment.ISO_8601).format('Do'), '3y', 'ordinal uses child string (overwrite parent function)');
+});
+
+test('ordinal parse', function (assert) {
+ moment.defineLocale('base-ordinal-parse-1', {
+ ordinalParse : /\d{1,2}x/
+ });
+ moment.defineLocale('child-ordinal-parse-1', {
+ parentLocale: 'base-ordinal-parse-1',
+ ordinalParse : /\d{1,2}y/
+ });
+
+ assert.ok(moment.utc('2015-01-1y', 'YYYY-MM-Do', true).isValid(), 'ordinal parse uses child');
+
+ moment.defineLocale('base-ordinal-parse-2', {
+ ordinalParse : /\d{1,2}x/
+ });
+ moment.defineLocale('child-ordinal-parse-2', {
+ parentLocale: 'base-ordinal-parse-2',
+ ordinalParse : null
+ });
+
+ assert.ok(moment.utc('2015-01-1', 'YYYY-MM-Do', true).isValid(), 'ordinal parse uses child (default)');
+});
+
+test('months', function (assert) {
+ moment.defineLocale('base-months', {
+ months : 'One_Two_Three_Four_Five_Six_Seven_Eight_Nine_Ten_Eleven_Twelve'.split('_')
+ });
+ moment.defineLocale('child-months', {
+ parentLocale: 'base-months',
+ months : 'First_Second_Third_Fourth_Fifth_Sixth_Seventh_Eighth_Ninth_Tenth_Eleventh_Twelveth '.split('_')
+ });
+ assert.ok(moment.utc('2015-01-01', 'YYYY-MM-DD').format('MMMM'), 'First', 'months uses child');
+});
diff --git a/src/test/moment/locale_update.js b/src/test/moment/locale_update.js
new file mode 100644
index 0000000..dbac84b
--- /dev/null
+++ b/src/test/moment/locale_update.js
@@ -0,0 +1,166 @@
+import { module, test } from '../qunit';
+import moment from '../../moment';
+
+module('locale update');
+
+test('calendar', function (assert) {
+ moment.defineLocale('cal', null);
+ moment.defineLocale('cal', {
+ calendar : {
+ sameDay: '[Today at] HH:mm',
+ nextDay: '[Tomorrow at] HH:mm',
+ nextWeek: '[Next week at] HH:mm',
+ lastDay: '[Yesterday at] HH:mm',
+ lastWeek: '[Last week at] HH:mm',
+ sameElse: '[whatever]'
+ }
+ });
+ moment.updateLocale('cal', {
+ calendar: {
+ sameDay: '[Today] HH:mm',
+ nextDay: '[Tomorrow] HH:mm',
+ nextWeek: '[Next week] HH:mm'
+ }
+ });
+
+ moment.locale('cal');
+ var anchor = moment.utc('2015-05-05T12:00:00', moment.ISO_8601);
+ assert.equal(anchor.clone().add(3, 'hours').calendar(anchor), 'Today 15:00', 'today uses child version');
+ assert.equal(anchor.clone().add(1, 'day').calendar(anchor), 'Tomorrow 12:00', 'tomorrow uses child version');
+ assert.equal(anchor.clone().add(3, 'days').calendar(anchor), 'Next week 12:00', 'next week uses child version');
+
+ assert.equal(anchor.clone().subtract(1, 'day').calendar(anchor), 'Yesterday at 12:00', 'yesterday uses parent version');
+ assert.equal(anchor.clone().subtract(3, 'days').calendar(anchor), 'Last week at 12:00', 'last week uses parent version');
+ assert.equal(anchor.clone().subtract(7, 'days').calendar(anchor), 'whatever', 'sameElse uses parent version -');
+ assert.equal(anchor.clone().add(7, 'days').calendar(anchor), 'whatever', 'sameElse uses parent version +');
+});
+
+test('missing', function (assert) {
+ moment.defineLocale('cal-2', null);
+ moment.defineLocale('cal-2', {
+ calendar: {
+ sameDay: '[Today at] HH:mm',
+ nextDay: '[Tomorrow at] HH:mm',
+ nextWeek: '[Next week at] HH:mm',
+ lastDay: '[Yesterday at] HH:mm',
+ lastWeek: '[Last week at] HH:mm',
+ sameElse: '[whatever]'
+ }
+ });
+ moment.updateLocale('cal-2', {
+ });
+ moment.locale('cal-2');
+ var anchor = moment.utc('2015-05-05T12:00:00', moment.ISO_8601);
+ assert.equal(anchor.clone().add(3, 'hours').calendar(anchor), 'Today at 15:00', 'today uses parent version');
+ assert.equal(anchor.clone().add(1, 'day').calendar(anchor), 'Tomorrow at 12:00', 'tomorrow uses parent version');
+ assert.equal(anchor.clone().add(3, 'days').calendar(anchor), 'Next week at 12:00', 'next week uses parent version');
+ assert.equal(anchor.clone().subtract(1, 'day').calendar(anchor), 'Yesterday at 12:00', 'yesterday uses parent version');
+ assert.equal(anchor.clone().subtract(3, 'days').calendar(anchor), 'Last week at 12:00', 'last week uses parent version');
+ assert.equal(anchor.clone().subtract(7, 'days').calendar(anchor), 'whatever', 'sameElse uses parent version -');
+ assert.equal(anchor.clone().add(7, 'days').calendar(anchor), 'whatever', 'sameElse uses parent version +');
+});
+
+// Test function vs obj both directions
+
+test('long date format', function (assert) {
+ moment.defineLocale('ldf', null);
+ moment.defineLocale('ldf', {
+ longDateFormat : {
+ LTS : 'h:mm:ss A',
+ LT : 'h:mm A',
+ L : 'MM/DD/YYYY',
+ LL : 'MMMM D, YYYY',
+ LLL : 'MMMM D, YYYY h:mm A',
+ LLLL : 'dddd, MMMM D, YYYY h:mm A'
+ }
+ });
+ moment.updateLocale('ldf', {
+ longDateFormat: {
+ LLL : '[child] MMMM D, YYYY h:mm A',
+ LLLL : '[child] dddd, MMMM D, YYYY h:mm A'
+ }
+ });
+
+ moment.locale('ldf');
+ var anchor = moment.utc('2015-09-06T12:34:56', moment.ISO_8601);
+ assert.equal(anchor.format('LTS'), '12:34:56 PM', 'LTS uses base');
+ assert.equal(anchor.format('LT'), '12:34 PM', 'LT uses base');
+ assert.equal(anchor.format('L'), '09/06/2015', 'L uses base');
+ assert.equal(anchor.format('l'), '9/6/2015', 'l uses base');
+ assert.equal(anchor.format('LL'), 'September 6, 2015', 'LL uses base');
+ assert.equal(anchor.format('ll'), 'Sep 6, 2015', 'll uses base');
+ assert.equal(anchor.format('LLL'), 'child September 6, 2015 12:34 PM', 'LLL uses child');
+ assert.equal(anchor.format('lll'), 'child Sep 6, 2015 12:34 PM', 'lll uses child');
+ assert.equal(anchor.format('LLLL'), 'child Sunday, September 6, 2015 12:34 PM', 'LLLL uses child');
+ assert.equal(anchor.format('llll'), 'child Sun, Sep 6, 2015 12:34 PM', 'llll uses child');
+});
+
+test('ordinal', function (assert) {
+ moment.defineLocale('ordinal-1', null);
+ moment.defineLocale('ordinal-1', {
+ ordinal : '%dx'
+ });
+ moment.updateLocale('ordinal-1', {
+ ordinal : '%dy'
+ });
+
+ assert.equal(moment.utc('2015-02-03', moment.ISO_8601).format('Do'), '3y', 'ordinal uses child string');
+
+ moment.defineLocale('ordinal-2', null);
+ moment.defineLocale('ordinal-2', {
+ ordinal : '%dx'
+ });
+ moment.updateLocale('ordinal-2', {
+ ordinal : function (num) {
+ return num + 'y';
+ }
+ });
+
+ assert.equal(moment.utc('2015-02-03', moment.ISO_8601).format('Do'), '3y', 'ordinal uses child function');
+
+ moment.defineLocale('ordinal-3', null);
+ moment.defineLocale('ordinal-3', {
+ ordinal : function (num) {
+ return num + 'x';
+ }
+ });
+ moment.updateLocale('ordinal-3', {
+ ordinal : '%dy'
+ });
+
+ assert.equal(moment.utc('2015-02-03', moment.ISO_8601).format('Do'), '3y', 'ordinal uses child string (overwrite parent function)');
+});
+
+test('ordinal parse', function (assert) {
+ moment.defineLocale('ordinal-parse-1', null);
+ moment.defineLocale('ordinal-parse-1', {
+ ordinalParse : /\d{1,2}x/
+ });
+ moment.updateLocale('ordinal-parse-1', {
+ ordinalParse : /\d{1,2}y/
+ });
+
+ assert.ok(moment.utc('2015-01-1y', 'YYYY-MM-Do', true).isValid(), 'ordinal parse uses child');
+
+ moment.defineLocale('ordinal-parse-2', null);
+ moment.defineLocale('ordinal-parse-2', {
+ ordinalParse : /\d{1,2}x/
+ });
+ moment.updateLocale('ordinal-parse-2', {
+ ordinalParse : null
+ });
+
+ assert.ok(moment.utc('2015-01-1', 'YYYY-MM-Do', true).isValid(), 'ordinal parse uses child (default)');
+});
+
+test('months', function (assert) {
+ moment.defineLocale('months', null);
+ moment.defineLocale('months', {
+ months : 'One_Two_Three_Four_Five_Six_Seven_Eight_Nine_Ten_Eleven_Twelve'.split('_')
+ });
+ moment.updateLocale('months', {
+ parentLocale: 'base-months',
+ months : 'First_Second_Third_Fourth_Fifth_Sixth_Seventh_Eighth_Ninth_Tenth_Eleventh_Twelveth '.split('_')
+ });
+ assert.ok(moment.utc('2015-01-01', 'YYYY-MM-DD').format('MMMM'), 'First', 'months uses child');
+});
diff --git a/src/test/moment/now.js b/src/test/moment/now.js
index 35a7ff2..eada0c0 100644
--- a/src/test/moment/now.js
+++ b/src/test/moment/now.js
@@ -10,6 +10,31 @@
assert.ok(startOfTest <= momentNowTime, 'moment now() time should be now, not in the past');
assert.ok(momentNowTime <= afterMomentCreationTime, 'moment now() time should be now, not in the future');
+});
+
+test('now - Date mocked', function (assert) {
+ // We need to test mocking the global Date object, so disable 'Read Only' jshint check
+ /* jshint -W020 */
+ var RealDate = Date,
+ customTimeMs = moment('2015-01-01T01:30:00.000Z').valueOf();
+
+ function MockDate() {
+ return new RealDate(customTimeMs);
+ }
+
+ MockDate.now = function () {
+ return new MockDate().valueOf();
+ };
+
+ MockDate.prototype = RealDate.prototype;
+
+ Date = MockDate;
+
+ try {
+ assert.equal(moment().valueOf(), customTimeMs, 'moment now() time should use the global Date object');
+ } finally {
+ Date = RealDate;
+ }
});
test('now - custom value', function (assert) {
diff --git a/src/test/moment/preparse_postformat.js b/src/test/moment/preparse_postformat.js
index 87c2fe0..4f09f2e 100644
--- a/src/test/moment/preparse_postformat.js
+++ b/src/test/moment/preparse_postformat.js
@@ -41,6 +41,9 @@
});
}
});
+ },
+ teardown: function () {
+ moment.defineLocale('symbol', null);
}
});
@@ -59,12 +62,12 @@
});
test('calendar day', function (assert) {
- var a = moment().hours(2).minutes(0).seconds(0);
+ var a = moment().hours(12).minutes(0).seconds(0);
- assert.equal(moment(a).calendar(), 'Today at @:)) AM', 'today at the same time');
- assert.equal(moment(a).add({m: 25}).calendar(), 'Today at @:@% AM', 'Now plus 25 min');
- assert.equal(moment(a).add({h: 1}).calendar(), 'Today at #:)) AM', 'Now plus 1 hour');
- assert.equal(moment(a).add({d: 1}).calendar(), 'Tomorrow at @:)) AM', 'tomorrow at the same time');
- assert.equal(moment(a).subtract({h: 1}).calendar(), 'Today at !:)) AM', 'Now minus 1 hour');
- assert.equal(moment(a).subtract({d: 1}).calendar(), 'Yesterday at @:)) AM', 'yesterday at the same time');
+ assert.equal(moment(a).calendar(), 'Today at !@:)) PM', 'today at the same time');
+ assert.equal(moment(a).add({m: 25}).calendar(), 'Today at !@:@% PM', 'Now plus 25 min');
+ assert.equal(moment(a).add({h: 1}).calendar(), 'Today at !:)) PM', 'Now plus 1 hour');
+ assert.equal(moment(a).add({d: 1}).calendar(), 'Tomorrow at !@:)) PM', 'tomorrow at the same time');
+ assert.equal(moment(a).subtract({h: 1}).calendar(), 'Today at !!:)) AM', 'Now minus 1 hour');
+ assert.equal(moment(a).subtract({d: 1}).calendar(), 'Yesterday at !@:)) PM', 'yesterday at the same time');
});
diff --git a/src/test/moment/start_end_of.js b/src/test/moment/start_end_of.js
index 8773d1b..519c764 100644
--- a/src/test/moment/start_end_of.js
+++ b/src/test/moment/start_end_of.js
@@ -188,6 +188,35 @@
assert.equal(m.seconds(), 59, 'set the seconds');
assert.equal(m.milliseconds(), 999, 'set the seconds');
});
+
+test('start of date', function (assert) {
+ var m = moment(new Date(2011, 1, 2, 3, 4, 5, 6)).startOf('date'),
+ ms = moment(new Date(2011, 1, 2, 3, 4, 5, 6)).startOf('dates');
+
+ assert.equal(+m, +ms, 'Plural or singular should work');
+ assert.equal(m.year(), 2011, 'keep the year');
+ assert.equal(m.month(), 1, 'keep the month');
+ assert.equal(m.date(), 2, 'keep the day');
+ assert.equal(m.hours(), 0, 'strip out the hours');
+ assert.equal(m.minutes(), 0, 'strip out the minutes');
+ assert.equal(m.seconds(), 0, 'strip out the seconds');
+ assert.equal(m.milliseconds(), 0, 'strip out the milliseconds');
+});
+
+test('end of date', function (assert) {
+ var m = moment(new Date(2011, 1, 2, 3, 4, 5, 6)).endOf('date'),
+ ms = moment(new Date(2011, 1, 2, 3, 4, 5, 6)).endOf('dates');
+
+ assert.equal(+m, +ms, 'Plural or singular should work');
+ assert.equal(m.year(), 2011, 'keep the year');
+ assert.equal(m.month(), 1, 'keep the month');
+ assert.equal(m.date(), 2, 'keep the day');
+ assert.equal(m.hours(), 23, 'set the hours');
+ assert.equal(m.minutes(), 59, 'set the minutes');
+ assert.equal(m.seconds(), 59, 'set the seconds');
+ assert.equal(m.milliseconds(), 999, 'set the seconds');
+});
+
test('start of hour', function (assert) {
var m = moment(new Date(2011, 1, 2, 3, 4, 5, 6)).startOf('hour'),
@@ -294,6 +323,10 @@
};
m = moment('2014-03-15T00:00:00-07:00').parseZone();
+ m.startOf('y');
+ assert.equal(m.format(), '2014-01-01T00:00:00-08:00', 'startOf(\'year\') across +1');
+
+ m = moment('2014-03-15T00:00:00-07:00').parseZone();
m.startOf('M');
assert.equal(m.format(), '2014-03-01T00:00:00-08:00', 'startOf(\'month\') across +1');
@@ -329,6 +362,10 @@
};
m = moment('2014-11-15T00:00:00-08:00').parseZone();
+ m.startOf('y');
+ assert.equal(m.format(), '2014-01-01T00:00:00-07:00', 'startOf(\'year\') across -1');
+
+ m = moment('2014-11-15T00:00:00-08:00').parseZone();
m.startOf('M');
assert.equal(m.format(), '2014-11-01T00:00:00-07:00', 'startOf(\'month\') across -1');
diff --git a/src/test/moment/utc.js b/src/test/moment/utc.js
index 6dc111f..64a0bb1 100644
--- a/src/test/moment/utc.js
+++ b/src/test/moment/utc.js
@@ -13,7 +13,7 @@
// local
m.local();
- if (m.zone() > 180) {
+ if (m.utcOffset() < -180) {
assert.equal(m.date(), 1, 'the date should be correct for local');
assert.equal(m.day(), 2, 'the day should be correct for local');
} else {
diff --git a/src/test/moment/utc_offset.js b/src/test/moment/utc_offset.js
index 6768293..8f2a8f2 100644
--- a/src/test/moment/utc_offset.js
+++ b/src/test/moment/utc_offset.js
@@ -476,94 +476,3 @@
assert.equal(moment().utcOffset(-90).format('ZZ'), '-0130', '+90 -> -0130');
assert.equal(moment().utcOffset(-120).format('ZZ'), '-0200', '+120 -> -0200');
});
-
-test('local to utc, keepLocalTime = true', function (assert) {
- var m = moment(),
- fmt = 'YYYY-DD-MM HH:mm:ss';
- assert.equal(m.clone().utc(true).format(fmt), m.format(fmt), 'local to utc failed to keep local time');
-});
-
-test('local to utc, keepLocalTime = false', function (assert) {
- var m = moment();
- assert.equal(m.clone().utc().valueOf(), m.valueOf(), 'local to utc failed to keep utc time (implicit)');
- assert.equal(m.clone().utc(false).valueOf(), m.valueOf(), 'local to utc failed to keep utc time (explicit)');
-});
-
-test('local to zone, keepLocalTime = true', function (assert) {
- var m = moment(),
- fmt = 'YYYY-DD-MM HH:mm:ss',
- z;
-
- // Apparently there is -12:00 and +14:00
- // http://en.wikipedia.org/wiki/UTC+14:00
- // http://en.wikipedia.org/wiki/UTC-12:00
- for (z = -12; z <= 14; ++z) {
- assert.equal(m.clone().utcOffset(z * 60, true).format(fmt),
- m.format(fmt),
- 'local to utcOffset(' + z + ':00) failed to keep local time');
- }
-});
-
-test('local to zone, keepLocalTime = false', function (assert) {
- var m = moment(),
- z;
-
- // Apparently there is -12:00 and +14:00
- // http://en.wikipedia.org/wiki/UTC+14:00
- // http://en.wikipedia.org/wiki/UTC-12:00
- for (z = -12; z <= 14; ++z) {
- assert.equal(m.clone().utcOffset(z * 60).valueOf(),
- m.valueOf(),
- 'local to utcOffset(' + z + ':00) failed to keep utc time (implicit)');
- assert.equal(m.clone().utcOffset(z * 60, false).valueOf(),
- m.valueOf(),
- 'local to utcOffset(' + z + ':00) failed to keep utc time (explicit)');
- }
-});
-
-test('utc to local, keepLocalTime = true', function (assert) {
- var um = moment.utc(),
- fmt = 'YYYY-DD-MM HH:mm:ss';
-
- assert.equal(um.clone().local(true).format(fmt), um.format(fmt), 'utc to local failed to keep local time');
-});
-
-test('utc to local, keepLocalTime = false', function (assert) {
- var um = moment.utc();
- assert.equal(um.clone().local().valueOf(), um.valueOf(), 'utc to local failed to keep utc time (implicit)');
- assert.equal(um.clone().local(false).valueOf(), um.valueOf(), 'utc to local failed to keep utc time (explicit)');
-});
-
-test('zone to local, keepLocalTime = true', function (assert) {
- var m = moment(),
- fmt = 'YYYY-DD-MM HH:mm:ss',
- z;
-
- // Apparently there is -12:00 and +14:00
- // http://en.wikipedia.org/wiki/UTC+14:00
- // http://en.wikipedia.org/wiki/UTC-12:00
- for (z = -12; z <= 14; ++z) {
- m.utcOffset(z * 60);
-
- assert.equal(m.clone().local(true).format(fmt),
- m.format(fmt),
- 'utcOffset(' + z + ':00) to local failed to keep local time');
- }
-});
-
-test('zone to local, keepLocalTime = false', function (assert) {
- var m = moment(),
- z;
-
- // Apparently there is -12:00 and +14:00
- // http://en.wikipedia.org/wiki/UTC+14:00
- // http://en.wikipedia.org/wiki/UTC-12:00
- for (z = -12; z <= 14; ++z) {
- m.utcOffset(z * 60);
-
- assert.equal(m.clone().local(false).valueOf(), m.valueOf(),
- 'utcOffset(' + z + ':00) to local failed to keep utc time (explicit)');
- assert.equal(m.clone().local().valueOf(), m.valueOf(),
- 'utcOffset(' + z + ':00) to local failed to keep utc time (implicit)');
- }
-});
diff --git a/src/test/moment/week_year.js b/src/test/moment/week_year.js
index 4694876..522ce88 100644
--- a/src/test/moment/week_year.js
+++ b/src/test/moment/week_year.js
@@ -66,16 +66,18 @@
// Verifies that the week number, week day computation is correct for all dow, doy combinations
test('week year roundtrip', function (assert) {
- var dow, doy, wd, m;
+ var dow, doy, wd, m, localeName;
for (dow = 0; dow < 7; ++dow) {
for (doy = dow; doy < dow + 7; ++doy) {
for (wd = 0; wd < 7; ++wd) {
- moment.locale('dow: ' + dow + ', doy: ' + doy, {week: {dow: dow, doy: doy}});
+ localeName = 'dow: ' + dow + ', doy: ' + doy;
+ moment.locale(localeName, {week: {dow: dow, doy: doy}});
// We use the 10th week as the 1st one can spill to the previous year
m = moment('2015 10 ' + wd, 'gggg w d', true);
assert.equal(m.format('gggg w d'), '2015 10 ' + wd, 'dow: ' + dow + ' doy: ' + doy + ' wd: ' + wd);
m = moment('2015 10 ' + wd, 'gggg w e', true);
assert.equal(m.format('gggg w e'), '2015 10 ' + wd, 'dow: ' + dow + ' doy: ' + doy + ' wd: ' + wd);
+ moment.defineLocale(localeName, null);
}
}
}
@@ -90,6 +92,185 @@
assert.equal(2, moment('2013-01-11', 'YYYY-MM-DD').week(), '2013-01-11 is week 2'); // 53 -- should be 2
assert.equal(3, moment('2013-01-12', 'YYYY-MM-DD').week(), '2013-01-12 is week 3'); // 1 -- should be 3
assert.equal(52, moment('2012-01-01', 'YYYY-MM-DD').weeksInYear(), 'weeks in 2012 are 52'); // 52
+ moment.defineLocale('dow: 6, doy: 12', null);
+});
+
+test('weeks numbers dow:1 doy:4', function (assert) {
+ moment.locale('dow: 1, doy: 4', {week: {dow: 1, doy: 4}});
+ assert.equal(moment([2012, 0, 1]).week(), 52, 'Jan 1 2012 should be week 52');
+ assert.equal(moment([2012, 0, 2]).week(), 1, 'Jan 2 2012 should be week 1');
+ assert.equal(moment([2012, 0, 8]).week(), 1, 'Jan 8 2012 should be week 1');
+ assert.equal(moment([2012, 0, 9]).week(), 2, 'Jan 9 2012 should be week 2');
+ assert.equal(moment([2012, 0, 15]).week(), 2, 'Jan 15 2012 should be week 2');
+ assert.equal(moment([2007, 0, 1]).week(), 1, 'Jan 1 2007 should be week 1');
+ assert.equal(moment([2007, 0, 7]).week(), 1, 'Jan 7 2007 should be week 1');
+ assert.equal(moment([2007, 0, 8]).week(), 2, 'Jan 8 2007 should be week 2');
+ assert.equal(moment([2007, 0, 14]).week(), 2, 'Jan 14 2007 should be week 2');
+ assert.equal(moment([2007, 0, 15]).week(), 3, 'Jan 15 2007 should be week 3');
+ assert.equal(moment([2007, 11, 31]).week(), 1, 'Dec 31 2007 should be week 1');
+ assert.equal(moment([2008, 0, 1]).week(), 1, 'Jan 1 2008 should be week 1');
+ assert.equal(moment([2008, 0, 6]).week(), 1, 'Jan 6 2008 should be week 1');
+ assert.equal(moment([2008, 0, 7]).week(), 2, 'Jan 7 2008 should be week 2');
+ assert.equal(moment([2008, 0, 13]).week(), 2, 'Jan 13 2008 should be week 2');
+ assert.equal(moment([2008, 0, 14]).week(), 3, 'Jan 14 2008 should be week 3');
+ assert.equal(moment([2002, 11, 30]).week(), 1, 'Dec 30 2002 should be week 1');
+ assert.equal(moment([2003, 0, 1]).week(), 1, 'Jan 1 2003 should be week 1');
+ assert.equal(moment([2003, 0, 5]).week(), 1, 'Jan 5 2003 should be week 1');
+ assert.equal(moment([2003, 0, 6]).week(), 2, 'Jan 6 2003 should be week 2');
+ assert.equal(moment([2003, 0, 12]).week(), 2, 'Jan 12 2003 should be week 2');
+ assert.equal(moment([2003, 0, 13]).week(), 3, 'Jan 13 2003 should be week 3');
+ assert.equal(moment([2008, 11, 29]).week(), 1, 'Dec 29 2008 should be week 1');
+ assert.equal(moment([2009, 0, 1]).week(), 1, 'Jan 1 2009 should be week 1');
+ assert.equal(moment([2009, 0, 4]).week(), 1, 'Jan 4 2009 should be week 1');
+ assert.equal(moment([2009, 0, 5]).week(), 2, 'Jan 5 2009 should be week 2');
+ assert.equal(moment([2009, 0, 11]).week(), 2, 'Jan 11 2009 should be week 2');
+ assert.equal(moment([2009, 0, 13]).week(), 3, 'Jan 12 2009 should be week 3');
+ assert.equal(moment([2009, 11, 28]).week(), 53, 'Dec 28 2009 should be week 53');
+ assert.equal(moment([2010, 0, 1]).week(), 53, 'Jan 1 2010 should be week 53');
+ assert.equal(moment([2010, 0, 3]).week(), 53, 'Jan 3 2010 should be week 53');
+ assert.equal(moment([2010, 0, 4]).week(), 1, 'Jan 4 2010 should be week 1');
+ assert.equal(moment([2010, 0, 10]).week(), 1, 'Jan 10 2010 should be week 1');
+ assert.equal(moment([2010, 0, 11]).week(), 2, 'Jan 11 2010 should be week 2');
+ assert.equal(moment([2010, 11, 27]).week(), 52, 'Dec 27 2010 should be week 52');
+ assert.equal(moment([2011, 0, 1]).week(), 52, 'Jan 1 2011 should be week 52');
+ assert.equal(moment([2011, 0, 2]).week(), 52, 'Jan 2 2011 should be week 52');
+ assert.equal(moment([2011, 0, 3]).week(), 1, 'Jan 3 2011 should be week 1');
+ assert.equal(moment([2011, 0, 9]).week(), 1, 'Jan 9 2011 should be week 1');
+ assert.equal(moment([2011, 0, 10]).week(), 2, 'Jan 10 2011 should be week 2');
+ moment.defineLocale('dow: 1, doy: 4', null);
+});
+
+test('weeks numbers dow:6 doy:12', function (assert) {
+ moment.locale('dow: 6, doy: 12', {week: {dow: 6, doy: 12}});
+ assert.equal(moment([2011, 11, 31]).week(), 1, 'Dec 31 2011 should be week 1');
+ assert.equal(moment([2012, 0, 6]).week(), 1, 'Jan 6 2012 should be week 1');
+ assert.equal(moment([2012, 0, 7]).week(), 2, 'Jan 7 2012 should be week 2');
+ assert.equal(moment([2012, 0, 13]).week(), 2, 'Jan 13 2012 should be week 2');
+ assert.equal(moment([2012, 0, 14]).week(), 3, 'Jan 14 2012 should be week 3');
+ assert.equal(moment([2006, 11, 30]).week(), 1, 'Dec 30 2006 should be week 1');
+ assert.equal(moment([2007, 0, 5]).week(), 1, 'Jan 5 2007 should be week 1');
+ assert.equal(moment([2007, 0, 6]).week(), 2, 'Jan 6 2007 should be week 2');
+ assert.equal(moment([2007, 0, 12]).week(), 2, 'Jan 12 2007 should be week 2');
+ assert.equal(moment([2007, 0, 13]).week(), 3, 'Jan 13 2007 should be week 3');
+ assert.equal(moment([2007, 11, 29]).week(), 1, 'Dec 29 2007 should be week 1');
+ assert.equal(moment([2008, 0, 1]).week(), 1, 'Jan 1 2008 should be week 1');
+ assert.equal(moment([2008, 0, 4]).week(), 1, 'Jan 4 2008 should be week 1');
+ assert.equal(moment([2008, 0, 5]).week(), 2, 'Jan 5 2008 should be week 2');
+ assert.equal(moment([2008, 0, 11]).week(), 2, 'Jan 11 2008 should be week 2');
+ assert.equal(moment([2008, 0, 12]).week(), 3, 'Jan 12 2008 should be week 3');
+ assert.equal(moment([2002, 11, 28]).week(), 1, 'Dec 28 2002 should be week 1');
+ assert.equal(moment([2003, 0, 1]).week(), 1, 'Jan 1 2003 should be week 1');
+ assert.equal(moment([2003, 0, 3]).week(), 1, 'Jan 3 2003 should be week 1');
+ assert.equal(moment([2003, 0, 4]).week(), 2, 'Jan 4 2003 should be week 2');
+ assert.equal(moment([2003, 0, 10]).week(), 2, 'Jan 10 2003 should be week 2');
+ assert.equal(moment([2003, 0, 11]).week(), 3, 'Jan 11 2003 should be week 3');
+ assert.equal(moment([2008, 11, 27]).week(), 1, 'Dec 27 2008 should be week 1');
+ assert.equal(moment([2009, 0, 1]).week(), 1, 'Jan 1 2009 should be week 1');
+ assert.equal(moment([2009, 0, 2]).week(), 1, 'Jan 2 2009 should be week 1');
+ assert.equal(moment([2009, 0, 3]).week(), 2, 'Jan 3 2009 should be week 2');
+ assert.equal(moment([2009, 0, 9]).week(), 2, 'Jan 9 2009 should be week 2');
+ assert.equal(moment([2009, 0, 10]).week(), 3, 'Jan 10 2009 should be week 3');
+ assert.equal(moment([2009, 11, 26]).week(), 1, 'Dec 26 2009 should be week 1');
+ assert.equal(moment([2010, 0, 1]).week(), 1, 'Jan 1 2010 should be week 1');
+ assert.equal(moment([2010, 0, 2]).week(), 2, 'Jan 2 2010 should be week 2');
+ assert.equal(moment([2010, 0, 8]).week(), 2, 'Jan 8 2010 should be week 2');
+ assert.equal(moment([2010, 0, 9]).week(), 3, 'Jan 9 2010 should be week 3');
+ assert.equal(moment([2011, 0, 1]).week(), 1, 'Jan 1 2011 should be week 1');
+ assert.equal(moment([2011, 0, 7]).week(), 1, 'Jan 7 2011 should be week 1');
+ assert.equal(moment([2011, 0, 8]).week(), 2, 'Jan 8 2011 should be week 2');
+ assert.equal(moment([2011, 0, 14]).week(), 2, 'Jan 14 2011 should be week 2');
+ assert.equal(moment([2011, 0, 15]).week(), 3, 'Jan 15 2011 should be week 3');
+ moment.defineLocale('dow: 6, doy: 12', null);
+});
+
+test('weeks numbers dow:1 doy:7', function (assert) {
+ moment.locale('dow: 1, doy: 7', {week: {dow: 1, doy: 7}});
+ assert.equal(moment([2011, 11, 26]).week(), 1, 'Dec 26 2011 should be week 1');
+ assert.equal(moment([2012, 0, 1]).week(), 1, 'Jan 1 2012 should be week 1');
+ assert.equal(moment([2012, 0, 2]).week(), 2, 'Jan 2 2012 should be week 2');
+ assert.equal(moment([2012, 0, 8]).week(), 2, 'Jan 8 2012 should be week 2');
+ assert.equal(moment([2012, 0, 9]).week(), 3, 'Jan 9 2012 should be week 3');
+ assert.equal(moment([2007, 0, 1]).week(), 1, 'Jan 1 2007 should be week 1');
+ assert.equal(moment([2007, 0, 7]).week(), 1, 'Jan 7 2007 should be week 1');
+ assert.equal(moment([2007, 0, 8]).week(), 2, 'Jan 8 2007 should be week 2');
+ assert.equal(moment([2007, 0, 14]).week(), 2, 'Jan 14 2007 should be week 2');
+ assert.equal(moment([2007, 0, 15]).week(), 3, 'Jan 15 2007 should be week 3');
+ assert.equal(moment([2007, 11, 31]).week(), 1, 'Dec 31 2007 should be week 1');
+ assert.equal(moment([2008, 0, 1]).week(), 1, 'Jan 1 2008 should be week 1');
+ assert.equal(moment([2008, 0, 6]).week(), 1, 'Jan 6 2008 should be week 1');
+ assert.equal(moment([2008, 0, 7]).week(), 2, 'Jan 7 2008 should be week 2');
+ assert.equal(moment([2008, 0, 13]).week(), 2, 'Jan 13 2008 should be week 2');
+ assert.equal(moment([2008, 0, 14]).week(), 3, 'Jan 14 2008 should be week 3');
+ assert.equal(moment([2002, 11, 30]).week(), 1, 'Dec 30 2002 should be week 1');
+ assert.equal(moment([2003, 0, 1]).week(), 1, 'Jan 1 2003 should be week 1');
+ assert.equal(moment([2003, 0, 5]).week(), 1, 'Jan 5 2003 should be week 1');
+ assert.equal(moment([2003, 0, 6]).week(), 2, 'Jan 6 2003 should be week 2');
+ assert.equal(moment([2003, 0, 12]).week(), 2, 'Jan 12 2003 should be week 2');
+ assert.equal(moment([2003, 0, 13]).week(), 3, 'Jan 13 2003 should be week 3');
+ assert.equal(moment([2008, 11, 29]).week(), 1, 'Dec 29 2008 should be week 1');
+ assert.equal(moment([2009, 0, 1]).week(), 1, 'Jan 1 2009 should be week 1');
+ assert.equal(moment([2009, 0, 4]).week(), 1, 'Jan 4 2009 should be week 1');
+ assert.equal(moment([2009, 0, 5]).week(), 2, 'Jan 5 2009 should be week 2');
+ assert.equal(moment([2009, 0, 11]).week(), 2, 'Jan 11 2009 should be week 2');
+ assert.equal(moment([2009, 0, 12]).week(), 3, 'Jan 12 2009 should be week 3');
+ assert.equal(moment([2009, 11, 28]).week(), 1, 'Dec 28 2009 should be week 1');
+ assert.equal(moment([2010, 0, 1]).week(), 1, 'Jan 1 2010 should be week 1');
+ assert.equal(moment([2010, 0, 3]).week(), 1, 'Jan 3 2010 should be week 1');
+ assert.equal(moment([2010, 0, 4]).week(), 2, 'Jan 4 2010 should be week 2');
+ assert.equal(moment([2010, 0, 10]).week(), 2, 'Jan 10 2010 should be week 2');
+ assert.equal(moment([2010, 0, 11]).week(), 3, 'Jan 11 2010 should be week 3');
+ assert.equal(moment([2010, 11, 27]).week(), 1, 'Dec 27 2010 should be week 1');
+ assert.equal(moment([2011, 0, 1]).week(), 1, 'Jan 1 2011 should be week 1');
+ assert.equal(moment([2011, 0, 2]).week(), 1, 'Jan 2 2011 should be week 1');
+ assert.equal(moment([2011, 0, 3]).week(), 2, 'Jan 3 2011 should be week 2');
+ assert.equal(moment([2011, 0, 9]).week(), 2, 'Jan 9 2011 should be week 2');
+ assert.equal(moment([2011, 0, 10]).week(), 3, 'Jan 10 2011 should be week 3');
+ moment.defineLocale('dow: 1, doy: 7', null);
+});
+
+test('weeks numbers dow:0 doy:6', function (assert) {
+ moment.locale('dow: 0, doy: 6', {week: {dow: 0, doy: 6}});
+ assert.equal(moment([2012, 0, 1]).week(), 1, 'Jan 1 2012 should be week 1');
+ assert.equal(moment([2012, 0, 7]).week(), 1, 'Jan 7 2012 should be week 1');
+ assert.equal(moment([2012, 0, 8]).week(), 2, 'Jan 8 2012 should be week 2');
+ assert.equal(moment([2012, 0, 14]).week(), 2, 'Jan 14 2012 should be week 2');
+ assert.equal(moment([2012, 0, 15]).week(), 3, 'Jan 15 2012 should be week 3');
+ assert.equal(moment([2006, 11, 31]).week(), 1, 'Dec 31 2006 should be week 1');
+ assert.equal(moment([2007, 0, 1]).week(), 1, 'Jan 1 2007 should be week 1');
+ assert.equal(moment([2007, 0, 6]).week(), 1, 'Jan 6 2007 should be week 1');
+ assert.equal(moment([2007, 0, 7]).week(), 2, 'Jan 7 2007 should be week 2');
+ assert.equal(moment([2007, 0, 13]).week(), 2, 'Jan 13 2007 should be week 2');
+ assert.equal(moment([2007, 0, 14]).week(), 3, 'Jan 14 2007 should be week 3');
+ assert.equal(moment([2007, 11, 29]).week(), 52, 'Dec 29 2007 should be week 52');
+ assert.equal(moment([2008, 0, 1]).week(), 1, 'Jan 1 2008 should be week 1');
+ assert.equal(moment([2008, 0, 5]).week(), 1, 'Jan 5 2008 should be week 1');
+ assert.equal(moment([2008, 0, 6]).week(), 2, 'Jan 6 2008 should be week 2');
+ assert.equal(moment([2008, 0, 12]).week(), 2, 'Jan 12 2008 should be week 2');
+ assert.equal(moment([2008, 0, 13]).week(), 3, 'Jan 13 2008 should be week 3');
+ assert.equal(moment([2002, 11, 29]).week(), 1, 'Dec 29 2002 should be week 1');
+ assert.equal(moment([2003, 0, 1]).week(), 1, 'Jan 1 2003 should be week 1');
+ assert.equal(moment([2003, 0, 4]).week(), 1, 'Jan 4 2003 should be week 1');
+ assert.equal(moment([2003, 0, 5]).week(), 2, 'Jan 5 2003 should be week 2');
+ assert.equal(moment([2003, 0, 11]).week(), 2, 'Jan 11 2003 should be week 2');
+ assert.equal(moment([2003, 0, 12]).week(), 3, 'Jan 12 2003 should be week 3');
+ assert.equal(moment([2008, 11, 28]).week(), 1, 'Dec 28 2008 should be week 1');
+ assert.equal(moment([2009, 0, 1]).week(), 1, 'Jan 1 2009 should be week 1');
+ assert.equal(moment([2009, 0, 3]).week(), 1, 'Jan 3 2009 should be week 1');
+ assert.equal(moment([2009, 0, 4]).week(), 2, 'Jan 4 2009 should be week 2');
+ assert.equal(moment([2009, 0, 10]).week(), 2, 'Jan 10 2009 should be week 2');
+ assert.equal(moment([2009, 0, 11]).week(), 3, 'Jan 11 2009 should be week 3');
+ assert.equal(moment([2009, 11, 27]).week(), 1, 'Dec 27 2009 should be week 1');
+ assert.equal(moment([2010, 0, 1]).week(), 1, 'Jan 1 2010 should be week 1');
+ assert.equal(moment([2010, 0, 2]).week(), 1, 'Jan 2 2010 should be week 1');
+ assert.equal(moment([2010, 0, 3]).week(), 2, 'Jan 3 2010 should be week 2');
+ assert.equal(moment([2010, 0, 9]).week(), 2, 'Jan 9 2010 should be week 2');
+ assert.equal(moment([2010, 0, 10]).week(), 3, 'Jan 10 2010 should be week 3');
+ assert.equal(moment([2010, 11, 26]).week(), 1, 'Dec 26 2010 should be week 1');
+ assert.equal(moment([2011, 0, 1]).week(), 1, 'Jan 1 2011 should be week 1');
+ assert.equal(moment([2011, 0, 2]).week(), 2, 'Jan 2 2011 should be week 2');
+ assert.equal(moment([2011, 0, 8]).week(), 2, 'Jan 8 2011 should be week 2');
+ assert.equal(moment([2011, 0, 9]).week(), 3, 'Jan 9 2011 should be week 3');
+ moment.defineLocale('dow: 0, doy: 6', null);
});
test('week year overflows', function (assert) {
diff --git a/src/test/moment/zone_switching.js b/src/test/moment/zone_switching.js
index 7d84606..61ff821 100644
--- a/src/test/moment/zone_switching.js
+++ b/src/test/moment/zone_switching.js
@@ -1,5 +1,6 @@
-import { module, test } from '../qunit';
+import { module, test, expect } from '../qunit';
import moment from '../../moment';
+import { isNearSpringDST } from '../helpers/dst';
module('zone switching');
@@ -16,6 +17,7 @@
});
test('local to zone, keepLocalTime = true', function (assert) {
+ test.expectedDeprecations('moment().zone');
var m = moment(),
fmt = 'YYYY-DD-MM HH:mm:ss',
z;
@@ -30,6 +32,7 @@
});
test('local to zone, keepLocalTime = false', function (assert) {
+ test.expectedDeprecations('moment().zone');
var m = moment(),
z;
@@ -45,6 +48,12 @@
});
test('utc to local, keepLocalTime = true', function (assert) {
+ // Don't test near the spring DST transition
+ if (isNearSpringDST()) {
+ expect(0);
+ return;
+ }
+
var um = moment.utc(),
fmt = 'YYYY-DD-MM HH:mm:ss';
@@ -58,6 +67,13 @@
});
test('zone to local, keepLocalTime = true', function (assert) {
+ test.expectedDeprecations('moment().zone');
+ // Don't test near the spring DST transition
+ if (isNearSpringDST()) {
+ expect(0);
+ return;
+ }
+
var m = moment(),
fmt = 'YYYY-DD-MM HH:mm:ss',
z;
@@ -74,6 +90,7 @@
});
test('zone to local, keepLocalTime = false', function (assert) {
+ test.expectedDeprecations('moment().zone');
var m = moment(),
z;
diff --git a/src/test/moment/zones.js b/src/test/moment/zones.js
index e9e0b34..11ede11 100644
--- a/src/test/moment/zones.js
+++ b/src/test/moment/zones.js
@@ -1,7 +1,11 @@
import { module, test } from '../qunit';
import moment from '../../moment';
-module('zones');
+module('zones', {
+ 'setup': function () {
+ test.expectedDeprecations('moment().zone');
+ }
+});
test('set zone', function (assert) {
var zone = moment();
@@ -360,6 +364,7 @@
});
test('zone names', function (assert) {
+ test.expectedDeprecations();
assert.equal(moment().zoneAbbr(), '', 'Local zone abbr should be empty');
assert.equal(moment().format('z'), '', 'Local zone formatted abbr should be empty');
assert.equal(moment().zoneName(), '', 'Local zone name should be empty');
@@ -422,6 +427,7 @@
});
test('parse zone with more arguments', function (assert) {
+ test.expectedDeprecations();
var m;
m = moment.parseZone('2013 01 01 05 -13:00', 'YYYY MM DD HH ZZ');
assert.equal(m.format(), '2013-01-01T05:00:00-13:00', 'accept input and format');
diff --git a/src/test/qunit.js b/src/test/qunit.js
index b6d9875..42f1d08 100644
--- a/src/test/qunit.js
+++ b/src/test/qunit.js
@@ -1,6 +1,8 @@
/*global QUnit:false*/
import moment from '../moment';
+import { defineCommonLocaleTests } from './helpers/common-locale';
+import { setupDeprecationHandler, teardownDeprecationHandler } from './helpers/deprecation-handler';
export var test = QUnit.test;
@@ -13,11 +15,13 @@
moment.createFromInputFallback = function (config) {
throw new Error('input not handled by moment: ' + config._i);
};
+ setupDeprecationHandler(test, moment, 'core');
if (lifecycle && lifecycle.setup) {
lifecycle.setup();
}
},
teardown : function () {
+ teardownDeprecationHandler(test, moment, 'core');
if (lifecycle && lifecycle.teardown) {
lifecycle.teardown();
}
@@ -32,15 +36,18 @@
moment.createFromInputFallback = function (config) {
throw new Error('input not handled by moment: ' + config._i);
};
+ setupDeprecationHandler(test, moment, 'locale');
if (lifecycle && lifecycle.setup) {
lifecycle.setup();
}
},
teardown : function () {
moment.locale('en');
+ teardownDeprecationHandler(test, moment, 'locale');
if (lifecycle && lifecycle.teardown) {
lifecycle.teardown();
}
}
});
+ defineCommonLocaleTests(name, -1, -1);
}
diff --git a/tasks/embed_locales.js b/tasks/embed_locales.js
deleted file mode 100644
index 5027af1..0000000
--- a/tasks/embed_locales.js
+++ /dev/null
@@ -1,47 +0,0 @@
-
-module.exports = function (grunt) {
- grunt.registerTask('embedLocales', function () {
- var config = grunt.config('embedLocales');
-
- var files = grunt.file.expand(config.targetLocales);
- var embeddedContents = determineEmbeddedContent(files);
-
- var momentContents = grunt.file.read(config.moment);
- var modifiedContents = momentContents.replace('/* EMBED_LOCALES */', function () {
- // If we don't do this, $ symbols in locale files may get interpreted in
- // the regex replacement
- return embeddedContents;
- });
-
- grunt.file.write(config.dest, modifiedContents);
- });
-
- var languageReset = 'moment.locale(\'en\');';
-
- function determineEmbeddedContent(files) {
- var embeddedContent = '';
- files.forEach(function (file) {
- embeddedContent += transformFile(file);
- });
- embeddedContent += '\n ' + languageReset + '\n';
- return embeddedContent;
- }
-
- var reTransform = /function \(factory\) \{[^]*\}(?=\(function \(moment\) \{)/gm;
- var replaceWith =
- 'function (factory) {\n' +
- ' factory(moment);\n' +
- '}';
-
- function transformFile(file) {
- var fileContents = grunt.file.read(file);
-
- if (!fileContents.match(reTransform)) {
- grunt.warn('Warning: all locale files must use the common UMD wrapper pattern. Failed locale file: ' + file);
- return '';
- }
-
- return fileContents.replace(reTransform, replaceWith);
- }
-};
-
diff --git a/tasks/history.js b/tasks/history.js
deleted file mode 100644
index 85e8333..0000000
--- a/tasks/history.js
+++ /dev/null
@@ -1,123 +0,0 @@
-var https = require('https'),
- zlib = require('zlib'),
- path = require('path'),
- fs = require('fs');
-
-var count = 0;
-var resolved = 0;
-
-var outputs = [];
-
-var done;
-
-function check() {
- if (resolved === count) {
- normalize();
- display();
- }
-}
-
-function makeBar(length) {
- var i = '';
- while (i.length < length) {
- i += '=';
- }
- return i;
-}
-
-function normalize() {
- var i,
- max = 0,
- max2 = 0;
- for (i = 0; i < count; i++) {
- max = Math.max(max, outputs[i].gzip);
- max2 = Math.max(max2, outputs[i].original);
- }
- for (i = 0; i < count; i++) {
- outputs[i].bargraph = makeBar((outputs[i].gzip / max) * 80);
- outputs[i].bargraph2 = makeBar((outputs[i].original / max2) * 80);
- }
-}
-
-function display() {
- var i;
- for (i = 0; i < count; i++) {
- console.log(outputs[i].version + ' ' + outputs[i].gzip + ' ' + outputs[i].original);
- console.log('gzip ' + outputs[i].bargraph);
- console.log('orig ' + outputs[i].bargraph2);
- }
- done();
-}
-
-function getSizeAtVersion(version, path) {
- var data = '',
- op = {},
-
- req = https.request({
- host: 'raw.github.com',
- port: 443,
- path: '/timrwood/moment/' + version + path
- }, function (res) {
- res.setEncoding('utf8');
- res.on('data', function (chunk) {
- data += chunk;
- });
- res.on('end', function (e) {
- zlib.gzip(data, function (error, result) {
- op.version = version;
- op.gzip = result.length;
- op.original = data.length;
- resolved++;
- check();
- });
- });
- });
-
- req.on('error', function (e) {
- console.log('problem with request: ' + e.message);
- });
- req.end();
- count++;
- outputs.push(op);
-}
-
-function getRemote() {
- var oldVersions = '1.0.1 1.1.0 1.1.1 1.1.2 1.2.0 1.3.0 1.4.0'.split(' '),
- newVersions = '1.5.0 1.5.1 1.6.0 1.6.1 1.7.0 1.7.1'.split(' '),
- i;
-
- for (i = 0; i < oldVersions.length; i++) {
- getSizeAtVersion(oldVersions[i], '/moment.min.js');
- }
- for (i = 0; i < newVersions.length; i++) {
- getSizeAtVersion(newVersions[i], '/min/moment.min.js');
- }
-}
-
-function getLocal() {
- count++;
- var op = {};
- outputs.push(op);
- fs.readFile(path.normalize(__dirname + '/../min/moment.min.js'), 'utf8', function (err, data) {
- if (err) {
- throw err;
- }
- zlib.gzip(data, function (error, result) {
- op.version = '.next';
- op.gzip = result.length;
- op.original = data.length;
- resolved++;
- check();
- });
- });
-}
-
-
-
-module.exports = function (grunt) {
- grunt.registerTask('history', 'Check the codebase filesize over different releases.', function () {
- done = this.async();
- getRemote();
- getLocal();
- });
-};
diff --git a/tasks/size.js b/tasks/size.js
deleted file mode 100644
index 2ab380e..0000000
--- a/tasks/size.js
+++ /dev/null
@@ -1,59 +0,0 @@
-var https = require('https'),
- zlib = require('zlib'),
- path = require('path'),
- fs = require('fs');
-
-var stable = '1.7.1',
- done;
-
-function getVersion(path, cb) {
- var data = '',
- req = https.request({
- host: 'raw.github.com',
- port: 443,
- path: '/timrwood/moment/' + path
- }, function (res) {
- res.setEncoding('utf8');
- res.on('data', function (chunk) {
- data += chunk;
- });
- res.on('end', function (e) {
- zlib.gzip(data, function (error, result) {
- cb(data.length, result.length);
- });
- });
- });
- req.on('error', function (e) {
- console.log('problem with request: ' + e.message);
- });
- req.end();
-}
-
-function printDiffs(stableLen, stableGzip, currentLen, currentGzip) {
- var diff = currentLen - stableLen,
- gzipDiff = currentGzip - stableGzip;
-
- console.log('Filesize difference from current branch to ' + stable);
- console.log(stable + ' ' + stableLen + ' / ' + stableGzip);
- console.log('curr ' + currentLen + ' / ' + currentGzip);
- console.log('diff ' + (diff > 0 ? '+' : '') + diff);
- console.log('gzip ' + (gzipDiff > 0 ? '+' : '') + gzipDiff);
-}
-
-
-module.exports = function (grunt) {
- grunt.registerTask('size', 'Check the codebase filesize against the latest stable version.', function () {
- done = this.async();
- fs.readFile(path.normalize(__dirname + '/../min/moment.min.js'), 'utf8', function (err, data) {
- if (err) {
- throw err;
- }
- zlib.gzip(data, function (error, result) {
- getVersion(stable + '/min/moment.min.js', function (stableLength, stableGzipLength) {
- printDiffs(stableLength, stableGzipLength, data.length, result.length);
- done();
- });
- });
- });
- });
-};
diff --git a/tasks/zones.js b/tasks/zones.js
deleted file mode 100644
index 7aa88b1..0000000
--- a/tasks/zones.js
+++ /dev/null
@@ -1,70 +0,0 @@
-var fs = require('fs');
-
-
-module.exports = function (grunt) {
- var ZONE_TAB = '/usr/share/zoneinfo/zone.tab';
-
- grunt.registerTask('zones', 'Run the unit tests in different timezones.', function () {
- var done = this.async();
-
- getAllTimezones(function (err, zones) {
- if (err != null) {
- throw err;
- }
- (function iterator(i) {
- if (i >= zones.length) {
- return done();
- }
- runTestsInZone(zones[i], function (err) {
- if (err != null) {
- throw err;
- }
- iterator(i + 1);
- });
- }(0));
- });
- });
-
- function getAllTimezones (callback) {
- fs.readFile(ZONE_TAB, 'ascii', function (err, content) {
- if (err != null) {
- callback(err);
- }
- callback(null, content.split(/\r\n|\r|\n/)
- // remove empty and commented lines
- .filter(function (line) {
- return line && !/^#/.test(line);
- })
- // country code TAB coordinates TAB timezone
- .map(function (line) {
- return line.split('\t')[2];
- }));
- });
- }
-
- function runTestsInZone (zone, next) {
- grunt.log.ok('Running tests in zone ' + zone);
- grunt.util.spawn({
- cmd: 'grunt',
- opts: {
- env: {
- 'PATH': process.env.PATH,
- 'TZ': zone
- }
- },
- args: ['--no-color', 'nodeunit']
- }, function (err, result, code) {
- if (code !== 0) {
- grunt.log.error(result.stdout.split(/\r\n|\r|\n/)
- .filter(function (line) {
- return /^(>>|Warning:|$)/.test(line);
- })
- .map(function (line) {
- return (line.substr(0, 3) === '>> ' ? line.substr(3) : line);
- })
- .join('\n'));
- }
- next();
- });
- }
-};